//----------------------------------------------------------------------- public override void Paste() { if (WrappedItem != null) { WrappedItem.Paste(); } else { GraphNodeDefinition chosen = null; foreach (var def in ReferenceDef.Definitions.Values) { if (Clipboard.ContainsData(def.CopyKey)) { var flat = Clipboard.GetData(def.CopyKey) as string; var root = XElement.Parse(flat); if (root.Name == def.Name) { chosen = def; break; } } } if (chosen == null) { return; } GraphNodeItem item = null; using (UndoRedo.DisableUndoScope()) { item = chosen.CreateData(UndoRedo) as GraphNodeItem; if (item is GraphStructItem && item.Children.Count == 0) { (item.Definition as GraphStructDefinition).CreateChildren(item as GraphStructItem, UndoRedo); } item.Paste(); } UndoRedo.ApplyDoUndo(delegate { ChosenDefinition = chosen; WrappedItem = item; }, delegate { ChosenDefinition = null; WrappedItem = null; }, "Paste Item " + item.Name); } }
//----------------------------------------------------------------------- public void Create(string chosenName = null) { var Node = GetParentNode(); var chosen = chosenName != null ? (Definition as GraphReferenceDefinition).Definitions[chosenName] : (Definition as GraphReferenceDefinition).Definitions[SelectedDefinition.Item1]; GraphNodeItem item = null; using (UndoRedo.DisableUndoScope()) { item = chosen.CreateData(UndoRedo) as GraphNodeItem; if (Node != null) { var x = Node.X + 100; if (!double.IsNaN(Node.GraphNode.ActualWidth)) { x += Node.GraphNode.ActualWidth; } else { x += 200; } item.X = x; item.Y = Node.Y; } } UndoRedo.ApplyDoUndo(delegate { WrappedItem = item; if (!DataModel.GraphNodeItems.Contains(item)) { DataModel.GraphNodeItems.Add(item); } }, delegate { WrappedItem = null; DataModel.GraphNodeItems.Remove(item); }, "Create Item " + item.Name); IsExpanded = true; }
//----------------------------------------------------------------------- public void SetWrappedItem(GraphNodeItem item) { var oldItem = WrappedItem; UndoRedo.ApplyDoUndo(delegate { WrappedItem = item; }, delegate { WrappedItem = oldItem; }, "Set Item " + item.Name); if (IsCircular()) { LinkType = LinkType.Reference; } }