Example #1
0
        public void SetGraph(Graph graph)
        {
            graph.IsVisible = true;

            GraphViewer graphViewer = new GraphViewer();

            graphViewer.BindToPanel(Panel);

            graphViewer.Graph = graph;
        }
Example #2
0
        private void fixedAmountButton_CheckedChanged(object sender, EventArgs e)
        {
            if ((sender as RadioButton).Checked)
            {
                this.GraphViewer.Graph.SelectedAmountType = AmountType.FixedAmount;
            }

            GraphViewer.Graph.UpdateNodeValues();
            GraphViewer.UpdateNodes();
            GraphViewer.Invalidate();
        }
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            GraphViewer graphViewer = new GraphViewer();

            graphViewer.BindToPanel(Panel);
            Graph graph = new Graph();

            graph.AddEdge("A", "B");
            graph.Attr.LayerDirection = LayerDirection.LR;
            graphViewer.Graph         = graph; // throws exception
        }
Example #4
0
        private void btnRender_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(SymFile) || string.IsNullOrWhiteSpace(TraceFile))
            {
                return;
            }

            string source, target;

            graphViewer = new GraphViewer();
            graphViewer.LayoutEditingEnabled = false;
            graphViewer.BindToPanel(gvPanel);
            Drawing.Edge edg    = null;
            var          dgraph = new Drawing.Graph();

            var tot = new totts(SymFile, TraceFile);

            var blocks = tot.GetBlocks();

            foreach (var block in blocks)
            {
                if (block == null)
                {
                    break;
                }
                source = block.StepEvent.FROM_RIP.ToString("X");
                target = block.StepEvent.RIP.ToString("X");

                //var edge = new Drawing.Edge(source, "", target);
                edg = dgraph.AddEdge(source, target);
            }
            foreach (var block in blocks)
            {
                var blockLabel = new StringBuilder();
                foreach (var line in block.Lines.Values)
                {
                    blockLabel.Append(line.Address.ToString("X") + "\t" + line.NasmDisLine);
                }

                var node = dgraph.FindNode(block.StepEvent.FROM_RIP.ToString("X"));
                if (node == null)
                {
                    continue;
                }

                node.LabelText       = blockLabel.ToString();
                node.Label.FontSize  = 10;
                node.Label.FontName  = "New Courier";
                node.Label.FontColor = Drawing.Color.Blue;
            }
            dgraph.Attr.LayerDirection         = Drawing.LayerDirection.TB;
            dgraph.Attr.OptimizeLabelPositions = false;
            graphViewer.Graph = dgraph;
        }
        private void SetGraph(Graph graph)
        {
            if (graph == null)
            {
                dockPanel.Children.Clear();
                return;
            }
            var graphViewer = new GraphViewer();

            graphViewer.BindToPanel(dockPanel);
            graphViewer.Graph = graph;
        }
        private void DisplayAbstractGraph()
        {
            _graphViewer = new GraphViewer
            {
                LayoutEditingEnabled = false,
            };

            _graphViewer.BindToPanel(GraphPanel);
            _graphViewer.MouseDown += MouseDownHandler;
            _graphViewer.MouseUp   += MouseUpHandler;
            _graphViewer.Graph      = _graph;
        }
Example #7
0
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            graphViewer = new GraphViewer();
            graphViewer.BindToPanel(GraphDockPanel);


            graphViewer.ObjectUnderMouseCursorChanged += GraphViewer_ObjectUnderMouseCursorChanged;
            graphViewer.MouseUp += GraphViewer_MouseUp;


            DrawGraph();
        }
Example #8
0
        public MainView()
        {
            InitializeComponent();

            GraphPanel.ClipToBounds = true;

            GraphViewer = new GraphViewer();
            GraphViewer.BindToPanel(GraphPanel);
            GraphViewer.Graph = new Graph();

            Loaded += (sender, args) => SetupBinding();
        }
