Skip to content

Implemented run as admin and randomize window title option #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 16, 2020

Conversation

Timboy67678
Copy link
Contributor

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

@@ -63,21 +63,25 @@ public MainForm()

InitializeComponent();

Text = $"{Constants.ApplicationName} ({Constants.Platform})";
string randomWindowTitle = Utils.RandomString(Program.GlobalRandom.Next(15, 20));
Copy link
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;
}


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
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.

@@ -66,6 +67,12 @@ static void Main(string[] args)
Settings = SettingsSerializer.Load();
Logger = new GuiLogger();

if(Settings.RunAsAdmin && !WinUtil.IsAdministrator)
Copy link
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.

@@ -149,5 +152,20 @@ private void SetTypedefinitionBindings()
SetBinding(utf16TextTypeTextBox, nameof(TextBox.Text), typeMapping, nameof(CppTypeMapping.TypeUtf16Text));
SetBinding(functionPtrTypeTextBox, nameof(TextBox.Text), typeMapping, nameof(CppTypeMapping.TypeFunctionPtr));
}

private void runAsAdminCheckBox_CheckedChanged(object sender, EventArgs e)
Copy link
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
Copy link
Member

KN4CK3R commented Feb 16, 2020

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