mlaumcherb/Млаумчерб.Клиент/Окне.axaml.cs

97 lines
3.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Avalonia;
using Avalonia.Controls;
using Avalonia.Data;
using Avalonia.Interactivity;
using Avalonia.Platform.Storage;
namespace Млаумчерб.Клиент;
public partial class Окне : Window
{
public static readonly StyledProperty<string> UsernameProperty =
AvaloniaProperty.Register<Окне, string>(nameof(Username),
defaultBindingMode: BindingMode.TwoWay);
public string Username
{
get => GetValue(UsernameProperty);
set => SetValue(UsernameProperty, value);
}
public static readonly StyledProperty<int> MemoryLimitProperty =
AvaloniaProperty.Register<Окне, int>(nameof(MemoryLimit),
defaultBindingMode: BindingMode.TwoWay, defaultValue: 2048);
public int MemoryLimit
{
get => GetValue(MemoryLimitProperty);
set => SetValue(MemoryLimitProperty, value);
}
public static readonly StyledProperty<bool> FullscreenProperty =
AvaloniaProperty.Register<Окне, bool>(nameof(Fullscreen),
defaultBindingMode: BindingMode.TwoWay, defaultValue: false);
public bool Fullscreen
{
get => GetValue(FullscreenProperty);
set => SetValue(FullscreenProperty, value);
}
public static readonly StyledProperty<bool> UpdateGameFilesProperty =
AvaloniaProperty.Register<Окне, bool>(nameof(UpdateGameFiles),
defaultBindingMode: BindingMode.TwoWay, defaultValue: true);
public bool UpdateGameFiles
{
get => GetValue(UpdateGameFilesProperty);
set => SetValue(UpdateGameFilesProperty, value);
}
public Окне()
{
InitializeComponent();
}
protected override void OnLoaded(RoutedEventArgs e)
{
try
{
Приложение.Настройки = Настройки.ЗагрузитьИзФайла();
Username = Приложение.Настройки.имя_пользователя;
MemoryLimit = Приложение.Настройки.выделенная_память_мб;
Fullscreen = Приложение.Настройки.открыватьаесь_экран;
}
catch (Exception ex)
{
Ошибки.ПоказатьСообщение(ex);
}
}
private void LaunchButtonHandler(object? sender, RoutedEventArgs e)
{
try
{
Приложение.Настройки.имя_пользователя = Username;
Приложение.Настройки.выделенная_память_мб = MemoryLimit;
Приложение.Настройки.открыватьаесь_экран = Fullscreen;
Приложение.Настройки.СохранитьВФайл();
}
catch (Exception ex)
{
Ошибки.ПоказатьСообщение(ex);
}
}
private void OpenLogsDirectory(object? s, RoutedEventArgs e)
{
Launcher.LaunchDirectoryInfoAsync(new DirectoryInfo(LauncherLogger.LogsDirectory.ToString()));
}
private void OpenLogFile(object? sender, RoutedEventArgs e)
{
Launcher.LaunchFileInfoAsync(new FileInfo(Приложение.Логгер.LogfileName.ToString()));
}
private void OpenSourceRepository(object? sender, RoutedEventArgs e)
{
Launcher.LaunchUriAsync(new Uri("https://timerix.ddns.net:3322/Timerix/mlaumcherb"));
}
}