Skip to content

Commit 2476d10

Browse files
committed
Hotfix to 2.5
1 parent e0a1b4c commit 2476d10

6 files changed

Lines changed: 35 additions & 35 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [2.5] - 2019-11-21
6+
- Bugfix when restoring state
7+
58
## [2.4] - 2019-11-15
69
- New: Choose font size
710
- New: Hide passwords from list

Lain/MainForm.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ public MainForm(SecureString key)
5252

5353
private void RestoreWindowState()
5454
{
55-
if (Options.CurrentOptions.WindowSize.IsEmpty && Options.CurrentOptions.WindowLocation == null)
56-
{
57-
return;
58-
}
59-
55+
this.WindowState = Options.CurrentOptions.WindowState;
6056
this.Size = Options.CurrentOptions.WindowSize;
6157

6258
if (Options.CurrentOptions.WindowLocation != null)
@@ -71,8 +67,18 @@ private void RestoreWindowState()
7167

7268
private void SaveWindowState()
7369
{
74-
Options.CurrentOptions.WindowLocation = this.Location;
75-
Options.CurrentOptions.WindowSize = this.Size;
70+
Options.CurrentOptions.WindowState = this.WindowState;
71+
72+
if (this.WindowState == FormWindowState.Normal)
73+
{
74+
Options.CurrentOptions.WindowLocation = this.Location;
75+
Options.CurrentOptions.WindowSize = this.Size;
76+
}
77+
else
78+
{
79+
Options.CurrentOptions.WindowLocation = this.RestoreBounds.Location;
80+
Options.CurrentOptions.WindowSize = this.RestoreBounds.Size;
81+
}
7682
}
7783

7884
private string NewVersionMessage(string latest)

Lain/Options.cs

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class SettingsJson
1717
public int FontSize { get; set; }
1818
public Size WindowSize { get; set; }
1919
public Point? WindowLocation { get; set; }
20+
public FormWindowState WindowState { get; set; }
2021
}
2122

2223
internal static class Options
@@ -30,9 +31,6 @@ internal static class Options
3031

3132
internal static SettingsJson CurrentOptions = new SettingsJson();
3233

33-
// use this to determine if changes have been made
34-
static SettingsJson _flag = new SettingsJson();
35-
3634
internal static void ApplyTheme(Form f)
3735
{
3836
switch (CurrentOptions.Color)
@@ -97,19 +95,16 @@ internal static void SaveSettings()
9795
{
9896
if (File.Exists(_settingsFile))
9997
{
100-
if ((_flag.HidePasswords != CurrentOptions.HidePasswords) || (_flag.WindowLocation != CurrentOptions.WindowLocation) || (_flag.WindowSize != CurrentOptions.WindowSize) || (_flag.FontSize != CurrentOptions.FontSize) || (_flag.Color != CurrentOptions.Color) || (_flag.Authorize != CurrentOptions.Authorize) || (_flag.AutoLock != CurrentOptions.AutoLock) || (_flag.AutoStart != CurrentOptions.AutoStart) || (_flag.Minutes != CurrentOptions.Minutes))
101-
{
102-
File.Delete(_settingsFile);
98+
File.WriteAllText(_settingsFile, string.Empty);
10399

104-
using (FileStream fs = File.Open(_settingsFile, FileMode.OpenOrCreate))
105-
using (StreamWriter sw = new StreamWriter(fs))
106-
using (JsonWriter jw = new JsonTextWriter(sw))
107-
{
108-
jw.Formatting = Formatting.Indented;
100+
using (FileStream fs = File.Open(_settingsFile, FileMode.OpenOrCreate))
101+
using (StreamWriter sw = new StreamWriter(fs))
102+
using (JsonWriter jw = new JsonTextWriter(sw))
103+
{
104+
jw.Formatting = Formatting.Indented;
109105

110-
JsonSerializer serializer = new JsonSerializer();
111-
serializer.Serialize(jw, CurrentOptions);
112-
}
106+
JsonSerializer serializer = new JsonSerializer();
107+
serializer.Serialize(jw, CurrentOptions);
113108
}
114109
}
115110
}
@@ -127,6 +122,7 @@ internal static void LoadSettings()
127122
CurrentOptions.WindowLocation = null;
128123
CurrentOptions.WindowSize = new Size(907, 681);
129124
CurrentOptions.FontSize = 1;
125+
CurrentOptions.WindowState = FormWindowState.Normal;
130126

131127
using (FileStream fs = File.Open(_settingsFile, FileMode.CreateNew))
132128
using (StreamWriter sw = new StreamWriter(fs))
@@ -142,16 +138,11 @@ internal static void LoadSettings()
142138
{
143139
CurrentOptions = JsonConvert.DeserializeObject<SettingsJson>(File.ReadAllText(_settingsFile));
144140

145-
// initialize flag
146-
_flag.Color = CurrentOptions.Color;
147-
_flag.Authorize = CurrentOptions.Authorize;
148-
_flag.AutoLock = CurrentOptions.AutoLock;
149-
_flag.AutoStart = CurrentOptions.AutoStart;
150-
_flag.Minutes = CurrentOptions.Minutes;
151-
_flag.WindowLocation = CurrentOptions.WindowLocation;
152-
_flag.WindowSize = CurrentOptions.WindowSize;
153-
_flag.FontSize = CurrentOptions.FontSize;
154-
_flag.HidePasswords = CurrentOptions.HidePasswords;
141+
if (CurrentOptions.WindowSize.IsEmpty)
142+
{
143+
CurrentOptions.WindowSize = new Size(907, 681);
144+
SaveSettings();
145+
}
155146
}
156147
}
157148
}

Lain/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ static class Program
1313

1414
// Enter current version here
1515
internal readonly static float Major = 2;
16-
internal readonly static float Minor = 4;
16+
internal readonly static float Minor = 5;
1717

1818
/* END OF VERSION PROPERTIES */
1919

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ https://github.com/hellzerg/lain/blob/master/IMAGES.md
2424

2525
## Details: ##
2626

27-
* Latest version: 2.4
28-
* Released: November 15, 2019
27+
* Latest version: 2.5
28+
* Released: November 21, 2019

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4
1+
2.5

0 commit comments

Comments
 (0)