Skip to content

Implemented run as admin and randomize window title option - #146

Merged
KN4CK3R merged 3 commits into
ReClassNET:masterfrom
Timboy67678:master
Feb 16, 2020
Merged

KN4CK3R merged 3 commits into
ReClassNET:masterfrom
Timboy67678:master

Conversation

@Timboy67678

Copy link
Copy Markdown
Contributor

only thing im not sure about is using MainForm.Close for leaving the checkbox event

Comment thread ReClass.NET/Forms/MainForm.cs Outdated
InitializeComponent();

Text = $"{Constants.ApplicationName} ({Constants.Platform})";
string randomWindowTitle = Utils.RandomString(Program.GlobalRandom.Next(15, 20));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you replace the three changes with a single (inline) method? Possible implementation:

void SetWindowTitle(string extra = null)
{
	var title = $"{(Program.Settings.RandomizeWindowTitle ? Utils.RandomString(Program.GlobalRandom.Next(15, 20)) : Constants.ApplicationName)} ({Constants.Platform})";
	if (!string.IsNullOrEmpty(extra))
	{
		title += $" - {extra}";
	}
	Text = title;
}

Comment thread ReClass.NET/Forms/SettingsForm.cs Outdated

if (runAsAdminCheckBox.Checked && !WinUtil.IsAdministrator)
{
var msgboxResult = MessageBox.Show("Would you like to restart ReClass.NET as administrator now?", "ReClass.NET", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just notify the user that he has to restart ReClass to apply the change. This would remove the logic code from the settings form.

Comment thread ReClass.NET/Program.cs Outdated
Settings = SettingsSerializer.Load();
Logger = new GuiLogger();

if(Settings.RunAsAdmin && !WinUtil.IsAdministrator)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add NativeMethods.IsUnix(). Otherwise this will fail on unix systems.

Comment thread ReClass.NET/Forms/SettingsForm.cs Outdated
SetBinding(functionPtrTypeTextBox, nameof(TextBox.Text), typeMapping, nameof(CppTypeMapping.TypeFunctionPtr));
}

private void runAsAdminCheckBox_CheckedChanged(object sender, EventArgs e)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the checkboxes should be disabled if NativeMethods.IsUnix().

@KN4CK3R

KN4CK3R commented Feb 16, 2020

Copy link
Copy Markdown
Member

Thank you for the changes!

@KN4CK3R
KN4CK3R merged commit 5446b0f into ReClassNET:master Feb 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants