Example #1
0
        private void RunOnStartupChecked(object sender, EventArgs e)
        {
            AutoStart.SetShortcut(toolStripRunOnStartup.Checked, Environment.SpecialFolder.Startup, "-silent");

            Settings.Default.RunOnStartup = toolStripRunOnStartup.Checked;
            Settings.Default.Save();
        }
Example #2
0
 protected override void View_SaveData(object sender, EventArgs e)
 {
     base.View_SaveData(sender, e);
     try
     {
         Setting.Instance.LocalPort        = int.Parse(View.LocalPort_Text);
         Setting.Instance.RemotePort       = int.Parse(View.RemotePort_Text);
         Setting.Instance.RemoteClientPath = View.RemoteClientPath;
         Setting.Instance.RemoteClientArgs = View.RemoteClientArgs;
         Setting.Instance.HideClient       = View.HideClient_Toggle;
         AutoStart.Set(View.AutoStart_Toggle);
         Setting.Instance.Save();
         CloseForm?.Invoke(this, EventArgs.Empty);
     }
     catch (FormatException)
     {
         MsgBox.Error("Illegal port number format");
         return;
     }
     catch (Exception ex)
     {
         MsgBox.Error(ex.Message);
         return;
     }
 }
Example #3
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Helper.SetAllowUnsafeHeaderParsing(true);

            string firstArgument = args.Length > 0 ? args[0] : String.Empty;

            if (firstArgument == "--enable-autostart")
            {
                AutoStart.SetAutoStart(true);
                return;
            }
            else if (firstArgument == "--disable-autostart")
            {
                AutoStart.SetAutoStart(false);
                return;
            }

            var createdNew = true;
            var mutexName  = Setting.AppName + ":" + Application.StartupPath.GetHashCode();

            using (var mutex = new Mutex(true, mutexName, out createdNew))
            {
                if (!createdNew)
                {
                    MsgBox.Info(string.Format(I18n.MsgInstanceExist, Setting.AppName));
                    return;
                }

                Launcher.Start();
            }
        }
Example #4
0
 private void DoneBtn_Click(object sender, RoutedEventArgs e)
 {
     if (IsAdmin)
     {
         AutoStart.Toggle(autostartEnabledTb.IsChecked.Value, autostartAsAdminCb.IsChecked.Value);
     }
     this.Hide();
 }
        /// <summary>
        /// Removes a Windows shortcut from the "Startup" menu.
        /// </summary>
        /// <param name="autoStart">Information about the shortcut to be removed.</param>
        /// <param name="machineWide">The shortcut was created machine-wide instead of just for the current user.</param>
        public static void Remove(AutoStart autoStart, bool machineWide)
        {
            #region Sanity checks
            if (autoStart == null) throw new ArgumentNullException("autoStart");
            #endregion

            string filePath = GetStartupPath(autoStart.Name, machineWide);
            if (File.Exists(filePath)) File.Delete(filePath);
        }
        /// <summary>
        /// Creates a new Windows shortcut in the "Startup" menu.
        /// </summary>
        /// <param name="autoStart">Information about the shortcut to be created.</param>
        /// <param name="target">The target the shortcut shall point to.</param>
        /// <param name="handler">A callback object used when the the user is to be informed about the progress of long-running operations such as downloads.</param>
        /// <param name="machineWide">Create the shortcut machine-wide instead of just for the current user.</param>
        public static void Create(AutoStart autoStart, FeedTarget target, ITaskHandler handler, bool machineWide)
        {
            #region Sanity checks
            if (autoStart == null) throw new ArgumentNullException("autoStart");
            if (handler == null) throw new ArgumentNullException("handler");
            #endregion

            string filePath = GetStartupPath(autoStart.Name, machineWide);
            Create(filePath, target.GetRunStub(autoStart.Command, handler));
        }
Example #7
0
        public void AutoStartTest()
        {
            string location = System.Reflection.Assembly.GetExecutingAssembly().Location;

            AutoStart.SetAutoStart(location);
            Assert.IsTrue(AutoStart.IsAutoStartEnabled(location));

            AutoStart.UnSetAutoStart(location);
            Assert.IsFalse(AutoStart.IsAutoStartEnabled(location));
        }
