private NGroup CreateStartElement(string text) { NGroup group = new NGroup(); document.ActiveLayer.AddChild(group); // Create the ellipse shape NShape ellipseShape = new NEllipseShape(0, 0, 1, 1); group.Shapes.AddChild(ellipseShape); ellipseShape.Text = text; ellipseShape.SizeToText(new NMarginsF(100, 18, 10, 18)); ellipseShape.Location = new NPointF(0, 0); // Create the check shape NBrainstormingShapesFactory brainstormingFactory = new NBrainstormingShapesFactory(document); NShape checkShape = brainstormingFactory.CreateShape(BrainstormingShapes.Check); checkShape.Bounds = new NRectangleF(26, 12, 24, 23); group.Shapes.AddChild(checkShape); // Create the ports CreatePorts(group, ellipseShape); // Set the protections SetProtections(group); group.UpdateModelBounds(); return(group); }
private void InitDocument() { document.Style.TextStyle.FontStyle.InitFromFont(new Font("Arial Narrow", 8)); NBrainstormingShapesFactory factory = new NBrainstormingShapesFactory(document); factory.DefaultSize = new NSizeF(80, 60); int count = factory.ShapesCount; for (int i = 0; i < count; i++) { // create a brainstorming shape NShape shape = factory.CreateShape(i); shape.Style.InteractivityStyle = new NInteractivityStyle(shape.Name); // add it to the active layer document.ActiveLayer.AddChild(shape); } // 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); // create a layout context NLayoutContext layoutContext = new NLayoutContext(); layoutContext.GraphAdapter = new NShapeGraphAdapter(); layoutContext.BodyAdapter = new NShapeBodyAdapter(document); layoutContext.BodyContainerAdapter = new NDrawingBodyContainerAdapter(document); // layout the shapes layout.Layout(shapes, layoutContext); // resize document to fit all shapes document.SizeToContent(); }
void InitToolbar() { if (nDrawingViewToolbar.RequiresInitialization) { ActiveCommand = toolbarButtons[0].CommandName; // begin view init nDrawingViewToolbar.ViewLayout = CanvasLayout.Normal; nDrawingViewToolbar.DocumentPadding = new Nevron.Diagram.NMargins(0); // init document nDrawingViewToolbar.Document.BeginInit(); nDrawingViewToolbar.Document.AutoBoundsPadding = new Nevron.Diagram.NMargins(4); nDrawingViewToolbar.Document.GraphicsSettings.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; nDrawingViewToolbar.Document.GraphicsSettings.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; nDrawingViewToolbar.Document.GraphicsSettings.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; // set up visual formatting nDrawingViewToolbar.Document.Style.FillStyle = new NColorFillStyle(Color.White); nDrawingViewToolbar.Document.Style.TextStyle.FontStyle.InitFromFont(new Font("Arial Narrow", 8)); nDrawingViewToolbar.Document.BackgroundStyle.FrameStyle.Visible = false; // set up the shape factories NBasicShapesFactory buttonFactory = new NBasicShapesFactory(nDrawingViewToolbar.Document); buttonFactory.DefaultSize = new NSizeF(24, 24); NBrainstormingShapesFactory iconFactory = new NBrainstormingShapesFactory(nDrawingViewToolbar.Document); iconFactory.DefaultSize = new NSizeF(16, 16); // create a batch layout, which will align shapes NBatchLayout batchLayout = new NBatchLayout(nDrawingViewToolbar.Document); // create buttons int count = toolbarButtons.Length; for (int i = 0; i < count; i++) { ToolbarButton btn = toolbarButtons[i]; bool isActive = (this.ActiveCommand == btn.CommandName); NShape buttonShape = buttonFactory.CreateShape(BasicShapes.RoundedRectangle); // create the button shape group NGroup g = new NGroup(); NBatchGroup bgroup = new NBatchGroup(nDrawingViewToolbar.Document); NNodeList shapes = new NNodeList(); if (btn.IsSeparator) { buttonShape.Width /= 2; buttonShape.Style.StrokeStyle = new NStrokeStyle(Color.White); shapes.Add(buttonShape); } else if (!btn.IsColorSelector) { shapes.Add(buttonShape); } else { buttonShape.Style.FillStyle = new NColorFillStyle(btn.Color); shapes.Add(buttonShape); } NRectanglePath imagePath = new NRectanglePath(0f, 0f, btn.IconSize.Width, btn.IconSize.Height); NImageFillStyle fs1 = new NImageFillStyle(this.MapPathSecure(@"..\..\..\Images\FlowChartBuilder\" + btn.IconFile)); NStyle.SetFillStyle(imagePath, fs1); NStyle.SetStrokeStyle(imagePath, new NStrokeStyle(0, Color.White)); NCompositeShape imageShape = new NCompositeShape(); imageShape.Primitives.AddChild(imagePath); imageShape.UpdateModelBounds(); shapes.Add(imageShape); NShape coverShape = buttonFactory.CreateShape(BasicShapes.RoundedRectangle); coverShape.Width = buttonShape.Width; coverShape.Name = "coverShape"; shapes.Add(coverShape); if (!isActive && !btn.IsClientSide && !btn.IsSeparator) { if (btn.IsColorSelector) { coverShape.Style.FillStyle = new NColorFillStyle(Color.FromArgb(180, Color.White)); } else { coverShape.Style.FillStyle = new NColorFillStyle(Color.FromArgb(160, Color.White)); } coverShape.Style.StrokeStyle = new NStrokeStyle(Color.FromArgb(160, Color.White)); } else { coverShape.Style.FillStyle = new NColorFillStyle(Color.FromArgb(0, Color.White)); coverShape.Style.StrokeStyle = new NStrokeStyle(Color.FromArgb(0, Color.White)); if (!btn.IsSeparator) { coverShape.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.FromArgb(70, Color.Black), new NPointL(1, 0)); } } // perform layout batchLayout.Build(shapes); batchLayout.AlignVertically(buttonShape, VertAlign.Center, false); batchLayout.AlignHorizontally(buttonShape, HorzAlign.Center, false); // group shapes bgroup.Build(shapes); bgroup.Group(null, false, out g); // enable interactivity if (!btn.IsSeparator) { g.Style.InteractivityStyle = new NInteractivityStyle(true, btn.CommandName, btn.Title, CursorType.Hand); } // set the command of the button g.Tag = btn.CommandName; nDrawingViewToolbar.Document.ActiveLayer.AddChild(g); } // 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 = toolbarButtons.Length; layout.HorizontalSpacing = 7; // create a layout context NLayoutContext layoutContext = new NLayoutContext(); layoutContext.GraphAdapter = new NShapeGraphAdapter(); layoutContext.BodyAdapter = new NShapeBodyAdapter(nDrawingViewToolbar.Document); layoutContext.BodyContainerAdapter = new NDrawingBodyContainerAdapter(nDrawingViewToolbar.Document); // layout the shapes layout.Layout(nDrawingViewToolbar.Document.ActiveLayer.Children(null), layoutContext); nDrawingViewToolbar.Document.EndInit(); } }
protected void InitDocument() { NDrawingDocument document = NDrawingView1.Document; document.GraphicsSettings.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; document.GraphicsSettings.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; document.GraphicsSettings.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; document.Style.FillStyle = new NColorFillStyle(Color.Linen); document.Style.TextStyle.FontStyle.InitFromFont(new Font("Arial Narrow", 8)); document.BackgroundStyle.FrameStyle.Visible = false; NBrainstormingShapesFactory factory = new NBrainstormingShapesFactory(document); int maxOrdinal = 0; switch (shapeSizeDropDownList.SelectedValue) { case "Small": factory.DefaultSize = new NSizeF(40, 30); maxOrdinal = 7; break; case "Medium": factory.DefaultSize = new NSizeF(80, 60); maxOrdinal = 4; break; case "Large": factory.DefaultSize = new NSizeF(200, 150); maxOrdinal = 1; break; default: throw new NotImplementedException(shapeSizeDropDownList.SelectedValue); } int count = factory.ShapesCount; for (int i = 0; i < count; i++) { // create a basic shape NShape shape = factory.CreateShape(i); shape.Style.InteractivityStyle = new NInteractivityStyle(shape.Name); // add it to the active layer document.ActiveLayer.AddChild(shape); } // 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 = maxOrdinal; layout.VerticalSpacing = 20; layout.HorizontalSpacing = 20; layout.HorizontalContentPlacement = ContentPlacement.Center; layout.VerticalContentPlacement = ContentPlacement.Center; // create a layout context NLayoutContext layoutContext = new NLayoutContext(); layoutContext.GraphAdapter = new NShapeGraphAdapter(); layoutContext.BodyAdapter = new NShapeBodyAdapter(document); layoutContext.BodyContainerAdapter = new NDrawingBodyContainerAdapter(document); // layout the shapes layout.Layout(document.ActiveLayer.Children(null), layoutContext); // resize document to fit all shapes document.SizeToContent(); }