Skip to content

Commit

Permalink
Instance GUI remember location and size
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCheatsrichter committed Aug 13, 2019
1 parent 96aa434 commit 7b75990
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Gw2 Launchbuddy/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
<setting name="plugins_autoupdate" serializeAs="String">
<value>False</value>
</setting>
<setting name="instancegui_windowsettings" serializeAs="String">
<value>0</value>
</setting>
</Gw2_Launchbuddy.Properties.Settings>
</userSettings>
<runtime>
Expand Down
2 changes: 1 addition & 1 deletion Gw2 Launchbuddy/GUI_ApplicationManager.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:local="clr-namespace:Gw2_Launchbuddy"
mc:Ignorable="d"
Name="myWindow"
Title="Game Instances" Height="300" ResizeMode="CanResizeWithGrip" Width="160" WindowStartupLocation="Manual" Topmost="True" WindowStyle="None" Loaded="Window_Loaded" AllowsTransparency="True" Background="Transparent" MouseLeftButtonDown="Window_MouseLeftButtonDown" Initialized="Window_Initialized" Icon="launchbuddy.ico">
Title="Game Instances" Height="300" MinHeight="160" MinWidth="160" ResizeMode="CanResizeWithGrip" Width="160" WindowStartupLocation="Manual" Topmost="True" WindowStyle="None" Loaded="Window_Loaded" AllowsTransparency="True" Background="Transparent" MouseLeftButtonDown="Window_MouseLeftButtonDown" Icon="launchbuddy.ico" SizeChanged="myWindow_SizeChanged">

<Window.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
Expand Down
28 changes: 22 additions & 6 deletions Gw2 Launchbuddy/GUI_ApplicationManager.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,29 @@ public partial class GUI_ApplicationManager : Window
public GUI_ApplicationManager()
{
InitializeComponent();
this.Left = Properties.Settings.Default.instance_win_X;
this.Top = Properties.Settings.Default.instance_win_Y;
var windowsettings = Properties.Settings.Default.instancegui_windowsettings;
if (windowsettings.Equals((0, 0, 0, 0)))
{
Properties.Settings.Default.instancegui_windowsettings = (0, 0, 160, 300);
Properties.Settings.Default.Save();
}
Left = windowsettings.Item1;
Top = windowsettings.Item2;
Width = windowsettings.Item3;
Height = windowsettings.Item4;
}

private void bt_close_Click(object sender, RoutedEventArgs e)
{
this.WindowState = WindowState.Minimized;
}

private void SaveWindowSettings()
{
Properties.Settings.Default.instancegui_windowsettings = (Left, Top, ActualWidth, ActualHeight);
Properties.Settings.Default.Save();
}

private void Window_Loaded(object sender, RoutedEventArgs e)
{
lv_instances.ItemsSource = ClientManager.ActiveClients;
Expand Down Expand Up @@ -53,10 +67,7 @@ private void bt_maxmin_Click(object sender, RoutedEventArgs e)
private void Window_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
this.DragMove();
}

private void Window_Initialized(object sender, EventArgs e)
{
SaveWindowSettings();
}

private void bt_suspend_Click(object sender, RoutedEventArgs e)
Expand All @@ -68,5 +79,10 @@ private void bt_resume_Click(object sender, RoutedEventArgs e)
{
((sender as Button).DataContext as Client).Resume();
}

private void myWindow_SizeChanged(object sender, SizeChangedEventArgs e)
{
SaveWindowSettings();
}
}
}
11 changes: 11 additions & 0 deletions Gw2 Launchbuddy/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Gw2 Launchbuddy/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,8 @@
<Setting Name="plugins_autoupdate" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="instancegui_windowsettings" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
</Settings>
</SettingsFile>

0 comments on commit 7b75990

Please sign in to comment.