Skip to content

Commit fa59ab9

Browse files
committed
⚓ Restore last window bounds ...
Added: - Settings -> Startup: Restore last window bounds (#22) - Settings -> Startup: Maximize window (#22) - Translation for window's JumpList - Settings: Update tab merged with Startup tab
1 parent 9ccabb5 commit fa59ab9

31 files changed

+325
-66
lines changed

.vs/quick-picture-viewer/v16/.suo

1.5 KB
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
-12.1 KB
Binary file not shown.

quick-picture-viewer/App.config

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@
5252
<setting name="StartupMaximize" serializeAs="String">
5353
<value>False</value>
5454
</setting>
55+
<setting name="StartupRestoreBounds" serializeAs="String">
56+
<value>True</value>
57+
</setting>
58+
<setting name="StartupWindowSize" serializeAs="String">
59+
<value>700, 485</value>
60+
</setting>
61+
<setting name="StartupWindowLocation" serializeAs="String">
62+
<value>100, 100</value>
63+
</setting>
5564
</quick_picture_viewer.Properties.Settings>
5665
</userSettings>
5766
</configuration>

quick-picture-viewer/CustomJumplist.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ public class CustomJumplist
77
{
88
private JumpList list;
99

10-
public CustomJumplist()
10+
public CustomJumplist(string newWindowTitle, string newWindowDesc)
1111
{
1212
JumpItem[] jumpItems = { new JumpTask() {
13-
Title = "New window",
14-
Description = "Create new QuickPictureViewer window",
13+
Title = newWindowTitle,
14+
Description = newWindowDesc,
1515
ApplicationPath = Assembly.GetEntryAssembly().Location,
1616
Arguments = "-1",
1717
IconResourcePath = "quick-picture-viewer.exe"

quick-picture-viewer/MainForm.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public MainForm(string openPath, bool darkMode)
5050
{
5151
if (darkMode)
5252
{
53-
this.HandleCreated += new EventHandler(ThemeManager.formHandleCreated);
53+
HandleCreated += new EventHandler(ThemeManager.formHandleCreated);
5454
}
5555

5656
this.darkMode = darkMode;
@@ -78,9 +78,15 @@ public MainForm(string openPath, bool darkMode)
7878

7979
closeFile();
8080

81+
if (Properties.Settings.Default.StartupRestoreBounds)
82+
{
83+
StartPosition = FormStartPosition.Manual;
84+
Location = Properties.Settings.Default.StartupWindowLocation;
85+
Size = Properties.Settings.Default.StartupWindowSize;
86+
}
8187
if (Properties.Settings.Default.StartupMaximize)
8288
{
83-
this.WindowState = FormWindowState.Maximized;
89+
WindowState = FormWindowState.Maximized;
8490
}
8591
}
8692

@@ -91,7 +97,7 @@ protected override void WndProc(ref Message m)
9197
{
9298
if (m.WParam == (IntPtr)NativeMethodsManager.SC_MAXIMIZE)
9399
{
94-
this.OnResizeEnd(EventArgs.Empty);
100+
OnResizeEnd(EventArgs.Empty);
95101
}
96102
}
97103
}
@@ -1819,6 +1825,13 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
18191825

18201826
e.Cancel = (window == DialogResult.No);
18211827
}
1828+
1829+
if (Properties.Settings.Default.StartupRestoreBounds)
1830+
{
1831+
Properties.Settings.Default.StartupWindowLocation = Location;
1832+
Properties.Settings.Default.StartupWindowSize = Size;
1833+
Properties.Settings.Default.Save();
1834+
}
18221835
}
18231836

18241837
private void showFileButton_Click(object sender, EventArgs e)
@@ -2025,7 +2038,7 @@ private void MainForm_Shown(object sender, EventArgs e)
20252038
{
20262039
try
20272040
{
2028-
CustomJumplist jumplist = new CustomJumplist();
2041+
CustomJumplist jumplist = new CustomJumplist(resMan.GetString("new-window"), resMan.GetString("new-window-desc"));
20292042
}
20302043
catch (Exception ex)
20312044
{

quick-picture-viewer/Properties/Settings.Designer.cs

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

quick-picture-viewer/Properties/Settings.settings

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,14 @@
4444
<Setting Name="StartupMaximize" Type="System.Boolean" Scope="User">
4545
<Value Profile="(Default)">False</Value>
4646
</Setting>
47+
<Setting Name="StartupRestoreBounds" Type="System.Boolean" Scope="User">
48+
<Value Profile="(Default)">True</Value>
49+
</Setting>
50+
<Setting Name="StartupWindowSize" Type="System.Drawing.Size" Scope="User">
51+
<Value Profile="(Default)">700, 485</Value>
52+
</Setting>
53+
<Setting Name="StartupWindowLocation" Type="System.Drawing.Point" Scope="User">
54+
<Value Profile="(Default)">100, 100</Value>
55+
</Setting>
4756
</Settings>
4857
</SettingsFile>

quick-picture-viewer/SettingsForm.Designer.cs

Lines changed: 75 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)