private void FormBatchModifyServerInfo_Shown(object sender, EventArgs e) { this.cboxMark.Items.Clear(); foreach (var mark in servers.GetMarkList()) { this.cboxMark.Items.Add(mark); } var firstCtrl = servers .GetAllServersOrderByIndex() .Where(s => s.GetCoreStates().IsSelected()) .FirstOrDefault(); if (firstCtrl == null) { return; } var first = firstCtrl.GetCoreStates().GetAllRawCoreInfo(); this.cboxInMode.SelectedIndex = first.customInbType; this.tboxInIP.Text = first.inbIp; this.tboxInPort.Text = first.inbPort.ToString(); this.cboxMark.Text = first.customMark; this.cboxAutorun.SelectedIndex = first.isAutoRun ? 0 : 1; this.cboxImport.SelectedIndex = first.isInjectImport ? 0 : 1; this.cboxIsInjectSkipCNSite.SelectedIndex = first.isInjectSkipCNSite ? 0 : 1; }
void SetServerItemPanelCollapseLevel(int collapseLevel) { collapseLevel = Lib.Utils.Clamp(collapseLevel, 0, 3); servers .GetAllServersOrderByIndex() .Where(s => s.GetCoreStates().IsSelected()) .Select(s => { s.GetCoreStates().SetFoldingState(collapseLevel); return(true); }) .ToList(); // force linq to execute }
void RefreshServerList() { ClearServerList(); var summaryList = new List <string>(); var allServers = servers.GetAllServersOrderByIndex(); foreach (var serv in allServers) { var summary = serv.GetCoreStates().GetTitle(); var config = serv.GetConfiger().GetConfig(); summaryList.Add(summary); this.serverList.Add(config); } VgcApis.Libs.UI.RunInUiThread(cboxServList, () => { cboxServList.Items.Clear(); cboxServList.Items.AddRange(summaryList.ToArray()); Lib.UI.ResetComboBoxDropdownMenuWidth(cboxServList); if (summaryList.Count <= 0) { cboxServList.SelectedIndex = -1; return; } var oldIndex = servIndex; servIndex = -1; cboxServList.SelectedIndex = VgcApis.Libs.Utils.Clamp( oldIndex, 0, summaryList.Count); }); }
void UpdateServerMenus() { var serverList = servers.GetAllServersOrderByIndex(); var loadServMiList = new List<ToolStripMenuItem>(); var replaceServMiList = new List<ToolStripMenuItem>(); for (int i = 0; i < serverList.Count; i++) { var name = string.Format( "{0}.{1}", i + 1, serverList[i].GetCoreStates().GetName()); var org = serverList[i].GetConfiger().GetConfig(); loadServMiList.Add(GenMenuItemLoad(name, org)); replaceServMiList.Add(GenMenuItemReplace(name, org)); } VgcApis.Libs.UI.RunInUiThread( formConfiger, () => { try { ReplaceOldMenus(loadServMiList, replaceServMiList); } catch { } }); }
void UpdateCboxServerNameList(int index = -1) { var oldIndex = index < 0 ? cboxServList.SelectedIndex : index; cboxServList.Items.Clear(); var serverList = servers.GetAllServersOrderByIndex(); if (serverList.Count <= 0) { cboxServList.SelectedIndex = -1; return; } this.serverList = new Dictionary <string, string>(); foreach (var server in serverList) { var name = server.GetCoreStates().GetName(); cboxServList.Items.Add(name); this.serverList[name] = server.GetConfiger().GetConfig(); } servIndex = Lib.Utils.Clamp(oldIndex, 0, serverList.Count); cboxServList.SelectedIndex = servIndex; UpdateLink(); Lib.UI.ResetComboBoxDropdownMenuWidth(cboxServList); }
public List <VgcApis.Models.Interfaces.ICoreServCtrl> GetFilteredList() { var list = servers.GetAllServersOrderByIndex(); var keywords = (searchKeywords ?? "").Split( new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries); if (keywords.Length < 1) { return(list.ToList()); } return(list .Where(serv => serv.GetCoreStates().GetterInfoFor( infos => keywords.All( kw => infos.Any( info => Lib.Utils.PartialMatch(info, kw))))) .ToList()); }
private void InitCtrlBatchOperation( ToolStripMenuItem stopSelected, ToolStripMenuItem restartSelected, ToolStripMenuItem speedTestOnSelected, ToolStripMenuItem modifySelected, ToolStripMenuItem packSelected) { modifySelected.Click += ApplyActionOnSelectedServers( () => Views.WinForms.FormBatchModifyServerSetting.GetForm()); packSelected.Click += ApplyActionOnSelectedServers(() => { var list = servers .GetAllServersOrderByIndex() .Where(s => s.GetCoreStates().IsSelected()) .Select(s => s as VgcApis.Models.Interfaces.ICoreServCtrl) .ToList(); if (setting.isUseV4) { servers.PackServersIntoV4Package(list, null, null); } else { list.Reverse(); servers.PackServersIntoV3Package(list); } }); speedTestOnSelected.Click += ApplyActionOnSelectedServers(() => { if (!Lib.UI.Confirm(I18N.TestWillTakeALongTime)) { return; } if (!servers.RunSpeedTestOnSelectedServers()) { MessageBox.Show(I18N.LastTestNoFinishYet); } }); stopSelected.Click += ApplyActionOnSelectedServers(() => { if (Lib.UI.Confirm(I18N.ConfirmStopAllSelectedServers)) { servers.StopSelectedServersThen(); } }); restartSelected.Click += ApplyActionOnSelectedServers(() => { if (Lib.UI.Confirm(I18N.ConfirmRestartAllSelectedServers)) { servers.RestartSelectedServersThen(); } }); }
void SelectCurPageWhere(Func <Views.UserControls.ServerUI, bool> condiction) { var panel = GetFlyPanel(); var configs = panel.GetFilteredList().Select(s => s.GetConfiger().GetConfig()); // clear all not in current filtered list servers.GetAllServersOrderByIndex() .Where(s => !configs.Contains(s.GetConfiger().GetConfig())) .Select(s => { s.GetCoreStates().SetIsSelected(false); return(true); }) .ToList(); panel.LoopThroughAllServerUI(s => { s.SetSelected(condiction(s)); }); }
public List <VgcApis.Models.Interfaces.ICoreServCtrl> GetFilteredList() { var list = servers.GetAllServersOrderByIndex(); var keyword = searchKeywords?.Replace(@" ", ""); if (string.IsNullOrEmpty(keyword)) { return(list.ToList()); } return(list .Where(serv => serv.GetCoreStates().GetterInfoForSearch( infos => infos.Any( info => VgcApis.Libs.Utils.PartialMatchCi(info, keyword)))) .ToList()); }
void UpdateServerMenu() { var menuReplaceServer = replaceExistServerToolStripMenuItem.DropDownItems; var menuLoadServer = loadServerToolStripMenuItem.DropDownItems; menuReplaceServer.Clear(); menuLoadServer.Clear(); var serverList = servers.GetAllServersOrderByIndex(); var enable = serverList.Count > 0; replaceExistServerToolStripMenuItem.Enabled = enable; loadServerToolStripMenuItem.Enabled = enable; for (int i = 0; i < serverList.Count; i++) { var name = string.Format( "{0}.{1}", i + 1, serverList[i].GetCoreStates().GetName()); var org = serverList[i].GetConfiger().GetConfig(); menuReplaceServer.Add(new ToolStripMenuItem(name, null, (s, a) => { if (Lib.UI.Confirm(I18N.ReplaceServer)) { if (configer.ReplaceServer(org)) { SetTitle(configer.GetAlias()); } } })); menuLoadServer.Add(new ToolStripMenuItem(name, null, (s, a) => { if (!configer.IsConfigSaved() && !Lib.UI.Confirm(I18N.ConfirmLoadNewServer)) { return; } configer.LoadServer(org); SetTitle(configer.GetAlias()); })); } }
public string GetUid() { lock (genUidLocker) { if (string.IsNullOrEmpty(coreInfo.uid)) { var uidList = servers .GetAllServersOrderByIndex() .Select(s => s.GetCoreStates().GetRawUid()) .ToList(); string newUid; do { newUid = Lib.Utils.RandomHex(16); } while (uidList.Contains(newUid)); coreInfo.uid = newUid; container.InvokeEventOnPropertyChange(); } } return(coreInfo.uid); }
public void ExportAllServersToTextFile() { if (this.servers.IsEmpty()) { MessageBox.Show(I18N.ServerListIsEmpty); return; } var serverList = servers.GetAllServersOrderByIndex(); string s = string.Empty; foreach (var server in serverList) { var vlink = Lib.Utils.AddLinkPrefix( Lib.Utils.Base64Encode(server.GetConfiger().GetConfig()), VgcApis.Models.Datas.Enum.LinkTypes.v2cfg); s += vlink + System.Environment.NewLine + System.Environment.NewLine; } VgcApis.Libs.UI.SaveToFile( VgcApis.Models.Consts.Files.TxtExt, s); }