/// <summary> /// 拷贝粘贴-----粘贴(从某例子中拷贝过来的没弄明白呢) /// </summary> private void MenuItemEditPaste() { IDataObject data = Clipboard.GetDataObject(); if (data.GetDataPresent("AddFlow.XMLFormat")) { // We first unselect the selected items this.addFlow1.SelectedItems.Clear(); // Get the data from the clipboard MemoryStream stream = (MemoryStream)data.GetData("AddFlow.XMLFormat"); // We paste the portion of the diagram in our AddFlow control. // We group all the load actions in only one action so that we could undo // the paste action in one time. this.addFlow1.BeginAction(1003); XmlTextReader reader = new XmlTextReader(stream); reader.WhitespaceHandling = WhitespaceHandling.None; this.addFlow1.ReadXml(reader, true, false, false); reader.Close(); // We move a little each pasted node and link so that they do not recover // the original items. float dx = this.addFlow1.Grid.Size.Width; float dy = this.addFlow1.Grid.Size.Height; foreach (Lassalle.Flow.Item item in addFlow1.SelectedItems) { if (item is Lassalle.Flow.Node) { Lassalle.Flow.Node node = (Lassalle.Flow.Node)item; node.Location = new PointF(node.Location.X + dx, node.Location.Y + dy); } else { PointF pt; Lassalle.Flow.Link link = (Lassalle.Flow.Link)item; if (link.AdjustOrg) { pt = link.Points[0]; link.Points[0] = new PointF(pt.X + dx, pt.Y + dy); } for (int k = 1; k < link.Points.Count - 1; k++) { pt = link.Points[k]; link.Points[k] = new PointF(pt.X + dx, pt.Y + dy); } if (link.AdjustDst) { pt = link.Points[link.Points.Count - 1]; link.Points[link.Points.Count - 1] = new PointF(pt.X + dx, pt.Y + dy); } } } addFlow1.EndAction(); } }
/// <summary> /// (从某例子中拷贝过来的没弄明白呢,反正是配合剪切用的) /// </summary> private void SelectionChangeHandle() { Lassalle.Flow.Item item = addFlow1.SelectedItem; if (item != null) { if (item is Lassalle.Flow.Node) { Lassalle.Flow.Node node = (Lassalle.Flow.Node)item; propertyGrid1.SelectedObject = node; //Label1.Text = "Selected Node"; } else if (item is Lassalle.Flow.Link) { Lassalle.Flow.Link link = (Lassalle.Flow.Link)item; propertyGrid1.SelectedObject = link; //Label1.Text = "Selected Link"; } } else { propertyGrid1.SelectedObject = addFlow1; // Label1.Text = "AddFlow control"; } }