feat: persist window location between launches
This commit is contained in:
parent
16a00a704e
commit
787bf93dbd
|
@ -11,6 +11,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using WpfWindowPlacement;
|
||||
using XIVChatCommon.Message;
|
||||
using XIVChatCommon.Message.Server;
|
||||
|
||||
|
@ -46,6 +47,8 @@ namespace XIVChat_Desktop {
|
|||
|
||||
public ObservableCollection<Notification> Notifications { get; set; } = new ObservableCollection<Notification>();
|
||||
|
||||
public WindowPlacement WindowPlacement { get; set; }
|
||||
|
||||
#region io
|
||||
|
||||
private static readonly JsonSerializerSettings Settings = new JsonSerializerSettings {
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
AllowsTransparency="True"
|
||||
Opacity="{Binding App.Config.Opacity}"
|
||||
Icon="/Resources/logo.ico"
|
||||
SourceInitialized="MainWindow_OnSourceInitialized"
|
||||
Closing="MainWindow_OnClosing"
|
||||
d:DataContext="{d:DesignInstance local:MainWindow}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
|
|
|
@ -8,6 +8,7 @@ using System.Windows;
|
|||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using WpfWindowPlacement;
|
||||
using XIVChatCommon.Message;
|
||||
using XIVChatCommon.Message.Server;
|
||||
|
||||
|
@ -403,5 +404,14 @@ namespace XIVChat_Desktop {
|
|||
channel.ContextMenu!.PlacementTarget = channel;
|
||||
channel.ContextMenu!.IsOpen = true;
|
||||
}
|
||||
|
||||
private void MainWindow_OnSourceInitialized(object? sender, EventArgs e) {
|
||||
this.SetPlacement(this.App.Config.WindowPlacement);
|
||||
}
|
||||
|
||||
private void MainWindow_OnClosing(object sender, CancelEventArgs e) {
|
||||
this.App.Config.WindowPlacement = this.GetPlacement();
|
||||
this.App.Config.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
<PackageReference Include="Sentry" Version="3.0.3" />
|
||||
<PackageReference Include="Sodium.Core" Version="1.2.3" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="5.0.0" />
|
||||
<PackageReference Include="WpfWindowPlacement" Version="3.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
Loading…
Reference in New Issue
Block a user