Example #9
0
        private void LanguageDropDown_SelectedIndexChanged(object sender, EventArgs e)
        {
            String newLocale = (LanguageDropDown.SelectedItem as Language).Name;

            DataCache.LocaleFiles.Clear();
            DataCache.LoadLocaleFiles(newLocale);

            GraphViewer.UpdateNodes();
            UpdateControlValues();

            Properties.Settings.Default["Language"] = newLocale;
            Properties.Settings.Default.Save();
        }
Example #10
0
        private void EnableDisableButton_Click(object sender, EventArgs e)
        {
            EnableDisableItemsForm form = new EnableDisableItemsForm();

            form.ShowDialog();
            SaveEnabledObjects();

            if (form.ModsChanged)
            {
                GraphViewer.LoadFromJson(JObject.Parse(JsonConvert.SerializeObject(GraphViewer)));
                UpdateControlValues();
            }
        }
Example #11
0
        private void AddRecipeButton_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem lvItem in RecipeListView.SelectedItems)
            {
                Point location = GraphViewer.ScreenToGraph(new Point(GraphViewer.Width / 2, GraphViewer.Height / 2));

                NodeElement newElement = new NodeElement(RecipeNode.Create((Recipe)lvItem.Tag, GraphViewer.Graph), GraphViewer);
                newElement.Update();
                newElement.Location = Point.Add(location, new Size(-newElement.Width / 2, -newElement.Height / 2));
            }

            GraphViewer.Graph.UpdateNodeValues();
        }
        /// <summary>
        /// Constructeur
        /// </summary>
        public Visualisation()
        {
            this.DataContext = this;
            InitializeComponent();

            viewer1 = new GraphViewer();
            viewer1.RunLayoutAsync = true;

            viewer1.BindToPanel(this.grapheContainer1);

            viewer2 = new GraphViewer();
            viewer2.RunLayoutAsync = true;
            viewer2.BindToPanel(this.grapheContainer2);
        }
Example #13
0
        private void MainWindow_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            graphViewer = new GraphViewer();
            graphViewer.BindToPanel(GraphDockPanel);


            graphViewer.ObjectUnderMouseCursorChanged += GraphViewer_ObjectUnderMouseCursorChanged;
            graphViewer.MouseUp += GraphViewer_MouseUp;


            graph = GraphCore.LoadGraphFromFile(@"C:\Users\rnamedyn\Downloads\Telegram Desktop\bez cyklu.txt");

            DrawGraph();
        }
Example #14
0
 private void rateButton_CheckedChanged(object sender, EventArgs e)
 {
     if ((sender as RadioButton).Checked)
     {
         this.GraphViewer.Graph.SelectedAmountType = AmountType.Rate;
         rateOptionsDropDown.Enabled = true;
     }
     else
     {
         rateOptionsDropDown.Enabled = false;
     }
     GraphViewer.UpdateNodes();
     GraphViewer.Invalidate();
 }
