private void AddServerClipboard(object parameter) { List <V2RayVMess> serverList = V2RayVMess.ImportServers(Clipboard.GetText(TextDataFormat.Text)); if (serverList.Count > 0) { AddServer(serverList, out int added, out int updated); string notify; if (SettingManager.Configuration.IsReplaceOldServer) { notify = $"{added} {sr_server_x_added}, {updated} {sr_server_x_updated}"; } else { notify = $"{added} {sr_server_x_added}"; } InterfaceCtrl.ShowHomeNotify(notify); } else { InterfaceCtrl.ShowHomeNotify(sr_server_not_found); } }
private void AddServerFile(object parameter) { Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog { InitialDirectory = App.DirectoryApplication, DefaultExt = "txt", Filter = "Text|*.txt", AddExtension = true }; string fileContent = null; if (openFileDialog.ShowDialog() == true) { try { fileContent = System.IO.File.ReadAllText(openFileDialog.FileName); } catch { } } if (string.IsNullOrWhiteSpace(fileContent)) { return; } List <V2RayVMess> serverList = V2RayVMess.ImportServers(fileContent); if (serverList.Count > 0) { AddServer(serverList, out int added, out int updated); string notify; if (SettingManager.Configuration.IsReplaceOldServer) { notify = $"{added} {sr_server_x_added}, {updated} {sr_server_x_updated}"; } else { notify = $"{added} {sr_server_x_added}"; } InterfaceCtrl.ShowHomeNotify(notify); } else { InterfaceCtrl.ShowHomeNotify(sr_server_not_found); } }