diff --git a/MetaforceInstaller.UI/MainWindow.axaml b/MetaforceInstaller.UI/MainWindow.axaml
index 61a426d..7b8c85a 100644
--- a/MetaforceInstaller.UI/MainWindow.axaml
+++ b/MetaforceInstaller.UI/MainWindow.axaml
@@ -10,11 +10,11 @@
-
+
-
+
-
+
@@ -22,49 +22,44 @@
+
-
-
-
-
-
-
-
+
+
-
-
-
+
-
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/MetaforceInstaller.UI/MainWindow.axaml.cs b/MetaforceInstaller.UI/MainWindow.axaml.cs
index d6a49e1..975928c 100644
--- a/MetaforceInstaller.UI/MainWindow.axaml.cs
+++ b/MetaforceInstaller.UI/MainWindow.axaml.cs
@@ -26,205 +26,211 @@ public partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();
-
- LogMessage("MetaforceInstaller by slavagm");
-
- _adbService = new AdbService();
- _adbService.ProgressChanged += OnAdbProgressChanged;
- _adbService.StatusChanged += OnAdbStatusChanged;
-
- CheckAndEnableInstallButton();
-
- ChooseApkButton.Click += OnChooseApkClicked;
- ChooseContentButton.Click += OnChooseContentClicked;
- InstallButton.Click += OnInstallClicked;
+ NewInstallationButton.Click += OnNewInstalltionClick;
+ // LogMessage("MetaforceInstaller by slavagm");
+ //
+ // _adbService = new AdbService();
+ // _adbService.ProgressChanged += OnAdbProgressChanged;
+ // _adbService.StatusChanged += OnAdbStatusChanged;
+ //
+ // CheckAndEnableInstallButton();
+ //
+ // ChooseApkButton.Click += OnChooseApkClicked;
+ // ChooseContentButton.Click += OnChooseContentClicked;
+ // InstallButton.Click += OnInstallClicked;
}
- private void OnAdbProgressChanged(object? sender, ProgressInfo e)
+ public async void OnNewInstalltionClick(object? sender, RoutedEventArgs e)
{
- Dispatcher.UIThread.InvokeAsync(() =>
- {
- if (e.PercentageComplete != _lastUpdatedProgress &&
- e.PercentageComplete % PROGRESS_UPDATE_STEP == 0)
- {
- InstallProgressBar.Value = e.PercentageComplete;
- _lastUpdatedProgress = e.PercentageComplete;
- }
-
- if (e.PercentageComplete != _lastLoggedProgress &&
- e.PercentageComplete % PROGRESS_LOG_STEP == 0 || e.PercentageComplete == 100)
- {
- LogMessage(
- e.TotalBytes > 0
- ? $"Прогресс: {e.PercentageComplete}% ({FormatBytes(e.BytesTransferred)} / {FormatBytes(e.TotalBytes)})"
- : $"Прогресс: {e.PercentageComplete}%");
-
- _lastLoggedProgress = e.PercentageComplete;
- }
- });
+ var newInstallationDialog = new NewInstallationDialog();
+ await newInstallationDialog.ShowDialog(this);
}
- private void OnProgressReport(ProgressInfo progressInfo)
- {
- Dispatcher.UIThread.InvokeAsync(() =>
- {
- if (progressInfo.PercentageComplete != _lastUpdatedProgress &&
- progressInfo.PercentageComplete % PROGRESS_UPDATE_STEP == 0)
- {
- InstallProgressBar.Value = progressInfo.PercentageComplete;
- _lastUpdatedProgress = progressInfo.PercentageComplete;
- }
-
-
- if (progressInfo.PercentageComplete != _lastLoggedProgress &&
- (progressInfo.PercentageComplete % PROGRESS_LOG_STEP == 0 || progressInfo.PercentageComplete == 100))
- {
- LogMessage(
- progressInfo.TotalBytes > 0
- ? $"Прогресс: {progressInfo.PercentageComplete}% ({FormatBytes(progressInfo.BytesTransferred)} / {FormatBytes(progressInfo.TotalBytes)})"
- : $"Прогресс: {progressInfo.PercentageComplete}%");
-
- _lastLoggedProgress = progressInfo.PercentageComplete;
- }
- });
- }
-
- private void OnAdbStatusChanged(object? sender, string e)
- {
- Dispatcher.UIThread.InvokeAsync(() =>
- {
- InstallProgressBar.Value = 0;
- _lastLoggedProgress = -1;
- _lastUpdatedProgress = -1;
- LogMessage(e);
- });
- }
-
- private string FormatBytes(long bytes)
- {
- string[] suffixes = ["B", "KB", "MB", "GB", "TB"];
- var counter = 0;
- double number = bytes;
-
- while (Math.Round(number / 1024) >= 1)
- {
- number /= 1024;
- counter++;
- }
-
- return $"{number:N1} {suffixes[counter]}";
- }
-
-
- private async void CheckAndEnableInstallButton()
- {
- InstallButton.IsEnabled = !string.IsNullOrEmpty(_apkPath) && !string.IsNullOrEmpty(_zipPath);
- }
-
- private async void OnChooseApkClicked(object? sender, RoutedEventArgs e)
- {
- var topLevel = GetTopLevel(this);
- var files = await topLevel!.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
- {
- Title = "Выберите APK файл",
- AllowMultiple = false,
- FileTypeFilter = new[]
- {
- new FilePickerFileType("APK Files")
- {
- Patterns = new[] { "*.apk" }
- }
- }
- });
-
- if (files.Count >= 1)
- {
- _apkPath = files[0].Path.LocalPath;
- LogMessage($"APK выбран: {Path.GetFileName(_apkPath)}");
- }
-
- CheckAndEnableInstallButton();
- }
-
- private async void OnChooseContentClicked(object? sender, RoutedEventArgs e)
- {
- var topLevel = GetTopLevel(this);
- var files = await topLevel!.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
- {
- Title = "Выберите архив с контентом",
- AllowMultiple = false,
- FileTypeFilter = new[]
- {
- new FilePickerFileType("ZIP Files")
- {
- Patterns = new[] { "*.zip" }
- }
- }
- });
-
- if (files.Count >= 1)
- {
- _zipPath = files[0].Path.LocalPath;
- LogMessage($"Контент выбран: {Path.GetFileName(_zipPath)}");
- }
-
- CheckAndEnableInstallButton();
- }
-
- private async void OnInstallClicked(object? sender, RoutedEventArgs e)
- {
- if (string.IsNullOrEmpty(_apkPath) || string.IsNullOrEmpty(_zipPath))
- {
- LogMessage("Ошибка: Выберите APK файл и папку с контентом");
- return;
- }
-
- _adbService.RefreshDeviceData();
-
- InstallButton.IsEnabled = false;
- InstallProgressBar.Value = 0;
-
- try
- {
- LogMessage("Начинаем установку...");
-
- var deviceInfo = _adbService.GetDeviceInfo();
- LogMessage($"Найдено устройство: {deviceInfo.SerialNumber}");
- LogMessage($"Состояние: {deviceInfo.State}");
- LogMessage($"Модель: {deviceInfo.Model} - {deviceInfo.Name}");
-
- var progress = new Progress(OnProgressReport);
-
- await _adbService.InstallApkAsync(_apkPath, progress);
-
- var apkInfo = ApkScrapper.GetApkInfo(_apkPath);
- LogMessage($"Ставим {apkInfo.PackageName} версии {apkInfo.VersionName}");
- var zipName = Path.GetFileName(_zipPath);
- var outputPath =
- @$"/storage/emulated/0/Android/data/{apkInfo.PackageName}/files/{zipName}";
- LogMessage($"Начинаем копирование контента в {outputPath}");
-
- await _adbService.CopyFileAsync(_zipPath, outputPath, progress);
-
- LogMessage("Установка завершена успешно!");
- }
- catch (Exception ex)
- {
- LogMessage($"Ошибка установки: {ex.Message}");
- }
- finally
- {
- InstallButton.IsEnabled = true;
- InstallProgressBar.Value = 0;
- }
- }
-
- private void LogMessage(string message)
- {
- var timestamp = DateTime.Now.ToString("HH:mm:ss");
- LogsTextBox.Text += $"[{timestamp}] {message}\n";
-
- var scrollViewer = LogsTextBox.FindAncestorOfType();
- scrollViewer?.ScrollToEnd();
- }
+ // private void OnAdbProgressChanged(object? sender, ProgressInfo e)
+ // {
+ // Dispatcher.UIThread.InvokeAsync(() =>
+ // {
+ // if (e.PercentageComplete != _lastUpdatedProgress &&
+ // e.PercentageComplete % PROGRESS_UPDATE_STEP == 0)
+ // {
+ // InstallProgressBar.Value = e.PercentageComplete;
+ // _lastUpdatedProgress = e.PercentageComplete;
+ // }
+ //
+ // if (e.PercentageComplete != _lastLoggedProgress &&
+ // e.PercentageComplete % PROGRESS_LOG_STEP == 0 || e.PercentageComplete == 100)
+ // {
+ // LogMessage(
+ // e.TotalBytes > 0
+ // ? $"Прогресс: {e.PercentageComplete}% ({FormatBytes(e.BytesTransferred)} / {FormatBytes(e.TotalBytes)})"
+ // : $"Прогресс: {e.PercentageComplete}%");
+ //
+ // _lastLoggedProgress = e.PercentageComplete;
+ // }
+ // });
+ // }
+ //
+ // private void OnProgressReport(ProgressInfo progressInfo)
+ // {
+ // Dispatcher.UIThread.InvokeAsync(() =>
+ // {
+ // if (progressInfo.PercentageComplete != _lastUpdatedProgress &&
+ // progressInfo.PercentageComplete % PROGRESS_UPDATE_STEP == 0)
+ // {
+ // InstallProgressBar.Value = progressInfo.PercentageComplete;
+ // _lastUpdatedProgress = progressInfo.PercentageComplete;
+ // }
+ //
+ //
+ // if (progressInfo.PercentageComplete != _lastLoggedProgress &&
+ // (progressInfo.PercentageComplete % PROGRESS_LOG_STEP == 0 || progressInfo.PercentageComplete == 100))
+ // {
+ // LogMessage(
+ // progressInfo.TotalBytes > 0
+ // ? $"Прогресс: {progressInfo.PercentageComplete}% ({FormatBytes(progressInfo.BytesTransferred)} / {FormatBytes(progressInfo.TotalBytes)})"
+ // : $"Прогресс: {progressInfo.PercentageComplete}%");
+ //
+ // _lastLoggedProgress = progressInfo.PercentageComplete;
+ // }
+ // });
+ // }
+ //
+ // private void OnAdbStatusChanged(object? sender, string e)
+ // {
+ // Dispatcher.UIThread.InvokeAsync(() =>
+ // {
+ // InstallProgressBar.Value = 0;
+ // _lastLoggedProgress = -1;
+ // _lastUpdatedProgress = -1;
+ // LogMessage(e);
+ // });
+ // }
+ //
+ // private string FormatBytes(long bytes)
+ // {
+ // string[] suffixes = ["B", "KB", "MB", "GB", "TB"];
+ // var counter = 0;
+ // double number = bytes;
+ //
+ // while (Math.Round(number / 1024) >= 1)
+ // {
+ // number /= 1024;
+ // counter++;
+ // }
+ //
+ // return $"{number:N1} {suffixes[counter]}";
+ // }
+ //
+ //
+ // private async void CheckAndEnableInstallButton()
+ // {
+ // InstallButton.IsEnabled = !string.IsNullOrEmpty(_apkPath) && !string.IsNullOrEmpty(_zipPath);
+ // }
+ //
+ // private async void OnChooseApkClicked(object? sender, RoutedEventArgs e)
+ // {
+ // var topLevel = GetTopLevel(this);
+ // var files = await topLevel!.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
+ // {
+ // Title = "Выберите APK файл",
+ // AllowMultiple = false,
+ // FileTypeFilter = new[]
+ // {
+ // new FilePickerFileType("APK Files")
+ // {
+ // Patterns = new[] { "*.apk" }
+ // }
+ // }
+ // });
+ //
+ // if (files.Count >= 1)
+ // {
+ // _apkPath = files[0].Path.LocalPath;
+ // LogMessage($"APK выбран: {Path.GetFileName(_apkPath)}");
+ // }
+ //
+ // CheckAndEnableInstallButton();
+ // }
+ //
+ // private async void OnChooseContentClicked(object? sender, RoutedEventArgs e)
+ // {
+ // var topLevel = GetTopLevel(this);
+ // var files = await topLevel!.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
+ // {
+ // Title = "Выберите архив с контентом",
+ // AllowMultiple = false,
+ // FileTypeFilter = new[]
+ // {
+ // new FilePickerFileType("ZIP Files")
+ // {
+ // Patterns = new[] { "*.zip" }
+ // }
+ // }
+ // });
+ //
+ // if (files.Count >= 1)
+ // {
+ // _zipPath = files[0].Path.LocalPath;
+ // LogMessage($"Контент выбран: {Path.GetFileName(_zipPath)}");
+ // }
+ //
+ // CheckAndEnableInstallButton();
+ // }
+ //
+ // private async void OnInstallClicked(object? sender, RoutedEventArgs e)
+ // {
+ // if (string.IsNullOrEmpty(_apkPath) || string.IsNullOrEmpty(_zipPath))
+ // {
+ // LogMessage("Ошибка: Выберите APK файл и папку с контентом");
+ // return;
+ // }
+ //
+ // _adbService.RefreshDeviceData();
+ //
+ // InstallButton.IsEnabled = false;
+ // InstallProgressBar.Value = 0;
+ //
+ // try
+ // {
+ // LogMessage("Начинаем установку...");
+ //
+ // var deviceInfo = _adbService.GetDeviceInfo();
+ // LogMessage($"Найдено устройство: {deviceInfo.SerialNumber}");
+ // LogMessage($"Состояние: {deviceInfo.State}");
+ // LogMessage($"Модель: {deviceInfo.Model} - {deviceInfo.Name}");
+ //
+ // var progress = new Progress(OnProgressReport);
+ //
+ // await _adbService.InstallApkAsync(_apkPath, progress);
+ //
+ // var apkInfo = ApkScrapper.GetApkInfo(_apkPath);
+ // LogMessage($"Ставим {apkInfo.PackageName} версии {apkInfo.VersionName}");
+ // var zipName = Path.GetFileName(_zipPath);
+ // var outputPath =
+ // @$"/storage/emulated/0/Android/data/{apkInfo.PackageName}/files/{zipName}";
+ // LogMessage($"Начинаем копирование контента в {outputPath}");
+ //
+ // await _adbService.CopyFileAsync(_zipPath, outputPath, progress);
+ //
+ // LogMessage("Установка завершена успешно!");
+ // }
+ // catch (Exception ex)
+ // {
+ // LogMessage($"Ошибка установки: {ex.Message}");
+ // }
+ // finally
+ // {
+ // InstallButton.IsEnabled = true;
+ // InstallProgressBar.Value = 0;
+ // }
+ // }
+ //
+ // private void LogMessage(string message)
+ // {
+ // var timestamp = DateTime.Now.ToString("HH:mm:ss");
+ // LogsTextBox.Text += $"[{timestamp}] {message}\n";
+ //
+ // var scrollViewer = LogsTextBox.FindAncestorOfType();
+ // scrollViewer?.ScrollToEnd();
+ // }
}
\ No newline at end of file
diff --git a/MetaforceInstaller.UI/NewInstallationDialog.axaml b/MetaforceInstaller.UI/NewInstallationDialog.axaml
new file mode 100644
index 0000000..29a5f78
--- /dev/null
+++ b/MetaforceInstaller.UI/NewInstallationDialog.axaml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+ Install server
+ Install admin
+ Save android admin
+ Save VR client
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MetaforceInstaller.UI/NewInstallationDialog.axaml.cs b/MetaforceInstaller.UI/NewInstallationDialog.axaml.cs
new file mode 100644
index 0000000..85d5f28
--- /dev/null
+++ b/MetaforceInstaller.UI/NewInstallationDialog.axaml.cs
@@ -0,0 +1,118 @@
+using System.IO.Compression;
+using Avalonia.Controls;
+using Avalonia.Interactivity;
+using Avalonia.Platform.Storage;
+using MetaforceInstaller.Core.Models;
+using MetaforceInstaller.Core.Services;
+
+namespace MetaforceInstaller.UI;
+
+public partial class NewInstallationDialog : Window
+{
+ private string? _zipPath;
+ private InstallationParts? _installationParts;
+
+ public NewInstallationDialog()
+ {
+ InitializeComponent();
+ RefreshCheckboxes();
+ CancelButton.Click += OnCancelClick;
+ ChooseZip.Click += OnChooseZipClick;
+ InstallButton.IsEnabled = false;
+ InstallButton.Click += OnInstallClick;
+ }
+
+ private async void RefreshCheckboxes()
+ {
+ var serverCheckbox = ServerCheckBox;
+ var pcAdminCheckbox = PcAdminCheckBox;
+ var androidAdminCheckbox = AndroidAdminCheckbox;
+ var vrClientCheckbox = VrClientCheckbox;
+ serverCheckbox.Content = TextDefaults.InstallServer;
+ serverCheckbox.IsEnabled = true;
+ pcAdminCheckbox.Content = TextDefaults.InstallAdmin;
+ pcAdminCheckbox.IsEnabled = true;
+ androidAdminCheckbox.Content = TextDefaults.SaveAndroidAdmin;
+ androidAdminCheckbox.IsEnabled = true;
+ vrClientCheckbox.Content = TextDefaults.SaveVRClient;
+ vrClientCheckbox.IsEnabled = true;
+ }
+
+ private async void OnChooseZipClick(object? sender, RoutedEventArgs e)
+ {
+ var topLevel = GetTopLevel(this);
+ var files = await topLevel!.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
+ {
+ Title = "Выберите архив с контентом",
+ AllowMultiple = false,
+ FileTypeFilter =
+ [
+ new FilePickerFileType("ZIP Files")
+ {
+ Patterns = ["*.zip"]
+ }
+ ]
+ });
+
+ if (files.Count >= 1)
+ {
+ _zipPath = files[0].Path.LocalPath;
+ using var archive = ZipFile.OpenRead(_zipPath);
+ _installationParts = ZipScrapper.PeekFiles(archive);
+ UpdateCheckboxes();
+ archive.Dispose();
+ }
+ }
+
+ private async void OnInstallClick(object? sender, RoutedEventArgs e)
+ {
+ using var archive = ZipFile.OpenRead(_zipPath);
+
+ }
+
+ private void UpdateCheckboxes()
+ {
+ RefreshCheckboxes();
+ var serverCheckbox = ServerCheckBox;
+ var pcAdminCheckbox = PcAdminCheckBox;
+ var androidAdminCheckbox = AndroidAdminCheckbox;
+ var vrClientCheckbox = VrClientCheckbox;
+
+ if (!_installationParts.WindowsServerExists)
+ {
+ serverCheckbox.IsEnabled = false;
+ serverCheckbox.Content += "\nCouldn't find directory with server";
+ }
+
+ if (!_installationParts.WindowsAdminExists)
+ {
+ pcAdminCheckbox.IsEnabled = false;
+ pcAdminCheckbox.Content += "\nCouldn't find directory with PC admin";
+ }
+
+ if (!_installationParts.WindowsContentExists)
+ {
+ pcAdminCheckbox.IsEnabled = false;
+ pcAdminCheckbox.Content += "\nCouldn't find windows content";
+ }
+
+ if (!_installationParts.AndroidContentExists)
+ {
+ vrClientCheckbox.IsEnabled = false;
+ vrClientCheckbox.Content += "\nCouldn't find android content";
+ androidAdminCheckbox.IsEnabled = false;
+ androidAdminCheckbox.Content += "\nCouldn't find android content";
+ }
+
+ if (!_installationParts.PicoClientExists && !_installationParts.OculusClientExists)
+ {
+ vrClientCheckbox.IsEnabled = false;
+ vrClientCheckbox.Content += "\nCouldn't find any VR clients";
+ }
+ }
+
+ private void OnCancelClick(object? sender, RoutedEventArgs e)
+ {
+ Close();
+ }
+}
\ No newline at end of file
diff --git a/MetaforceInstaller.UI/TextDefaults.cs b/MetaforceInstaller.UI/TextDefaults.cs
new file mode 100644
index 0000000..176e1f6
--- /dev/null
+++ b/MetaforceInstaller.UI/TextDefaults.cs
@@ -0,0 +1,9 @@
+namespace MetaforceInstaller.UI;
+
+public static class TextDefaults
+{
+ public static readonly string InstallServer = "Install Server";
+ public static readonly string InstallAdmin = "Install Admin";
+ public static readonly string SaveAndroidAdmin = "Save Android admin";
+ public static readonly string SaveVRClient = "Save VR client";
+}
\ No newline at end of file