private void button_save_Click(object sender, EventArgs e) { bool registryChange = (bool)Globals.MainConfig["Cygwin"]["SetContextMenu"] != checkBox_set_windows_context_menu.Checked; Globals.MainConfig["Cygwin"]["ExecutableExtension"] = textBox_executable_files.Text; Globals.MainConfig["Cygwin"]["ExitAfterExec"] = checkBox_exit_after_execution.Checked; Globals.MainConfig["Cygwin"]["SetContextMenu"] = checkBox_set_windows_context_menu.Checked; Globals.MainConfig["Cygwin"]["Shell"] = comboBox_shell.Text; Globals.MainConfig["Cygwin"]["NoMsgBox"] = checkBox_disable_message_boxes.Checked; Globals.MainConfig["Cygwin"]["CygwinMirror"] = textBox_cygwin_mirror.Text; Globals.MainConfig["Cygwin"]["CygwinPortsMirror"] = textBox_cygwin_ports_mirror.Text; Globals.MainConfig["Cygwin"]["CygwinFirstInstallDeleteUnneeded"] = checkBox_delete_unneeded_files.Checked; Globals.MainConfig["Cygwin"]["InstallUnofficial"] = checkBox_install_unofficial_cygwin_tools.Checked; Globals.MainConfig["Cygwin"]["WindowsPathToCygwin"] = checkBox_add_windows_path_variables_to_cygwin.Checked; Globals.MainConfig["Cygwin"]["SupportWSL"] = checkBox_support_wsl.Checked; Globals.MainConfig["Cygwin"]["DefaultEnvironment"] = comboBox_default_environment.Text; Globals.MainConfig["Cygwin"]["Username"] = textBox_username.Text; Globals.MainConfig["Cygwin"]["CygwinDeleteInstallation"] = checkBox_delete_complete_installation.Checked; Globals.MainConfig["Cygwin"]["CygwinDeleteInstallationFolders"] = textBox_drop_these_folders_on_reinstall.Text; System.IO.File.WriteAllText(Globals.ConfigPath + "\\Configuration.json", JsonConvert.SerializeObject(Globals.MainConfig["Cygwin"], Formatting.Indented)); if (registryChange) { ChangeRegistryPath.Change(); } //Check if Key really is set or deleted /*if (ChangeRegistryPath.RegistryKeyExists()) * { * Globals.MainConfig["Cygwin"]["SetContextMenu"].BoolValue = true; * } * else * { * Globals.MainConfig["Cygwin"]["SetContextMenu"].BoolValue = false; * }*/ checkBox_set_windows_context_menu.Checked = (bool)Globals.MainConfig["Cygwin"]["SetContextMenu"]; this.Close(); }
private void button_save_Click(object sender, EventArgs e) { bool registryChange = Globals.Config["Main"]["SetContextMenu"].StringValue != checkBox_set_windows_context_menu.Checked.ToString(); Globals.Config["Main"]["ExecutableExtension"].StringValue = textBox_executable_files.Text; Globals.Config["Main"]["ExitAfterExec"].StringValue = checkBox_exit_after_execution.Checked.ToString(); Globals.Config["Main"]["SetContextMenu"].StringValue = checkBox_set_windows_context_menu.Checked.ToString(); Globals.Config["Main"]["Shell"].StringValue = comboBox_shell.Text; Globals.Config["Main"]["NoMsgBox"].StringValue = checkBox_disable_message_boxes.Checked.ToString(); Globals.Config["Main"]["CygwinMirror"].StringValue = textBox_cygwin_mirror.Text; Globals.Config["Main"]["CygwinPortsMirror"].StringValue = textBox_cygwin_ports_mirror.Text; Globals.Config["Main"]["CygwinFirstInstallDeleteUnneeded"].StringValue = checkBox_delete_unneeded_files.Checked.ToString(); Globals.Config["Main"]["InstallUnofficial"].StringValue = checkBox_install_unofficial_cygwin_tools.Checked.ToString(); Globals.Config["Main"]["WindowsPathToCygwin"].StringValue = checkBox_add_windows_path_variables_to_cygwin.Checked.ToString(); Globals.Config["Static"]["Username"].StringValue = textBox_username.Text; Globals.Config["Expert"]["CygwinDeleteInstallation"].StringValue = checkBox_delete_complete_installation.Checked.ToString(); Globals.Config["Expert"]["CygwinDeleteInstallationFolders"].StringValue = textBox_drop_these_folders_on_reinstall.Text; Globals.Config.SaveToFile(Globals.ConfigPath + "\\Configuration.ini"); if (registryChange) { ChangeRegistryPath.Change(); } //Check if Key really is set or deleted /*if (ChangeRegistryPath.RegistryKeyExists()) * { * Globals.Config["Main"]["SetContextMenu"].BoolValue = true; * } * else * { * Globals.Config["Main"]["SetContextMenu"].BoolValue = false; * }*/ checkBox_set_windows_context_menu.Checked = Globals.Config["Main"]["SetContextMenu"].BoolValue; this.Close(); }
public Form_TrayMenu() { //Check Arguments First -> Dont load GUI string[] args = Environment.GetCommandLineArgs(); try { if (args[1] != null) { Console.WriteLine("CommandLine Parameter 1: " + args[1]); if (!args[1].StartsWith("-")) { Cygwin.CygwinOpen(args[1]); Environment.Exit(-1); } else if (args[1].StartsWith("-uactask")) { ChangeRegistryPath.Change(); Environment.Exit(-1); } else { string path = ""; string exitAfterExecute = "0"; int idx = 0; foreach (string arg in args) { if (args[idx] == "-path") { path = args[idx + 1]; } if (args[idx] == "-wsl") { Globals.CurrentEnvironment = "wsl"; } if (args[idx] == "-cygwin") { Globals.CurrentEnvironment = "cygwin"; } if (args[idx] == "-exit") { if (args[idx + 1] != null) { exitAfterExecute = args[idx + 1]; Console.WriteLine("exitAfterExecute set to: " + exitAfterExecute); } } idx = idx + 1; } if (exitAfterExecute == "1") { Globals.MainConfig["Cygwin"]["ExitAfterExec"] = true; } //MessageBox.Show("Test" + path, "Test", MessageBoxButtons.YesNo); Cygwin.CygwinOpen(path); Environment.Exit(-1); } } } catch (IndexOutOfRangeException) { Console.WriteLine("Possible Commandline options: " + args[0] + " [-cygwin] [-wsl] [-path <PATH>] [-exit <0/1>]"); Console.WriteLine("-path 'C:\\Windows' open Windows folder"); Console.WriteLine("-exit 0 let the cygwin window open, -exit 1 close the cygwin window after execution"); Console.WriteLine(""); Console.WriteLine("Sample to open C:\\Windows Folder:"); Console.WriteLine(" " + args[0] + " -path 'C:\\Windows'"); Console.WriteLine("Sample to open Shellscript and dont close window after execution:"); Console.WriteLine(" " + args[0] + " -path 'C:\\shellscript.sh' -exit 0"); Console.WriteLine("Sample to open C:\\Windows Folder WITHOUT arguemnts:"); Console.WriteLine(" " + args[0] + " 'C:\\Windows'"); Console.WriteLine("Sample to open C:\\Windows Folder with cygwin:"); Console.WriteLine(" " + args[0] + " -cygwin -path 'C:\\Windows'"); Console.WriteLine("Sample to open C:\\Windows Folder with wsl:"); Console.WriteLine(" " + args[0] + " -wsl -path 'C:\\Windows'"); } ChangeRegistryPath.Change(); //Check Arguments Ended -> If CygwinPortable still lives -> go on InitializeComponent(); WindowState = FormWindowState.Minimized; if ((WindowState == FormWindowState.Minimized)) { contextMenuStrip1.Show(); Hide(); ShowInTaskbar = false; } }