Example #8
0
 protected override void View_LoadData(object sender, EventArgs e)
 {
     base.View_LoadData(sender, e);
     View.LocalPort_Text    = Setting.Instance.LocalPort.ToString();
     View.RemotePort_Text   = Setting.Instance.RemotePort.ToString();
     View.RemoteClientPath  = Setting.Instance.RemoteClientPath;
     View.RemoteClientArgs  = Setting.Instance.RemoteClientArgs;
     View.HideClient_Toggle = Setting.Instance.HideClient;
     View.AutoStart_Toggle  = AutoStart.Check();
 }
Example #9
0
        public PrettyForm()
        {
            InitializeComponent();

            KeyPreview = true;

            buttonExit.Click  += (s, e) => Close();
            buttonRun.Click   += (s, e) => AutoStart?.Invoke(s, e);
            buttonStop.Click  += (s, e) => AutoStop?.Invoke(s, e);
            buttonReset.Click += (s, e) => ResetAll?.Invoke(s, e);
            buttonStep.Click  += (s, e) => OneStep?.Invoke(s, e);
        }
Example #10
0
 private void checkBox2_CheckedChanged(object sender, EventArgs e)
 {
     JsonConfig.AddConfigAndSave("autoStart", ckbAutostart.Checked.ToString());
     if (ckbAutostart.Checked)
     {
         AutoStart.SetAutorunSetup();
     }
     else
     {
         AutoStart.DeleteAutoSetup();
     }
 }
Example #11
0
        private void button1_Click(object sender, EventArgs e)
        {
            AppConfig.Instance.CompanyAddress     = txtCompanyAddress.Text;
            AppConfig.Instance.CompanyName        = txtCompanyName.Text;
            AppConfig.Instance.CompanyPhoneNumber = txtCompanyPhone.Text;
            AppConfig.Instance.SaveCompanySettting();

            AutoStart auto = new AutoStart();

            auto.EnabledThroughStartupMenu = true;
            Close();
        }
        private void CheckBox_AutoStart_CheckedChanged(object sender, EventArgs e)
        {
            var autoStartFlag = AutoStart.Check();

            if (autoStartFlag)
            {
                AutoStart.Remove();
                MessageBox.Show("Success Remove AutoStart");
            }
            else
            {
                AutoStart.Set();
                MessageBox.Show("Success Set AutoStart");
            }
        }
        /// <summary>
        /// Removes a Windows shortcut from the "Startup" menu.
        /// </summary>
        /// <param name="autoStart">Information about the shortcut to be removed.</param>
        public static void Remove(AutoStart autoStart)
        {
            #region Sanity checks
            if (autoStart == null)
            {
                throw new ArgumentNullException("autoStart");
            }
            #endregion

            string filePath = GetStartupPath(autoStart.Name);
            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }
        }
Example #14
0
        /// <summary>
        /// Creates a new Windows shortcut in the "Startup" menu.
        /// </summary>
        /// <param name="autoStart">Information about the shortcut to be created.</param>
        /// <param name="target">The target the shortcut shall point to.</param>
        /// <param name="iconStore">Stores icon files downloaded from the web as local files.</param>
        /// <param name="machineWide">Create the shortcut machine-wide instead of just for the current user.</param>
        public static void Create(AutoStart autoStart, FeedTarget target, IIconStore iconStore, bool machineWide)
        {
            #region Sanity checks
            if (autoStart == null)
            {
                throw new ArgumentNullException(nameof(autoStart));
            }
            if (iconStore == null)
            {
                throw new ArgumentNullException(nameof(iconStore));
            }
            #endregion

            string filePath = GetStartupPath(autoStart.Name, machineWide);
            Create(filePath, targetPath: StubBuilder.GetRunStub(target, autoStart.Command, iconStore));
        }
        /// <summary>
        /// Creates a new Windows shortcut in the "Startup" menu.
        /// </summary>
        /// <param name="autoStart">Information about the shortcut to be created.</param>
        /// <param name="target">The target the shortcut shall point to.</param>
        /// <param name="handler">A callback object used when the the user is to be informed about the progress of long-running operations such as downloads.</param>
        public static void Create(AutoStart autoStart, FeedTarget target, ITaskHandler handler)
        {
            #region Sanity checks
            if (autoStart == null)
            {
                throw new ArgumentNullException("autoStart");
            }
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }
            #endregion

            string filePath = GetStartupPath(autoStart.Name);
            Create(filePath, target.GetRunStub(autoStart.Command, handler));
        }
