switched to new way

This commit is contained in:
Boki 2026-02-13 01:12:51 -05:00
parent f22d182c8f
commit 4a65c8e17b
96 changed files with 4991 additions and 10025 deletions

View file

@ -0,0 +1,69 @@
using System.Collections.Specialized;
using Avalonia;
using Avalonia.Controls;
using Poe2Trade.Core;
using Poe2Trade.Ui.ViewModels;
namespace Poe2Trade.Ui.Views;
public partial class MainWindow : Window
{
private ConfigStore? _store;
public MainWindow()
{
InitializeComponent();
}
public void SetConfigStore(ConfigStore store)
{
_store = store;
var s = store.Settings;
if (s.WindowWidth.HasValue && s.WindowHeight.HasValue)
{
Width = s.WindowWidth.Value;
Height = s.WindowHeight.Value;
}
if (s.WindowX.HasValue && s.WindowY.HasValue)
{
Position = new PixelPoint((int)s.WindowX.Value, (int)s.WindowY.Value);
WindowStartupLocation = WindowStartupLocation.Manual;
}
else
{
WindowStartupLocation = WindowStartupLocation.CenterScreen;
}
}
protected override void OnDataContextChanged(EventArgs e)
{
base.OnDataContextChanged(e);
if (DataContext is MainWindowViewModel vm)
{
vm.Logs.CollectionChanged += (_, args) =>
{
if (args.Action == NotifyCollectionChangedAction.Add)
{
var logList = this.FindControl<ListBox>("LogList");
if (logList != null && vm.Logs.Count > 0)
logList.ScrollIntoView(vm.Logs[^1]);
}
};
}
}
protected override void OnClosing(WindowClosingEventArgs e)
{
if (_store != null)
{
_store.UpdateSettings(s =>
{
s.WindowX = Position.X;
s.WindowY = Position.Y;
s.WindowWidth = Width;
s.WindowHeight = Height;
});
}
base.OnClosing(e);
}
}