Skip to content

Commit 31e0432

Browse files
committed
Added option to disable screen docking.
Fixed issue causing net graph form location to reset to load position upon saving options.
1 parent 70a67b2 commit 31e0432

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

Source/Forms/NetGraphForm.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private void SyncOptionsWithSampler(Options options) {
8282
}
8383

8484
private void SyncOptionsWithUI(Options options) {
85-
if (!options.Bounds.Location.IsEmpty) {
85+
if (!options.Bounds.Location.IsEmpty && StartPosition != FormStartPosition.Manual) {
8686
StartPosition = FormStartPosition.Manual;
8787
Location = options.Bounds.Location;
8888
}
@@ -139,6 +139,10 @@ private void ToggleWindowVisibility() {
139139
}
140140

141141
private bool CanSnap(int clientEdge, int containerEdge, int tension) {
142+
if (!options.Docking) {
143+
return false;
144+
}
145+
142146
const int DOCK_DISTANCE = 10;
143147

144148
return Math.Abs(clientEdge - containerEdge) <= DOCK_DISTANCE && Math.Abs(tension) <= DOCK_DISTANCE;

Source/Forms/OptionsForm.Designer.cs

Lines changed: 20 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/Forms/OptionsForm.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,30 @@ internal OptionsForm(Options options) {
2121

2222
InitializeComponent();
2323
LoadNetworkInterfaces();
24+
LoadSettings();
25+
26+
// Load default page.
27+
networking.SimulateClick();
2428
}
2529

2630
internal delegate void ApplyOptionsDelegate(OptionsForm sender, Options options);
2731

2832
internal event ApplyOptionsDelegate ApplyOptions;
2933

3034
private void SaveSettings() {
31-
if (SelectedNic != null) {
35+
if ((Options.NetworkInterface = SelectedNic) != null) {
3236
Options.NicSpeeds[SelectedNic.Id] = ulong.Parse(customSpeed.Text);
3337
}
3438

39+
Options.Docking = dock.Checked;
40+
3541
Options.Save();
3642
}
3743

44+
private void LoadSettings() {
45+
dock.Checked = Options.Docking;
46+
}
47+
3848
private void LoadNetworkInterfaces() {
3949
var interfaces = showDisabledAdapters.Checked ? NetworkInterfaces.FetchAll() : NetworkInterfaces.FetchOperational();
4050

@@ -99,8 +109,6 @@ private void apply_Click(object sender, EventArgs e) {
99109
}
100110

101111
private void nics_SelectedIndexChanged(object sender, EventArgs e) {
102-
Options.NetworkInterface = SelectedNic;
103-
104112
detectedSpeed.Text = (SelectedNic?.Speed / 8).ToString();
105113
customSpeed.Text = SelectedNic != null && Options.NicSpeeds.ContainsKey(SelectedNic.Id)
106114
? Options.NicSpeeds[SelectedNic.Id].ToString()

Source/Options.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public Options(Settings settings) {
1717
Bounds = settings.Bounds;
1818
Topmost = settings.Topmost;
1919
Transparent = settings.Transparent;
20+
Docking = settings.Docking;
2021
}
2122

2223
public NetworkInterface NetworkInterface { get; set; }
@@ -29,6 +30,8 @@ public Options(Settings settings) {
2930

3031
public bool Transparent { get; set; }
3132

33+
public bool Docking { get; set; }
34+
3235
public Options Clone() {
3336
var clone = (Options)MemberwiseClone();
3437
clone.NicSpeeds = new Dictionary<string, ulong>(NicSpeeds);
@@ -42,6 +45,7 @@ public void Save() {
4245
settings.Bounds = Bounds;
4346
settings.Topmost = Topmost;
4447
settings.Transparent = Transparent;
48+
settings.Docking = Docking;
4549

4650
settings.Save();
4751
}

0 commit comments

Comments
 (0)