Пример #1
0
        internal void AdjustGraph(GraphSelector selector)
        {
            var nodes = new HashSet <Node>();

            if (selector.HitNode != null)
            {
                nodes.Add(selector.HitNode);
            }
            if (selector.HitEdge != null)
            {
                nodes.Add(selector.HitEdge.Node1); nodes.Add(selector.HitEdge.Node2);
            }
            foreach (var node in selector.Nodes)
            {
                nodes.Add(node);
            }
            foreach (var edge in selector.Edges)
            {
                nodes.Add(edge.Node1); nodes.Add(edge.Node2);
            }
            foreach (var e in selector.Points)
            {
                var edge = e.Key;
                nodes.Add(edge.Node1);
                nodes.Add(edge.Node2);
            }

            ExpandNeighborhood();
            AdjustNodes(nodes);

            #region ExpandNeighborhood  =======================================
            void ExpandNeighborhood()
            {
                for (int i = 0; i < 2; i++)
                {
                    var ndList = nodes.ToArray();
                    foreach (var nd in ndList)
                    {
                        if (Node_Edges.TryGetValue(nd, out List <Edge> egList))
                        {
                            foreach (var eg in egList)
                            {
                                nodes.Add(eg.Node1);
                                nodes.Add(eg.Node2);
                            }
                        }
                    }
                }
            }

            #endregion
        }
Пример #2
0
        internal GraphModel(PageModel owner, Graph graph) : base(owner)
        {
            Graph    = graph;
            Selector = new GraphSelector(graph);

            EditorWidth = 300;

            Overview      = Editor; // enable overview
            OverviewWidth = 100;    // inital width

            SetModeNames(typeof(DrawMode));
            SetStateNames(typeof(DrawState));
            SetModeStateEventActions();
            SetModeStateCursors();

            FlyTreeModel     = new TreeModel(owner, null);
            Editor.GetExtent = graph.ResetExtent;

            HasUndoRedo = true;

            UpdateEditorData();
        }
Пример #3
0
 internal void TakeSnapshot(GraphSelector selector)
 {
     _undoStack.Push(new Snapshot(selector));
 }