Updated Avalonia
This commit is contained in:
Родитель
d7aa1ee846
Коммит
f1abb0080d
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia.Desktop" Version="0.8.2" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="0.8.999-cibuild0004115-beta" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SharpDX" Version="4.0.1" />
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="0.8.2" />
|
||||
<PackageReference Include="Avalonia" Version="0.8.999-cibuild0004115-beta" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Serilog" Version="2.5.0" />
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
// Copyright (c) Wiesław Šoltés. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Diagnostics;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Logging.Serilog;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
|
@ -13,11 +12,13 @@ namespace SimpleWavSplitter.Avalonia
|
|||
/// </summary>
|
||||
public class App : Application
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize()
|
||||
/// <summary>
|
||||
/// Program entry point.
|
||||
/// </summary>
|
||||
/// <param name="args">The program arguments.</param>
|
||||
static void Main(string[] args)
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
base.Initialize();
|
||||
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -28,25 +29,23 @@ namespace SimpleWavSplitter.Avalonia
|
|||
=> AppBuilder.Configure<App>()
|
||||
.UsePlatformDetect()
|
||||
.LogToDebug();
|
||||
|
||||
/// <summary>
|
||||
/// Program entry point.
|
||||
/// </summary>
|
||||
/// <param name="args">The program arguments.</param>
|
||||
static void Main(string[] args)
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize()
|
||||
{
|
||||
BuildAvaloniaApp().Start<MainWindow>();
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attaches development tools to window in debug mode.
|
||||
/// </summary>
|
||||
/// <param name="window">The window to attach development tools.</param>
|
||||
public static void AttachDevTools(Window window)
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
#if DEBUG
|
||||
DevTools.Attach(window);
|
||||
#endif
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime)
|
||||
{
|
||||
desktopLifetime.MainWindow = new MainWindow();
|
||||
}
|
||||
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewLifetime)
|
||||
{
|
||||
//singleViewLifetime.MainView = new MainView();
|
||||
}
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,13 +15,13 @@ namespace SimpleWavSplitter.Avalonia
|
|||
public class MainWindow : Window
|
||||
{
|
||||
private SimpleWavFileSplitter _wavFileSplitter;
|
||||
private Button btnGetWavHeader;
|
||||
private ProgressBar progress;
|
||||
private Button btnCancel;
|
||||
private Button btnSplitWavFiles;
|
||||
private TextBox textOutputPath;
|
||||
private Button btnBrowseOutputPath;
|
||||
private TextBox textOutput;
|
||||
private Button _btnGetWavHeader;
|
||||
private ProgressBar _progress;
|
||||
private Button _btnCancel;
|
||||
private Button _btnSplitWavFiles;
|
||||
private TextBox _textOutputPath;
|
||||
private Button _btnBrowseOutputPath;
|
||||
private TextBox _textOutput;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the new instance of <see cref="MainWindow"/> class.
|
||||
|
@ -29,26 +29,25 @@ namespace SimpleWavSplitter.Avalonia
|
|||
public MainWindow()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
App.AttachDevTools(this);
|
||||
|
||||
_wavFileSplitter = new SimpleWavFileSplitter();
|
||||
|
||||
btnGetWavHeader = this.FindControl<Button>("btnGetWavHeader");
|
||||
progress = this.FindControl<ProgressBar>("progress");
|
||||
btnCancel = this.FindControl<Button>("btnCancel");
|
||||
btnSplitWavFiles = this.FindControl<Button>("btnSplitWavFiles");
|
||||
textOutputPath = this.FindControl<TextBox>("textOutputPath");
|
||||
btnBrowseOutputPath = this.FindControl<Button>("btnBrowseOutputPath");
|
||||
textOutput = this.FindControl<TextBox>("textOutput");
|
||||
_btnGetWavHeader = this.FindControl<Button>("btnGetWavHeader");
|
||||
_progress = this.FindControl<ProgressBar>("progress");
|
||||
_btnCancel = this.FindControl<Button>("btnCancel");
|
||||
_btnSplitWavFiles = this.FindControl<Button>("btnSplitWavFiles");
|
||||
_textOutputPath = this.FindControl<TextBox>("textOutputPath");
|
||||
_btnBrowseOutputPath = this.FindControl<Button>("btnBrowseOutputPath");
|
||||
_textOutput = this.FindControl<TextBox>("textOutput");
|
||||
|
||||
var version = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
Title = string.Format("SimpleWavSplitter v{0}.{1}.{2}", version?.Major, version?.Minor, version?.Build);
|
||||
|
||||
btnBrowseOutputPath.Click += async (sender, e) => await GetOutputPath();
|
||||
btnGetWavHeader.Click += async (sender, e) => await GetWavHeader();
|
||||
btnSplitWavFiles.Click += async (sender, e) => await SplitWavFiles();
|
||||
btnCancel.Click += async (sender, e) => await _wavFileSplitter.CancelSplitWavFiles(
|
||||
value => Dispatcher.UIThread.InvokeAsync(() => progress.Value = value));
|
||||
_btnBrowseOutputPath.Click += async (sender, e) => await GetOutputPath();
|
||||
_btnGetWavHeader.Click += async (sender, e) => await GetWavHeader();
|
||||
_btnSplitWavFiles.Click += async (sender, e) => await SplitWavFiles();
|
||||
_btnCancel.Click += async (sender, e) => await _wavFileSplitter.CancelSplitWavFiles(
|
||||
value => Dispatcher.UIThread.InvokeAsync(() => _progress.Value = value));
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
|
@ -60,16 +59,16 @@ namespace SimpleWavSplitter.Avalonia
|
|||
{
|
||||
var dlg = new OpenFolderDialog();
|
||||
|
||||
string text = textOutputPath.Text;
|
||||
string text = _textOutputPath.Text;
|
||||
if (text.Length > 0)
|
||||
{
|
||||
dlg.InitialDirectory = textOutputPath.Text;
|
||||
dlg.Directory = _textOutputPath.Text;
|
||||
}
|
||||
|
||||
var result = await dlg.ShowAsync(this);
|
||||
if (!string.IsNullOrWhiteSpace(result))
|
||||
{
|
||||
textOutputPath.Text = result;
|
||||
_textOutputPath.Text = result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +82,7 @@ namespace SimpleWavSplitter.Avalonia
|
|||
var result = await dlg.ShowAsync(this);
|
||||
if (result != null)
|
||||
{
|
||||
_wavFileSplitter.GetWavHeader(result, text => textOutput.Text = text);
|
||||
_wavFileSplitter.GetWavHeader(result, text => _textOutput.Text = text);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,9 +98,9 @@ namespace SimpleWavSplitter.Avalonia
|
|||
{
|
||||
await _wavFileSplitter.SplitWavFiles(
|
||||
result,
|
||||
textOutputPath.Text,
|
||||
value => Dispatcher.UIThread.InvokeAsync(() => progress.Value = value),
|
||||
text => Dispatcher.UIThread.InvokeAsync(() => textOutput.Text = text));
|
||||
_textOutputPath.Text,
|
||||
value => Dispatcher.UIThread.InvokeAsync(() => _progress.Value = value),
|
||||
text => Dispatcher.UIThread.InvokeAsync(() => _textOutput.Text = text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче