private void UpdateAboutMenu() { var items = AboutItems.MenuItems; while (items[0] != aboutSeperatorItem) { items.RemoveAt(0); } Configuration config = controller.ConfigController.GetConfigurationCopy(); if (!string.IsNullOrEmpty(config.language)) { I18N.SetLang(config.language); } IList <I18N.Lang> langlist = I18N.GetLangList(); for (int i = 0; i < langlist.Count; i++) { I18N.Lang lang = langlist[i]; MenuItem item = new MenuItem(I18N.GetString(lang.fullname)); item.Tag = lang; item.Click += OnLanguageItemClick; if (lang == I18N.Current) { item.Checked = true; } items.Add(i, item); } }
private void OnLanguageItemClick(object sender, EventArgs e) { MenuItem item = (MenuItem)sender; I18N.Lang lang = (I18N.Lang)item.Tag; I18N.SetLang(lang.name); controller.ConfigController.SelectLanguage(lang); }
public MenuViewController(MainController controller) { this.controller = controller; Configuration config = controller.ConfigController.GetCurrentConfiguration(); if (!string.IsNullOrEmpty(config.language)) { I18N.SetLang(config.language); } I18N.LangChanged += onLanguageChanged; LoadMenu(); controller.KCPTunnelController.Started += OnKCPTunnelStarted; controller.KCPTunnelController.Stoped += OnKCPTunnelStoped; controller.ConfigController.ConfigChanged += OnConfigChanged; controller.UpdateChecker.CheckUpdateCompleted += OnCheckUpdateCompleted; controller.UpdateChecker.DownloadCompleted += OnDownloadCompleted; _balloonTipActions = new LinkedList <BalloonTipAction>(); _notifyIcon = new NotifyIcon(); _notifyIcon.DoubleClick += OnNotifyIconDoubleClick; _notifyIcon.BalloonTipClicked += OnBalloonTipClicked; UpdateTrayIcon(); _notifyIcon.Visible = true; _notifyIcon.ContextMenu = contextMenu1; LoadCurrentConfiguration(); _firstRun = config.isDefault; if (_firstRun) { ShowEditServersForm(); } if (config.check_gui_update) { controller.UpdateChecker.CheckUpdateForGUI(5000); } if (config.check_kcptun_update || config.auto_upgrade_kcptun) { controller.UpdateChecker.CheckUpdateForKCPTun(5000); } }