Beispiel #1
0
            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
                NRadialGraphLayout layout = new NRadialGraphLayout();

                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();
            }
        protected override void LoadExample()
        {
            // init form fields
            m_Layout = new NRadialGraphLayout();
            propertyGrid1.SelectedObject = m_Layout;

            view.BeginInit();
            view.Grid.Visible = false;
            view.GlobalVisibility.ShowPorts      = false;
            view.GlobalVisibility.ShowArrowheads = false;
            view.ViewLayout = ViewLayout.Fit;

            // init document
            document.BeginInit();
            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));

            InitDocument();
            document.EndInit();

            // init form controls
            InitFormControls();

            // end view init
            view.EndInit();
        }
        protected override void InitDiagram()
        {
            base.InitDiagram();

            // Create a group
            NGroup group = new NGroup();

            m_DrawingDocument.Content.ActivePage.Items.Add(group);
            group.PinX = 300;
            group.PinY = 300;

            // Create some shapes and add them to the group
            NBasicShapeFactory factory = new NBasicShapeFactory();

            NShape root = factory.CreateShape(ENBasicShape.Rectangle);

            root.Text = "Root";
            group.Shapes.Add(root);

            NShape shape1 = factory.CreateShape(ENBasicShape.Circle);

            shape1.Text = "Circle 1";
            group.Shapes.Add(shape1);

            NShape shape2 = factory.CreateShape(ENBasicShape.Circle);

            shape2.Text = "Circle 2";
            group.Shapes.Add(shape2);

            NShape shape3 = factory.CreateShape(ENBasicShape.Circle);

            shape3.Text = "Circle 3";
            group.Shapes.Add(shape3);

            // Connect the shapes
            ConnectShapes(root, shape1);
            ConnectShapes(root, shape2);
            ConnectShapes(root, shape3);

            // Update group bounds
            group.UpdateBounds();

            // Create a layout context and configure the area you want the group to be arranged in.
            // The layout area is in page coordinates
            NDrawingLayoutContext layoutContext = new NDrawingLayoutContext(m_DrawingDocument, group);

            layoutContext.LayoutArea = new NRectangle(100, 100, 200, 200);

            // Layout the shapes in the group
            NRadialGraphLayout layout = new NRadialGraphLayout();

            layout.Arrange(group.Shapes.ToArray(), layoutContext);

            // Update the group bounds
            group.UpdateBounds();
        }
Beispiel #4
0
        private void PerformLayout(Hashtable args)
        {
            // create a layout
            NRadialGraphLayout layout = new NRadialGraphLayout();

            // Configure the layout
            NLayoutsHelper.ConfigureLayout(layout, args);

            // 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();
        }
Beispiel #5
0
        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.HighQuality;

            // 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, String.Empty, NSizeL.Empty,
                                                                  document.Style.FillStyle, document.Style.StrokeStyle);
            sheet.Style.EndArrowheadStyle = new NArrowheadStyle(ArrowheadShape.None, String.Empty, NSizeL.Empty,
                                                                document.Style.FillStyle, document.Style.StrokeStyle);
            document.StyleSheets.AddChild(sheet);

            // create a tree
            NGenericTreeTemplate tree = new NGenericTreeTemplate();

            tree.LayoutScheme        = TreeLayoutScheme.None;
            tree.Levels              = 4;
            tree.BranchNodes         = 4;
            tree.HorizontalSpacing   = 10;
            tree.VerticalSpacing     = 10;
            tree.ConnectorType       = ConnectorType.Line;
            tree.VerticesShape       = BasicShapes.Circle;
            tree.VerticesSize        = new NSizeF(40, 40);
            tree.EdgesStyleSheetName = "edges";
            tree.Create(document);

            // Create the layout
            NRadialGraphLayout layout = new NRadialGraphLayout();

            // 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();
        }