void menu_copyJSONtoClipboard(object sender, System.EventArgs e) { string strError; if (listView1.SelectedIndices.Count == 0) { strError = "尚未选择要刷新 UID 的事项 ..."; goto ERROR1; } List <CopyServer> servers = new List <CopyServer>(); foreach (int index in this.listView1.SelectedIndices) { dp2Server server = Servers[index] as dp2Server; servers.Add(CopyServer.From(server)); } string value = JsonConvert.SerializeObject(servers, Formatting.Indented); Clipboard.SetText(value); return; ERROR1: MessageBox.Show(this, strError); }
public static CopyServer From(dp2Server server) { CopyServer result = new CopyServer { Name = server.Name, Url = server.Url, UID = server.UID, UserName = server.DefaultUserName, SavePassword = server.SavePassword, EncryptPassword = server.SavePassword == false ? null : Cryptography.Encrypt(server.DefaultPassword, GetKey()), }; return(result); }