Skip to content

Commit 3edc3d1

Browse files
committed
implemented suggestions by @KN4CK3R
1 parent ebd7018 commit 3edc3d1

File tree

4 files changed

+18
-28
lines changed

4 files changed

+18
-28
lines changed

ReClass.NET/Forms/MainForm.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,32 +56,37 @@ public ClassNode CurrentClassNode
5656
}
5757
}
5858

59+
private void UpdateWindowTitle(string extra = null)
60+
{
61+
var title = $"{(Program.Settings.RandomizeWindowTitle ? Utils.RandomString(Program.GlobalRandom.Next(15, 20)) : Constants.ApplicationName)} ({Constants.Platform})";
62+
if (!string.IsNullOrEmpty(extra))
63+
{
64+
title += $" - {extra}";
65+
}
66+
Text = title;
67+
}
68+
5969
public MainForm()
6070
{
6171
Contract.Ensures(pluginManager != null);
6272
Contract.Ensures(currentProject != null);
6373

6474
InitializeComponent();
65-
66-
string randomWindowTitle = Utils.RandomString(Program.GlobalRandom.Next(15, 20));
67-
68-
Text = $"{(Program.Settings.RandomizeWindowTitle ? randomWindowTitle : Constants.ApplicationName)} ({Constants.Platform})";
75+
UpdateWindowTitle();
6976

7077
mainMenuStrip.Renderer = new CustomToolStripProfessionalRenderer(true, true);
7178
toolStrip.Renderer = new CustomToolStripProfessionalRenderer(true, false);
7279

7380
Program.RemoteProcess.ProcessAttached += sender =>
7481
{
75-
string randomWindowTitle = Utils.RandomString(Program.GlobalRandom.Next(15, 20));
7682
var text = $"{sender.UnderlayingProcess.Name} (ID: {sender.UnderlayingProcess.Id.ToString()})";
77-
78-
Text = $"{(Program.Settings.RandomizeWindowTitle ? randomWindowTitle : Constants.ApplicationName)} ({Constants.Platform}) - {text}";
7983
processInfoToolStripStatusLabel.Text = text;
84+
UpdateWindowTitle(text);
85+
8086
};
8187
Program.RemoteProcess.ProcessClosed += sender =>
8288
{
83-
string randomWindowTitle = Utils.RandomString(Program.GlobalRandom.Next(15, 20));
84-
Text = $"{(Program.Settings.RandomizeWindowTitle ? randomWindowTitle : Constants.ApplicationName)} ({Constants.Platform})";
89+
UpdateWindowTitle();
8590
processInfoToolStripStatusLabel.Text = "No process selected";
8691
};
8792

ReClass.NET/Forms/SettingsForm.Designer.cs

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

ReClass.NET/Forms/SettingsForm.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public SettingsForm(Settings settings, CppTypeMapping typeMapping)
4444
if (NativeMethods.IsUnix())
4545
{
4646
fileAssociationGroupBox.Enabled = false;
47+
runAsAdminCheckBox.Enabled = false;
4748
}
4849
else
4950
{
@@ -152,20 +153,5 @@ private void SetTypedefinitionBindings()
152153
SetBinding(utf16TextTypeTextBox, nameof(TextBox.Text), typeMapping, nameof(CppTypeMapping.TypeUtf16Text));
153154
SetBinding(functionPtrTypeTextBox, nameof(TextBox.Text), typeMapping, nameof(CppTypeMapping.TypeFunctionPtr));
154155
}
155-
156-
private void runAsAdminCheckBox_CheckedChanged(object sender, EventArgs e)
157-
{
158-
settings.RunAsAdmin = runAsAdminCheckBox.Checked;
159-
160-
if (runAsAdminCheckBox.Checked && !WinUtil.IsAdministrator)
161-
{
162-
var msgboxResult = MessageBox.Show("Would you like to restart ReClass.NET as administrator now?", "ReClass.NET", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
163-
if(msgboxResult == DialogResult.Yes)
164-
{
165-
WinUtil.RunElevated(Process.GetCurrentProcess().MainModule.FileName, string.Empty);
166-
Program.MainForm.Close();
167-
}
168-
}
169-
}
170156
}
171157
}

ReClass.NET/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static void Main(string[] args)
6767
Settings = SettingsSerializer.Load();
6868
Logger = new GuiLogger();
6969

70-
if(Settings.RunAsAdmin && !WinUtil.IsAdministrator)
70+
if(!NativeMethods.IsUnix() && Settings.RunAsAdmin && !WinUtil.IsAdministrator)
7171
{
7272
WinUtil.RunElevated(Process.GetCurrentProcess().MainModule.FileName, args.Length > 0 ? string.Join(" ", args) : null);
7373
return;

0 commit comments

Comments
 (0)