add logs, help and logo

This commit is contained in:
Oleksandr Bezdieniezhnykh
2024-05-17 09:11:48 +03:00
parent 6c2e46552a
commit 8c02514ce9
7 changed files with 47 additions and 33 deletions
+10 -1
View File
@@ -1,6 +1,8 @@
using System.Reflection; using System.IO;
using System.Reflection;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Threading;
using Azaion.Annotator.DTO; using Azaion.Annotator.DTO;
using LibVLCSharp.Shared; using LibVLCSharp.Shared;
using MediatR; using MediatR;
@@ -30,6 +32,13 @@ public partial class App : Application
services.AddSingleton<PlayerControlHandler>(); services.AddSingleton<PlayerControlHandler>();
_serviceProvider = services.BuildServiceProvider(); _serviceProvider = services.BuildServiceProvider();
_mediator = _serviceProvider.GetService<IMediator>()!; _mediator = _serviceProvider.GetService<IMediator>()!;
DispatcherUnhandledException += OnDispatcherUnhandledException;
}
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
File.AppendAllText("logs.txt", e.Exception.Message);
e.Handled = true;
} }
protected override void OnStartup(StartupEventArgs e) protected override void OnStartup(StartupEventArgs e)
@@ -6,6 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
<TargetFramework>net8.0-windows</TargetFramework> <TargetFramework>net8.0-windows</TargetFramework>
<ApplicationIcon>logo.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -26,4 +27,11 @@
</Content> </Content>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Remove="logo.ico" />
<Resource Include="logo.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
</ItemGroup>
</Project> </Project>
@@ -5,8 +5,11 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Azaion.Annotator" xmlns:local="clr-namespace:Azaion.Annotator"
mc:Ignorable="d" mc:Ignorable="d"
Title="HelpWindow" Height="450" Width="800"> Title="Як анотувати" Height="580" Width="800"
<Grid> ResizeMode="NoResize"
Topmost="True"
WindowStartupLocation="CenterScreen">
<Grid Margin="15">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
@@ -39,10 +42,10 @@
<TextBlock Grid.Row="6" TextWrapping="Wrap" FontSize="18" > <TextBlock Grid.Row="6" TextWrapping="Wrap" FontSize="18" >
6. Артилерія - це гармати, міномети. Якщо це САУ наприклад, або будь що на гусеничній техніці, це Броньована техніка. 6. Артилерія - це гармати, міномети. Якщо це САУ наприклад, або будь що на гусеничній техніці, це Броньована техніка.
</TextBlock> </TextBlock>
<CheckBox Grid.Row="7" x:Name="CbShowHelp" IsChecked="{Binding Path=ShowHelpOnStart}"> <CheckBox Grid.Row="7" x:Name="CbShowHelp" Margin="10" Checked="CbShowHelp_OnChecked" Unchecked="CbShowHelp_OnUnchecked">
Показувати при запуску Показувати при запуску
</CheckBox> </CheckBox>
<Button Grid.Row="8" Click="Close" IsEnabledChanged="UIElement_OnIsEnabledChanged"> <Button Grid.Row="8" Click="Close" Height="28" Margin="10" Cursor="Hand">
Закрити Закрити
</Button> </Button>
</Grid> </Grid>
@@ -5,23 +5,16 @@ namespace Azaion.Annotator;
public partial class HelpWindow : Window public partial class HelpWindow : Window
{ {
public bool ShowHelpOnStart { get; set; }
private readonly Config _config; private readonly Config _config;
public HelpWindow(Config config) public HelpWindow(Config config)
{ {
_config = config; _config = config;
ShowHelpOnStart = config.ShowHelpOnStart; Loaded += (_, _) => CbShowHelp.IsChecked = _config.ShowHelpOnStart;
InitializeComponent(); InitializeComponent();
} }
private void Close(object sender, RoutedEventArgs e) => Close();
private void Close(object sender, RoutedEventArgs e) private void CbShowHelp_OnChecked(object sender, RoutedEventArgs e) => _config.ShowHelpOnStart = true;
{ private void CbShowHelp_OnUnchecked(object sender, RoutedEventArgs e) => _config.ShowHelpOnStart = false;
Close();
}
private void UIElement_OnIsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
{
_config.ShowHelpOnStart = CbShowHelp.IsChecked ?? true;
}
} }
@@ -70,7 +70,12 @@
<MenuItem Header="Файл" Foreground="#FFBDBCBC" Margin="0,3,0,0"> <MenuItem Header="Файл" Foreground="#FFBDBCBC" Margin="0,3,0,0">
<MenuItem x:Name="OpenFolderItem" <MenuItem x:Name="OpenFolderItem"
Foreground="Black" Foreground="Black"
IsEnabled="True" Header="Відкрити папку..." Click="MenuItem_OnClick"/> IsEnabled="True" Header="Відкрити папку..." Click="OpenFolderItemClick"/>
</MenuItem>
<MenuItem Header="Допомога" Foreground="#FFBDBCBC" Margin="0,3,0,0">
<MenuItem x:Name="OpenHelpWindow"
Foreground="Black"
IsEnabled="True" Header="Як анотувати" Click="OpenHelpWindowClick"/>
</MenuItem> </MenuItem>
</Menu> </Menu>
<Grid <Grid
@@ -1,15 +1,15 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Globalization; using System.Drawing;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Windows; using System.Windows;
using System.Windows.Forms;
using System.Windows.Threading;
using Azaion.Annotator.DTO; using Azaion.Annotator.DTO;
using Azaion.Annotator.Extensions; using Azaion.Annotator.Extensions;
using LibVLCSharp.Shared; using LibVLCSharp.Shared;
using MediatR; using MediatR;
using Microsoft.WindowsAPICodePack.Dialogs; using Microsoft.WindowsAPICodePack.Dialogs;
using Point = System.Windows.Point;
using Size = System.Windows.Size;
namespace Azaion.Annotator; namespace Azaion.Annotator;
@@ -74,18 +74,7 @@ public partial class MainWindow
ShowHelpOnStart = _config.ShowHelpOnStart; ShowHelpOnStart = _config.ShowHelpOnStart;
if (ShowHelpOnStart) if (ShowHelpOnStart)
{
_helpWindow.Show(); _helpWindow.Show();
_ = Task.Run(() =>
{
Task.Delay(300);
Dispatcher.Invoke(() =>
{
_helpWindow.Activate();
});
});
}
} }
public void BlinkHelp(string helpText, int times = 3) public void BlinkHelp(string helpText, int times = 3)
@@ -230,6 +219,7 @@ public partial class MainWindow
_libVLC.Dispose(); _libVLC.Dispose();
_config.AnnotationClasses = AnnotationClasses.ToList(); _config.AnnotationClasses = AnnotationClasses.ToList();
_config.Save(); _config.Save();
Application.Current.Shutdown();
} }
// private void AddClassBtnClick(object sender, RoutedEventArgs e) // private void AddClassBtnClick(object sender, RoutedEventArgs e)
@@ -238,7 +228,7 @@ public partial class MainWindow
// AnnotationClasses.Add(new AnnotationClass(AnnotationClasses.Count)); // AnnotationClasses.Add(new AnnotationClass(AnnotationClasses.Count));
// LvClasses.SelectedIndex = AnnotationClasses.Count - 1; // LvClasses.SelectedIndex = AnnotationClasses.Count - 1;
// } // }
private void MenuItem_OnClick(object sender, RoutedEventArgs e) => OpenFolder(); private void OpenFolderItemClick(object sender, RoutedEventArgs e) => OpenFolder();
private void OpenFolderButtonClick(object sender, RoutedEventArgs e) => OpenFolder(); private void OpenFolderButtonClick(object sender, RoutedEventArgs e) => OpenFolder();
private void OpenFolder() private void OpenFolder()
{ {
@@ -266,4 +256,10 @@ public partial class MainWindow
private void RemoveSelectedClick(object sender, RoutedEventArgs e) => _mediator.Publish(new PlaybackControlEvent(PlaybackControlEnum.RemoveSelectedAnns)); private void RemoveSelectedClick(object sender, RoutedEventArgs e) => _mediator.Publish(new PlaybackControlEvent(PlaybackControlEnum.RemoveSelectedAnns));
private void RemoveAllClick(object sender, RoutedEventArgs e) => _mediator.Publish(new PlaybackControlEvent(PlaybackControlEnum.RemoveAllAnns)); private void RemoveAllClick(object sender, RoutedEventArgs e) => _mediator.Publish(new PlaybackControlEvent(PlaybackControlEnum.RemoveAllAnns));
private void OpenHelpWindowClick(object sender, RoutedEventArgs e)
{
_helpWindow.Show();
_helpWindow.Activate();
}
} }
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB