using Avalonia; using Avalonia.Controls; using Avalonia.Data; using Avalonia.Interactivity; namespace Млаумчерб.Клиент; public partial class Окне : Window { public static readonly StyledProperty UsernameProperty = AvaloniaProperty.Register<Окне, string>(nameof(Username), defaultBindingMode: BindingMode.TwoWay); public string Username { get => GetValue(UsernameProperty); set => SetValue(UsernameProperty, value); } public static readonly StyledProperty 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 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 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 { Config.LoadFromFile(); Username = Config.Instance.username; MemoryLimit = Config.Instance.memory; Fullscreen = Config.Instance.fullscreen; } catch (Exception ex) { Errors.ShowMessageBox(ex); } } private void LaunchButtonHandler(object? sender, RoutedEventArgs e) { try { Config.Instance.username = Username; Config.Instance.memory = MemoryLimit; Config.Instance.fullscreen = Fullscreen; Config.SaveToFile(); } catch (Exception ex) { Errors.ShowMessageBox(ex); } } }