void SetDragDecorator(IViewerObject obj) { var dNode = obj as DNode; if (dNode != null) { draggedObjectOriginalColors[dNode] = dNode.DrawingNode.Attr.Color; dNode.DrawingNode.Attr.Color = Color.Magenta; gViewer.Invalidate(obj); } }
private void selectedEntityColor_Click(object sender, EventArgs e) { if (entityColorDialog.ShowDialog() == DialogResult.OK) { //FreezeGraphLayout(); System.Drawing.Color c = entityColorDialog.Color; if (this.selectedObject is Node) { //(this.selectedObject as Node).Attr.LineWidth -= 1; (this.selectedObject as Node).Attr.Color = new MSAGLColor(c.A, c.R, c.G, c.B); viewer.Invalidate(); //ResumeGraphLayout(); } else if (this.selectedObject is Edge) { (this.selectedObject as Edge).Attr.Color = new MSAGLColor(c.A, c.R, c.G, c.B); //ResumeGraphLayout(); } else if (this.selectedObject is Microsoft.Msagl.Drawing.Label) { ((this.selectedObject as Microsoft.Msagl.Drawing.Label).Owner as Edge).Attr.Color = new MSAGLColor(c.A, c.R, c.G, c.B); } this.viewer.Invalidate(); //this.reloadGraph_Click(this.reloadGraph, null); } }
private void Form1_KeyDown(object sender, KeyEventArgs e) { Keys key = e.KeyCode; if (key == Keys.T) { if (oe == null) { return; } if (oe.Attr.ArrowheadAtTarget == ArrowStyle.None) { oe.Attr.ArrowheadAtTarget = ArrowStyle.ODiamond; } else { oe.Attr.ArrowheadAtTarget = ArrowStyle.None; } gViewer.Invalidate(); } else if (key == Keys.N) { _useOpMode = UserOprationMode.AddNode; } }
void gViewer_ObjectUnderMouseCursorChanged(object sender, ObjectUnderMouseCursorChangedEventArgs e) { selectedObject = e.OldObject != null ? e.OldObject.DrawingObject : null; if (selectedObject != null) { RestoreSelectedObjAttr(); gViewer.Invalidate(e.OldObject); selectedObject = null; } if (gViewer.SelectedObject == null) { infoLabel.Text = "No object under the mouse"; gViewer.SetToolTip(toolTip, ""); } else { selectedObject = gViewer.SelectedObject; var edge = selectedObject as Edge; if (edge != null) { selectedObjectAttr = edge.Attr.Clone(); edge.Attr.Color = Color.Blue; gViewer.Invalidate(e.NewObject); // here we can use e.Attr.Id or e.UserData to get back to the user data gViewer.SetToolTip(toolTip, String.Format("edge from {0} to {1}", edge.Source, edge.Target)); } else if (selectedObject is Microsoft.Msagl.Drawing.Node) { selectedObjectAttr = (gViewer.SelectedObject as Microsoft.Msagl.Drawing.Node).Attr.Clone(); (selectedObject as Microsoft.Msagl.Drawing.Node).Attr.Color = Color.Green; // // here you can use e.Attr.Id to get back to your data gViewer.SetToolTip(toolTip, String.Format("node {0}", (selectedObject as Microsoft.Msagl.Drawing.Node).Attr.Id)); gViewer.Invalidate(e.NewObject); } infoLabel.Text = selectedObject.ToString(); } }
/// <summary> /// Changes an edge's label and updates the display /// </summary> /// <param name="e">The edge whose label has to be changed</param> /// <param name="newLabel">The new label</param> internal void RelabelEdge(Edge e, string newLabel) { if (e.Label == null) { e.Label = new Label(newLabel); } else { e.Label.Text = newLabel; } gViewer.SetEdgeLabel(e, e.Label); e.Label.GeometryLabel.InnerPoints = new List <Point>(); var ep = new EdgeLabelPlacement(gViewer.Graph.GeometryGraph); ep.Run(); gViewer.Graph.GeometryGraph.UpdateBoundingBox(); gViewer.Invalidate(); }
private void Gviewer_ObjectUnderMouseCursorChanged(object sender, ObjectUnderMouseCursorChangedEventArgs e) { RestorePreviouslyHoverObjectColor(e.OldObject); if (e.OldObject != null) { gviewer.Invalidate(e.OldObject); } if (gviewer.ObjectUnderMouseCursor == null) { gviewer.SetToolTip(viewerToolTip, ""); return; } selectedObjectMouseHover = gviewer.ObjectUnderMouseCursor; DrawingObject currentDrawingObject = selectedObjectMouseHover.DrawingObject; string selectedObjetLabel = null; if (currentDrawingObject is Edge) { var edge = currentDrawingObject as Edge; edge.Attr.Color = Color.Blue; selectedObjetLabel = edge.Attr.Id; // Attr.Id holds the relationship information } else if (currentDrawingObject is Node) { var node = currentDrawingObject as Node; node.Attr.Color = Color.Green; string entityName = node.Attr.Id; selectedObjetLabel = entityRelations.GetEREntitieAttributesByEntityName(entityName)?.FirstOrDefault <EREntityAttribute>()?.Description; } else { return; } gviewer.SetToolTip(viewerToolTip, selectedObjetLabel); if (e.NewObject != null) { gviewer.Invalidate(e.NewObject); } }
void GViewerOnMouseMove(Edge edge, string value) { if (edge.Label == null) { return; } edge.Label.Text = value; var rect = edge.Label.BoundingBox; var font = new Font(edge.Label.FontName, (int)edge.Label.FontSize); StringMeasure.MeasureWithFont(edge.Label.Text, font, out double width, out double height); if (width <= 0) { StringMeasure.MeasureWithFont("a", font, out width, out height); } edge.Label.Width = width; edge.Label.Height = height; rect.Add(edge.Label.BoundingBox); gViewer.Invalidate(gViewer.MapSourceRectangleToScreenRectangle(rect)); }
private void selectNode(Node node) { if (previouslySelectedNode != null || highlightedNodes.Count != 0) { unselectNode(); } if (node != null) { // format new one node.Attr.Color = selectionColor; node.Attr.LineWidth = 5; node.Label.FontColor = Color.White; // plus all parents foreach (var sourceNode in node.InEdges.Select(inEdge => inEdge.SourceNode)) { highlightNode(sourceNode); } previouslySelectedNode = node; _z3AxiomProfiler.SetInfoPanel((Instantiation)node.UserData); } _viewer.Invalidate(); }
private void selectNode(string newSelectedNodeID) { //If there is allready a selected node then "deselect" it if (_selectedNode != null) { _selectedNode.Attr.Color = Color.Black; } _selectedNode = _gViewer.Graph.FindNode(newSelectedNodeID); //save new selected node if (_selectedNode != null) { _selectedNode.Attr.Color = Color.Red; //and "select" it } _gViewer.CenterToPoint(_selectedNode.BoundingBox.Center); _gViewer.Invalidate(); }
void gViewer_ObjectUnderMouseCursorChanged(object sender, ObjectUnderMouseCursorChangedEventArgs e) { if (e.OldObject != null) { selectedObject = e.OldObject.DrawingObject; } else { selectedObject = null; } selectedObject = gViewer.SelectedObject; Edge edge = selectedObject as Edge; if (edge != null) { this.gViewer.SetToolTip(toolTip1, String.Format(edge.LabelText)); } gViewer.Invalidate(); }
/// <summary> /// Create form with given graph /// </summary> public MainForm() { viewer.MouseClick += ViewerMouseClicked; InitializeComponent(); viewer.EdgeAdded += ViewerOnEdgeAdded; viewer.Graph = graph.Graph; viewer.PanButtonPressed = true; viewer.MouseMove += (sender, args) => { viewer.Graph.GeometryGraph.UpdateBoundingBox(); viewer.Invalidate(); }; viewer.ToolBarIsVisible = false; viewer.MouseDown += ViewerOnMouseDown; viewer.MouseWheel += (sender, args) => viewer.ZoomF += args.Delta * SystemInformation.MouseWheelScrollLines / 4000f; SuspendLayout(); viewer.Dock = DockStyle.Fill; mainLayout.Controls.Add(viewer, 0, 0); ResumeLayout(); InitPalette(); }