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(); }
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 INCustomRequestCallback.OnCustomRequestCallback(NAspNetThinWebControl control, NRequestContext context, string argument) { NThinDiagramControl diagramControl = (NThinDiagramControl)control; NDrawingDocument document = diagramControl.Document; string[] args = argument.Split(','); string cityName = args[0]; float x = Single.Parse(args[1], CultureInfo.InvariantCulture); float y = Single.Parse(args[2], CultureInfo.InvariantCulture); if (document.Tag is NPointElement) { ((NPointElement)document.Tag).StyleSheetName = String.Empty; document.Tag = null; } NLayer cityLayer = diagramControl.Document.Layers.GetChildByName("cities") as NLayer; if (cityLayer != null) { // Apply the new style to the newly zoomed city NMapLabelsShape labelsShape = (NMapLabelsShape)cityLayer.GetChildAt(0); NMapPointLabel city = (NMapPointLabel)labelsShape.MapLabels.GetChildByName(cityName); city.StyleSheetName = "ZoomedCity"; // Remember the currently highlighted city in the document's tag document.Tag = city; } diagramControl.View.Layout = CanvasLayout.Normal; diagramControl.Zoom(2, new NPointF(x, y)); }
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(); }
void INAutoUpdateCallback.OnAutoUpdate(NAspNetThinWebControl control) { NThinDiagramControl diagramControl = (NThinDiagramControl)control; NDrawingDocument document = diagramControl.Document; NEllipseShape rotatingEllipse = document.ActiveLayer.GetChildByName("RotatingEllipse", 0) as NEllipseShape; if (rotatingEllipse == null) { return; } NEllipseShape rotatingEllipse2 = document.ActiveLayer.GetChildByName("RotatingEllipse2", 0) as NEllipseShape; if (rotatingEllipse2 == null) { return; } rotatingEllipse.Rotate(CoordinateSystem.Scene, 7, rotatingEllipse.PinPoint); rotatingEllipse2.Rotate(CoordinateSystem.Scene, -4, rotatingEllipse2.PinPoint); diagramControl.UpdateView(); }
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); DiagramRenderer renderer = new DiagramRenderer(); switch (settings["command"]) { case "RandomTree6Levels": renderer.CreateTree(document, 6, 3); break; case "RandomTree8Levels": renderer.CreateTree(document, 8, 2); break; } // Layout the diagram renderer.ApplyLayout(document, settings); // Resize document to fit all shapes document.SizeToContent(); // Update the view diagramControl.UpdateView(); }
void INCustomRequestCallback.OnCustomRequestCallback(NAspNetThinWebControl control, NRequestContext context, string argument) { NThinDiagramControl diagramControl = (NThinDiagramControl)control; string[] args = argument.Split(','); NDataGrouping dataGrouping = null; switch (args[0]) { case "EqualDistribution": dataGrouping = new NDataGroupingEqualDistribution(); break; case "EqualInterval": dataGrouping = new NDataGroupingEqualInterval(); break; case "Optimal": dataGrouping = new NDataGroupingOptimal(); break; default: throw new Exception("New data grouping type?"); } dataGrouping.RoundedRanges = Boolean.Parse(args[1]); MapRenderer mapRenderer = new MapRenderer(); mapRenderer.InitDocument(diagramControl.Document, dataGrouping); diagramControl.UpdateView(); diagramControl.AddCustomClientCommand("UpdateLegend"); }
void INCustomRequestCallback.OnCustomRequestCallback(NAspNetThinWebControl control, NRequestContext context, string argument) { NThinDiagramControl diagramControl = (NThinDiagramControl)control; InitDocument(diagramControl.Document, Type.GetType(argument)); control.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(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; int index = Int32.Parse(argument); MapRenderer mapRenderer = new MapRenderer(); mapRenderer.InitDocument(document, MapProjections[index]); diagramControl.UpdateView(); }
void INAutoUpdateCallback.OnAutoUpdate(NAspNetThinWebControl control) { NThinDiagramControl diagramControl = (NThinDiagramControl)control; NClickomaniaGame game = (NClickomaniaGame)diagramControl.Document.Tag; game.ClearHighlightedCells(); diagramControl.ServerSettings.EnableAutoUpdate = false; diagramControl.Update(); }
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(); }
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(); } }
void INMouseEventCallback.OnMouseEvent(NAspNetThinWebControl control, NBrowserMouseEventArgs e) { NThinDiagramControl diagramControl = (NThinDiagramControl)control; NNodeList allShapes = diagramControl.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.Shape2D); NNodeList affectedNodes = diagramControl.HitTest(new NPointF(e.X, e.Y)); NNodeList affectedShapes = affectedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D); int length; bool fillChanged = false; length = allShapes.Count; for (int i = 0; i < length; i++) { NShape shape = allShapes[i] as NShape; shape.Style.ShadowStyle = null; if (shape.Tag != null) { NColorFillStyle newFill = new NColorFillStyle((Color)shape.Tag); fillChanged = fillChanged || !shape.Style.FillStyle.Equals(newFill); shape.Style.FillStyle = newFill; } } 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; NColorFillStyle newFill = new NColorFillStyle(Color.YellowGreen); fillChanged = fillChanged || !shape.Style.FillStyle.Equals(newFill); shape.Style.FillStyle = newFill; } } if (fillChanged) { diagramControl.UpdateView(); } else { diagramControl.ClearResponse(); } }
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(NFilters.Shape2D); NDrawingDocument document = diagramControl.Document; if (String.IsNullOrEmpty(m_MapRenderer.CurrentState)) { if (shapes.Count == 0) { return; } // The user has clicked a state NShape shape = (NShape)shapes[0]; m_MapRenderer.LoadStateMap(document, shape.Name); } else { if (shapes.Count == 0) { // Return to the States map m_MapRenderer.LoadUsaMap(document); } else { // The user has clicked a county NShape shape = (NShape)shapes[0]; if (shape.StyleSheetName == "ClickedCounty") { // The user has clicked a selected county - unselect it shape.StyleSheetName = String.Empty; shape.Text = String.Empty; } else { // The user has clicked a non selected county - select it (make it red) shape.StyleSheetName = "ClickedCounty"; shape.Text = shape.Name; } } } diagramControl.UpdateView(); }
public NDrawingDocument Deserialize(NThinDiagramControl control) { if (m_Document == null) { // Create the default data grouping NDataGrouping dataGrouping = new NDataGroupingOptimal(); dataGrouping.RoundedRanges = true; // Init the document m_Document = new NDrawingDocument(); m_Document.BeginInit(); MapRenderer mapRenderer = new MapRenderer(); mapRenderer.InitDocument(m_Document, dataGrouping); m_Document.EndInit(); } return(m_Document); }
void NThinDiagramControl1_Postback(object sender, ThinWeb.NPostbackEventArgs e) { NThinDiagramControl diagramControl = (NThinDiagramControl)sender; NNodeList allShapes = diagramControl.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.Shape2D); NNodeList hitNodes = diagramControl.HitTest(e.MousePosition.ToNPointF()); hitNodes = hitNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D); foreach (NShape shape in allShapes) { if (NSystem.SafeEquals(shape.Tag, true)) { shape.Style.FillStyle = new NColorFillStyle(Color.LightBlue); } } foreach (NShape shape in hitNodes) { if (NSystem.SafeEquals(shape.Tag, true)) { shape.Style.FillStyle = new NColorFillStyle(Color.Red); } } }
public void Serialize(NThinDiagramControl control, NDrawingDocument document) { }