Example #15
0
        public void buildGui()
        {
            GraphModeTopPanels   = this.add_1x1("Select root node", "Graph", true, this.width() / 2);
            GraphModeRightPanels = this.GraphModeTopPanels[1].add_1x1(false);

            var GraphTreeViewWithMethods = this.GraphModeTopPanels[0].add_TreeViewWithFilter(AllMethods).sort();

            this.GraphModeRightPanels[0].backColor(Color.White);

            GraphViewer = this.GraphModeRightPanels[0].add_Graph();
            GraphScript = this.GraphModeRightPanels[1].add_Script(false);

            //GraphModeRightPanels[1].parent<SplitContainer>().panel2Collapsed(true);

            GraphTreeViewWithMethods.afterSelect <string>(createAndAddGraphNode);

            GraphOptionsPanel = GraphScript.insert_Left <Forms.Panel>(200);

            // GraphOptionsPanel options & actions

            GraphOptionsPanel.add_Link("Auto Expand All Methods", 0, 0, () => graphAutoExpandAllMethods());

            GraphOptionsPanel.add_Label("Select graph Layout", 20, 0);

            var OptionsLayoutCombox = GraphOptionsPanel.add_ComboBox(35, 0);

            OptionsLayoutCombox.add_Items(new List <string> {
                "Tree",
                "CompoundFDP",
                "LinLog",
                "ISOM",
                "KK",
                "BoundedFR",
                "FR",
                "Circular"
            });
            OptionsLayoutCombox.select_Item(0);
            OptionsLayoutCombox.onSelection(() => GraphViewer.layout(OptionsLayoutCombox.get_Text()));

            GraphOptionsPanel.add_Link("Load All Methods", 60, 0, () => graphAllMethods());

            GraphOptionsPanel.add_CheckBox("Expand Methods Called", 80, 0, (value) => ExpandMethodsCalled          = value).check().autoSize();
            GraphOptionsPanel.add_CheckBox("Expand Method Is CalledBy", 100, 0, (value) => ExpandMethodIsCalledBy  = value).check().autoSize();
            GraphOptionsPanel.add_CheckBox("Clear Graph on Method View", 120, 0, (value) => ClearGraphOnMethodView = value).check().autoSize();
            GraphOptionsPanel.add_CheckBox("use '*' as node Text", 140, 0, (value) => UseStarAsNodeText            = value).autoSize();

            GraphOptionsPanel.add_Link("set note text to: '*' ", 160, 0, () => setNodeTextTo_Star());
            //GraphOptionsPanel.add_Link("set note text to: method name " , 190,0,()=> setNodeTextTo_MethodName());
            //GraphOptionsPanel.add_Link("set note text to: method signature " , 180,0,()=> setNodeTextTo_MethodSignature());
        }
Example #16
0
        public GraphControl(GraphProvider echoGraph, ITheme theme, FontSettings font)
        {
            InitializeComponent();

            // could set LastChildFill to true, doesn't seem to matter
            Panel.HorizontalAlignment = HorizontalAlignment.Center;
            Panel.VerticalAlignment   = VerticalAlignment.Center;

            var viewer = new GraphViewer();

            viewer.BindToPanel(Panel);
            viewer.Graph = echoGraph.ToMicrosoftGraph(theme, font);

            viewer.NodeToCenterWithScale(viewer.Graph.Nodes.OrderBy(n => n.UserData is long u ? u : long.MaxValue).First(), 1);
        }
Example #17
0
 public WPF.Label unexpandedNode()
 {
     foreach (var node in GraphViewer.nodes())
     {
         if (node is WPF.Label)
         {
             var label = (node as WPF.Label);
             if (label.get_Color() != Media.Brushes.Green)
             {
                 return(label);
             }
         }
     }
     return(null);
 }
Example #18
0
        public static IViewerNode addNode(GraphViewer gv, string id, double x, double y)
        {
            //var node = new Node(id);
            var graph     = gv.Graph;
            var node      = graph.AddNode(id);
            var lnode     = GeometryGraphCreator.CreateGeometryNode(graph, graph.GeometryGraph, node, ConnectionToGraph.Disconnected);
            var labelSize = Common.MeasureLabel(node.Label);

            lnode.BoundaryCurve = NodeBoundaryCurves.GetNodeBoundaryCurve(node, labelSize.Width, labelSize.Height);
            node.GeometryNode   = lnode;
            var vnode = gv.CreateIViewerNode(node, new DPoint(x, y), null);

            return(vnode);
            //gv.AddNode(vnode, true);
            //gv.CreateVNode(node);
        }
Example #19
0
        public static IViewerNode addVnodeByDnode(GraphViewer gv, Node node, DPoint pos)
        {
            var graph = gv.Graph;

            Debug.Assert(node.GeometryNode == null);
            LNode lnode     = GeometryGraphCreator.CreateGeometryNode(graph, graph.GeometryGraph, node, ConnectionToGraph.Disconnected);
            var   labelSize = Common.MeasureLabel(node.Label);
            var   mar       = node.Attr.LabelMargin;

            lnode.BoundaryCurve = NodeBoundaryCurves.GetNodeBoundaryCurve(node, labelSize.Width + mar * 2, labelSize.Height + mar * 2);
            node.GeometryNode   = lnode;

            var vnode = gv.CreateIViewerNode(node, pos, null);

            return(vnode);
        }
