public void Export2ClientConfig(int index, Config config) { //int index = GetLvSelectedIndex(); if (index < 0) { return; } if (config.vmess[index].configType != (int)EConfigType.Vmess) { UI.Show(UIRes.I18N("NonVmessService")); return; } SaveFileDialog fileDialog = new SaveFileDialog { Filter = "Config|*.json", FilterIndex = 2, RestoreDirectory = true }; if (fileDialog.ShowDialog() != DialogResult.OK) { return; } string fileName = fileDialog.FileName; if (Utils.IsNullOrEmpty(fileName)) { return; } Config configCopy = Utils.DeepCopy(config); configCopy.index = index; if (V2rayConfigHandler.Export2ClientConfig(configCopy, fileName, out string msg) != 0) { UI.Show(msg); } else { UI.ShowWarning(string.Format(UIRes.I18N("SaveClientConfigurationIn"), fileName)); } }
public void Export2ClientConfig(VmessItem item, Config config) { if (item == null) { return; } if (item.configType != EConfigType.Vmess && item.configType != EConfigType.VLESS) { UI.Show(ResUI.NonVmessService); return; } SaveFileDialog fileDialog = new SaveFileDialog { Filter = "Config|*.json", FilterIndex = 2, RestoreDirectory = true }; if (fileDialog.ShowDialog() != DialogResult.OK) { return; } string fileName = fileDialog.FileName; if (Utils.IsNullOrEmpty(fileName)) { return; } //Config configCopy = Utils.DeepCopy(config); //configCopy.index = index; if (V2rayConfigHandler.Export2ClientConfig(item, fileName, out string msg) != 0) { UI.Show(msg); } else { UI.ShowWarning(string.Format(ResUI.SaveClientConfigurationIn, fileName)); } }