using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Win32;
using SpaceEngineersBlueprintEditor.Installer.Profiles;
using SpaceEngineersBlueprintEditor.Installer.Utilities;
using SpaceEngineersBlueprintEditor.Installer.Views.Pages;
using SpaceEngineersBlueprintEditor.Installer.Views.Pages.Popups;
using SpaceEngineersBlueprintEditor.Installer.Views.Windows;
using System.IO;
using System.Reflection;
namespace SpaceEngineersBlueprintEditor.Installer.ViewModel.Pages;
public partial class InstallPageViewModel(InstallPage viewPage) : ViewModelBase
{
[ObservableProperty]
bool agreementChecked = false;
[ObservableProperty]
string installPath = @$"{Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)}\SpaceEngineersBlueprintEditor";
public InstallPage ViewPage { get; set; } = viewPage;
[RelayCommand]
void GotoInstallProgressPage()
{
if (MainWindow.Current is not null)
MainWindow.Current.contentFrame.Content = new InstallProgressPage();
}
[RelayCommand]
void ChangeInstallPath()
{
var openFolderDialog = new OpenFolderDialog
{
RootDirectory = InstallPath,
Multiselect = false
};
if (openFolderDialog.ShowDialog() == true)
{
if (FileHelper.IsRootPath(openFolderDialog.FolderName))
InstallPath = $@"{openFolderDialog.FolderName}SpaceEngineersBlueprintEditor";
else
InstallPath = openFolderDialog.FolderName;
SystemProfile.InstallPath = InstallPath;
}
}
[RelayCommand]
void ViewEULAAgreement()
{
if (Assembly.GetExecutingAssembly().GetManifestResourceStream("SpaceEngineersBlueprintEditor.Installer.Resources.Resource.EULA.txt") is Stream stream && new StreamReader(stream).ReadToEnd() is string agreementText)
PopupHelper.ShowDialog(new AgreementDialogPopupPage
{
Title = "软件最终用户许可协议",
Agreement = agreementText
}, 480, 420);
}
[RelayCommand]
void ViewUserPrivateAgreement()
{
if (Assembly.GetExecutingAssembly().GetManifestResourceStream("SpaceEngineersBlueprintEditor.Installer.Resources.Resource.PrivateService.txt") is Stream stream && new StreamReader(stream).ReadToEnd() is string agreementText)
PopupHelper.ShowDialog(new AgreementDialogPopupPage
{
Title = "用户隐私协议",
Agreement = agreementText
}, 480, 420);
}
}
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Win32;
using SpaceEngineersBlueprintEditor.Installer.Profiles;
using SpaceEngineersBlueprintEditor.Installer.Utilities;
using SpaceEngineersBlueprintEditor.Installer.Views.Pages;
using SpaceEngineersBlueprintEditor.Installer.Views.Pages.Popups;
using SpaceEngineersBlueprintEditor.Installer.Views.Windows;
using System.IO;
using System.Reflection;
namespace SpaceEngineersBlueprintEditor.Installer.ViewModel.Pages;
public partial class InstallPageViewModel(InstallPage viewPage) : ViewModelBase
{
[ObservableProperty]
bool agreementChecked = false;
[ObservableProperty]
string installPath = @$"{Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)}\SpaceEngineersBlueprintEditor";
public InstallPage ViewPage { get; set; } = viewPage;
[RelayCommand]
void GotoInstallProgressPage()
{
if (MainWindow.Current is not null)
MainWindow.Current.contentFrame.Content = new InstallProgressPage();
}
[RelayCommand]
void ChangeInstallPath()
{
var openFolderDialog = new OpenFolderDialog
{
RootDirectory = InstallPath,
Multiselect = false
};
if (openFolderDialog.ShowDialog() == true)
{
if (FileHelper.IsRootPath(openFolderDialog.FolderName))
InstallPath = $@"{openFolderDialog.FolderName}SpaceEngineersBlueprintEditor";
else
InstallPath = openFolderDialog.FolderName;
SystemProfile.InstallPath = InstallPath;
}
}
[RelayCommand]
void ViewEULAAgreement()
{
if (Assembly.GetExecutingAssembly().GetManifestResourceStream("SpaceEngineersBlueprintEditor.Installer.Resources.Resource.EULA.txt") is Stream stream && new StreamReader(stream).ReadToEnd() is string agreementText)
PopupHelper.ShowDialog(new AgreementDialogPopupPage
{
Title = "软件最终用户许可协议",
Agreement = agreementText
}, 480, 420);
}
[RelayCommand]
void ViewUserPrivateAgreement()
{
if (Assembly.GetExecutingAssembly().GetManifestResourceStream("SpaceEngineersBlueprintEditor.Installer.Resources.Resource.PrivateService.txt") is Stream stream && new StreamReader(stream).ReadToEnd() is string agreementText)
PopupHelper.ShowDialog(new AgreementDialogPopupPage
{
Title = "用户隐私协议",
Agreement = agreementText
}, 480, 420);
}
}