Example #20
0
        private void fixedAmountButton_CheckedChanged(object sender, EventArgs e)
        {
            if ((sender as RadioButton).Checked)
            {
                this.GraphViewer.Graph.SelectedAmountType = AmountType.FixedAmount;
            }

            MinerDisplayCheckBox.Checked
                      = MinerDisplayCheckBox.Enabled
                      = AssemblerDisplayCheckBox.Enabled
                      = AssemblerDisplayCheckBox.Checked
                      = !(sender as RadioButton).Checked;

            GraphViewer.UpdateNodes();
            GraphViewer.Invalidate();
        }
Example #21
0
        private void rateOptionsDropDown_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch ((sender as ComboBox).SelectedIndex)
            {
            case 0:
                GraphViewer.Graph.SelectedUnit = RateUnit.PerSecond;
                break;

            case 1:
                GraphViewer.Graph.SelectedUnit = RateUnit.PerMinute;
                break;
            }
            GraphViewer.Graph.UpdateNodeValues();
            GraphViewer.Invalidate();
            GraphViewer.UpdateNodes();
        }
Example #22
0
 public void graphAllMethods()
 {
     O2Thread.mtaThread(
         () => {
         var maxNodeSize = 300;
         foreach (var methodSignature in AllMethods)
         {
             addGraphNode(methodSignature);
             if (maxNodeSize < GraphViewer.nodes().size())
             {
                 "in graphAutoExpandAllMethods, maxNode size reached: {0}".error(maxNodeSize);
                 break;
             }
         }
         "graphAllMethods completed".info();
     });
 }
Example #23
0
        private void ModDirectoryButton_Click(object sender, EventArgs e)
        {
            using (DirectoryChooserForm form = new DirectoryChooserForm(Properties.Settings.Default.FactorioModPath))
            {
                form.Text = "Locate the mods directory";
                if (form.ShowDialog() == DialogResult.OK)
                {
                    Properties.Settings.Default["FactorioModPath"] = form.SelectedPath;
                    Properties.Settings.Default.Save();

                    JObject savedGraph = JObject.Parse(JsonConvert.SerializeObject(GraphViewer));
                    ReloadFactorioData();
                    GraphViewer.LoadFromJson(savedGraph);
                    UpdateControlValues();
                }
            }
        }
Example #24
0
        /// <summary>
        /// 各コントロールの初期化
        /// </summary>c
        private void InintializeViewers() {
            // ソートオブジェクトの初期化
            sortObj = cmb_SortAlgorythm.SelectedItem as SortObject<int>;

            // 各ビューの初期化
            int x = 50;
            var barColor1 = Color.FromArgb( 255, x, x );
            var barColor2 = Color.FromArgb( x, 255, x );
            var barColor3 = Color.FromArgb( x, x, 255 );
            graphViewer = new GraphViewer( pbx_GraphView, barColor1, barColor2, barColor3 );
            graphViewer.SetDataSource( sortObj );

            compareCountViewer = new CompareCountViewer( lbl_CompareCount );
            compareCountViewer.SetDataSource( sortObj );

            swapCountViewer = new SwapCountViewer( lbl_SwapCount );
            swapCountViewer.SetDataSource( sortObj );
        }
Example #25
0
        private void InitControls()
        {
            //panel.LastChildFill = true;
            GraphViewer graphViewer = new GraphViewer();

            graphViewer.BindToPanel(panel);

            panel.Background = Brushes.LightGray;
            panel.Focusable  = true;
            panel.UpdateLayout();
            _graphViewer = graphViewer;

            nodeAttrGroup.Visibility = Visibility.Hidden;
            //propertyPanel.UpdateLayout();
            //edgeAttrGroup.Visibility = Visibility.Hidden;
            edgeEditor.Visibility = Visibility.Visible;
            global_graphViewer    = _graphViewer;
        }
