private void Paste() { try { VariableItemListContent content = XmlUtility.StringToObject <VariableItemListContent>(Clipboard.GetText()); for (int i = 0; i < content.DataList.Count; i++) { VariableFieldDesigner variableField = content.DataList[i]; string variableStr = variableField.VariableFieldName; do { variableStr += "_New"; }while (m_EditContextVariable.ExistVariableStr(variableStr)); variableField.VariableFieldName = variableStr; m_EditContextVariable.Add(variableField); } Exec("Refresh"); MainForm.Instance.ShowInfo("您粘贴了" + content.DataList.Count + "个变量选项!!!"); } catch (Exception ex) { MainForm.Instance.ShowInfo("无法进行粘贴,错误信息:" + ex.Message); MainForm.Instance.ShowMessage("无法进行粘贴,错误信息:" + ex.Message, "警告"); } }
private void Copy() { if (listView1.SelectedItems.Count > 0) { VariableItemListContent content = new VariableItemListContent(); foreach (ListViewItem lvItem in listView1.SelectedItems) { if (lvItem.Tag is VariableFieldDesigner) { content.DataList.Add((VariableFieldDesigner)lvItem.Tag); } } if (content.DataList.Count > 0) { Clipboard.SetText(XmlUtility.ObjectToString(content)); } MainForm.Instance.ShowInfo("您复制了" + content.DataList.Count.ToString() + "个变量选项!!!"); } else { MainForm.Instance.ShowInfo("您必须选择至少一个进行复制!!!"); MainForm.Instance.ShowMessage("您必须选择至少一个进行复制!!!", "警告"); } }