private void startWithSystem_CheckedChanged(object sender, EventArgs e) { var currentEnabled = AutoStart.CheckEnabled(AppName); if (startWithSystem.Checked == currentEnabled) { return; } if (startWithSystem.Checked) { AutoStart.Enable(AppName, "\"" + Application.ExecutablePath + "\""); } else { AutoStart.Disable(AppName); } }
private void buttonSave_Click(object sender, EventArgs e) { bool changed = false; bool restartV2Ray = false; bool restartPAC = false; bool updatePAC = false; if (textBoxGFWListURL.Text != Setting.GFWListURL) { changed = true; Setting.GFWListURL = textBoxGFWListURL.Text; } if (checkBoxEnableAccessLog.Checked != Setting.EnableAccessLog) { changed = restartV2Ray = true; Setting.EnableAccessLog = checkBoxEnableAccessLog.Checked; } if (checkBoxEnableErrorLog.Checked != Setting.EnableErrorLog) { changed = restartV2Ray = true; Setting.EnableErrorLog = checkBoxEnableErrorLog.Checked; } if (checkBoxAutoStart.Checked != Setting.AutoStart) { changed = updatePAC = true; int exitCode = -1; if (checkBoxAutoStart.Checked) { exitCode = AutoStart.Enable(); } else { exitCode = AutoStart.Disable(); } if (exitCode == 0) { Setting.AutoStart = checkBoxAutoStart.Checked; } } if (comboBoxLogLevel.SelectedIndex != (int)Setting.LogLevel) { changed = restartV2Ray = true; Setting.LogLevel = (LogLevel)comboBoxLogLevel.SelectedIndex; } if (checkBoxAcceptLAN.Checked != Setting.AcceptLAN) { changed = restartV2Ray = true; Setting.AcceptLAN = checkBoxAcceptLAN.Checked; } if (numericUpDownSock5Port.Value != Setting.SocksPort) { changed = restartV2Ray = true; Setting.SocksPort = Convert.ToInt32(numericUpDownSock5Port.Value); } if (numericUpDownHTTPPort.Value != Setting.HttpPort) { changed = restartV2Ray = true; Setting.HttpPort = Convert.ToInt32(numericUpDownHTTPPort.Value); } if (numericUpDownPACPort.Value != Setting.PacPort) { changed = restartPAC = true; Setting.PacPort = Convert.ToInt32(numericUpDownPACPort.Value); } if (Setting.UpdateViaProxy != checkBoxUpdateViaProxy.Checked) { changed = true; Setting.UpdateViaProxy = checkBoxUpdateViaProxy.Checked; } if (changed) { if (restartV2Ray) { Launcher.ActivateServer(Setting.ActiveServerIndex); } if (restartPAC) { Launcher.Pac.Start(); if (Setting.Mode == Model.ProxyMode.PAC) { Launcher.SwitchProxyMode(Model.ProxyMode.PAC); } } if (updatePAC) { Launcher.GetGFWList(Setting.GFWListURL); } Setting.Save(); } Close(); }