void ApplySetting(ZoomControl zoom, GraphArea area, bool nav = false)
        {
            //Zoombox.SetViewFinderVisibility(zoom, System.Windows.Visibility.Visible);

            //This property sets vertex overlap removal algorithm.
            //Such algorithms help to arrange vertices in the layout so no one overlaps each other.
            area.DefaultOverlapRemovalAlgorithm       = GraphX.OverlapRemovalAlgorithmTypeEnum.FSA;
            area.DefaultOverlapRemovalAlgorithmParams = Area.AlgorithmFactory.CreateOverlapRemovalParameters
                                                            (GraphX.OverlapRemovalAlgorithmTypeEnum.FSA);

            if (nav)
            {
                ((OverlapRemovalParameters)area.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 150;
                ((OverlapRemovalParameters)area.DefaultOverlapRemovalAlgorithmParams).VerticalGap   = 100;
            }
            else
            {
                ((OverlapRemovalParameters)area.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50;
                ((OverlapRemovalParameters)area.DefaultOverlapRemovalAlgorithmParams).VerticalGap   = 50;
            }
            //This property sets edge routing algorithm that is used to build route paths according to algorithm logic.
            //For ex., SimpleER algorithm will try to set edge paths around vertices so no edge will intersect any vertex.
            //Bundling algorithm will try to tie different edges that follows same direction to a single channel making complex graphs more appealing.
            area.DefaultEdgeRoutingAlgorithm = GraphX.EdgeRoutingAlgorithmTypeEnum.None;

            //This property sets async algorithms computation so methods like: Area.RelayoutGraph() and Area.GenerateGraph()
            //will run async with the UI thread. Completion of the specified methods can be catched by corresponding events:
            //Area.RelayoutFinished and Area.GenerateGraphFinished.
            area.AsyncAlgorithmCompute = true;

            //area.UseLayoutRounding = false;
            area.UseNativeObjectArrange = false;
        }
示例#2
0
        public override void Refresh()
        {
            GraphArea.Invalidate();
            GraphArea.Update();

            base.Refresh();
        }
示例#3
0
        public string SerializeGraphAsDotString()
        {
            DotGraph gr  = DotGraphConverter.ToDot(GraphArea.ToGraph());
            string   dot = DotFileGenerator.Serialize(gr);

            return(dot);
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        private void Register()
        {
            //
            graph_area_ = AssociatedObject;

            // Find the graph behavior
            graphBehavior = Interaction.GetBehaviors(graph_area_).OfType <NodeGraphBehavior>().FirstOrDefault();
            if (graphBehavior != null)
            {
                graphBehavior.VerticesCollectionChanged += GraphBehavior_VerticesCollectionChanged;
                graphBehavior.EdgesCollectionChanged    += GraphBehavior_EdgesCollectionChanged;
            }

            // Travel up the visual tree and get the zoom control
            // If the zoom control doesn't exist, then we can't use this behavior
            // TODO: Done on logical tree for now because visual tree is not valid during behavior OnAttachAndLoaded()
            zoom_control_ = graph_area_.FindLogicalParentOfType <ZoomControl>();
            if (zoom_control_ == null)
            {
                // TODO throw exception!
            }

            graph_area_.VertexSelected           += OnVertexSelected;
            graph_area_.VertexMouseUp            += OnVertexMouseLeftButtonUp;
            graph_area_.EdgeSelected             += OnEdgeSelected;
            zoom_control_.AreaSelected           += OnVertexAreaSelected;
            zoom_control_.MouseLeftButtonUp      += OnMouseLeftButtonUp;
            zoom_control_.MouseLeftButtonDown    += OnMouseLeftButtonDown;
            selected_vertices_.CollectionChanged += OnSelectedVerticesChanged;
            selected_edges_.CollectionChanged    += OnSelectedEdgesChanged;
        }
示例#5
0
        private MDITabItem NewTab()
        {
            var model          = new GraphModel();
            var graphViewModel = new GraphViewModel(model);

            graphViewModel.ModelChanged += OnModelChanged;
            var area = new GraphArea
            {
                DataContext = graphViewModel,
                Background  = Brushes.WhiteSmoke,
                Name        = "graphArea",
                Focusable   = true
            };

            area.MouseMove += GraphAreaOnMouseMove;
            area.SubscribeEvents();
            var tab = new MDITabItem
            {
                Header         = $"Tab {_indexNewTab}",
                Content        = area,
                GraphViewModel = graphViewModel
            };

            _indexNewTab++;
            tab.CloseTab += TabOnCloseTab;
            Tabs.Add(tab);
            return(tab);
        }
示例#6
0
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            GraphArea.GenerateGraph(_vm.Graph);

            if (_vm.HasAutosave())
            {
                var result = MessageBox.Show(
                    "Program did not properly close last time.\nDo you wish to load the last automatic save?\nPressing No will discard the save.",
                    "Auto-save available",
                    MessageBoxButton.YesNo,
                    MessageBoxImage.Exclamation,
                    MessageBoxResult.Yes
                    );

                if (result == MessageBoxResult.Yes)
                {
                    _vm.LoadAutosave();
                }
                else
                {
                    _vm.ClearAutosave();
                }
            }

            _vm.StartAutosaveTimer();
        }
        private void GenerateGraph(string initialState, ICollection <FsmTransition> transitions)
        {
            try
            {
                _logger.Info("Generating graph from FSM transitions.");

                GraphArea.LogicCore = _graphManager.Generate(initialState, transitions);

                _logger.Debug("Graph successfully generated from transitions.");

                GraphArea.GenerateGraph();
                GraphArea.ShowAllEdgesArrows();
                GraphArea.ShowAllEdgesLabels();
                GraphArea.ShowAllVerticesLabels();

                if (_graphManager.AlignEdgeLabels)
                {
                    GraphArea.AlignAllEdgesLabels();
                }

                _logger.Debug("Zooming to generated graph.");

                GraphZoomControl.ZoomToFill();
                //enlarge current zoom
                GraphZoomControl.ZoomToContent(EnlargeBy(GraphZoomControl.Viewport, 50));

                _logger.Info("Graph successfully generated and displayed.");
            }
            catch (Exception e)
            {
                _logger.Error(e, "Error while generating graph in OnLoad event.");
                throw;
            }
        }
示例#8
0
 public LabelElement(GraphArea rootGraph, string name)
 {
     Name      = name;
     RootGraph = rootGraph;
     RootGraph.Children.Add(this);
     Panel.SetZIndex(this, 5);
 }
示例#9
0
        public void SaveGraph()
        {
            List <GraphSerializationData> serializationData = GraphArea.ExtractSerializationData();

            using (System.IO.StreamWriter writer = new System.IO.StreamWriter($"DrawnMapNodePositions_{DateTime.Now.ToString("MMddyyyyhhmmss")}.txt"))
            {
                foreach (GraphSerializationData graphPiece in serializationData)
                {
                    if (graphPiece.Data is DrawnMapNode)
                    {
                        DrawnMapNode node = (DrawnMapNode)graphPiece.Data;
                        writer.WriteLine(
                            "{ MapNodes.Get(\"" +
                            node.MapNode.ShortName +
                            "\"), MapNodeRenderStyle.Get(\"" +
                            node.MapNode.ShortName +
                            $"\",{graphPiece.Position.X},{graphPiece.Position.Y}" +
                            ")},"
                            );
                    }
                    else if (graphPiece.Data is DrawnMapEdge)
                    {
                        DrawnMapEdge edge = (DrawnMapEdge)graphPiece.Data;
                    }
                }
            }
        }
示例#10
0
        private void SetPositon()
        {
            var app = Application.Current;

            if (app != null)
            {
                RunCodeInUiThread(() =>
                {
                    if (_x != double.MinValue)
                    {
                        GraphArea.SetX(_vCtrl, _x, true);
                    }
                    if (_y != double.MinValue)
                    {
                        GraphArea.SetY(_vCtrl, _y, true);
                    }
                }, app.Dispatcher, DispatcherPriority.Loaded);
            }
            else
            {
                if (_x != double.MinValue)
                {
                    GraphArea.SetX(_vCtrl, _x, true);
                }
                if (_y != double.MinValue)
                {
                    GraphArea.SetY(_vCtrl, _y, true);
                }
            }
        }
示例#11
0
 public static void RecolorVertices(GraphArea GA)
 {
     if (areaRandomizer)
     {
         foreach (var kvp in GA.VertexList)
         {
             if (AreaToColor.TryGetValue(kvp.Key.Name, out Color col))
             {
                 kvp.Value.Background = new SolidColorBrush(col);
             }
         }
     }
     else if (roomRandomizer)
     {
         foreach (var kvp in GA.VertexList)
         {
             if (roomToArea.TryGetValue(kvp.Key.Name, out string areaName))
             {
                 if (AreaToColor.TryGetValue(areaName, out Color col))
                 {
                     kvp.Value.Background = new SolidColorBrush(col);
                 }
             }
         }
     }
 }
 private void UpdateCanDrag(GraphArea area, bool canDrag)
 {
     foreach (var item in area.VertexList)
     {
         DragBehaviour.SetIsDragEnabled(item.Value, canDrag);
     }
 }
示例#13
0
 public EdgeControl(GraphArea rootGraph, VertexControl from)
 {
     From      = from;
     RootGraph = rootGraph;
     RootGraph.Children.Add(this);
     Panel.SetZIndex(this, 10);
     Color = Colors.Black;
 }
 private void HookVertexEvent(GraphArea Area)
 {
     foreach (var vertex in Area.VertexList)
     {
         vertex.Key.IsExpandedChanged += (s, e) => vertex_IsExpandedChanged(s, e);
     }
     //throw new NotImplementedException();
 }
示例#15
0
 public EdgeOperation(GraphArea graph, DataVertex source, DataVertex target, Action <EdgeControl> callback = null, Action <EdgeControl> undoCallback = null)
 {
     _graph        = graph;
     _callback     = callback;
     _undoCallback = undoCallback;
     _source       = source;
     _target       = target;
 }
 public EdgeOperation(GraphArea graph, DataVertex source, DataVertex target, Action<EdgeControl> callback = null, Action<EdgeControl> undoCallback = null)
 {
     _graph = graph;
     _callback = callback;
     _undoCallback = undoCallback;
     _source = source;
     _target = target;
 }
示例#17
0
        public void Draw(AllianceScenario allianceScenario, Powers focus)
        {
            try
            {
                _executing = true;

                var logicCore             = new AllianceScenarioGXLogicCore();
                var drawnAllianceScenario = new DrawnAllianceScenario();
                drawnAllianceScenario.FocusPower = focus;
                drawnAllianceScenario.Populate(allianceScenario);
                logicCore.Graph = drawnAllianceScenario;

                /*
                 * logicCore.DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.FR;
                 * logicCore.DefaultLayoutAlgorithmParams = logicCore.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.FR);
                 * ((FreeFRLayoutParameters)logicCore.DefaultLayoutAlgorithmParams).IdealEdgeLength = 100;
                 * ((FreeFRLayoutParameters)logicCore.DefaultLayoutAlgorithmParams).RepulsiveMultiplier = 1.5;
                 * ((FreeFRLayoutParameters)logicCore.DefaultLayoutAlgorithmParams).Seed = 23423423;
                 */


                logicCore.DefaultLayoutAlgorithm       = LayoutAlgorithmTypeEnum.KK;
                logicCore.DefaultLayoutAlgorithmParams = logicCore.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.KK);
                ((KKLayoutParameters)logicCore.DefaultLayoutAlgorithmParams).Width            = 1000;
                ((KKLayoutParameters)logicCore.DefaultLayoutAlgorithmParams).Height           = 1000;
                ((KKLayoutParameters)logicCore.DefaultLayoutAlgorithmParams).AdjustForGravity = true;


                ////Setup optional params
                logicCore.DefaultOverlapRemovalAlgorithmParams =
                    logicCore.AlgorithmFactory.CreateOverlapRemovalParameters(OverlapRemovalAlgorithmTypeEnum.FSA);
                ((OverlapRemovalParameters)logicCore.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50;
                ((OverlapRemovalParameters)logicCore.DefaultOverlapRemovalAlgorithmParams).VerticalGap   = 50;

                //This property sets edge routing algorithm that is used to build route paths according to algorithm logic.
                //For ex., SimpleER algorithm will try to set edge paths around vertices so no edge will intersect any vertex.
                logicCore.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.SimpleER;
                //This property sets async algorithms computation so methods like: Area.RelayoutGraph() and Area.GenerateGraph()
                //will run async with the UI thread. Completion of the specified methods can be catched by corresponding events:
                //Area.RelayoutFinished and Area.GenerateGraphFinished.
                logicCore.AsyncAlgorithmCompute = false;

                logicCore.EdgeCurvingEnabled   = true;
                logicCore.EnableParallelEdges  = true;
                logicCore.ParallelEdgeDistance = 50;

                //Finally assign logic core to GraphArea object
                GraphArea.LogicCore = logicCore;
                GraphArea.SetVerticesDrag(true);
                GraphArea.GenerateGraph();

                ZoomControl.ZoomToFill();
            }
            finally
            {
                _executing = false;
            }
        }
示例#18
0
 //dispose operation, release reference
 public virtual void Dispose()
 {
     _vertex.Dispose();
     _vertex       = null;
     _vCtrl        = null;
     _callback     = null;
     _undoCallback = null;
     _graph        = null;
 }
示例#19
0
 public EditorObjectManager(GraphArea graphArea, ZoomControl zc)
 {
     this.graphArea   = graphArea;
     this.zoomControl = zc;
     this.rd          = new ResourceDictionary
     {
         Source = new Uri("pack://application:,,,/View/Templates/EditorTemplate.xaml", UriKind.RelativeOrAbsolute),
     };
 }
 //dispose operation, release reference
 public virtual void Dispose()
 {
     _Edge.Dispose();
     _Edge = null;
     _eCtrl = null;
     _callback = null;
     _undoCallback = null;
     _graph = null;
 }
        public VertexPositionChangeOperation(GraphArea graph, VertexControl vc, double offsetX, double offsetY, DataVertex data = null, Action <DataVertex, VertexControl> callback = null, Action <DataVertex> undoCallback = null)
            : base(graph, data, callback, undoCallback)
        {
            _vc      = vc;
            _offsetX = offsetX;
            _offsetY = offsetY;

            Status = Orc.GraphExplorer.Status.Done;
        }
        public VertexPositionChangeOperation(GraphArea graph, VertexControl vc, double offsetX, double offsetY, DataVertex data = null, Action<DataVertex, VertexControl> callback = null, Action<DataVertex> undoCallback = null)
            : base(graph, data, callback, undoCallback)
        {
            _vc = vc;
            _offsetX = offsetX;
            _offsetY = offsetY;

            Status = Orc.GraphExplorer.Status.Done;
        }
示例#23
0
 //dispose operation, release reference
 public virtual void Dispose()
 {
     _Edge.Dispose();
     _Edge         = null;
     _eCtrl        = null;
     _callback     = null;
     _undoCallback = null;
     _graph        = null;
 }
示例#24
0
        public void SelectPoint(int subset, int index)
        {
            CursorSubset = subset;
            CursorPoint  = index;

            if (_lazyRefresh == false)
            {
                GraphArea.Refresh();
            }
        }
示例#25
0
 public IsHamiltonian()
 {
     _graphArea   = new GraphArea();
     _zoomControl = new GraphXZoomControl {
         Content = _graphArea
     };
     Output.Controls.Add(new ElementHost {
         Dock = DockStyle.Fill, Child = _zoomControl
     });
 }
 public DeleteVertexOperation(GraphArea graph, DataVertex data = null, Action<DataVertex, VertexControl> callback = null, Action<DataVertex> undoCallback = null)
     : base(graph, data, callback, undoCallback)
 {
     if (graph.VertexList.ContainsKey(_vertex))
         _vCtrl = graph.VertexList[_vertex];
     else
     {
         //throw new ArgumentNullException("Vertex Control");
     }
 }
示例#27
0
 /// <summary>
 /// The basic constructor
 /// </summary>
 /// <param name="graphArea"></param>
 /// <param name="zoomControl"></param>
 public EditorObjectManager(GraphArea graphArea, ZoomControl zoomControl)
 {
     this.graphArea         = graphArea;
     this.zoomControl       = zoomControl;
     zoomControl.MouseMove += ZoomControlMouseMove;
     resourceDictionary     = new ResourceDictionary
     {
         Source = new Uri("pack://application:,,,/ControlsLibrary;component/View/Templates/EditorTemplates.xaml", UriKind.RelativeOrAbsolute)
     };
 }
        public CreateVertexOperation(GraphArea graph, DataVertex data = null, double x = double.MinValue, double y = double.MinValue, Action<DataVertex, VertexControl> callback = null, Action<DataVertex> undoCallback = null)
            : base(graph, data, callback, undoCallback)
        {
            _vCtrl = new VertexControl(_vertex);

            if (x != double.MinValue)
                _x = x;

            if (y != double.MinValue)
                _y = y;
        }
示例#29
0
 public void Dispose()
 {
     ClearEdgeBluePrint();
     graphArea = null;
     if (zoomControl != null)
     {
         zoomControl.MouseMove -= ZoomControlMouseMove;
     }
     zoomControl        = null;
     resourceDictionary = null;
 }
示例#30
0
        private void LayoutAlgorithmComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox comboBox = (ComboBox)sender;

            GraphAreaModel.GraphAreaSetupLayoutAlgorithm((LayoutAlgorithmTypeEnum)comboBox.SelectedIndex);
            if (GraphArray == null)
            {
                return;
            }
            GraphArea.GenerateGraph();
        }
示例#31
0
        public VertexControl(GraphArea rootGraph, int id, Point p)
        {
            Id        = id;
            RootGraph = rootGraph;
            SetPosition(p);
            RootGraph.Children.Add(this);
            Panel.SetZIndex(this, 100);

            Edges = new Dictionary <int, IEdgeUiElement>();
            Color = Colors.Green;
        }
 public DeleteVertexOperation(GraphArea graph, DataVertex data = null, Action <DataVertex, VertexControl> callback = null, Action <DataVertex> undoCallback = null)
     : base(graph, data, callback, undoCallback)
 {
     if (graph.VertexList.ContainsKey(_vertex))
     {
         _vCtrl = graph.VertexList[_vertex];
     }
     else
     {
         //throw new ArgumentNullException("Vertex Control");
     }
 }
        public void Dispose()
        {
            this.ClearEdgeBlueprint();
            this.graphArea = null;
            if (this.zoomControl != null)
            {
                this.zoomControl.MouseMove -= this.ZoomControlMouseMove;
            }

            this.zoomControl        = null;
            this.resourceDictionary = null;
        }
示例#34
0
        public void Dispose()
        {
            this.ClearEdgeBp();
            this.graphArea = null;
            if (this.zoomControl != null)
            {
                this.zoomControl.MouseMove -= this.ZoomControl_MouseMove;
            }

            this.zoomControl = null;
            this.rd          = null;
        }
示例#35
0
 void GraphArea_RelayoutFinished(object sender, EventArgs e)
 {
     ZoomBox.ZoomToFill();
     ZoomBox.Mode = GraphX.Controls.ZoomControlModes.Custom;
     foreach (var item in GraphArea.VertexList)
     {
         DragBehaviour.SetIsDragEnabled(item.Value, true);
         item.Value.EventOptions.PositionChangeNotification = true;
     }
     GraphArea.ShowAllEdgesLabels();
     GraphArea.InvalidateVisual();
 }
示例#36
0
        private UIElement GenerateWpfVisuals()
        {
            _zoomctrl = new ZoomControl();
            ZoomControl.SetViewFinderVisibility(_zoomctrl, Visibility.Visible);
            /* ENABLES WINFORMS HOSTING MODE --- >*/
            var logic = new GXLogicCore<DataVertex, DataEdge, BidirectionalGraph<DataVertex, DataEdge>>();
            _gArea = new GraphArea() { EnableWinFormsHostingMode = true, LogicCore = logic };

            logic.Graph = totalGraph;

            logic.DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.LinLog;
            logic.DefaultLayoutAlgorithmParams = logic.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.Tree);
            //((LinLogLayoutParameters)logic.DefaultLayoutAlgorithmParams). = 100;
            logic.DefaultOverlapRemovalAlgorithm = OverlapRemovalAlgorithmTypeEnum.FSA;
            logic.DefaultOverlapRemovalAlgorithmParams = logic.AlgorithmFactory.CreateOverlapRemovalParameters(OverlapRemovalAlgorithmTypeEnum.FSA);
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50;
            ((OverlapRemovalParameters)logic.DefaultOverlapRemovalAlgorithmParams).VerticalGap = 50;
            logic.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.None;
            logic.AsyncAlgorithmCompute = false;
            _zoomctrl.Content = _gArea;
            _gArea.RelayoutFinished += gArea_RelayoutFinished;

            var myResourceDictionary = new ResourceDictionary { Source = new Uri("Templates\\template.xaml", UriKind.Relative) };
            _zoomctrl.Resources.MergedDictionaries.Add(myResourceDictionary);

            return _zoomctrl;
        }
        public CreateEdgeOperation(GraphArea graph, DataVertex source, DataVertex target, Action<EdgeControl> callback = null, Action<EdgeControl> undoCallback = null):base(graph,source,target,callback,undoCallback)
        {

        }
 public DeleteEdgeOperation(GraphArea graph, DataVertex source, DataVertex target,DataEdge edge, Action<EdgeControl> callback = null, Action<EdgeControl> undoCallback = null)
     : base(graph, source, target, callback, undoCallback)
 {
     _Edge = edge;
     base.Sammary = "Delete Edge";
 }