void UpdateSummaryCache(List <string> updateList) { var serverList = FilterSummaryUpdateList(updateList); if (serverList.Count <= 0) { return; } Task.Factory.StartNew(() => { var summaryList = ParseAllConfigsImport(serverList); lock (summaryCache.writeLock) { for (var i = 0; i < serverList.Count; i++) { var key = serverList[i]; summaryCache[key] = summaryList[i]; } } OnSettingChange?.Invoke(this, EventArgs.Empty); }); }
public void DeleteAllServers() { servers = new List <string>(); SaveServers(); OnSettingChange?.Invoke(this, null); OnRequireCoreRestart?.Invoke(this, null); }
public void DeleteAllServers() { servers.Clear(); SaveServers(); OnSettingChange?.Invoke(this, EventArgs.Empty); OnRequireCoreRestart?.Invoke(this, EventArgs.Empty); }
public void DeleteServer(int index) { Debug.WriteLine("delete server: " + index); if (index < 0 || index >= GetServeNum()) { Debug.WriteLine("delete server index out of range"); return; } servers.RemoveAt(index); SaveServers(); if (_SelectedServerIndex >= GetServeNum()) { // normal restart _SelectedServerIndex = GetServeNum() - 1; OnRequireCoreRestart?.Invoke(this, null); } else if (_SelectedServerIndex == index) { // force restart OnRequireCoreRestart?.Invoke(this, null); } else if (_SelectedServerIndex > index) { // dont need restart _SelectedServerIndex--; } // dont need restart OnSettingChange?.Invoke(this, null); }
public void DeleteServer(int index) { Debug.WriteLine("delete server: " + index); if (index < 0 || index >= GetServerCount()) { Debug.WriteLine("index out of range"); return; } servers.RemoveAt(index); SaveServers(); if (_curServIndex >= GetServerCount()) { // normal restart _curServIndex = GetServerCount() - 1; OnRequireCoreRestart?.Invoke(this, EventArgs.Empty); } else if (_curServIndex == index) { // force restart OnRequireCoreRestart?.Invoke(this, EventArgs.Empty); } else if (_curServIndex > index) { // dont need restart _curServIndex--; } // dont need restart OnSettingChange?.Invoke(this, EventArgs.Empty); }
public bool ReplaceServer(JObject config, int index) { if (index < 0 || index >= GetServerCount()) { return(AddServer(config)); } var b64ConfigString = Lib.Utils.Config2Base64String(config); if (GetServerIndex(b64ConfigString) >= 0) { SendLog(I18N("DuplicateServer") + "\r\n"); return(false); } servers[index] = b64ConfigString; SaveServers(); if (index == _curServIndex) { OnRequireCoreRestart?.Invoke(this, EventArgs.Empty); } OnSettingChange?.Invoke(this, EventArgs.Empty); return(true); }
public bool AddServer(JObject config, bool quiet = false) { var result = false; var b64ConfigString = Lib.Utils.Config2Base64String(config); lock (addServerLock) { if (GetServerIndex(b64ConfigString) < 0) { result = true; if (quiet) { servers.AddQuiet(b64ConfigString); } else { servers.Add(b64ConfigString); } SaveServers(); } } if (result && !quiet) { try { OnSettingChange?.Invoke(this, EventArgs.Empty); } catch { } } return(result); }
public void ActivateServer(int index = -1) { if (index >= 0) { _curServIndex = index; } OnRequireCoreRestart?.Invoke(this, EventArgs.Empty); OnSettingChange?.Invoke(this, EventArgs.Empty); }
public bool AddServer(string b64ConfigString) { if (servers.IndexOf(b64ConfigString) >= 0) { Debug.WriteLine("Duplicate server, skip!"); return(false); } servers.Add(b64ConfigString); SaveServers(); OnSettingChange?.Invoke(this, null); return(true); }
public void ImportLinks(string links) { var that = this; var tasks = new Task <Tuple <bool, List <string[]> > >[] { new Task <Tuple <bool, List <string[]> > >(() => ImportVmessLinks(links)), new Task <Tuple <bool, List <string[]> > >(() => ImportV2RayLinks(links)), new Task <Tuple <bool, List <string[]> > >(() => ImportSSLinks(links)), }; Task.Factory.StartNew(() => { // import all links foreach (var task in tasks) { task.Start(); } Task.WaitAll(tasks); // get results var allResults = new List <string[]>(); var isAddNewServer = false; foreach (var task in tasks) { isAddNewServer = isAddNewServer || task.Result.Item1; allResults.AddRange(task.Result.Item2); task.Dispose(); } // show results if (isAddNewServer) { servers.Notify(); OnSettingChange?.Invoke(that, EventArgs.Empty); } if (allResults.Count > 0) { new Views.FormImportLinksResult(allResults); Application.Run(); } else { MessageBox.Show(I18N("NoLinkFound")); } }); }
public bool ImportLinks(string links) { var vmess = ImportVmessLinks(links, true); var v2ray = ImportV2RayLinks(links, true); var ss = ImportSSLinks(links, true); if (vmess || v2ray || ss) { servers.Notify(); OnSettingChange?.Invoke(this, EventArgs.Empty); return(true); } return(false); }
public bool ReplaceServer(string b64ConfigString, int replaceIndex) { if (replaceIndex < 0 || replaceIndex >= GetServeNum()) { return(AddServer(b64ConfigString)); } servers[replaceIndex] = b64ConfigString; SaveServers(); if (replaceIndex == _SelectedServerIndex) { OnRequireCoreRestart?.Invoke(this, null); } OnSettingChange?.Invoke(this, null); return(true); }
public bool ReplaceServer(string b64ConfigString, int index) { if (index < 0 || index >= GetServerCount()) { return(AddServer(b64ConfigString)); } servers[index] = b64ConfigString; SaveServers(); if (index == _curServIndex) { OnRequireCoreRestart?.Invoke(this, EventArgs.Empty); } OnSettingChange?.Invoke(this, EventArgs.Empty); return(true); }
public void MoveItemToButtom(int index) { var n = Lib.Utils.Clamp(index, 0, GetServeNum() - 1); if (_SelectedServerIndex == n) { _SelectedServerIndex = GetServeNum() - 1; } else if (_SelectedServerIndex > n) { _SelectedServerIndex--; } var item = servers[n]; servers.RemoveAt(n); servers.Add(item); SaveServers(); OnSettingChange?.Invoke(this, null); }
public void MoveItemToButtom(int index) { var n = Lib.Utils.Clamp(index, 0, GetServerCount()); if (_curServIndex == n) { _curServIndex = GetServerCount() - 1; } else if (_curServIndex > n) { _curServIndex--; } var item = servers[n]; servers.RemoveAtQuiet(n); servers.Add(item); SaveServers(); OnSettingChange?.Invoke(this, EventArgs.Empty); }
public void MoveItemToTop(int index) { var n = Lib.Utils.Clamp(index, 0, GetServeNum() - 1); if (_SelectedServerIndex == n) { _SelectedServerIndex = 0; } else if (_SelectedServerIndex < n) { _SelectedServerIndex++; } var item = servers[n]; servers.RemoveAt(n); servers.Insert(0, item); SaveServers(); OnSettingChange?.Invoke(this, null); }
public void MoveItemToTop(int index) { var n = Lib.Utils.Clamp(index, 0, GetServerCount()); if (_curServIndex == n) { _curServIndex = 0; } else if (_curServIndex < n) { _curServIndex++; } var item = servers[n]; servers.RemoveAtQuiet(n); servers.Insert(0, item); SaveServers(); OnSettingChange?.Invoke(this, EventArgs.Empty); }
public bool AddServer(string b64ConfigString, bool quiet = false) { if (servers.IndexOf(b64ConfigString) >= 0) { SendLog(I18N("DuplicateServer") + "\r\n"); return(false); } if (quiet) { servers.AddQuiet(b64ConfigString); SaveServers(); } else { servers.Add(b64ConfigString); SaveServers(); OnSettingChange?.Invoke(this, EventArgs.Empty); } SendLog(I18N("AddServSuccess") + "\r\n"); return(true); }
public void MoveItemDown(int index) { if (index < 0 || index > GetServeNum() - 2) { return; } if (_SelectedServerIndex == index) { _SelectedServerIndex++; } else if (_SelectedServerIndex == index + 1) { _SelectedServerIndex--; } var item = servers[index]; servers.RemoveAt(index); servers.Insert(index + 1, item); SaveServers(); OnSettingChange?.Invoke(this, null); }
public void MoveItemDown(int index) { if (index < 0 || index > GetServerCount() - 2) { return; } if (_curServIndex == index) { _curServIndex++; } else if (_curServIndex == index + 1) { _curServIndex--; } var item = servers[index]; servers.RemoveAtQuiet(index); servers.Insert(index + 1, item); SaveServers(); OnSettingChange?.Invoke(this, EventArgs.Empty); }
internal static void HandleSettingChange(string setting, string oldValue, string newValue) { OnSettingChange?.Invoke(setting, oldValue, newValue); }
public void ActivateServer(int index) { _SelectedServerIndex = index; OnRequireCoreRestart?.Invoke(this, null); OnSettingChange?.Invoke(this, null); }
//Unity event receiver method //Invokes the OnSettingChange delegate to inform the listener of a setting change. public void OnValueChanged() { OnSettingChange?.Invoke(new SettingEvent(type, slider.value)); sliderValue.text = String.Format("{0:0.00}", slider.value); }