void CreateShape(NCallbackMouseEventArgs args) { nDrawingViewDocument.Document.HistoryService.StartTransaction("CreateShape"); try { // create the new shape NNodeList shapes = nDrawingViewLibrary.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.Shape2D); int length = shapes.Count; NShape newShape = null; for (int i = 0; i < length; i++) { NShape s = shapes[i] as NShape; if (s.Tag != null && s.Tag.ToString() == "selected") { newShape = s.CloneWithNewUniqueId(new Hashtable()) as NShape; newShape.Center = new NPointF(args.Point.X, args.Point.Y); nDrawingViewDocument.Document.ActiveLayer.AddChild(newShape); break; } } if (newShape == null) { return; } // select the new shape NNodeList docShapes = nDrawingViewDocument.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.Shape2D); length = docShapes.Count; for (int i = 0; i < length; i++) { NShape s = docShapes[i] as NShape; if (s.UniqueId == newShape.UniqueId) { s.Style.StrokeStyle = new NStrokeStyle(2, documentSelectedShapeBorderColor); } else { s.Style.StrokeStyle = null; } } SelectedShapeId = newShape.UniqueId; } finally { nDrawingViewDocument.Document.HistoryService.Commit(); } }