protected void OnMouseEvent(string webControlId, System.Web.HttpContext context, NStateObject state, NCallbackMouseEventArgs args) { NDiagramSessionStateObject diagramState = state as NDiagramSessionStateObject; NNodeList allShapes = diagramState.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.Shape2D); NNodeList affectedNodes = diagramState.HitTest(args); NNodeList affectedShapes = affectedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D); int length; length = allShapes.Count; for (int i = 0; i < length; i++) { NShape shape = allShapes[i] as NShape; shape.Style.ShadowStyle = null; if (shape.Tag != null) { shape.Style.FillStyle = new NColorFillStyle((Color)shape.Tag); } } length = affectedShapes.Count; for (int i = 0; i < length; i++) { NShape shape = affectedShapes[i] as NShape; shape.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.FromArgb(96, Color.Black), new NPointL(3, 3), 1, new NLength(10)); NColorFillStyle fs = shape.Style.FillStyle as NColorFillStyle; if (fs != null && fs.Color != Color.White) { shape.Tag = fs.Color; shape.Style.FillStyle = new NColorFillStyle(Color.YellowGreen); } } }
void INMouseEventCallback.OnMouseEvent(NAspNetThinWebControl control, NBrowserMouseEventArgs e) { NThinDiagramControl diagramControl = (NThinDiagramControl)control; NNodeList nodes = diagramControl.HitTest(new NPointF(e.X, e.Y)); NNodeList shapes = nodes.Filter(TableShapeFilter); if (shapes.Count == 0) { diagramControl.Document.Tag = null; return; } NNodeList decorators = nodes.Filter(DecoratorFilter); if (decorators.Count > 0) { // Toggle the clicked show/hide subtree decorator and update the view ((NShowHideSubtreeDecorator)decorators[0]).ToggleState(); diagramControl.UpdateView(); } // Send a custom command NTableShape table = (NTableShape)shapes[0]; NEmployee employee = (NEmployee)table.Tag; diagramControl.AddCustomClientCommand(employee.GetData()); }
void INCustomRequestCallback.OnCustomRequestCallback(NAspNetThinWebControl control, NRequestContext context, string argument) { NThinDiagramControl diagramControl = (NThinDiagramControl)control; NDrawingDocument document = diagramControl.Document; NDrawingDocumentHelper helper = new NDrawingDocumentHelper(document); Dictionary <string, string> settings = helper.ParseSettings(argument); // Create and configure the layout NSingleCycleLayout layout = new NSingleCycleLayout(); helper.ConfigureLayout(layout, settings); // Get the shapes to layout NNodeList shapes = document.ActiveLayer.Children(NFilters.Shape2D); // Layout the shapes layout.Layout(shapes, new NDrawingLayoutContext(document)); // Resize document to fit all shapes document.SizeToContent(); // Update the view diagramControl.UpdateView(); }
void INMouseEventCallback.OnMouseEvent(NAspNetThinWebControl control, NBrowserMouseEventArgs e) { NThinDiagramControl diagramControl = (NThinDiagramControl)control; NNodeList nodes = diagramControl.HitTest(new NPointF(e.X, e.Y)); NNodeList shapes = nodes.Filter(CellFilter); if (shapes.Count == 0) { return; } NClickomaniaGame game = (NClickomaniaGame)diagramControl.Document.Tag; NTableCell cell = (NTableCell)shapes[0]; if (cell.ParentNode.ParentNode != game.BoardShape) { return; } if (String.IsNullOrEmpty(cell.StyleSheetName)) { return; } if (game.OnCellClicked(cell) == false) { return; } // The user has clicked on a cell that is part of a region diagramControl.ServerSettings.EnableAutoUpdate = true; diagramControl.Update(); }
protected void UpdateStyles(NStateObject state, NRectangleShape hoverCell) { bool isCompleted = TestComplete(state); NDiagramSessionStateObject diagramState = state as NDiagramSessionStateObject; NNodeList allCells = GetAllCells(state); for (int i = 0; i < allCells.Count; i++) { NRectangleShape cell = allCells[i] as NRectangleShape; if (isCompleted) { cell.Style.FillStyle = completeCellFillStyle; } else { if (hoverCell == null || hoverCell.UniqueId != cell.UniqueId) { cell.Style.FillStyle = emptyCellFillStyle; } else if (TestCanSwap(GetClickedCellCoords(state, cell), GetEmptyCellCoords(state))) { cell.Style.FillStyle = hoverAllowedCellFillStyle; } else { cell.Style.FillStyle = hoverDeniedCellFillStyle; } } } diagramState.Document.RefreshAllViews(); }
protected void InitDocument(NDrawingDocument document) { // Remove the standard frame document.BackgroundStyle.FrameStyle.Visible = false; // Adjust the graphics quality document.GraphicsSettings.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; // Set up visual formatting document.Style.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant3, Color.FromArgb(251, 203, 156), Color.FromArgb(247, 150, 56)); document.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(68, 90, 108)); NStyleSheet sheet = new NStyleSheet("edges"); sheet.Style.StartArrowheadStyle = new NArrowheadStyle(ArrowheadShape.None, "", NSizeL.Empty, document.Style.FillStyle, document.Style.StrokeStyle); sheet.Style.EndArrowheadStyle = new NArrowheadStyle(ArrowheadShape.None, "", NSizeL.Empty, document.Style.FillStyle, document.Style.StrokeStyle); document.StyleSheets.AddChild(sheet); // Create a tree CreateTree(); // Create the layout NBalloonTreeLayout layout = new NBalloonTreeLayout(); // Get the shapes to layout NNodeList shapes = document.ActiveLayer.Children(NFilters.Shape2D); // Layout the shapes layout.Layout(shapes, new NDrawingLayoutContext(document)); // Resize document to fit all shapes document.SizeToContent(); }
void INCustomRequestCallback.OnCustomRequestCallback(NAspNetThinWebControl control, NRequestContext context, string argument) { NThinDiagramControl diagramControl = (NThinDiagramControl)control; NDrawingDocument document = diagramControl.Document; NDrawingDocumentHelper helper = new NDrawingDocumentHelper(document); Dictionary <string, string> settings = helper.ParseSettings(argument); // Create and configure the layout NSpringLayout layout = new NSpringLayout(); layout.BounceBackForce.Padding = 100f; layout.GravityForce.AttractionCoefficient = 0.2f; layout.BounceBackForce.Enabled = Boolean.Parse(settings["BounceBackForce"]); layout.GravityForce.Enabled = Boolean.Parse(settings["GravityForce"]); layout.ElectricalForce.NominalDistance = Single.Parse(settings["NominalDistance"]); layout.SpringForce.LogBase = helper.ParseFloat(settings["LogBase"]); layout.SpringForce.SpringForceLaw = (SpringForceLaw)Enum.Parse(typeof(SpringForceLaw), settings["SpringForceLaw"]); // Get the shapes to layout NNodeList shapes = document.ActiveLayer.Children(NFilters.Shape2D); // Layout the shapes layout.Layout(shapes, new NDrawingLayoutContext(document)); // Resize document to fit all shapes document.SizeToContent(); // Update the view diagramControl.UpdateView(); }
private string LayoutShapes() { string result = String.Empty; try { this.Cursor = Cursors.WaitCursor; document.BeginInit(); NNodeList nodes = document.ActiveLayer.Children(NFilters.Shape2D); NLayoutContext layoutContext = new NDrawingLayoutContext(document); NLayout layout = (NLayout)cbLayout.SelectedItem; layout.Layout(nodes, layoutContext); document.SizeToContent(); document.EndInit(); result = layout.PerformanceInfo; } finally { this.Cursor = Cursors.Default; } return(result); }
protected void NDrawingView1_AsyncClick(object sender, EventArgs e) { NCallbackMouseEventArgs args = e as NCallbackMouseEventArgs; NNodeList nodes = NDrawingView1.HitTest(args); NNodeList shapes = nodes.Filter(TABLE_SHAPE_FILTER); if (shapes.Count == 0) { NDrawingView1.Document.Tag = null; return; } NNodeList decorators = nodes.Filter(DECORATOR_FILTER); if (decorators.Count > 0) { ((NShowHideSubtreeDecorator)decorators[0]).ToggleState(); } NTableShape table = (NTableShape)shapes[0]; NEmployee employee = (NEmployee)table.Tag; NDrawingView1.Document.Tag = employee; NDrawingView1.Document.SmartRefreshAllViews(); }
void CreateLabeledPolyOutline(NPointF[] points, NPolygonShape polyShape, NNodeList labels, string title) { NNodeList nodes = new NNodeList(); nodes.Add(polyShape); if (labels != null) { nodes.AddRange(labels); } int length = points.Length - 1; int vIndex = 0, hIndex = 0, index = 0; for (int i = 0; i < length; i++) { nodes.Add(ConnectPointsLabeled(points[i], points[i + 1], ref hIndex, ref vIndex, ref index)); } nodes.Add(ConnectPointsLabeled(points[points.Length - 1], points[0], ref hIndex, ref vIndex, ref index)); NGroup g; NBatchGroup batchGroup = new NBatchGroup(document); batchGroup.Build(nodes); batchGroup.Group(document.ActiveLayer, true, out g); g.Name = title + " Group"; }
private void UpdatePortGeneralPropertiesControls(NPort port) { // can only disconnect the port if it is connected to any plugs disconnectPortButton.Enabled = (port.Plugs.Count != 0); // update port offset NSizeF offset = port.Offset; portOffsetXNumeric.Value = (decimal)offset.Width; portOffsetYNumeric.Value = (decimal)offset.Height; // populate the combo with available anchors INDiagramElementContainer searchRoot = port.GetRootForReferenceProperty("AnchorUniqueId"); NFilter filter = port.GetFilterForReferenceProperty("AnchorUniqueId"); NNodeList anchors = searchRoot.Descendants(null, -1); anchors.Insert(0, searchRoot); anchors = anchors.Filter(filter); anchorIdComboBox.Items.Clear(); anchorIdComboBox.Items.AddRange((object[])(anchors.ToArray(typeof(object)))); // select the currently chosen anchor for (int i = 0; i < anchorIdComboBox.Items.Count; i++) { Guid elemendGuid = (anchorIdComboBox.Items[i].Tag as INDiagramElement).UniqueId; if (elemendGuid.Equals(port.AnchorUniqueId)) { anchorIdComboBox.SelectedIndex = i; break; } } }
protected void NDrawingView1_AsyncClick(object sender, EventArgs e) { NCallbackMouseEventArgs args = e as NCallbackMouseEventArgs; NNodeList nodes = NDrawingView1.HitTest(args); NNodeList shapes = nodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D); NExpandCollapseCheck check = null; int length = shapes.Count; for (int i = 0; i < length; i++) { if (shapes[i] is NExpandCollapseCheck) { check = shapes[i] as NExpandCollapseCheck; break; } } if (check == null) { return; } NExpandableShape shape = check.ParentNode.ParentNode as NExpandableShape; shape.Expand(!shape.Expanded); }
private void InitDocument(NDrawingDocument document) { // Remove the standard frame document.BackgroundStyle.FrameStyle.Visible = false; // Adjust the graphics quality document.GraphicsSettings.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed; // Set up visual formatting document.Style.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant3, Color.FromArgb(192, 194, 194), Color.FromArgb(129, 133, 133)); document.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(68, 90, 108)); document.Style.StartArrowheadStyle = new NArrowheadStyle(ArrowheadShape.None, "", NSizeL.Empty, document.Style.FillStyle, document.Style.StrokeStyle); document.Style.EndArrowheadStyle = new NArrowheadStyle(ArrowheadShape.None, "", NSizeL.Empty, document.Style.FillStyle, document.Style.StrokeStyle); // Create a graph CreateGraph(document); // Create the layout NLayeredGraphLayout layout = new NLayeredGraphLayout(); // Get the shapes to layout NNodeList shapes = document.ActiveLayer.Children(NFilters.Shape2D); // Layout the shapes layout.Layout(shapes, new NDrawingLayoutContext(document)); // Resize document to fit all shapes document.SizeToContent(); }
public void ApplyLayout(NDrawingDocument document, Dictionary <string, string> settings) { // Create the layout NBarycenterLayout layout = new NBarycenterLayout(); // Configure the optional forces layout.BounceBackForce.RepulsionCoefficient = 20f; layout.GravityForce.AttractionCoefficient = 0.2f; // Free vertices are placed in the fixed vertices barycenter layout.FreeVertexPlacement.Mode = FreeVertexPlacementMode.FixedBarycenter; // Fixed vertices are placed on the rim of the specified ellipse layout.FixedVertexPlacement.Mode = FixedVertexPlacementMode.PredefinedEllipseRim; layout.FixedVertexPlacement.PredefinedEllipseBounds = new NRectangleF(0, 0, 700, 700); // Configure the layout if (settings != null) { layout.BounceBackForce.Enabled = Boolean.Parse(settings["BounceBackForce"]); layout.GravityForce.Enabled = Boolean.Parse(settings["GravityForce"]); layout.MinFixedVerticesCount = Int32.Parse(settings["MinFixedVerticesCount"]); } // Get the shapes to layout NNodeList shapes = document.ActiveLayer.Children(NFilters.Shape2D); // Layout the shapes layout.Layout(shapes, new NDrawingLayoutContext(document)); }
protected void OnMouseEvent(object sender, EventArgs e) { NCallbackMouseEventArgs args = e as NCallbackMouseEventArgs; NNodeList allShapes = NDrawingView1.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.Shape2D); NNodeList affectedNodes = NDrawingView1.HitTest(args); NNodeList affectedShapes = affectedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D); int length; length = allShapes.Count; for (int i = 0; i < length; i++) { NShape shape = allShapes[i] as NShape; shape.Style.ShadowStyle = null; if (shape.Tag != null) { shape.Style.FillStyle = new NColorFillStyle((Color)shape.Tag); } } length = affectedShapes.Count; for (int i = 0; i < length; i++) { NShape shape = affectedShapes[i] as NShape; shape.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.FromArgb(96, Color.Black), new NPointL(3, 3), 1, new NLength(10)); NColorFillStyle fs = shape.Style.FillStyle as NColorFillStyle; if (fs != null && fs.Color != Color.White) { shape.Tag = fs.Color; shape.Style.FillStyle = new NColorFillStyle(Color.YellowGreen); } } }
private void PerformLayout(Hashtable args) { // create a layout NSpringLayout layout = new NSpringLayout(); // configure the optional forces layout.BounceBackForce.Padding = 100f; layout.GravityForce.AttractionCoefficient = 0.2f; // configure the layout if (args != null) { layout.BounceBackForce.Enabled = Boolean.Parse(args["BounceBackForce"].ToString()); layout.GravityForce.Enabled = Boolean.Parse(args["GravityForce"].ToString()); layout.ElectricalForce.NominalDistance = Single.Parse(args["NominalDistance"].ToString()); layout.SpringForce.LogBase = NLayoutsHelper.ParseFloat(args["LogBase"]); layout.SpringForce.SpringForceLaw = (SpringForceLaw)Enum.Parse(typeof(SpringForceLaw), args["SpringForceLaw"].ToString()); } // get the shapes to layout NNodeList shapes = NDrawingView1.Document.ActiveLayer.Children(NFilters.Shape2D); // layout the shapes layout.Layout(shapes, new NDrawingLayoutContext(NDrawingView1.Document)); // resize document to fit all shapes NDrawingView1.Document.SizeToContent(); }
public void ApplyLayout(NDrawingDocument document, Dictionary <string, string> settings) { // create a layout NSymmetricalLayout layout = new NSymmetricalLayout(); // configure the optional forces layout.BounceBackForce.Padding = 100f; layout.GravityForce.AttractionCoefficient = 0.2f; layout.MagneticFieldForce.DistancePower = 0.6f; layout.MagneticFieldForce.FieldDirection = MagneticFieldDirection.OrthogonalLeftwardDownward; layout.MagneticFieldForce.MagnetizationType = MagnetizationType.Unidirectional; layout.MagneticFieldForce.TorsionCoefficient = 2f; // configure layout if (settings != null) { layout.BounceBackForce.Enabled = Boolean.Parse(settings["BounceBackForce"]); layout.GravityForce.Enabled = Boolean.Parse(settings["GravityForce"]); layout.MagneticFieldForce.Enabled = Boolean.Parse(settings["MagneticFieldForce"]); } // get the shapes to layout NNodeList shapes = document.ActiveLayer.Children(NFilters.Shape2D); // layout the shapes layout.Layout(shapes, new NDrawingLayoutContext(document)); }
private void groupButton_Click(object sender, System.EventArgs e) { // get the selected nodes NNodeList selectedNodes = view.Selection.Nodes; // determine whether they can be grouped NBatchGroup batchGroup = new NBatchGroup(document, selectedNodes); if (batchGroup.CanGroup(document.ActiveLayer, false) == false) { return; } // group them NGroup group; NTransactionResult res = batchGroup.Group(document.ActiveLayer, false, out group); // single select the new group if the group was successful if (res.Succeeded) { view.Selection.SingleSelect(group); } // ask the view to display any information about the transaction status (if it was not completed) view.ProcessTransactionResult(res); }
protected void ChangeCurrentShapeShadow(string webControlId, System.Web.HttpContext context, NStateObject state, EventArgs args) { NDiagramSessionStateObject diagramState = state as NDiagramSessionStateObject; NNodeList allShapes = diagramState.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.Shape2D); NNodeList affectedNodes = diagramState.HitTest(args as NCallbackMouseEventArgs); NNodeList affectedShapes = affectedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D); int length; NShape shape; length = allShapes.Count; for (int i = 0; i < length; i++) { shape = allShapes[i] as NShape; shape.Style.ShadowStyle = null; } if (affectedShapes.Count == 0) { return; } shape = affectedShapes[affectedShapes.Count - 1] as NShape; if (shape.Style.StrokeStyle == null) { shape.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.FromArgb(96, Color.Black), new NPointL(3, 3), 1, new NLength(10)); } }
public override void OnAsyncClick(string webControlId, System.Web.HttpContext context, NStateObject state, NCallbackMouseEventArgs args) { NDiagramSessionStateObject diagramState = state as NDiagramSessionStateObject; NNodeList clickedNodes = diagramState.HitTest(args); NNodeList clickedShapes = clickedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D); NNodeList shapes = diagramState.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.Shape2D); int length = shapes.Count; for (int i = 0; i < length; i++) { NShape s = shapes[i] as NShape; s.Style.FillStyle = null; s.Style.StrokeStyle = null; s.Style.ShadowStyle = null; s.Tag = null; } if (clickedShapes.Count == 0) { return; } NShape clickedShape = clickedShapes[0] as NShape; clickedShape.Style.FillStyle = new NColorFillStyle(libraryHighlightFillColor); clickedShape.Style.StrokeStyle = new NStrokeStyle(libraryHighlightBorderColor); clickedShape.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.FromArgb(90, Color.Black), new NPointL(2, 1)); clickedShape.Tag = "selected"; }
void Delete(NCallbackMouseEventArgs args) { nDrawingViewDocument.Document.HistoryService.StartTransaction("Delete"); try { NNodeList clickedNodes = nDrawingViewDocument.HitTest(args); NNodeList clickedShapes = clickedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D); if (clickedShapes.Count != 0) { NShape clickedShape = clickedShapes[clickedShapes.Count - 1] as NShape; nDrawingViewDocument.Document.ActiveLayer.RemoveChild(clickedShape); } else { NNodeList clickedConnectors = clickedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape1D); if (clickedConnectors.Count != 0) { NShape clickedConnector = clickedConnectors[clickedConnectors.Count - 1] as NShape; nDrawingViewDocument.Document.ActiveLayer.RemoveChild(clickedConnector); } } } finally { nDrawingViewDocument.Document.HistoryService.Commit(); } }
private void PerformLayout(Hashtable args) { // create a layout NBarycenterLayout layout = new NBarycenterLayout(); // configure the optional forces layout.BounceBackForce.RepulsionCoefficient = 20f; layout.GravityForce.AttractionCoefficient = 0.2f; // free vertices are placed in the fixed vertices barycenter layout.FreeVertexPlacement.Mode = FreeVertexPlacementMode.FixedBarycenter; // fixed vertices are placed on the rim of the specified ellipse layout.FixedVertexPlacement.Mode = FixedVertexPlacementMode.PredefinedEllipseRim; layout.FixedVertexPlacement.PredefinedEllipseBounds = new NRectangleF(0, 0, 700, 700); // configure the layout if (args != null) { layout.BounceBackForce.Enabled = Boolean.Parse(args["BounceBackForce"].ToString()); layout.GravityForce.Enabled = Boolean.Parse(args["GravityForce"].ToString()); layout.MinFixedVerticesCount = Int32.Parse(args["MinFixedVerticesCount"].ToString()); } // get the shapes to layout NNodeList shapes = NDrawingView1.Document.ActiveLayer.Children(NFilters.Shape2D); // layout the shapes layout.Layout(shapes, new NDrawingLayoutContext(NDrawingView1.Document)); // resize document to fit all shapes NDrawingView1.Document.SizeToContent(); }
private void LayoutButton_Click(object sender, EventArgs e) { // get the shapes to layout NNodeList shapes = document.ActiveLayer.Children(NFilters.Shape2D); // create a layout context NLayoutContext layoutContext = new NLayoutContext(); layoutContext.GraphAdapter = new NShapeGraphAdapter(); layoutContext.BodyAdapter = new NShapeBodyAdapter(document); NDrawingBodyContainerAdapter adapter = new NDrawingBodyContainerAdapter(document); adapter.SetLayoutArea(new NRectangleF(0, 0, 800, 800)); layoutContext.BodyContainerAdapter = adapter; // layout the shapes if (m_Layout != null) { m_Layout.Layout(shapes, layoutContext); } // resize document to fit all shapes document.SizeToContent(); }
protected void NDrawingView1_AsyncCustomCommand(object sender, EventArgs e) { NCallbackCustomCommandArgs args = e as NCallbackCustomCommandArgs; NCallbackCommand command = args.Command; string value = command.Arguments["value"].ToString(); NNodeList decorators = NDrawingView1.Document.ActiveLayer.Descendants(DecoratorFilter, -1); int i, count = decorators.Count; switch (command.Name) { case "background": ToggleDecoratorBackgroundShape background = (ToggleDecoratorBackgroundShape)Enum.Parse(typeof(ToggleDecoratorBackgroundShape), value); for (i = 0; i < count; i++) { ((NToggleDecorator)decorators[i]).Background.Shape = background; } m_bClientSideRedrawRequired = true; break; case "symbol": ToggleDecoratorSymbolShape symbol = (ToggleDecoratorSymbolShape)Enum.Parse(typeof(ToggleDecoratorSymbolShape), value); for (i = 0; i < count; i++) { ((NToggleDecorator)decorators[i]).Symbol.Shape = symbol; } m_bClientSideRedrawRequired = true; break; case "position": NContentAlignment alignment; NSizeF offset; if (value == "Left") { alignment = new NContentAlignment(ContentAlignment.TopLeft); offset = new NSizeF(11, 11); } else { alignment = new NContentAlignment(ContentAlignment.TopRight); offset = new NSizeF(-11, 11); } for (i = 0; i < count; i++) { NToggleDecorator decorator = (NToggleDecorator)decorators[i]; decorator.Alignment = alignment; decorator.Offset = offset; } m_bClientSideRedrawRequired = true; break; } }
void INCustomRequestCallback.OnCustomRequestCallback(NAspNetThinWebControl control, NRequestContext context, string argument) { NThinDiagramControl diagramControl = (NThinDiagramControl)control; NNodeList decorators = diagramControl.Document.ActiveLayer.Descendants(ShowHideSubtreeDecoratorFilter, -1); int i, count = decorators.Count; string[] data = argument.Split('='); string name = data[0]; string value = data[1]; switch (name) { case "background": ToggleDecoratorBackgroundShape background = (ToggleDecoratorBackgroundShape)Enum.Parse(typeof(ToggleDecoratorBackgroundShape), value); for (i = 0; i < count; i++) { ((NToggleDecorator)decorators[i]).Background.Shape = background; } break; case "symbol": ToggleDecoratorSymbolShape symbol = (ToggleDecoratorSymbolShape)Enum.Parse(typeof(ToggleDecoratorSymbolShape), value); for (i = 0; i < count; i++) { ((NToggleDecorator)decorators[i]).Symbol.Shape = symbol; } break; case "position": NContentAlignment alignment; NSizeF offset; if (value == "Left") { alignment = new NContentAlignment(ContentAlignment.TopLeft); offset = new NSizeF(11, 11); } else { alignment = new NContentAlignment(ContentAlignment.TopRight); offset = new NSizeF(-11, 11); } for (i = 0; i < count; i++) { NToggleDecorator decorator = (NToggleDecorator)decorators[i]; decorator.Alignment = alignment; decorator.Offset = offset; } break; } control.UpdateView(); }
private void CreateScene(NDrawingDocument document) { document.BackgroundStyle.FrameStyle.Visible = false; document.Style.TextStyle.FontStyle.InitFromFont(new Font("Arial Narrow", 8)); NNetworkShapesFactory factory = new NNetworkShapesFactory(document); factory.DefaultSize = new NSizeF(240, 180); NShape server = factory.CreateShape(NetworkShapes.Server); NShape computer = factory.CreateShape(NetworkShapes.Computer); NShape laptop = factory.CreateShape(NetworkShapes.Laptop); document.ActiveLayer.AddChild(server); document.ActiveLayer.AddChild(computer); document.ActiveLayer.AddChild(laptop); NRoutableConnector link1 = new NRoutableConnector(); document.ActiveLayer.AddChild(link1); link1.FromShape = server; link1.ToShape = computer; NRoutableConnector link2 = new NRoutableConnector(); document.ActiveLayer.AddChild(link2); link2.FromShape = server; link2.ToShape = laptop; // layout the shapes in the active layer using a table layout NLayeredGraphLayout layout = new NLayeredGraphLayout(); // get the shapes to layout NNodeList shapes = document.ActiveLayer.Children(NFilters.Shape2D); // layout the shapes layout.Layout(shapes, new NDrawingLayoutContext(document)); // resize document to fit all shapes document.SizeToContent(); // add the data shape const float shapeSize = 10; NEllipseShape data = new NEllipseShape(link2.EndPoint.X - shapeSize / 2, link2.EndPoint.Y - shapeSize, shapeSize, shapeSize); document.ActiveLayer.AddChild(data); NStyle.SetStrokeStyle(data, new NStrokeStyle(0, KnownArgbColorValue.Transparent)); NStyle.SetFillStyle(data, new NColorFillStyle(KnownArgbColorValue.Red)); // set the animations style SetAnimationsStyle(data, link1, link2); // resize document to fit all shapes document.SizeToContent(); }
private void InitDocument() { document.Style.TextStyle.FontStyle.InitFromFont(new Font("Arial Narrow", 8)); NBasicShapesFactory factory = new NBasicShapesFactory(document); factory.DefaultSize = new NSizeF(80, 60); int count = factory.ShapesCount; NShape shape = null; for (int i = 0; i < count; i++) { // create a basic shape shape = factory.CreateShape(i); shape.Text = shape.Name; // add it to the active layer document.ActiveLayer.AddChild(shape); } // Add some content to the table shape NTableShape table = (NTableShape)shape; table.InitTable(2, 2); table.BeginUpdate(); table.CellMargins = new Nevron.Diagram.NMargins(8); table[0, 0].Text = "Cell 1"; table[1, 0].Text = "Cell 2"; table[0, 1].Text = "Cell 3"; table[1, 1].Text = "Cell 4"; table.PortDistributionMode = TablePortDistributionMode.CellBased; table.EndUpdate(); // layout the shapes in the active layer using a table layout NTableLayout layout = new NTableLayout(); // setup the table layout layout.Direction = LayoutDirection.LeftToRight; layout.ConstrainMode = CellConstrainMode.Ordinal; layout.MaxOrdinal = 5; layout.HorizontalContentPlacement = ContentPlacement.Center; layout.VerticalContentPlacement = ContentPlacement.Center; layout.VerticalSpacing = 20; layout.HorizontalSpacing = 20; // get the shapes to layout NNodeList shapes = document.ActiveLayer.Children(NFilters.Shape2D); // layout the shapes layout.Layout(shapes, new NDrawingLayoutContext(document)); // resize document to fit all shapes document.SizeToContent(); }
private NNodeList GetShapesList(NGraphVertexList vertices, NObjectGraphPartMap map) { NNodeList list = new NNodeList(); int i, vertexCount = vertices.Count; for (i = 0; i < vertexCount; i++) { list.Add((NShape)map.GetObjectFromPart(vertices[i])); } return(list); }
private NNodeList GetShapesList(NGraphEdgeList edges, NObjectGraphPartMap map) { NNodeList list = new NNodeList(); int i, edgeCount = edges.Count; for (i = 0; i < edgeCount; i++) { list.Add((NShape)map.GetObjectFromPart(edges[i])); } return(list); }
void INMouseEventCallback.OnMouseEvent(NAspNetThinWebControl control, NBrowserMouseEventArgs e) { NThinDiagramControl diagramControl = (NThinDiagramControl)control; NNodeList nodes = diagramControl.HitTest(new NPointF(e.X, e.Y)); NNodeList decorators = nodes.Filter(ExpandCollapseDecoratorFilter); if (decorators.Count > 0) { ((NExpandCollapseDecorator)decorators[0]).ToggleState(); diagramControl.UpdateView(); } }