Example #26
0
 public void graphAutoExpandAllMethods()
 {
     O2Thread.mtaThread(
         () => {
         var maxNodeSize  = 300;
         var nodeToExpand = this.unexpandedNode();
         while (maxNodeSize > GraphViewer.nodes().size() && nodeToExpand != null)
         {
             addCallerAndCalleesToGraphNode(nodeToExpand);
             "after expand, there are: {0} nodes".info(GraphViewer.nodes().size());
             nodeToExpand = unexpandedNode();
         }
         if (maxNodeSize < GraphViewer.nodes().size())
         {
             "in graphAutoExpandAllMethods, maxNode size reached: {0}".error(maxNodeSize);
         }
         "graphAutoExpandAllMethods completed".info();
     });
 }
Example #27
0
        public static void addCordinate(GraphViewer gv)
        {
            Line a1 = new Line();

            a1.X1     = -100;
            a1.Y1     = 0;
            a1.X2     = 100;
            a1.Y2     = 0;
            a1.Stroke = Brushes.Black;
            gv.GraphCanvas.Children.Add(a1);

            Line a2 = new Line();

            a2.X1     = 00;
            a2.Y1     = 100;
            a2.X2     = 0;
            a2.Y2     = -100;
            a2.Stroke = Brushes.Black;
            gv.GraphCanvas.Children.Add(a2);
        }
Example #28
0
        void LoadData(string DatFile)
        {
            uniqD = new Dictionary <long, long>();

            using (var fs = File.OpenRead(DatFile))
            {
                using (var br = new BinaryReader(fs))
                {
                    graphViewer = new GraphViewer();
                    graphViewer.LayoutEditingEnabled = false;
                    graphViewer.BindToPanel(gvPanel);

                    /*
                     * graphMapsViewer = new GraphmapsViewer();
                     * graphMapsViewer.LayoutEditingEnabled = false;
                     * graphMapsViewer.BindToPanel(gvPanel);
                     */

                    var          dgraph = new Drawing.Graph();
                    Drawing.Edge edg    = null;

                    while (fs.Position < fs.Length - 128)
                    {
                        var tid      = br.ReadInt32();
                        var flags    = br.ReadInt32();
                        var rip      = br.ReadInt64();
                        var rsp      = br.ReadInt64();
                        var from_rip = br.ReadInt64();

                        if (!uniqD.ContainsKey(from_rip))
                        {
                            uniqD.Add(from_rip, rip);
                            edg = dgraph.AddEdge(from_rip.ToString("X"), rip.ToString("X"), rip.ToString("X"));
                        }
                    }

                    graphViewer.Graph = dgraph;
                    //graphMapsViewer.Graph = dgraph;
                }
            }
        }
Example #29
0
        private void UpdateControlValues()
        {
            fixedAmountButton.Checked = GraphViewer.Graph.SelectedAmountType == AmountType.FixedAmount;
            rateButton.Checked        = GraphViewer.Graph.SelectedAmountType == AmountType.Rate;
            if (GraphViewer.Graph.SelectedUnit == RateUnit.PerSecond)
            {
                rateOptionsDropDown.SelectedIndex = 0;
            }
            else
            {
                rateOptionsDropDown.SelectedIndex = 1;
            }

            AssemblerDisplayCheckBox.Checked = GraphViewer.ShowAssemblers;
            MinerDisplayCheckBox.Checked     = GraphViewer.ShowMiners;

            LoadItemList();
            LoadRecipeList();

            GraphViewer.Invalidate();
        }
Example #30
0
        public static IViewerNode addNodeWithStyles(GraphViewer gv, string id, DPoint pos, ICollection <Style> styles)
        {
            var graph = gv.Graph;
            var node  = graph.AddNode(id);

            if (styles != null)
            {
                foreach (var s in styles)
                {
                    node.Attr.AddStyle(s);
                }
            }

            var lnode     = GeometryGraphCreator.CreateGeometryNode(graph, graph.GeometryGraph, node, ConnectionToGraph.Disconnected);
            var labelSize = Common.MeasureLabel(node.Label);
            var mar       = node.Attr.LabelMargin;

            lnode.BoundaryCurve = NodeBoundaryCurves.GetNodeBoundaryCurve(node, labelSize.Width + mar * 2, labelSize.Height + mar * 2);
            node.GeometryNode   = lnode;
            var vnode = gv.CreateIViewerNode(node, pos, null);

            return(vnode);
        }