Skip to content

Commit 19f16b4

Browse files
committed
v1.6.0 - 2021-07-09
1 parent 103d3d4 commit 19f16b4

23 files changed

+1340
-288
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
utility that lets you quickly force any program to be always on top
44

55
should work on any version of windows that supports .net framework 4.0
6+
7+
[Click here to download!](https://github.com/flashwave/topmostfriend/releases/latest)

TopMostFriend/AboutWindow.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static void Display() {
1515
}
1616

1717
public AboutWindow() {
18-
Text = @"About Top Most Friend";
18+
Text = Locale.String(@"AboutTitle");
1919
Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
2020
BackgroundImage = Properties.Resources.about;
2121
StartPosition = FormStartPosition.CenterScreen;
@@ -24,11 +24,12 @@ public AboutWindow() {
2424
ClientSize = Properties.Resources.about.Size;
2525
MaximizeBox = MinimizeBox = false;
2626
MaximumSize = MinimumSize = Size;
27+
TopMost = true;
2728

2829
int tabIndex = 0;
2930

3031
Button closeButton = new Button {
31-
Text = @"Close",
32+
Text = Locale.String(@"AboutClose"),
3233
Size = new Size(BUTTON_WIDTH, BUTTON_HEIGHT),
3334
TabIndex = ++tabIndex,
3435
};
@@ -37,7 +38,7 @@ public AboutWindow() {
3738
Controls.Add(closeButton);
3839

3940
Button websiteButton = new Button {
40-
Text = @"Website",
41+
Text = Locale.String(@"AboutWebsite"),
4142
Size = new Size(BUTTON_WIDTH, BUTTON_HEIGHT),
4243
TabIndex = ++tabIndex,
4344
};
@@ -46,7 +47,7 @@ public AboutWindow() {
4647
Controls.Add(websiteButton);
4748

4849
Button donateButton = new Button {
49-
Text = @"Donate",
50+
Text = Locale.String(@"AboutDonate"),
5051
Size = new Size(BUTTON_WIDTH, BUTTON_HEIGHT),
5152
TabIndex = ++tabIndex,
5253
};

TopMostFriend/ActionTimeout.cs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Threading;
3+
4+
namespace TopMostFriend {
5+
public class ActionTimeout {
6+
private readonly Action Action;
7+
private bool Continue = true;
8+
private int Remaining = 0;
9+
private const int STEP = 500;
10+
11+
public ActionTimeout(Action action, int timeout) {
12+
Action = action ?? throw new ArgumentNullException(nameof(action));
13+
if(timeout < 1)
14+
throw new ArgumentException(@"Timeout must be a positive integer.", nameof(timeout));
15+
Remaining = timeout;
16+
new Thread(ThreadBody) { IsBackground = true }.Start();
17+
}
18+
19+
private void ThreadBody() {
20+
do {
21+
Thread.Sleep(STEP);
22+
Remaining -= STEP;
23+
24+
if(!Continue)
25+
return;
26+
} while(Remaining > 0);
27+
28+
Action.Invoke();
29+
}
30+
31+
public void Cancel() {
32+
Continue = false;
33+
}
34+
}
35+
}

TopMostFriend/BlacklistWindow.cs

+21-18
Original file line numberDiff line numberDiff line change
@@ -35,34 +35,35 @@ public BlacklistWindow(string title, string[] items) {
3535
MinimizeBox = MaximizeBox = false;
3636
MinimumSize = Size;
3737
DialogResult = DialogResult.Cancel;
38+
TopMost = true;
3839

3940
BlacklistView = new ListBox {
4041
TabIndex = 101,
4142
IntegralHeight = false,
4243
Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
43-
Location = new Point(BUTTON_WIDTH + (SPACING * 2), SPACING),
44+
Location = new Point(SPACING, SPACING),
4445
ClientSize = new Size(ClientSize.Width - BUTTON_WIDTH - (int)(SPACING * 3.5), ClientSize.Height - (int)(SPACING * 2.5)),
4546
};
4647
BlacklistView.SelectedIndexChanged += BlacklistView_SelectedIndexChanged;
4748
BlacklistView.MouseDoubleClick += BlacklistView_MouseDoubleClick;
4849

4950
AddButton = new Button {
50-
Anchor = AnchorStyles.Top | AnchorStyles.Left,
51-
Text = @"Add",
51+
Anchor = AnchorStyles.Top | AnchorStyles.Right,
52+
Text = Locale.String(@"BlacklistAdd"),
5253
ClientSize = new Size(BUTTON_WIDTH, BUTTON_HEIGHT),
53-
Location = new Point(SPACING, SPACING),
54+
Location = new Point(BlacklistView.Width + (SPACING * 2), SPACING),
5455
TabIndex = 201,
5556
};
5657
EditButton = new Button {
57-
Text = @"Edit",
58+
Text = Locale.String(@"BlacklistEdit"),
5859
Location = new Point(AddButton.Location.X, AddButton.Location.Y + AddButton.Height + SPACING),
5960
Enabled = false,
6061
Anchor = AddButton.Anchor,
6162
ClientSize = AddButton.ClientSize,
6263
TabIndex = 202,
6364
};
6465
RemoveButton = new Button {
65-
Text = @"Remove",
66+
Text = Locale.String(@"BlacklistRemove"),
6667
Location = new Point(AddButton.Location.X, EditButton.Location.Y + AddButton.Height + SPACING),
6768
Enabled = false,
6869
Anchor = AddButton.Anchor,
@@ -75,16 +76,16 @@ public BlacklistWindow(string title, string[] items) {
7576
RemoveButton.Click += RemoveButton_Click;
7677

7778
CancelButton = new Button {
78-
Anchor = AnchorStyles.Bottom | AnchorStyles.Left,
79-
Text = @"Cancel",
80-
Location = new Point(SPACING, ClientSize.Height - AddButton.ClientSize.Height - SPACING),
79+
Anchor = AnchorStyles.Bottom | AnchorStyles.Right,
80+
Text = Locale.String(@"BlacklistCancel"),
81+
Location = new Point(AddButton.Location.X, ClientSize.Height - AddButton.ClientSize.Height - SPACING),
8182
ClientSize = AddButton.ClientSize,
8283
TabIndex = 10001,
8384
};
8485
Button acceptButton = new Button {
85-
Anchor = AnchorStyles.Bottom | AnchorStyles.Left,
86-
Text = @"Done",
87-
Location = new Point(SPACING, ClientSize.Height - ((AddButton.ClientSize.Height + SPACING) * 2)),
86+
Anchor = AnchorStyles.Bottom | AnchorStyles.Right,
87+
Text = Locale.String(@"BlacklistDone"),
88+
Location = new Point(AddButton.Location.X, ClientSize.Height - ((AddButton.ClientSize.Height + SPACING) * 2)),
8889
ClientSize = AddButton.ClientSize,
8990
TabIndex = 10002,
9091
};
@@ -106,24 +107,26 @@ private class BlacklistEditorWindow : Form {
106107
public string Original { get; }
107108
public string String { get => TextBox.Text; }
108109

109-
private TextBox TextBox;
110+
private readonly TextBox TextBox;
110111

111112
public BlacklistEditorWindow(string original = null) {
112113
Original = original ?? string.Empty;
113-
Text = original == null ? @"Adding new entry..." : $@"Editing {original}...";
114+
Text = Locale.String(original == null ? @"BlacklistEditorAdding" : @"BlacklistEditorEditing", original);
115+
Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
114116
StartPosition = FormStartPosition.CenterParent;
115-
FormBorderStyle = FormBorderStyle.FixedToolWindow;
117+
FormBorderStyle = FormBorderStyle.FixedSingle;
116118
ClientSize = new Size(500, 39);
117119
MaximizeBox = MinimizeBox = false;
118120
MaximumSize = MinimumSize = Size;
121+
TopMost = true;
119122

120123
Button cancelButton = new Button {
121124
Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right,
122125
Location = new Point(ClientSize.Width - 75 - 8, 8),
123126
Name = @"cancelButton",
124127
Size = new Size(75, 23),
125128
TabIndex = 102,
126-
Text = @"Cancel",
129+
Text = Locale.String(@"BlacklistEditorCancel"),
127130
};
128131
cancelButton.Click += (s, e) => { DialogResult = DialogResult.Cancel; Close(); };
129132

@@ -133,14 +136,14 @@ public BlacklistEditorWindow(string original = null) {
133136
Name = @"saveButton",
134137
Size = new Size(75, 23),
135138
TabIndex = 101,
136-
Text = @"Save",
139+
Text = Locale.String(@"BlacklistEditorSave"),
137140
};
138141
saveButton.Click += (s, e) => { DialogResult = DialogResult.OK; Close(); };
139142

140143
TextBox = new TextBox {
141144
Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
142145
Location = new Point(8, 9),
143-
Name = @"deviceSelection",
146+
Name = @"deviceSelection", // ??????
144147
Size = new Size(ClientSize.Width - 8 - cancelButton.Width - saveButton.Width - 19, 23),
145148
TabIndex = 100,
146149
Text = Original,

0 commit comments

Comments
 (0)