Esempio n. 1
0
        public GraphGUI()
        {
            Selection = new SelectionClass(this);

            EditingMode = InkCanvasEditingMode.Select;
            var formats = new[]
            {
                InkCanvasClipboardFormat.Xaml,
                InkCanvasClipboardFormat.InkSerializedFormat
            };

            PreferredPasteFormats = formats;

            nodeShapes     = new ShapeBank(this);
            arcShapes      = new ShapeBank(this);
            hyperarcShapes = new ShapeBank(this);

            nullNodeIcons = new NullNodeIconBank(this);
            nodeIcons     = new NodeIconBank(this);
            arcIcons      = new ArcIconBank(this);
            hyperarcIcons = new HyperArcIconBank(this);

            gridAndAxes = new GridAndAxes(defaultLength);
            Children.Add(gridAndAxes);

            shapeSyncTimer.Tick += shapeSyncTimer_Tick;
            shapeSyncTimer.Start();
        }
Esempio n. 2
0
        internal SelectionClass FindCommonSelection(RuleDisplay ruleDisplay)
        {
            var sc = new SelectionClass(ruleDisplay);

            sc.selectedNodes.AddRange(ruleDisplay.graph.nodes.Where(r => selectedNodes.Select(n => n.name).Contains(r.name)));
            sc.selectedArcs.AddRange(ruleDisplay.graph.arcs.Where(r => selectedArcs.Select(a => a.name).Contains(r.name)));
            sc.selectedHyperArcs.AddRange(ruleDisplay.graph.hyperarcs.Where(r => selectedHyperArcs.Select(h => h.name).Contains(r.name)));

            return(sc);
        }
Esempio n. 3
0
        public new virtual void Paste()
        {
            var ClipboardString = Clipboard.GetText();
            var copiedSelection = SelectionClass.DeSerializeClipboardFormatFromXML(ClipboardString);

            RestoreDisplayShapes(copiedSelection.ReadInXmlShapes, copiedSelection.selectedNodes,
                                 copiedSelection.selectedArcs, copiedSelection.selectedHyperArcs);
            var newSelection = new List <UIElement>();

            var copiedData = new designGraph(copiedSelection.selectedNodes,
                                             copiedSelection.selectedArcs, copiedSelection.selectedHyperArcs);

            copiedData.RepairGraphConnections();


            foreach (var n in copiedData.nodes)
            {
                n.name = graph.makeUniqueNodeName(n.name);
                n.X    = n.X + MouseLocation.X - copiedSelection.ReferencePoint.X - Origin.X;
                n.Y    = n.Y + MouseLocation.Y - copiedSelection.ReferencePoint.Y - Origin.Y;
                addNodeShape(n);
                graph.addNode(n);
                newSelection.Add((Shape)n.DisplayShape.Shape);
            }
            foreach (var a in copiedData.arcs)
            {
                a.name = graph.makeUniqueArcName(a.name);
                graph.arcs.Add(a);
                AddArcShape(a);
                SetUpNewArcShape(a);
                newSelection.Add((ArcShape)a.DisplayShape.Shape);
            }
            foreach (var h in copiedData.hyperarcs)
            {
                h.name = graph.makeUniqueHyperArcName(h.name);
                graph.addHyperArc(h); //note that the list of nodes is not sent because it is
                //already connected to those from copiedData
                AddHyperArcShape(h);
                newSelection.Add((HyperArcShape)h.DisplayShape.Shape);
            }
            Select(newSelection);
            storeOnUndoStack();
        }
 private void Delete(SelectionClass newSelect)
 {
     Selection = newSelect;
     base.Delete();
 }
        public override void Paste()
        {
            var ClipboardString = Clipboard.GetText();
            var copiedSelection = SelectionClass.DeSerializeClipboardFormatFromXML(ClipboardString);

            RestoreDisplayShapes(copiedSelection.ReadInXmlShapes, copiedSelection.selectedNodes,
                                 copiedSelection.selectedArcs, copiedSelection.selectedHyperArcs);
            var newSelection = new List <UIElement>();

            if (copiedSelection != null)
            {
                var tempGraph = new designGraph();
                foreach (node n in copiedSelection.selectedNodes)
                {
                    if (n is ruleNode)
                    {
                        tempGraph.addNode(n);
                    }
                    else
                    {
                        tempGraph.addNode(new ruleNode(n));
                    }
                }
                foreach (arc a in copiedSelection.selectedArcs)
                {
                    if (a is ruleArc)
                    {
                        tempGraph.arcs.Add(a);
                    }
                    else
                    {
                        tempGraph.arcs.Add(new ruleArc(a));
                    }
                }
                foreach (hyperarc a in copiedSelection.selectedHyperArcs)
                {
                    if (a is ruleHyperarc)
                    {
                        tempGraph.addHyperArc(a);
                    }
                    else
                    {
                        tempGraph.addHyperArc(new ruleHyperarc(a));
                    }
                }
                tempGraph.RepairGraphConnections();

                foreach (node n in tempGraph.nodes)
                {
                    var mousePos = Mouse.GetPosition(this);
                    n.X    = mousePos.X + n.X - copiedSelection.ReferencePoint.X - Origin.X;
                    n.Y    = mousePos.Y + n.Y - copiedSelection.ReferencePoint.Y - Origin.Y;
                    n.name = rW.rule.makeUniqueNodeName(n.name);
                    addNodeShape(n);
                    graph.addNode(n);
                    newSelection.Add((Shape)n.DisplayShape.Shape);

                    if (rW.graphGUIK == this)
                    {
                        AddKNodeToLandR(n);
                    }
                }
                foreach (arc a in tempGraph.arcs)
                {
                    a.name = rW.rule.makeUniqueArcName(a.name);
                    graph.arcs.Add(a);
                    AddArcShape(a);
                    SetUpNewArcShape(a);
                    newSelection.Add((ArcShape)a.DisplayShape.Shape);

                    if (rW.graphGUIK == this)
                    {
                        AddKArcToLandR(a);
                    }
                }
                foreach (hyperarc h in tempGraph.hyperarcs)
                {
                    h.name = rW.rule.makeUniqueHyperarcName(h.name);
                    graph.addHyperArc(h);
                    AddHyperArcShape(h);
                    newSelection.Add((HyperArcShape)h.DisplayShape.Shape);

                    if (rW.graphGUIK == this)
                    {
                        AddKHyperToLandR(h);
                    }
                }
                Select(newSelection);
            }
        }