Example #16
0
        public void InitConfig()
        {
            LogHelper.LogAction = new Action <string>(this.DisplayLog);


            this.ckbAutostart.CheckedChanged -= new System.EventHandler(this.checkBox2_CheckedChanged);

            if (JsonConfig.ReadConfigByName("autoStart").ToLower().Trim() == "true")
            {
                AutoStart.SetAutorunSetup();
                ckbAutostart.Checked = true;
            }
            else
            {
                ckbAutostart.Checked = false;
            }

            this.ckbAutostart.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);

            if (JsonConfig.ReadConfigByName("autoInit").ToLower().Trim() == "true")
            {
                NewThreadStartYInhaiInit();
                chkAutoInit.Checked = true;
            }
            else
            {
                chkAutoInit.Checked = false;
            }

            if (JsonConfig.ReadConfigByName("needlog").ToLower().Trim() == "true")
            {
                YBYinHaiBLL.NeedLog = true;
                chkLog.Checked      = true;
            }
            else
            {
                chkLog.Checked = false;
            }

            YBYinHaiBLL.YiBaoPath = txtPath.Text = JsonConfig.ReadConfigByName("yibaoPath") ?? "";



            RegDll();

            StartServer();
        }
Example #17
0
        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);
            }
        }
Example #18
0
        public void Save()
        {
            try
            {
                setConf("AutoDetectExeName", AutoDetectExeName);
                setConf("AutoStart", AutoStart.ToString());
                setConf("AutoDetect", AutoDetect.ToString());
                setConf("Culture", Culture.Name);
                setConf("IgnoredKeys", ConcatenateIntList(IgnoredKeys));

                conf.Save();
            }
            catch
            {
                throw;
            }
        }
Example #19
0
        /// <inheritdoc />
        public MainWindow()
        {
            InitializeComponent();
            var dispatcherTimer = new DispatcherTimer();
            IMainWindowInstance mainWindowInstance = new MainWindowInstance(this);
            IAppSettingFromConfigurationManager appSettingFromConfigurationManager = new AppSettingFromConfigurationManager();
            ITaskbarIconInstance      taskbarIconInstance      = new TaskbarIconInstance(AvailabilityHandlerTaskbarIcon);
            ITaskbarIconContextMenu   taskbarIconContextMenu   = new TaskbarIconContextMenu(mainWindowInstance, taskbarIconInstance);
            ITaskbarIconConfiguration taskbarIconConfiguration = new TaskbarIconConfiguration(mainWindowInstance, taskbarIconInstance, taskbarIconContextMenu);
            ILyncClientInstance       lyncClientInstance       = new CachedLyncClientInstance();
            ILyncAvailability         lyncAvailability         = new LyncAvailability(lyncClientInstance);
            IApplicationList          applicationList          = new CachedApplicationList(appSettingFromConfigurationManager);
            IIsProcessRunning         isProcessRunning         = new IsProcessRunning();
            IDispatcherTimerTick      dispatcherTimerTick      = new DispatcherTimerTick(lyncClientInstance, lyncAvailability, applicationList, isProcessRunning);
            IDispatcherTimerInstance  dispatcherTimerInstance  = new DispatcherTimerInstance(dispatcherTimer, dispatcherTimerTick);
            IProcessDispatcherHandler processDispatcherHandler = new ProcessDispatcherHandler(dispatcherTimerInstance);
            IAutoStart autoStart = new AutoStart(Title, Assembly.GetExecutingAssembly().Location);
            IAutoStartByConfiguration autoStartByConfiguration = new AutoStartByConfiguration(appSettingFromConfigurationManager, autoStart);

            processDispatcherHandler.Run();
            taskbarIconConfiguration.Run();
            autoStartByConfiguration.Run();
        }
    /// <summary>
    /// Creates a new Windows shortcut in the "Startup" menu.
    /// </summary>
    /// <param name="autoStart">Information about the shortcut to be created.</param>
    /// <param name="target">The target the shortcut shall point to.</param>
    /// <param name="iconStore">Stores icon files downloaded from the web as local files.</param>
    /// <param name="machineWide">Create the shortcut machine-wide instead of just for the current user.</param>
    public static void Create(AutoStart autoStart, FeedTarget target, IIconStore iconStore, bool machineWide)
    {
        #region Sanity checks
        if (autoStart == null)
        {
            throw new ArgumentNullException(nameof(autoStart));
        }
        if (iconStore == null)
        {
            throw new ArgumentNullException(nameof(iconStore));
        }
        #endregion

        string filePath = GetStartupPath(autoStart.Name, machineWide);
        if (WindowsUtils.IsWindows)
        {
            var commandLine = new StubBuilder(iconStore).GetRunCommandLine(target, autoStart.Command, machineWide);
            Create(filePath, commandLine.First(), commandLine.Skip(1).JoinEscapeArguments());
        }
        else
        {
            Create(filePath, target, autoStart.Command, iconStore);
        }
    }
Example #21
0
 private void CheckStartWithSystem()
 {
     startWithSystem.Checked = AutoStart.CheckEnabled(AppName);
 }
Example #22
0
        protected override void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer)
        {
            // Wire up the onkeypress event handler to the ChangeBackgroundColor() JavaScript function
            Control       c           = Page.FindControl(ControlToManage);
            StringBuilder onClickCall = new StringBuilder();

            //make sure it's the right object
            if (c != null && c.GetType().ToString().Equals("BrightcoveSDK.UI.VideoPlayer"))
            {
                VideoPlayer vp = (VideoPlayer)c;

                //check video id
                if (VideoID.Equals(-1))
                {
                    onClickCall.Append(vp.VideoID);
                }
                else
                {
                    onClickCall.Append(VideoID);
                }
                onClickCall.Append(", ");

                //check for player id
                if (PlayerID.Equals(-1))
                {
                    onClickCall.Append(vp.PlayerID);
                }
                else
                {
                    onClickCall.Append(PlayerID);
                }

                //check for player name
                onClickCall.Append(", '" + vp.PlayerName + "', ");

                //check for auto start
                if (AutoStart.Equals(false))
                {
                    onClickCall.Append(vp.AutoStart.ToString().ToLower());
                }
                else
                {
                    onClickCall.Append(AutoStart.ToString().ToLower());
                }
                onClickCall.Append(", '");

                //check for back color
                if (BackColor.Equals("#000000"))
                {
                    onClickCall.Append(vp.BackColor);
                }
                else
                {
                    onClickCall.Append(BackColor);
                }
                onClickCall.Append("', ");

                //check for width
                if (Width.Equals(0))
                {
                    onClickCall.Append(vp.Width.ToString());
                }
                else
                {
                    onClickCall.Append(Width.ToString());
                }
                onClickCall.Append(", ");

                //check for Height
                if (Height.Equals(0))
                {
                    onClickCall.Append(vp.Height.ToString());
                }
                else
                {
                    onClickCall.Append(Height.ToString());
                }
                onClickCall.Append(", ");

                //check for IsVid
                if (IsVid.Equals(true))
                {
                    onClickCall.Append(vp.IsVid.ToString().ToLower());
                }
                else
                {
                    onClickCall.Append(IsVid.ToString().ToLower());
                }
                onClickCall.Append(", '");

                //check for WMode
                if (WMode.Equals(""))
                {
                    onClickCall.Append(vp.WMode);
                }
                else
                {
                    onClickCall.Append(WMode);
                }

                //append for ClientID
                onClickCall.Append("', '" + vp.ClientID + "', '" + PlaylistTabString + "', '" + PlaylistComboString + "', '" + VideoList.ToString() + "'");

                writer.AddAttribute("onclick", "javascript:addPlayer(" + onClickCall.ToString() + ");return false;");

                base.AddAttributesToRender(writer);
            }
            else
            {
                StringBuilder error = new StringBuilder();
                error.Append("The ControlToManage must be specified or point to a valid VideoPlayer.");

                if (c == null)
                {
                    error.Append("\n The ControlToManage was null.");
                }
                else if (!c.GetType().ToString().Equals("BrightcoveSDK.UI.VideoPlayer"))
                {
                    error.Append("\n The ControlToManage type was " + c.GetType().ToString() + ".");
                }
                throw new ArgumentException(error.ToString());
            }
        }
