private object GetObjectAt(int x, int y) { object result = null; try { result = _viewer.GetObjectAt(x, y); } catch (NullReferenceException) { } return(result); }
void gviewer_mouseup(object sender, MsaglMouseEventArgs e) { if (_useOpMode == UserOprationMode.Select) { var obj = gViewer.GetObjectAt(new Point(e.X, e.Y)); if (obj == null) { return; } var node = obj as DNode; if (node != null) { Text = node.DrawingNode.Id; } else { var edge = obj as DEdge; Text = edge.Edge.Source; } } else if (_useOpMode == UserOprationMode.AddNode) { var pos = gViewer.ScreenToSource(e); //var node = new Node("smt"); var gv = gViewer; gv.AddNode(gv.CreateIViewerNode(new Node("ssss"), pos, null), true); var ggg = gv.Graph; if (ggg.NodeCount > 100) { ; } ////(gv as IViewer).a .add(), pos, null); ////node.LabelText = "smt show"; //var graph = gViewer.Graph; ////graph.AddNode(node); //graph.AddEdge("11", "222"); ////DrawingUtilsForSamples.AddNode("smt", graph.GeometryGraph, 10, 2); //gViewer.Graph = graph; //var gv = gViewer; ////IViewerNode n=gViewer.CreateIViewerNode(new Node("smart")); ////gViewer.CreateIViewerNode(new Node("marks"), pos, null); ////gViewer.AddNode(n, true); } //var viewer = gViewer as IViewer; //viewer. }
void Form1_MouseUp(object sender, MsaglMouseEventArgs e) { object obj = gViewer.GetObjectAt(e.X, e.Y); DrawingNode node = null; Edge edge = null; var dnode = obj as DNode; var dedge = obj as DEdge; var dl = obj as DLabel; if (dnode != null) { node = dnode.DrawingNode; } else if (dedge != null) { edge = dedge.DrawingEdge; } else if (dl != null) { if (dl.Parent is DNode) { node = (dl.Parent as DNode).DrawingNode; } else if (dl.Parent is DEdge) { edge = (dl.Parent as DEdge).DrawingEdge; } } if (node != null) { ShowEditorDelegate(node); } else if (edge != null) { ShowEditorDelegate(edge); } else { CloseEditorDelegate(); } }