Ejemplo n.º 1
0
        private MenuControlController()
        {
            Configuration.Load();
            CreateMenu();

            _notifyIcon = new NotifyIcon
            {
                Icon        = Resources.icon,
                Visible     = true,
                ContextMenu = _contextMenu
            };
            _notifyIcon.BalloonTipClicked += (sender, e) =>
            {
                UpdateController updateCtllr = UpdateController.GetInstance();
                if (updateCtllr.LatestRelease != null)
                {
                    updateCtllr.StartUpdating(updateCtllr.LatestRelease);
                }
            };

            MainProcessController.KillAllKcptunProcess();

            _processCtler = MainProcessController.GetInstance();
            _processCtler.ProcessLogReceivedHandler += mProcessCtler_ProcessLogReceived;

            if (!_processCtler.CheckKcptunExists())
            {
                Configuration.EnabledServerList.Clear();
                Configuration.UpdateEnabledServerList();

                ClientSelectForm dlg = new ClientSelectForm();
                dlg.ShowDialog();
            }

            foreach (Server server in Configuration.Servers)
            {
                if (Configuration.EnabledServerList.Contains(server.Name))
                {
                    _processCtler.Start(server);
                }
            }
            LoadServersMenuItem();
        }
Ejemplo n.º 2
0
        private void CreateMenu()
        {
            this._contextMenu = new ContextMenu(new MenuItem[] {
                _serversItem = new MenuItem("服务器", new MenuItem[] {
                    _enableAllServerItem  = new MenuItem("启用所有服务器", this.enableAllServerItem_Click),
                    _disableAllServerItem = new MenuItem("停用所有服务器", this.disableAllServerItem_Click),
                    new MenuItem("-"),
                    _configItem = new MenuItem("编辑服务器", this.configItem_Click)
                }),
                new MenuItem("-"),
                _autoStartupItem = new MenuItem("开机自启动", this.autoStartupItem_Click),
                new MenuItem("-"),
                _logItem = new MenuItem("显示日志", this.logItem_Click),
                new MenuItem("更新", new MenuItem[]
                {
                    new MenuItem("检查更新", this.checkUpdateItem_Click),
                    new MenuItem("-"),
                    _autoCheckUpdateItem = new MenuItem("启动时检查更新", this.autoCheckUpdateItem_Click)
                }),
                _aboutItem = new MenuItem("关于", this.aboutItem_Click),
                new MenuItem("-"),
                new MenuItem("退出", this.exitItem_Click)
            });
            _autoStartupItem.Checked = AutoStartupUtil.Check();

            if (Configuration.GetConfigFile()["autoCheckUpdate"] == null)
            {
                JObject loCfg = Configuration.GetConfigFile();
                loCfg["autoCheckUpdate"] = false;
                Configuration.SaveConfigFile(loCfg);
            }
            _autoCheckUpdateItem.Checked = (bool)Configuration.GetConfigFile()["autoCheckUpdate"];
            if (_autoCheckUpdateItem.Checked)
            {
                UpdateController.GetInstance().StartChecking(true);
            }
        }
Ejemplo n.º 3
0
 private void checkUpdateItem_Click(object sender, EventArgs e)
 {
     UpdateController.GetInstance().StartChecking(false);
 }
Ejemplo n.º 4
0
 public static UpdateController GetInstance()
 {
     return(_controller ?? (_controller = new UpdateController()));
 }