move logic to Core project and create UI project with UI lol #1
8 changed files with 280 additions and 0 deletions
10
MetaforceInstaller.UI/App.axaml
Normal file
10
MetaforceInstaller.UI/App.axaml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<Application xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
x:Class="MetaforceInstaller.UI.App"
|
||||||
|
RequestedThemeVariant="Default">
|
||||||
|
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
||||||
|
|
||||||
|
<Application.Styles>
|
||||||
|
<FluentTheme />
|
||||||
|
</Application.Styles>
|
||||||
|
</Application>
|
||||||
23
MetaforceInstaller.UI/App.axaml.cs
Normal file
23
MetaforceInstaller.UI/App.axaml.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
namespace MetaforceInstaller.UI;
|
||||||
|
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
AvaloniaXamlLoader.Load(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnFrameworkInitializationCompleted()
|
||||||
|
{
|
||||||
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
|
{
|
||||||
|
desktop.MainWindow = new MainWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
base.OnFrameworkInitializationCompleted();
|
||||||
|
}
|
||||||
|
}
|
||||||
49
MetaforceInstaller.UI/MainWindow.axaml
Normal file
49
MetaforceInstaller.UI/MainWindow.axaml
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="MetaforceInstaller.UI.MainWindow"
|
||||||
|
Title="MetaforceInstaller">
|
||||||
|
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!-- Main Content Area -->
|
||||||
|
<Grid Grid.Row="0" Margin="8">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="3*"/> <!-- 30% -->
|
||||||
|
<ColumnDefinition Width="7*"/> <!-- 70% -->
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<!-- Left Panel - Buttons -->
|
||||||
|
<StackPanel Grid.Column="0" Margin="20" Spacing="15">
|
||||||
|
<Button Name="ChooseApkButton" Content="Choose .apk"
|
||||||
|
HorizontalAlignment="Stretch"/>
|
||||||
|
|
||||||
|
<Button Name="ChooseContentButton" Content="Choose .zip"
|
||||||
|
HorizontalAlignment="Stretch"/>
|
||||||
|
|
||||||
|
<Button Name="InstallButton" Content="Install"
|
||||||
|
HorizontalAlignment="Stretch"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Right Panel - Logs -->
|
||||||
|
<TextBox Grid.Column="1" Name="LogsTextBox"
|
||||||
|
IsReadOnly="True"
|
||||||
|
AcceptsReturn="True"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
FontFamily="Consolas,Courier New,monospace"
|
||||||
|
Focusable="False"
|
||||||
|
Margin="4,0,0,0"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- Progress Bar at Bottom -->
|
||||||
|
<ProgressBar Grid.Row="1" Name="InstallProgressBar"
|
||||||
|
Height="20" Minimum="0" Maximum="100" Value="0"
|
||||||
|
Margin="8"/>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
131
MetaforceInstaller.UI/MainWindow.axaml.cs
Normal file
131
MetaforceInstaller.UI/MainWindow.axaml.cs
Normal file
|
|
@ -0,0 +1,131 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
using Avalonia.Platform.Storage;
|
||||||
|
using Avalonia.VisualTree;
|
||||||
|
|
||||||
|
namespace MetaforceInstaller.UI;
|
||||||
|
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
private string? _apkPath;
|
||||||
|
private string? _zipPath;
|
||||||
|
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
CheckAndEnableInstallButton();
|
||||||
|
|
||||||
|
ChooseApkButton.Click += OnChooseApkClicked;
|
||||||
|
ChooseContentButton.Click += OnChooseContentClicked;
|
||||||
|
InstallButton.Click += OnInstallClicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
InstallButton.IsEnabled = false;
|
||||||
|
InstallProgressBar.Value = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LogMessage("Начинаем установку...");
|
||||||
|
|
||||||
|
// Здесь будет ваша логика установки
|
||||||
|
await SimulateInstallation();
|
||||||
|
|
||||||
|
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>();
|
||||||
|
scrollViewer?.ScrollToEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SimulateInstallation()
|
||||||
|
{
|
||||||
|
for (int i = 0; i <= 100; i += 10)
|
||||||
|
{
|
||||||
|
InstallProgressBar.Value = i;
|
||||||
|
LogMessage($"Прогресс: {i}%");
|
||||||
|
await Task.Delay(500); // Симуляция работы
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
MetaforceInstaller.UI/MetaforceInstaller.UI.csproj
Normal file
22
MetaforceInstaller.UI/MetaforceInstaller.UI.csproj
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Avalonia" Version="11.3.6"/>
|
||||||
|
<PackageReference Include="Avalonia.Desktop" Version="11.3.6"/>
|
||||||
|
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.6"/>
|
||||||
|
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.6"/>
|
||||||
|
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||||
|
<PackageReference Include="Avalonia.Diagnostics" Version="11.3.6">
|
||||||
|
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
||||||
|
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
21
MetaforceInstaller.UI/Program.cs
Normal file
21
MetaforceInstaller.UI/Program.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
using Avalonia;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace MetaforceInstaller.UI;
|
||||||
|
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
||||||
|
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
||||||
|
// yet and stuff might break.
|
||||||
|
[STAThread]
|
||||||
|
public static void Main(string[] args) => BuildAvaloniaApp()
|
||||||
|
.StartWithClassicDesktopLifetime(args);
|
||||||
|
|
||||||
|
// Avalonia configuration, don't remove; also used by visual designer.
|
||||||
|
public static AppBuilder BuildAvaloniaApp()
|
||||||
|
=> AppBuilder.Configure<App>()
|
||||||
|
.UsePlatformDetect()
|
||||||
|
.WithInterFont()
|
||||||
|
.LogToTrace();
|
||||||
|
}
|
||||||
18
MetaforceInstaller.UI/app.manifest
Normal file
18
MetaforceInstaller.UI/app.manifest
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<!-- This manifest is used on Windows only.
|
||||||
|
Don't remove it as it might cause problems with window transparency and embedded controls.
|
||||||
|
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
|
||||||
|
<assemblyIdentity version="1.0.0.0" name="MetaforceInstaller.UI.Desktop"/>
|
||||||
|
|
||||||
|
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||||
|
<application>
|
||||||
|
<!-- A list of the Windows versions that this application has been tested on
|
||||||
|
and is designed to work with. Uncomment the appropriate elements
|
||||||
|
and Windows will automatically select the most compatible environment. -->
|
||||||
|
|
||||||
|
<!-- Windows 10 -->
|
||||||
|
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
||||||
|
</application>
|
||||||
|
</compatibility>
|
||||||
|
</assembly>
|
||||||
|
|
@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MetaforceInstaller.Cli", "M
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MetaforceInstaller.Core", "MetaforceInstaller.Core\MetaforceInstaller.Core.csproj", "{83961B6E-21E7-4B7A-B4FA-6128A44BCE1F}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MetaforceInstaller.Core", "MetaforceInstaller.Core\MetaforceInstaller.Core.csproj", "{83961B6E-21E7-4B7A-B4FA-6128A44BCE1F}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MetaforceInstaller.UI", "MetaforceInstaller.UI\MetaforceInstaller.UI.csproj", "{546DDE53-4607-4852-B951-434061C46FB2}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
|
@ -18,5 +20,9 @@ Global
|
||||||
{83961B6E-21E7-4B7A-B4FA-6128A44BCE1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{83961B6E-21E7-4B7A-B4FA-6128A44BCE1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{83961B6E-21E7-4B7A-B4FA-6128A44BCE1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{83961B6E-21E7-4B7A-B4FA-6128A44BCE1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{83961B6E-21E7-4B7A-B4FA-6128A44BCE1F}.Release|Any CPU.Build.0 = Release|Any CPU
|
{83961B6E-21E7-4B7A-B4FA-6128A44BCE1F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{546DDE53-4607-4852-B951-434061C46FB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{546DDE53-4607-4852-B951-434061C46FB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{546DDE53-4607-4852-B951-434061C46FB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{546DDE53-4607-4852-B951-434061C46FB2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue