예제 #1
0
        public void Execute(PasteCommand command)
        {
            var copiedNodes = CopiedNodes.ToArray();

            foreach (var item in copiedNodes)
            {
                var filter = item as IGraphFilter;
                if (filter != null)
                {
                    CopiedNodes.AddRange(filter.FilterItems.Where(p => p.Node != item));
                }
            }
            var offset = command.Position - CopiedNodes.Last().Position;

            foreach (var item in CopiedNodes)
            {
                var node       = item.Node;
                var repository = node.Repository;
                var nodeJson   = InvertJsonExtensions.SerializeObject(node);
                var copiedNode = InvertJsonExtensions.DeserializeObject(node.GetType(), nodeJson) as GraphNode;
                copiedNode.Identifier = Guid.NewGuid().ToString();
                copiedNode.Name      += "_Copy";
                copiedNode.Graph      = InvertGraphEditor.CurrentDiagramViewModel.GraphData;
                repository.Add(copiedNode);

                foreach (var child in node.GraphItems.ToArray())
                {
                    if (child == node)
                    {
                        continue;
                    }
                    var childJson   = InvertJsonExtensions.SerializeObject(child);
                    var copiedChild = InvertJsonExtensions.DeserializeObject(child.GetType(), childJson) as IDiagramNodeItem;
                    copiedChild.Identifier = Guid.NewGuid().ToString();
                    copiedChild.Node       = copiedNode;
                    repository.Add(copiedChild);
                }

                //item.GetPropertiesByAttribute<>()
                InvertGraphEditor.CurrentDiagramViewModel.GraphData.CurrentFilter.ShowInFilter(copiedNode,
                                                                                               item.Position + offset);
            }
        }
예제 #2
0
 public void Execute(PickupCommand command)
 {
     CopiedNodes.Clear();
     CopiedNodes.AddRange(SelectedNodes);
     Signal <INotify>(_ => _.Notify("Now navigate to the target graph and press paste.", NotificationIcon.Info));
 }