Example #23
0
        public Cbhk_form()
        {
            InitializeComponent();

            if (SystemInformation.Network)
            {
                #region 初始化登录窗体
                //SignIn signIn = new SignIn();
                //ShowInTaskbar = false;
                //cbhk_notify.Visible = false;
                //WindowState = FormWindowState.Minimized;
                //if (signIn.ShowDialog() == DialogResult.OK)
                //{

                //    #region 绑定头像框点击事件
                //    link_tip.SetToolTip(user_head_box, signIn.user_name_string + "的主页");
                //    user_head_box.Click += (a, b) =>
                //    {
                //        Process.Start("https://mc.metamo.cn/u/" + signIn.user_id + "/");
                //    };
                //    signIn.Dispose();
                //    #endregion
                //}
                //else
                //    Environment.Exit(0);
                #endregion
            }

            #region 开启欢迎窗体
            WelcomeForm welcome = new WelcomeForm();
            if (welcome.ShowDialog() == DialogResult.OK)
            {
                #region 引用所提供的TreeView
                foreach (TreeNode item in welcome.register.Nodes[0].Nodes)
                {
                    register.Nodes.Add(item);
                }
                foreach (TreeNode item in welcome.command.Nodes[0].Nodes)
                {
                    Commands.Nodes.Add(item);
                }
                foreach (TreeNode item in welcome.block.Nodes[0].Nodes)
                {
                    Blocks.Nodes.Add(item);
                }
                foreach (TreeNode item in welcome.EntityNBT.Nodes[0].Nodes)
                {
                    EntityNBTs.Nodes.Add(item);
                }

                #endregion

                #region 开启主窗体窗体
                ShowInTaskbar       = true;
                cbhk_notify.Visible = true;
                WindowState         = FormWindowState.Normal;
                TopMost             = true;
                Show();
                TopMost = false;
                #endregion

                #region 自动解析msi包
                //string strInput = @"msiexec /i " + Application.StartupPath + "\\cbhk.setup.msi" + " /qn";
                //Process p = new Process();
                //p.StartInfo.FileName = "cmd.exe";
                //p.StartInfo.UseShellExecute = false;
                //p.StartInfo.RedirectStandardInput = true;
                //p.StartInfo.RedirectStandardOutput = true;
                //p.StartInfo.RedirectStandardError = true;
                //p.StartInfo.CreateNoWindow = true;
                //p.Start();
                //p.StandardInput.WriteLine(strInput + "&exit");
                //p.StandardInput.AutoFlush = true;
                //p.WaitForExit();
                //p.Close();
                #endregion

                #region 自动提取下载直链
                //该网址为自动解析直链API
                //UpdateForm uf = new UpdateForm("https://api.xinac.net/lanzous?url=", Application.StartupPath+"\\downloadurl.txt");
                //if(uf.ShowDialog() == DialogResult.OK)
                //{
                //    MessageBox.Show("success");
                //}
                #endregion
            }
            #endregion

            //初始化命令管家UI
            InitUISettings();
            //初始化命令管家启动项
            InitStartUpSetting();

            #region 开机自启
            AutoStart.SetMeStart(cbhk_properties.AutoStart);
            #endregion

            #region 自动更新
            #endregion
        }
