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.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using WpfWindowPlacement;
|
||||||
using XIVChatCommon.Message;
|
using XIVChatCommon.Message;
|
||||||
using XIVChatCommon.Message.Server;
|
using XIVChatCommon.Message.Server;
|
||||||
|
|
||||||
|
@ -46,6 +47,8 @@ namespace XIVChat_Desktop {
|
||||||
|
|
||||||
public ObservableCollection<Notification> Notifications { get; set; } = new ObservableCollection<Notification>();
|
public ObservableCollection<Notification> Notifications { get; set; } = new ObservableCollection<Notification>();
|
||||||
|
|
||||||
|
public WindowPlacement WindowPlacement { get; set; }
|
||||||
|
|
||||||
#region io
|
#region io
|
||||||
|
|
||||||
private static readonly JsonSerializerSettings Settings = new JsonSerializerSettings {
|
private static readonly JsonSerializerSettings Settings = new JsonSerializerSettings {
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
AllowsTransparency="True"
|
AllowsTransparency="True"
|
||||||
Opacity="{Binding App.Config.Opacity}"
|
Opacity="{Binding App.Config.Opacity}"
|
||||||
Icon="/Resources/logo.ico"
|
Icon="/Resources/logo.ico"
|
||||||
|
SourceInitialized="MainWindow_OnSourceInitialized"
|
||||||
|
Closing="MainWindow_OnClosing"
|
||||||
d:DataContext="{d:DesignInstance local:MainWindow}">
|
d:DataContext="{d:DesignInstance local:MainWindow}">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
|
|
@ -8,6 +8,7 @@ using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using WpfWindowPlacement;
|
||||||
using XIVChatCommon.Message;
|
using XIVChatCommon.Message;
|
||||||
using XIVChatCommon.Message.Server;
|
using XIVChatCommon.Message.Server;
|
||||||
|
|
||||||
|
@ -403,5 +404,14 @@ namespace XIVChat_Desktop {
|
||||||
channel.ContextMenu!.PlacementTarget = channel;
|
channel.ContextMenu!.PlacementTarget = channel;
|
||||||
channel.ContextMenu!.IsOpen = true;
|
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="Sentry" Version="3.0.3" />
|
||||||
<PackageReference Include="Sodium.Core" Version="1.2.3" />
|
<PackageReference Include="Sodium.Core" Version="1.2.3" />
|
||||||
<PackageReference Include="System.Drawing.Common" Version="5.0.0" />
|
<PackageReference Include="System.Drawing.Common" Version="5.0.0" />
|
||||||
|
<PackageReference Include="WpfWindowPlacement" Version="3.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
Loading…
Reference in New Issue