void PasteObject() { try { if (mObjectList == null) { Logger.Log("错误,数据列表【mObjectList】不存在!!!"); return; } // convert string to stream ObjectListContent content = (ObjectListContent)PropertySerializer.StringToObject( Clipboard.GetText(), typeof(ObjectListContent)); foreach (T data in content.DataList) { mObjectList.Add(data); } ShowData(); Logger.Log("恭喜,您粘贴了" + content.DataList.Count + "个劳动成果!!!"); } catch (Exception ex) { Logger.Log("无法进行粘贴,错误信息:" + ex.Message); } }
void CopyObject() { if (mListView.SelectedItems.Count > 0) { ObjectListContent content = new ObjectListContent(); foreach (ListViewItem item in mListView.SelectedItems) { if (item.Tag != null) { content.DataList.Add((T)item.Tag); } } if (content.DataList.Count > 0) { Clipboard.SetText(PropertySerializer.ObjectToString(content)); } Logger.Log("恭喜,您复制了" + content.DataList.Count.ToString() + "个劳动成果!!!"); } else { Logger.Log("您必须选择至少一个劳动成果进行复制!!!"); } }