Skip to content

Commit

Permalink
v1.6.0 - 2021-07-09
Browse files Browse the repository at this point in the history
  • Loading branch information
flashwave committed Aug 26, 2022
1 parent 103d3d4 commit 19f16b4
Show file tree
Hide file tree
Showing 23 changed files with 1,340 additions and 288 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
utility that lets you quickly force any program to be always on top

should work on any version of windows that supports .net framework 4.0

[Click here to download!](https://github.com/flashwave/topmostfriend/releases/latest)
9 changes: 5 additions & 4 deletions TopMostFriend/AboutWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public sealed class AboutWindow : Form {
}

public AboutWindow() {
Text = @"About Top Most Friend";
Text = Locale.String(@"AboutTitle");
Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
BackgroundImage = Properties.Resources.about;
StartPosition = FormStartPosition.CenterScreen;
Expand All @@ -24,11 +24,12 @@ public sealed class AboutWindow : Form {
ClientSize = Properties.Resources.about.Size;
MaximizeBox = MinimizeBox = false;
MaximumSize = MinimumSize = Size;
TopMost = true;

int tabIndex = 0;

Button closeButton = new Button {
Text = @"Close",
Text = Locale.String(@"AboutClose"),
Size = new Size(BUTTON_WIDTH, BUTTON_HEIGHT),
TabIndex = ++tabIndex,
};
Expand All @@ -37,7 +38,7 @@ public sealed class AboutWindow : Form {
Controls.Add(closeButton);

Button websiteButton = new Button {
Text = @"Website",
Text = Locale.String(@"AboutWebsite"),
Size = new Size(BUTTON_WIDTH, BUTTON_HEIGHT),
TabIndex = ++tabIndex,
};
Expand All @@ -46,7 +47,7 @@ public sealed class AboutWindow : Form {
Controls.Add(websiteButton);

Button donateButton = new Button {
Text = @"Donate",
Text = Locale.String(@"AboutDonate"),
Size = new Size(BUTTON_WIDTH, BUTTON_HEIGHT),
TabIndex = ++tabIndex,
};
Expand Down
35 changes: 35 additions & 0 deletions TopMostFriend/ActionTimeout.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Threading;

namespace TopMostFriend {
public class ActionTimeout {
private readonly Action Action;
private bool Continue = true;
private int Remaining = 0;
private const int STEP = 500;

public ActionTimeout(Action action, int timeout) {
Action = action ?? throw new ArgumentNullException(nameof(action));
if(timeout < 1)
throw new ArgumentException(@"Timeout must be a positive integer.", nameof(timeout));
Remaining = timeout;
new Thread(ThreadBody) { IsBackground = true }.Start();
}

private void ThreadBody() {
do {
Thread.Sleep(STEP);
Remaining -= STEP;

if(!Continue)
return;
} while(Remaining > 0);

Action.Invoke();
}

public void Cancel() {
Continue = false;
}
}
}
39 changes: 21 additions & 18 deletions TopMostFriend/BlacklistWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,35 @@ public class BlacklistWindow : Form {
MinimizeBox = MaximizeBox = false;
MinimumSize = Size;
DialogResult = DialogResult.Cancel;
TopMost = true;

BlacklistView = new ListBox {
TabIndex = 101,
IntegralHeight = false,
Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
Location = new Point(BUTTON_WIDTH + (SPACING * 2), SPACING),
Location = new Point(SPACING, SPACING),
ClientSize = new Size(ClientSize.Width - BUTTON_WIDTH - (int)(SPACING * 3.5), ClientSize.Height - (int)(SPACING * 2.5)),
};
BlacklistView.SelectedIndexChanged += BlacklistView_SelectedIndexChanged;
BlacklistView.MouseDoubleClick += BlacklistView_MouseDoubleClick;

AddButton = new Button {
Anchor = AnchorStyles.Top | AnchorStyles.Left,
Text = @"Add",
Anchor = AnchorStyles.Top | AnchorStyles.Right,
Text = Locale.String(@"BlacklistAdd"),
ClientSize = new Size(BUTTON_WIDTH, BUTTON_HEIGHT),
Location = new Point(SPACING, SPACING),
Location = new Point(BlacklistView.Width + (SPACING * 2), SPACING),
TabIndex = 201,
};
EditButton = new Button {
Text = @"Edit",
Text = Locale.String(@"BlacklistEdit"),
Location = new Point(AddButton.Location.X, AddButton.Location.Y + AddButton.Height + SPACING),
Enabled = false,
Anchor = AddButton.Anchor,
ClientSize = AddButton.ClientSize,
TabIndex = 202,
};
RemoveButton = new Button {
Text = @"Remove",
Text = Locale.String(@"BlacklistRemove"),
Location = new Point(AddButton.Location.X, EditButton.Location.Y + AddButton.Height + SPACING),
Enabled = false,
Anchor = AddButton.Anchor,
Expand All @@ -75,16 +76,16 @@ public class BlacklistWindow : Form {
RemoveButton.Click += RemoveButton_Click;

CancelButton = new Button {
Anchor = AnchorStyles.Bottom | AnchorStyles.Left,
Text = @"Cancel",
Location = new Point(SPACING, ClientSize.Height - AddButton.ClientSize.Height - SPACING),
Anchor = AnchorStyles.Bottom | AnchorStyles.Right,
Text = Locale.String(@"BlacklistCancel"),
Location = new Point(AddButton.Location.X, ClientSize.Height - AddButton.ClientSize.Height - SPACING),
ClientSize = AddButton.ClientSize,
TabIndex = 10001,
};
Button acceptButton = new Button {
Anchor = AnchorStyles.Bottom | AnchorStyles.Left,
Text = @"Done",
Location = new Point(SPACING, ClientSize.Height - ((AddButton.ClientSize.Height + SPACING) * 2)),
Anchor = AnchorStyles.Bottom | AnchorStyles.Right,
Text = Locale.String(@"BlacklistDone"),
Location = new Point(AddButton.Location.X, ClientSize.Height - ((AddButton.ClientSize.Height + SPACING) * 2)),
ClientSize = AddButton.ClientSize,
TabIndex = 10002,
};
Expand All @@ -106,24 +107,26 @@ private class BlacklistEditorWindow : Form {
public string Original { get; }
public string String { get => TextBox.Text; }

private TextBox TextBox;
private readonly TextBox TextBox;

public BlacklistEditorWindow(string original = null) {
Original = original ?? string.Empty;
Text = original == null ? @"Adding new entry..." : $@"Editing {original}...";
Text = Locale.String(original == null ? @"BlacklistEditorAdding" : @"BlacklistEditorEditing", original);
Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
StartPosition = FormStartPosition.CenterParent;
FormBorderStyle = FormBorderStyle.FixedToolWindow;
FormBorderStyle = FormBorderStyle.FixedSingle;
ClientSize = new Size(500, 39);
MaximizeBox = MinimizeBox = false;
MaximumSize = MinimumSize = Size;
TopMost = true;

Button cancelButton = new Button {
Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right,
Location = new Point(ClientSize.Width - 75 - 8, 8),
Name = @"cancelButton",
Size = new Size(75, 23),
TabIndex = 102,
Text = @"Cancel",
Text = Locale.String(@"BlacklistEditorCancel"),
};
cancelButton.Click += (s, e) => { DialogResult = DialogResult.Cancel; Close(); };

Expand All @@ -133,14 +136,14 @@ private class BlacklistEditorWindow : Form {
Name = @"saveButton",
Size = new Size(75, 23),
TabIndex = 101,
Text = @"Save",
Text = Locale.String(@"BlacklistEditorSave"),
};
saveButton.Click += (s, e) => { DialogResult = DialogResult.OK; Close(); };

TextBox = new TextBox {
Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
Location = new Point(8, 9),
Name = @"deviceSelection",
Name = @"deviceSelection", // ??????
Size = new Size(ClientSize.Width - 8 - cancelButton.Width - saveButton.Width - 19, 23),
TabIndex = 100,
Text = Original,
Expand Down
Loading

0 comments on commit 19f16b4

Please sign in to comment.