Compare commits

...
Sign in to create a new pull request.

6 commits

5 changed files with 50 additions and 24 deletions

View file

@ -7,20 +7,21 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="adb\adb.exe" /> <EmbeddedResource Include="adb\adb.exe"/>
<EmbeddedResource Include="adb\AdbWinApi.dll" /> <EmbeddedResource Include="adb\AdbWinApi.dll">
<EmbeddedResource Include="adb\AdbWinUsbApi.dll" /> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>AdbWinApi.dll</Link>
</EmbeddedResource>
<EmbeddedResource Include="adb\AdbWinUsbApi.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>AdbWinUsbApi.dll</Link>
</EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="AlphaOmega.ApkReader" Version="2.0.5" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="AdvancedSharpAdbClient" Version="3.4.14" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AdvancedSharpAdbClient" Version="3.4.14" /> <PackageReference Include="AlphaOmega.ApkReader" Version="2.0.5"/>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.3" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0"/>
<PackageReference Include="AdvancedSharpAdbClient" Version="3.4.14"/>
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -53,8 +53,6 @@ public class AdbService : IAdbService
if (File.Exists(adbPath)) return adbPath; if (File.Exists(adbPath)) return adbPath;
ExtractResource("MetaforceInstaller.Core.adb.adb.exe", adbPath); ExtractResource("MetaforceInstaller.Core.adb.adb.exe", adbPath);
ExtractResource("MetaforceInstaller.Core.adb.AdbWinApi.dll", Path.Combine(tempDir, "AdbWinApi.dll"));
ExtractResource("MetaforceInstaller.Core.adb.AdbWinUsbApi.dll", Path.Combine(tempDir, "AdbWinUsbApi.dll"));
return adbPath; return adbPath;
} }

View file

@ -45,12 +45,19 @@
HorizontalAlignment="Stretch" /> HorizontalAlignment="Stretch" />
</StackPanel> </StackPanel>
<Image Grid.Column="0" <StackPanel Grid.Column="0" Margin="20" Spacing="15" VerticalAlignment="Bottom">
Margin="20" <Image
VerticalAlignment="Bottom" Margin="20"
Source="{DynamicResource Logo}" VerticalAlignment="Bottom"
HorizontalAlignment="Center"> Source="{DynamicResource Logo}"
</Image> HorizontalAlignment="Center">
</Image>
<TextBlock
Name="VersionTextBlock"
FontFamily="Consolas,Courier New,monospace"
FontSize="14"
HorizontalAlignment="Center" />
</StackPanel>
<!-- Right Panel - Logs --> <!-- Right Panel - Logs -->
<TextBox Grid.Column="1" Name="LogsTextBox" <TextBox Grid.Column="1" Name="LogsTextBox"

View file

@ -1,5 +1,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Interactivity; using Avalonia.Interactivity;
@ -28,10 +29,10 @@ public partial class MainWindow : Window
InitializeComponent(); InitializeComponent();
LogMessage("MetaforceInstaller by slavagm"); LogMessage("MetaforceInstaller by slavagm");
VersionTextBlock.Text = Assembly.GetExecutingAssembly()
_adbService = new AdbService(); .GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version;
_adbService.ProgressChanged += OnAdbProgressChanged;
_adbService.StatusChanged += OnAdbStatusChanged; _ = InitializeAdbAsync();
CheckAndEnableInstallButton(); CheckAndEnableInstallButton();
@ -40,6 +41,19 @@ public partial class MainWindow : Window
InstallButton.Click += OnInstallClicked; InstallButton.Click += OnInstallClicked;
} }
private async Task InitializeAdbAsync()
{
LogMessage("Инициализация ADB сервера...");
await Task.Run(() =>
{
_adbService = new AdbService();
_adbService.ProgressChanged += OnAdbProgressChanged;
_adbService.StatusChanged += OnAdbStatusChanged;
});
LogMessage("ADB сервер готов");
}
private void OnAdbProgressChanged(object? sender, ProgressInfo e) private void OnAdbProgressChanged(object? sender, ProgressInfo e)
{ {
Dispatcher.UIThread.InvokeAsync(() => Dispatcher.UIThread.InvokeAsync(() =>
@ -179,6 +193,12 @@ public partial class MainWindow : Window
return; return;
} }
if (_adbService == null)
{
LogMessage("ADB сервис еще инициализируется, попробуйте позже");
return;
}
_adbService.RefreshDeviceData(); _adbService.RefreshDeviceData();
InstallButton.IsEnabled = false; InstallButton.IsEnabled = false;

View file

@ -8,7 +8,7 @@
<BuiltInComInteropSupport>true</BuiltInComInteropSupport> <BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest> <ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault> <AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<FileVersion>1.2.1</FileVersion> <FileVersion>1.2.2</FileVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>