Example #24
0
        private void toolStripRunOnStartup_CheckChanged(object sender, EventArgs e)
        {
            AutoStart.SetShortcut(toolStripRunOnStartup.Checked, Environment.SpecialFolder.Startup, "-silent -minimize");

            AppEnvironment.Setting("RunOnStartup", toolStripRunOnStartup.Checked);
        }
Example #25
0
        private MainHandler()
        {
            if (Settings.Default.ClickedAnswers == null)
            {
                Settings.Default.ClickedAnswers = new StringCollection();
            }
            if (Settings.Default.ShowedAnswers == null)
            {
                Settings.Default.ShowedAnswers = new StringCollection();
            }

            switch (DateTime.Now.DayOfWeek)
            {
            case DayOfWeek.Sunday:
                _notifyIcon.BalloonTipText = Resources.SkeetFactSunday;
                break;

            case DayOfWeek.Monday:
                _notifyIcon.BalloonTipText = Resources.SkeetFactMonday;
                break;

            case DayOfWeek.Tuesday:
                _notifyIcon.BalloonTipText = Resources.SkeetFactTuesday;
                break;

            case DayOfWeek.Wednesday:
                _notifyIcon.BalloonTipText = Resources.SkeetFactWednesday;
                break;

            case DayOfWeek.Thursday:
                _notifyIcon.BalloonTipText = Resources.SkeetFactThursday;
                break;

            case DayOfWeek.Friday:
                _notifyIcon.BalloonTipText = Resources.SkeetFactFriday;
                break;

            case DayOfWeek.Saturday:
                _notifyIcon.BalloonTipText = Resources.SkeetFactSaturday;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            _notifyIcon.ShowBalloonTip(1000);

            var contextMenu = new ContextMenuStrip {
                ShowImageMargin = false
            };

            var exitMenuItem = new ToolStripButton("Close")
            {
                Image = Resources.Exit, AutoToolTip = false
            };

            exitMenuItem.Click += (s, a) => System.Windows.Forms.Application.Exit();

            var refreshMenuItem = new ToolStripButton("Refresh")
            {
                Image = Resources.Refresh, AutoToolTip = false
            };

            refreshMenuItem.Click += (s, a) => _backgroundWorker.RunWorker();

            var autostartMenuItem = new ToolStripButton("Autostart")
            {
                Image = Resources.AutoStart, AutoToolTip = false, Checked = AutoStart.GetAutoStart(Application.ProductName)
            };

            autostartMenuItem.Click += (s, a) =>
            {
                AutoStart.SetAutoStart(!autostartMenuItem.Checked, Application.ProductName, Application.ExecutablePath);
                autostartMenuItem.Checked = AutoStart.GetAutoStart(Application.ProductName);
            };

            _notifyIcon.ContextMenuStrip = contextMenu;

            contextMenu.Items.AddRange(new ToolStripItem[] { new ToolStripSeparator(), refreshMenuItem, autostartMenuItem, exitMenuItem });

            // Timer
            _updateTimer.Tick += (s, a) => _backgroundWorker.RunWorker();

            // Worker
            _backgroundWorker.DoWork             += BackgroundWorkerDoWork;
            _backgroundWorker.RunWorkerCompleted += BackgroundWorkerRunWorkerCompleted;
            _backgroundWorker.RunWorker();
        }
 private void OptionsForm_Load(object sender, EventArgs e)
 {
     CheckBox_SaveSettings.Checked = Options.IsRefreshOnSave;
     CheckBox_AutoStart.Checked    = AutoStart.Check();
 }
Example #27
0
        private const int MouseHideHotKeyModifier = 0x008; // WIN-Key

        #endregion

        #region External access and processing

        #endregion


        #region Application Menu Events

        private void toolStripRunOnStartup_CheckChanged(object sender, EventArgs e)
        {
            AutoStart.Setup(toolStripRunOnStartup.Checked, "--silent --minimize");
            Config.Instance.AppSettings.RunOnStartup = toolStripRunOnStartup.Checked;
            Config.Save();
        }
Example #28
0
        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();
        }
Example #29
0
 public void Constructor_ReturnsInterfaceName(AutoStart sut)
 {
     sut.Should().BeAssignableTo <IAutoStart>();
 }