Пример #1
0
        private NCompositeShape CreateVerticalPipe()
        {
            NDynamicPort    port;
            NCompositeShape shape = new NCompositeShape();
            NRectanglePath  rect  = new NRectanglePath(SIZE, 0, SIZE, 3 * SIZE);

            NStyle.SetStrokeStyle(rect, new NStrokeStyle(0, Color.White));

            shape.Primitives.AddChild(rect);
            shape.Primitives.AddChild(new NLinePath(SIZE, 0, SIZE, 3 * SIZE));
            shape.Primitives.AddChild(new NLinePath(2 * SIZE, 0, 2 * SIZE, 3 * SIZE));
            shape.UpdateModelBounds();

            if (shape.Ports == null)
            {
                shape.CreateShapeElements(ShapeElementsMask.Ports);
            }

            port      = new NDynamicPort(shape.UniqueId, TOP, DynamicPortGlueMode.GlueToContour);
            port.Type = PortType.InwardAndOutward;
            shape.Ports.AddChild(port);

            port      = new NDynamicPort(shape.UniqueId, BOTTOM, DynamicPortGlueMode.GlueToContour);
            port.Type = PortType.InwardAndOutward;
            shape.Ports.AddChild(port);

            SetProtections(shape);
            return(shape);
        }
Пример #2
0
        protected NCompositeShape CreateState(XmlElement state)
        {
            string pathPoints = state.Attributes["PathPoints"].Value.ToString();
            string pathTypes  = state.Attributes["PathTypes"].Value.ToString();

            string[]  pathPointsStr = pathPoints.Split(' ');
            NPointF[] pathPointsF   = new NPointF[pathPointsStr.Length];

            float scaleX = NDrawingView1.Dimensions.Width;
            float scaleY = NDrawingView1.Dimensions.Height;

            for (int i = 0; i < pathPointsStr.Length; i++)
            {
                string[] xyStr = pathPointsStr[i].Split(',');

                pathPointsF[i].X = (Single.Parse(xyStr[0])) * scaleX;
                pathPointsF[i].Y = (Single.Parse(xyStr[1])) * scaleY;
            }

            string[] pathTypesStr = pathTypes.Split(' ');
            byte[]   pathTypesB   = new byte[pathTypesStr.Length];

            for (int i = 0; i < pathTypesStr.Length; i++)
            {
                pathTypesB[i] = Byte.Parse(pathTypesStr[i]);
            }

            NCustomPath     path  = new NCustomPath(pathPointsF, pathTypesB, PathType.ClosedFigure);
            NCompositeShape shape = new NCompositeShape();

            shape.Primitives.AddChild(path);
            shape.UpdateModelBounds();

            return(shape);
        }
Пример #3
0
        private void CreateCustomOpenFigureShape()
        {
            // create the coffee cup shape
            GraphicsPath graphicsPath = new GraphicsPath();

            AddStrokeCup(graphicsPath);
            AddStrokeCupHandle(graphicsPath);
            AddStrokeSteam(graphicsPath);

            NCompositeShape shape = new NCompositeShape();

            shape.Primitives.AddChild(new NCustomPath(graphicsPath, PathType.OpenFigure));
            shape.UpdateModelBounds();

            shape.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(0, 0, 0xaa));
            document.ActiveLayer.AddChild(shape);

            // describe the shape
            NTextShape text = new NTextShape("Custom Shape 2", 195, 340, 120, 50);

            text.Style.FillStyle           = new NColorFillStyle(Color.Black);
            text.Style.TextStyle           = new NTextStyle();
            text.Style.TextStyle.FontStyle = new NFontStyle(new Font("Arial", 9));
            document.ActiveLayer.AddChild(text);
        }
Пример #4
0
        private void addShapeButton_Click(object sender, System.EventArgs e)
        {
            // create a coffee cup with random location and scale
            NCompositeShape coffeeCup = CreateCoffeeCupShape(base.GetRandomPoint(view.Viewport), (float)Random.NextDouble() + 0.1f);

            // add to active layer and smart refresh all views
            document.ActiveLayer.AddChild(coffeeCup);
            document.SmartRefreshAllViews();
        }
Пример #5
0
        private void CreateArchitecturalDocument()
        {
            // set global document styles
            document.Style.TextStyle = new NTextStyle(new Font("Arial", 8.25f));
            document.Style.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Center;
            document.Style.TextStyle.StringFormatStyle.VertAlign = VertAlign.Center;

            // create the rim rect
            NRectangleShape rimRect = new NRectangleShape(new NRectangleF(0, 0, 5, 7));

            rimRect.Style.FillStyle = new NColorFillStyle(Color.FromArgb(0, Color.White));
            document.ActiveLayer.AddChild(rimRect);

            // create the room rects
            NRectangleShape roomRect1 = new NRectangleShape(new NRectangleF(0, 0, 2, 3));

            roomRect1.Text = "Room 1";
            document.ActiveLayer.AddChild(roomRect1);

            NRectangleShape roomRect2 = new NRectangleShape(new NRectangleF(3, 0, 2, 3));

            roomRect2.Text = "Room 2";
            document.ActiveLayer.AddChild(roomRect2);

            NRectangleShape roomRect3 = new NRectangleShape(new NRectangleF(0, 4, 2, 3));

            roomRect3.Text = "Room 3";
            document.ActiveLayer.AddChild(roomRect3);

            // create the stairs case
            NCompositeShape stairCase = new NCompositeShape();

            float stepXSize = 0.7f;
            float stepYSize = 0.25f;

            for (int i = 0; i < 9; i++)
            {
                NRectanglePath step = new NRectanglePath(0, stepYSize * i, stepXSize, stepYSize);
                stairCase.Primitives.AddChild(step);
            }

            stairCase.UpdateModelBounds();
            stairCase.Bounds = new NRectangleF(4, 4, 1, 3);

            stairCase.Text = "Stairs";
            NTextStyle textStyle = (document.Style.TextStyle.Clone() as NTextStyle);

            textStyle.Orientation     = 90;
            stairCase.Style.TextStyle = textStyle;

            document.ActiveLayer.AddChild(stairCase);

            // update the drawing bounds to size to content with some margins
            document.AutoBoundsMinSize = new NSizeF(1, 1);
            document.AutoBoundsPadding = new Nevron.Diagram.NMargins(0.5f);
            document.AutoBoundsMode    = AutoBoundsMode.AutoSizeToContent;
        }
Пример #6
0
        private NCompositeShape CreateCrossPipe()
        {
            NDynamicPort    port;
            NCompositeShape shape   = new NCompositeShape();
            NPolygonPath    polygon = new NPolygonPath(new NPointF[] {
                new NPointF(0, SIZE),
                new NPointF(SIZE, SIZE),
                new NPointF(SIZE, 0),
                new NPointF(2 * SIZE, 0),
                new NPointF(2 * SIZE, SIZE),
                new NPointF(3 * SIZE, SIZE),
                new NPointF(3 * SIZE, 2 * SIZE),
                new NPointF(2 * SIZE, 2 * SIZE),
                new NPointF(2 * SIZE, 3 * SIZE),
                new NPointF(SIZE, 3 * SIZE),
                new NPointF(SIZE, 2 * SIZE),
                new NPointF(0, 2 * SIZE)
            });

            NStyle.SetStrokeStyle(polygon, new NStrokeStyle(0, Color.White));
            shape.Primitives.AddChild(polygon);
            shape.Primitives.AddChild(new NLinePath(0, SIZE, SIZE, SIZE));
            shape.Primitives.AddChild(new NLinePath(SIZE, SIZE, SIZE, 0));
            shape.Primitives.AddChild(new NLinePath(2 * SIZE, 0, 2 * SIZE, SIZE));
            shape.Primitives.AddChild(new NLinePath(2 * SIZE, SIZE, 3 * SIZE, SIZE));
            shape.Primitives.AddChild(new NLinePath(3 * SIZE, 2 * SIZE, 2 * SIZE, 2 * SIZE));
            shape.Primitives.AddChild(new NLinePath(2 * SIZE, 2 * SIZE, 2 * SIZE, 3 * SIZE));
            shape.Primitives.AddChild(new NLinePath(SIZE, 3 * SIZE, SIZE, 2 * SIZE));
            shape.Primitives.AddChild(new NLinePath(SIZE, 2 * SIZE, 0, 2 * SIZE));
            shape.UpdateModelBounds();

            if (shape.Ports == null)
            {
                shape.CreateShapeElements(ShapeElementsMask.Ports);
            }

            port      = new NDynamicPort(shape.UniqueId, LEFT, DynamicPortGlueMode.GlueToContour);
            port.Type = PortType.InwardAndOutward;
            shape.Ports.AddChild(port);

            port      = new NDynamicPort(shape.UniqueId, TOP, DynamicPortGlueMode.GlueToContour);
            port.Type = PortType.InwardAndOutward;
            shape.Ports.AddChild(port);

            port      = new NDynamicPort(shape.UniqueId, RIGHT, DynamicPortGlueMode.GlueToContour);
            port.Type = PortType.InwardAndOutward;
            shape.Ports.AddChild(port);

            port      = new NDynamicPort(shape.UniqueId, BOTTOM, DynamicPortGlueMode.GlueToContour);
            port.Type = PortType.InwardAndOutward;
            shape.Ports.AddChild(port);

            SetProtections(shape);
            return(shape);
        }
        private void CreateCompositeShape(int row, int col, AbilitiesMask protection)
        {
            // create a composite shape
            NCompositeShape shape = new NCompositeShape();

            shape.Protection = new NAbilities(protection);
            shape.Text       = "Protected from: " + protection.ToString();

            shape.Primitives.AddChild(new NRectanglePath(new NRectangleF(0, 0, 1, 1)));
            shape.Primitives.AddChild(new NRectanglePath(new NRectangleF(2, 2, 1, 1)));

            shape.UpdateModelBounds();
            shape.Bounds = base.GetGridCell(row, col);

            document.ActiveLayer.AddChild(shape);
        }
Пример #8
0
        protected NCompositeShape CreateLegendItem(NRectangleF bounds, string str, NFillStyle fillStyle)
        {
            NCompositeShape item = new NCompositeShape();

            NRectanglePath rect = new NRectanglePath(0, 0, 2, 2);

            NStyle.SetFillStyle(rect, (fillStyle.Clone() as NFillStyle));
            item.Primitives.AddChild(rect);

            NTextPrimitive text = new NTextPrimitive(str, new NRectangleF(2, 0, 4, 2));

            item.Primitives.AddChild(text);

            item.UpdateModelBounds();
            item.Bounds = bounds;
            return(item);
        }
Пример #9
0
        private void InitDocument()
        {
            document.Style.ShadowStyle = new NShadowStyle(
                ShadowType.GaussianBlur,
                Color.BurlyWood,
                new NPointL(4, 4), 1,
                new NLength(2));

            document.ShadowsZOrder = ShadowsZOrder.BehindLayer;

            NCompositeShape coffeeCup1 = CreateCoffeeCupShape(new NPointF(10, 10), 0.5f);
            NCompositeShape coffeeCup2 = CreateCoffeeCupShape(new NPointF(200, 10), 0.75f);
            NCompositeShape coffeeCup3 = CreateCoffeeCupShape(new NPointF(400, 10), 1f);

            document.ActiveLayer.AddChild(coffeeCup1);
            document.ActiveLayer.AddChild(coffeeCup2);
            document.ActiveLayer.AddChild(coffeeCup3);

            ConnectCoffeeCups(coffeeCup1.Ports.GetChildAt(1) as NPort, coffeeCup2.Ports.GetChildAt(0) as NPort);
            ConnectCoffeeCups(coffeeCup2.Ports.GetChildAt(1) as NPort, coffeeCup3.Ports.GetChildAt(0) as NPort);
        }
Пример #10
0
        private void CreateMechanicalEngineeringDocument()
        {
            // create the key shape
            NCompositeShape key = new NCompositeShape();

            NRectanglePath keyRect = new NRectanglePath(new NRectangleF(12.5f, 30, 5f, 50));

            key.Primitives.AddChild(keyRect);

            NEllipsePath keyCircle = new NEllipsePath(new NRectangleF(0, 0, 30, 30));

            key.Primitives.AddChild(keyCircle);

            NEllipsePath keyHole = new NEllipsePath(new NRectangleF(13f, 2f, 4f, 4f));

            NStyle.SetFillStyle(keyHole, new NColorFillStyle(Color.White));
            NStyle.SetStrokeStyle(keyHole, new NStrokeStyle(0, Color.Black));
            key.Primitives.AddChild(keyHole);

            key.UpdateModelBounds();
            key.Style.FillStyle   = new NColorFillStyle(Color.DarkGray);
            key.Style.StrokeStyle = new NStrokeStyle(0, Color.Black);

            document.ActiveLayer.AddChild(key);

            // create the octagram
            NBasicShapesFactory factory = new NBasicShapesFactory(document);
            NShape octagram             = factory.CreateShape((int)BasicShapes.Octagram);

            octagram.Bounds            = new NRectangleF(40, 0, 40, 40);
            octagram.Style.FillStyle   = new NColorFillStyle(Color.DarkGray);
            octagram.Style.StrokeStyle = new NStrokeStyle(0, Color.Black);

            document.ActiveLayer.AddChild(octagram);

            // update the drawing bounds to size to content with some margins
            document.AutoBoundsMinSize = new NSizeF(1, 1);
            document.AutoBoundsPadding = new Nevron.Diagram.NMargins(5f);
            document.AutoBoundsMode    = AutoBoundsMode.AutoSizeToContent;
        }
Пример #11
0
        private void InitDocument()
        {
            document.Style.StartArrowheadStyle.Shape = ArrowheadShape.None;
            document.Style.EndArrowheadStyle.Shape   = ArrowheadShape.None;

            int row         = 0;
            int col         = 0;
            int maxColCount = 5;
            int index       = 0;

            foreach (NPointShape pointShape in document.PointShapeStencil.PredefinedPointShapes)
            {
                // create the path representing the arrow head shape
                NCustomPath path = new NCustomPath((GraphicsPath)pointShape.Path.Clone(), pointShape.Closed? PathType.ClosedFigure: PathType.OpenFigure);

                // create a shape to host the path
                NCompositeShape shape = new NCompositeShape();
                shape.Primitives.AddChild(path);
                shape.UpdateModelBounds();

                // reposition the shape and add to active layer
                shape.Bounds = base.GetGridCell(row, col);
                document.ActiveLayer.AddChild(shape);

                // describe it
                string     str  = NExamplesHelper.InsertSpacesBeforeUppers(((PointShape)(index + 2)).ToString());
                NTextShape text = new NTextShape(str, base.GetGridCell(row + 1, col));
                document.ActiveLayer.AddChild(text);

                col++;
                index++;

                if (col > maxColCount)
                {
                    row += 2;
                    col  = 0;
                }
            }
        }
Пример #12
0
        private void CreateLegend()
        {
            NGroup          legend = new NGroup();
            NCompositeShape item   = null;

            NRectangleShape ledendBackground = new NRectangleShape(0, 0, 1, 5);

            ledendBackground.Style.FillStyle = new NColorFillStyle(Color.White);
            legend.Shapes.AddChild(ledendBackground);

            item = CreateLegendItem(new NRectangleF(0.1f, 0.1f, 0.8f, 0.8f), "Metals", fsMetals);
            legend.Shapes.AddChild(item);

            item = CreateLegendItem(new NRectangleF(0.1f, 1.1f, 0.8f, 0.8f), "Metalloids", fsMatalloids);
            legend.Shapes.AddChild(item);

            item = CreateLegendItem(new NRectangleF(0.1f, 2.1f, 0.8f, 0.8f), "Non-metals", fsNonMetals);
            legend.Shapes.AddChild(item);

            item = CreateLegendItem(new NRectangleF(0.1f, 3.1f, 0.8f, 0.8f), "Transition Metals", feTransitionMetals);
            legend.Shapes.AddChild(item);

            item = CreateLegendItem(new NRectangleF(0.1f, 4.1f, 0.8f, 0.8f), "Gases", fsGases);
            legend.Shapes.AddChild(item);

            legend.UpdateModelBounds();

            NRectangleF bounds = this.GetElementBounds(13, 7);

            bounds.Y      = bounds.Y + bounds.Height * 0.1f;
            bounds.Width  = bounds.Width * 5;
            bounds.Height = bounds.Height * 1.8f;
            legend.Bounds = bounds;

            document.ActiveLayer.AddChild(legend);
        }
Пример #13
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // start document initialization
            Document = NDrawingView1.Document;
            Document.BeginInit();

            Document.Width  = NDrawingView1.Dimensions.Width;
            Document.Height = NDrawingView1.Dimensions.Height;

            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(this.MapPathSecure(this.TemplateSourceDirectory + "\\MapOfUSA.xml"));

            XmlElement map = (XmlElement)xmlDocument.ChildNodes[0];

            Color[] stateColorTable = new Color[6];

            stateColorTable[0] = Color.LightPink;
            stateColorTable[1] = Color.Bisque;
            stateColorTable[2] = Color.Moccasin;
            stateColorTable[3] = Color.MistyRose;
            stateColorTable[4] = Color.PowderBlue;
            stateColorTable[5] = Color.Ivory;

            int   stateCounter       = 0;
            Color stateHighlighColor = Color.Orange;

            foreach (XmlElement state in map.ChildNodes)
            {
                string stateId = state.Attributes["Id"].Value.ToString();

                NCompositeShape stateShape = CreateState(state);
                // add to active layer
                Document.ActiveLayer.AddChild(stateShape);

//				NRotatedBoundsLabel label = new NRotatedBoundsLabel("Click to go to :" + stateId + " webpage", stateShape.UniqueId, new Nevron.Diagram.NMargins());
//				stateShape.Labels.AddChild(label);

                // set fill and stroke styles
                Color stateColor = stateColorTable[stateCounter % 6];

                stateShape.Style.FillStyle   = new NColorFillStyle(stateColor);
                stateShape.Style.StrokeStyle = new NStrokeStyle(1, Color.Black);

                NInteractivityStyle interactivityStyle = new NInteractivityStyle();
                stateShape.Style.InteractivityStyle = interactivityStyle;

                string elementId   = new NElementIdentifier(((INElement)stateShape.Primitives.GetChildAt(0)).Id).ToString();
                string stateScript = "onmouseover = 'HighlightState(\"" + elementId + "\", \"" + ColorToSVG(stateHighlighColor) + "\")' onmouseout = 'HighlightState(\"" + elementId + "\", \"" + ColorToSVG(stateColor) + "\")'";
                interactivityStyle.CustomMapAreaAttribute.JScriptAttribute = stateScript;
                interactivityStyle.UrlLink.Url             = "http://worldatlas.com/webimage/countrys/namerica/usstates/" + stateId.ToString() + ".htm";
                interactivityStyle.UrlLink.OpenInNewWindow = true;

                NElementIdentifier identifier = new NElementIdentifier(stateShape.Id);
                stateCounter++;
            }

            Document.BackgroundStyle.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.LightSeaGreen, Color.LightBlue);

            // change the response type to SVG
            NImageResponse response = new NImageResponse();

            NSvgImageFormat svgImageFormat = new NSvgImageFormat();

            svgImageFormat.EnableInteractivity = true;
            svgImageFormat.CustomScript        = GetScript();

            Hashtable attributes = new Hashtable();

            attributes["onload"]      = "Initialize(evt)";
            svgImageFormat.Attributes = attributes;
            response.ImageFormat      = svgImageFormat;

            NDrawingView1.ServerSettings.BrowserResponseSettings.DefaultResponse = response;
        }
Пример #14
0
        private NCompositeShape CreateEndPipe(string type)
        {
            NDynamicPort      port;
            NCompositeShape   shape = new NCompositeShape();
            NPolygonPath      polygon;
            NContentAlignment ca;

            switch (type)
            {
            case "W":
                polygon = new NPolygonPath(new NPointF[] {
                    new NPointF(3 * SIZE, SIZE),
                    new NPointF(2 * SIZE, 1.5f * SIZE),
                    new NPointF(3 * SIZE, 2 * SIZE)
                });

                ca = RIGHT;
                break;

            case "N":
                polygon = new NPolygonPath(new NPointF[] {
                    new NPointF(SIZE, 3 * SIZE),
                    new NPointF(1.5f * SIZE, 2 * SIZE),
                    new NPointF(2 * SIZE, 3 * SIZE)
                });

                ca = BOTTOM;
                break;

            case "E":
                polygon = new NPolygonPath(new NPointF[] {
                    new NPointF(0, SIZE),
                    new NPointF(SIZE, 1.5f * SIZE),
                    new NPointF(0, 2 * SIZE)
                });

                ca = LEFT;
                break;

            case "S":
                polygon = new NPolygonPath(new NPointF[] {
                    new NPointF(SIZE, 0),
                    new NPointF(1.5f * SIZE, SIZE),
                    new NPointF(2 * SIZE, 0)
                });

                ca = TOP;
                break;

            default:
                throw new ArgumentException("Unsupported elbow pipe type");
            }

            NStyle.SetStrokeStyle(polygon, new NStrokeStyle(0, Color.White));
            shape.Primitives.AddChild(polygon);
            shape.Primitives.AddChild(new NLinePath(polygon.Points[0], polygon.Points[1]));
            shape.Primitives.AddChild(new NLinePath(polygon.Points[1], polygon.Points[2]));
            shape.UpdateModelBounds(new NRectangleF(0, 0, 3 * SIZE, 3 * SIZE));

            if (shape.Ports == null)
            {
                shape.CreateShapeElements(ShapeElementsMask.Ports);
            }

            port      = new NDynamicPort(shape.UniqueId, ca, DynamicPortGlueMode.GlueToContour);
            port.Type = PortType.InwardAndOutward;
            shape.Ports.AddChild(port);

            SetProtections(shape);
            return(shape);
        }
Пример #15
0
        private NLibraryView CreateLibrary()
        {
            NLibraryView libView = new NLibraryView();

            libView.ScrollBars     = ScrollBars.Vertical;
            libView.Selection.Mode = DiagramSelectionMode.Single;

            NLibraryDocument libDoc = new NLibraryDocument();

            libView.Document                 = libDoc;
            libDoc.BackgroundStyle           = new NBackgroundStyle();
            libDoc.BackgroundStyle.FillStyle = new NGradientFillStyle(Nevron.GraphicsCore.GradientStyle.Vertical, GradientVariant.Variant1,
                                                                      Color.RoyalBlue, Color.LightSkyBlue);

            // Horizontal Pipe
            NCompositeShape shape  = CreateHorizontalPipe();
            NMaster         master = new NMaster(shape, NGraphicsUnit.Pixel, "Horizontal Pipe", "Drag me on the drawing");

            libDoc.AddChild(master);

            // Vertical Pipe
            shape  = CreateVerticalPipe();
            master = new NMaster(shape, NGraphicsUnit.Pixel, "Vertical Pipe", "Drag me on the drawing");
            libDoc.AddChild(master);

            // Cross Pipe
            shape  = CreateCrossPipe();
            master = new NMaster(shape, NGraphicsUnit.Pixel, "Cross Pipe", "Drag me on the drawing");
            libDoc.AddChild(master);

            // North-West Pipe
            shape  = CreateElbowPipe("NW");
            master = new NMaster(shape, NGraphicsUnit.Pixel, "North-West Pipe", "Drag me on the drawing");
            libDoc.AddChild(master);

            // North-East Pipe
            shape  = CreateElbowPipe("NE");
            master = new NMaster(shape, NGraphicsUnit.Pixel, "North-East Pipe", "Drag me on the drawing");
            libDoc.AddChild(master);

            // South-West Pipe
            shape  = CreateElbowPipe("SW");
            master = new NMaster(shape, NGraphicsUnit.Pixel, "South-West Pipe", "Drag me on the drawing");
            libDoc.AddChild(master);

            // South-East Pipe
            shape  = CreateElbowPipe("SE");
            master = new NMaster(shape, NGraphicsUnit.Pixel, "South-East Pipe", "Drag me on the drawing");
            libDoc.AddChild(master);

            // North-East-West Pipe
            shape  = CreateTPipe("NEW");
            master = new NMaster(shape, NGraphicsUnit.Pixel, "North-East-West Pipe", "Drag me on the drawing");
            libDoc.AddChild(master);

            // North-East-South Pipe
            shape  = CreateTPipe("NES");
            master = new NMaster(shape, NGraphicsUnit.Pixel, "North-East-South Pipe", "Drag me on the drawing");
            libDoc.AddChild(master);

            // North-West-South Pipe
            shape  = CreateTPipe("NWS");
            master = new NMaster(shape, NGraphicsUnit.Pixel, "North-West-South Pipe", "Drag me on the drawing");
            libDoc.AddChild(master);

            // South-East-West Pipe
            shape  = CreateTPipe("SEW");
            master = new NMaster(shape, NGraphicsUnit.Pixel, "South-East-West Pipe", "Drag me on the drawing");
            libDoc.AddChild(master);

            // West-End Pipe
            shape  = CreateEndPipe("W");
            master = new NMaster(shape, NGraphicsUnit.Pixel, "West-End Pipe", "Drag me on the drawing");
            libDoc.AddChild(master);

            // North-End Pipe
            shape  = CreateEndPipe("N");
            master = new NMaster(shape, NGraphicsUnit.Pixel, "North-End Pipe", "Drag me on the drawing");
            libDoc.AddChild(master);

            // East-End Pipe
            shape  = CreateEndPipe("E");
            master = new NMaster(shape, NGraphicsUnit.Pixel, "East-End Pipe", "Drag me on the drawing");
            libDoc.AddChild(master);

            // South-End Pipe
            shape  = CreateEndPipe("S");
            master = new NMaster(shape, NGraphicsUnit.Pixel, "South-End Pipe", "Drag me on the drawing");
            libDoc.AddChild(master);

            return(libView);
        }
        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();
            }
        }
Пример #17
0
        protected NCompositeShape CreateCoffeeCupShape(NPointF location, float scale)
        {
            NCompositeShape shape = new NCompositeShape();

            // create the cup as a polygon path
            NPolygonPath cup = new NPolygonPath(new NPointF[] { new NPointF(45, 268),
                                                                new NPointF(63, 331),
                                                                new NPointF(121, 331),
                                                                new NPointF(140, 268) });

            shape.Primitives.AddChild(cup);

            // create the cup hangle as a closed curve path
            NClosedCurvePath handle = new NClosedCurvePath(new NPointF[] { new NPointF(175, 295),
                                                                           new NPointF(171, 278),
                                                                           new NPointF(140, 283),
                                                                           new NPointF(170, 290),
                                                                           new NPointF(128, 323) }, 1);

            NStyle.SetFillStyle(handle, new NColorFillStyle(Color.LightSalmon));
            shape.Primitives.AddChild(handle);

            // create the steam as a custom filled path
            GraphicsPath path = new GraphicsPath();

            path.AddBeziers(new PointF[] { new PointF(92, 258),
                                           new PointF(53, 163),
                                           new PointF(145, 160),
                                           new PointF(86, 50),
                                           new PointF(138, 194),
                                           new PointF(45, 145),
                                           new PointF(92, 258) });
            path.CloseAllFigures();

            NCustomPath steam = new NCustomPath(path, PathType.ClosedFigure);

            NStyle.SetFillStyle(steam, new NColorFillStyle(Color.FromArgb(50, 122, 122, 122)));
            shape.Primitives.AddChild(steam);

            // update the shape model bounds to fit the primitives it contains
            shape.UpdateModelBounds();

            // create the shape ports
            shape.CreateShapeElements(ShapeElementsMask.Ports);

            // create dynamic port anchored to the cup center
            NDynamicPort dynamicPort = new NDynamicPort(cup.UniqueId, ContentAlignment.MiddleCenter, DynamicPortGlueMode.GlueToContour);

            shape.Ports.AddChild(dynamicPort);

            // create rotated bounds port anchored to the middle right side of the handle
            NRotatedBoundsPort rotatedBoundsPort = new NRotatedBoundsPort(handle.UniqueId, ContentAlignment.MiddleRight);

            shape.Ports.AddChild(rotatedBoundsPort);

            // apply style to the shape
            shape.Style.FillStyle = new NColorFillStyle(Color.LightCoral);

            // position it and scale the shape
            shape.Location = location;
            shape.Width    = shape.Width * scale;
            shape.Height   = shape.Height * scale;

            return(shape);
        }
        protected void CreateScene()
        {
            // configure title
            NTextShape title = new NTextShape("The Business Company", 0, 0, Document.Width, 60);

            Document.ActiveLayer.AddChild(title);

            NTextStyle textStyle = title.ComposeTextStyle().Clone() as NTextStyle;

            textStyle.FontStyle.InitFromFont(new Font("Arial Black", 22, FontStyle.Bold | FontStyle.Italic));

            // set gradient fill style
            textStyle.FillStyle = new NGradientFillStyle(
                GradientStyle.Horizontal,
                GradientVariant.Variant1,
                Color.FromArgb(241, 100, 34),
                Color.FromArgb(255, 247, 151));

            // add shadow
            textStyle.ShadowStyle = new NShadowStyle(
                ShadowType.GaussianBlur,
                Color.FromArgb(50, 122, 122, 122),
                new Nevron.GraphicsCore.NPointL(5, 5),
                1,
                new NLength(3));

            title.Style.TextStyle = textStyle;

            NPersonalInfo[] personalInfos = NPersonalInfo.CreateCompanyInfo();


            // create an Org chart shape for each person in the Org chart
            NCompositeShape presidentShape = CreateOrgChartShape(personalInfos[0]);

            NCompositeShape vpMarketingShape  = CreateOrgChartShape(personalInfos[1]);
            NCompositeShape vpSalesShape      = CreateOrgChartShape(personalInfos[2]);
            NCompositeShape vpProductionShape = CreateOrgChartShape(personalInfos[3]);

            NCompositeShape mm01Shape = CreateOrgChartShape(personalInfos[4]);
            NCompositeShape mm02Shape = CreateOrgChartShape(personalInfos[5]);

            NCompositeShape sm01Shape = CreateOrgChartShape(personalInfos[6]);
            NCompositeShape sm02Shape = CreateOrgChartShape(personalInfos[7]);

            NCompositeShape pm01Shape = CreateOrgChartShape(personalInfos[8]);
            NCompositeShape pm02Shape = CreateOrgChartShape(personalInfos[9]);

            //	connect the Org chart shapes
            // 1. President to VPs
            NShape ge = null;

            ge = new NStep3Connector(true, 50, 0, true);
            Document.ActiveLayer.AddChild(ge);
            ge.StartPlug.Connect(presidentShape.Ports.GetChildByName("Bottom", 0) as NPort);
            ge.EndPlug.Connect(vpMarketingShape.Ports.GetChildByName("Top", 0) as NPort);

            ge = new NStep3Connector(true, 50, 0, true);
            Document.ActiveLayer.AddChild(ge);
            ge.StartPlug.Connect(presidentShape.Ports.GetChildByName("Bottom", 0) as NPort);
            ge.EndPlug.Connect(vpSalesShape.Ports.GetChildByName("Top", 0) as NPort);

            ge = new NStep3Connector(true, 50, 0, true);
            Document.ActiveLayer.AddChild(ge);
            ge.StartPlug.Connect(presidentShape.Ports.GetChildByName("Bottom", 0) as NPort);
            ge.EndPlug.Connect(vpProductionShape.Ports.GetChildByName("Top", 0) as NPort);

            // 1. VPs to managers
            ge = new NStep2Connector(true);
            Document.ActiveLayer.AddChild(ge);
            ge.StartPlug.Connect(vpMarketingShape.Ports.GetChildByName("Bottom", 0) as NPort);
            ge.EndPlug.Connect(mm01Shape.Ports.GetChildByName("Left", 0) as NPort);

            ge = new NStep2Connector(true);
            Document.ActiveLayer.AddChild(ge);
            ge.StartPlug.Connect(vpMarketingShape.Ports.GetChildByName("Bottom", 0) as NPort);
            ge.EndPlug.Connect(mm02Shape.Ports.GetChildByName("Left", 0) as NPort);

            ge = new NStep2Connector(true);
            Document.ActiveLayer.AddChild(ge);
            ge.StartPlug.Connect(vpSalesShape.Ports.GetChildByName("Bottom", 0) as NPort);
            ge.EndPlug.Connect(sm01Shape.Ports.GetChildByName("Left", 0) as NPort);

            ge = new NStep2Connector(true);
            Document.ActiveLayer.AddChild(ge);
            ge.StartPlug.Connect(vpSalesShape.Ports.GetChildByName("Bottom", 0) as NPort);
            ge.EndPlug.Connect(sm02Shape.Ports.GetChildByName("Left", 0) as NPort);

            ge = new NStep2Connector(true);
            Document.ActiveLayer.AddChild(ge);
            ge.StartPlug.Connect(vpProductionShape.Ports.GetChildByName("Bottom", 0) as NPort);
            ge.EndPlug.Connect(pm01Shape.Ports.GetChildByName("Left", 0) as NPort);

            ge = new NStep2Connector(true);
            Document.ActiveLayer.AddChild(ge);
            ge.StartPlug.Connect(vpProductionShape.Ports.GetChildByName("Bottom", 0) as NPort);
            ge.EndPlug.Connect(pm02Shape.Ports.GetChildByName("Left", 0) as NPort);
        }
        protected NCompositeShape CreateOrgChartShape(NPersonalInfo info)
        {
            NRectangleF bounds = info.Bounds;
            float       bottomPortAlignment = info.BottomPortAlignment;
            Bitmap      photo = new Bitmap(this.MapPathSecure(info.Picture));

            // compose a new graph vertex from a frame and an image
            NRectanglePath  frame           = new NRectanglePath(bounds);
            NRectanglePath  image           = new NRectanglePath(new NPointF(bounds.X + 5, bounds.Y + 5), new NSizeF(photo.Size));
            NImageFillStyle imgageFillStyle = new NImageFillStyle(photo, 0xff);

            NStyle.SetFillStyle(image, imgageFillStyle);

            NCompositeShape shape = new NCompositeShape();

            shape.Primitives.AddChild(frame);
            shape.Primitives.AddChild(image);
            shape.UpdateModelBounds();
            Document.ActiveLayer.AddChild(shape);

            // set the vertex fill style
            NColorFillStyle fillStyle = null;

            switch (info.Level)
            {
            case 0:
                fillStyle = new NColorFillStyle(Color.FromArgb(241, 100, 34));
                break;

            case 1:
                fillStyle = new NColorFillStyle(Color.FromArgb(249, 167, 26));
                break;

            case 2:
                fillStyle = new NColorFillStyle(Color.FromArgb(255, 247, 151));
                break;
            }

            fillStyle.ImageFiltersStyle.Filters.Add(new NLightingImageFilter());
            shape.Style.FillStyle = fillStyle;

            NInteractivityStyle interactivityStyle = new NInteractivityStyle();

            interactivityStyle.Tooltip.Text = "Click to show " + info.Name + " personal information";
            interactivityStyle.UrlLink.Url  = "../Examples/WebControl/GettingStarted/NPersonalInfoPage.aspx?" + info.Id.ToString();
            shape.Style.InteractivityStyle  = interactivityStyle;

            // add a new label for the person name
            NRotatedBoundsLabel nameLabel = new NRotatedBoundsLabel(info.Name, shape.UniqueId, new Nevron.Diagram.NMargins(40, 1, 50, 1));

            shape.Labels.AddChild(nameLabel);
            NStyle.SetTextStyle(nameLabel, nameLabel.ComposeTextStyle().Clone() as NTextStyle);
            nameLabel.Style.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Right;
            nameLabel.Style.TextStyle.StringFormatStyle.VertAlign = VertAlign.Top;

            // configure default label (used for the person position)
            NRotatedBoundsLabel positionLabel = shape.Labels.DefaultLabel as NRotatedBoundsLabel;

            NStyle.SetTextStyle(positionLabel, positionLabel.ComposeTextStyle().Clone() as NTextStyle);
            positionLabel.Style.TextStyle.FontStyle.InitFromFont(new Font("Arial", 10, FontStyle.Bold));
            positionLabel.Style.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Right;
            positionLabel.Style.TextStyle.StringFormatStyle.VertAlign = VertAlign.Bottom;
            positionLabel.Margins = new Nevron.Diagram.NMargins(40, 5, 1, 50);
            positionLabel.Text    = info.Position;

            // create the optional ports of the shape
            shape.CreateShapeElements(ShapeElementsMask.Ports);

            // add rotated bounds ports
            NPort leftPort = new NRotatedBoundsPort(shape.UniqueId, new NContentAlignment(ContentAlignment.MiddleLeft));

            leftPort.Name = "Left";
            shape.Ports.AddChild(leftPort);

            NPort rightPort = new NRotatedBoundsPort(shape.UniqueId, new NContentAlignment(ContentAlignment.MiddleRight));

            rightPort.Name = "Right";
            shape.Ports.AddChild(rightPort);

            NPort topPort = new NRotatedBoundsPort(shape.UniqueId, new NContentAlignment(ContentAlignment.TopCenter));

            topPort.Name = "Top";
            shape.Ports.AddChild(topPort);

            NRotatedBoundsPort bottomPort = new NRotatedBoundsPort(shape.UniqueId, new NContentAlignment(bottomPortAlignment, 50));

            bottomPort.Name = "Bottom";
            shape.Ports.AddChild(bottomPort);

            return(shape);
        }
Пример #20
0
        protected NCompositeShape CreateComputer()
        {
            NCompositeShape computer = new NCompositeShape();

            // create the frame
            NEllipsePath frame = new NEllipsePath(-28, -28, 140, 140);

            NStyle.SetFillStyle(frame, new NColorFillStyle(Color.WhiteSmoke));
            computer.Primitives.AddChild(frame);

            // create display 1
            computer.Primitives.AddChild(new NRectanglePath(0, 0, 57, 47));

            // create display 2
            computer.Primitives.AddChild(new NRectanglePath(6, 4, 47, 39));

            // create the keyboard
            computer.Primitives.AddChild(new NRectanglePath(-21, 53, 60, 14));

            // create the tower case
            computer.Primitives.AddChild(new NRectanglePath(65, 0, 32, 66));

            // create floppy 1
            computer.Primitives.AddChild(new NRectanglePath(70, 5, 20, 3.75f));

            // create floppy 2
            computer.Primitives.AddChild(new NRectanglePath(70, 15, 20, 3.75f));

            // create floppy 3
            computer.Primitives.AddChild(new NRectanglePath(70, 25, 20, 3.75f));

            // create the mouse tail
            computer.Primitives.AddChild(new NBezierCurvePath(new NPointF(38, 82), new NPointF(61, 74), new NPointF(27, 57), new NPointF(63, 54)));

            // create the mouse
            NEllipsePath mouse = new NEllipsePath(26, 79, 11, 19);

            mouse.Rotate(CoordinateSystem.Scene, 42, new NPointF(36.5f, 88.5f));
            computer.Primitives.AddChild(mouse);

            // update the model bounds to fit the primitives
            computer.UpdateModelBounds();

            // the default fill style is dold
            computer.Style.FillStyle = new NColorFillStyle(Color.Gold);

            // create the computer ports
            computer.CreateShapeElements(ShapeElementsMask.Ports);

            // create a dynamic port anchored to the center of the frame
            NDynamicPort port = new NDynamicPort(frame.UniqueId, ContentAlignment.MiddleCenter, DynamicPortGlueMode.GlueToContour);

            port.Name = "port";

            // make the new port the one and default port of the computer
            computer.Ports.RemoveAllChildren();
            computer.Ports.AddChild(port);
            computer.Ports.DefaultInwardPortUniqueId = port.UniqueId;

            return(computer);
        }
Пример #21
0
        protected NGroup CreateNetwork(NPointF location, string labelText)
        {
            NGroup group = new NGroup();

            document.ActiveLayer.AddChild(group);

            // create computer1
            NCompositeShape computer1 = CreateComputer();

            computer1.Location = new NPointF(0, 0);
            group.Shapes.AddChild(computer1);

            // create computer2
            NCompositeShape computer2 = CreateComputer();

            computer2.Location = new NPointF(200, 0);
            group.Shapes.AddChild(computer2);

            // create computer3
            NCompositeShape computer3 = CreateComputer();

            computer3.Location = new NPointF(100, 180);
            group.Shapes.AddChild(computer3);

            // connect the computers in the network
            ConnectComputers(computer1, computer2, group);
            ConnectComputers(computer2, computer3, group);
            ConnectComputers(computer3, computer1, group);

            // update the group model bounds
            group.UpdateModelBounds();

            // insert a frame
            NRectangleShape frame = new NRectangleShape(group.ModelBounds);

            frame.Protection = new NAbilities(AbilitiesMask.Select | AbilitiesMask.InplaceEdit);
            group.Shapes.InsertChild(0, frame);

            // change group fill style
            group.Style.FillStyle = new NGradientFillStyle(GradientStyle.FromCenter, GradientVariant.Variant2, Color.Gainsboro, Color.White);

            // reposition and resize the group
            group.Location = location;
            group.Width    = 155;
            group.Height   = 155;

            // add a dynamic port to the group
            group.CreateShapeElements(ShapeElementsMask.Ports);

            NDynamicPort port = new NDynamicPort(group.UniqueId, ContentAlignment.MiddleCenter, DynamicPortGlueMode.GlueToContour);

            group.Ports.AddChild(port);
            group.Ports.DefaultInwardPortUniqueId = port.UniqueId;

            // modify the margins and text of the default label
            group.CreateShapeElements(ShapeElementsMask.Labels);

            NRotatedBoundsLabel label = new NRotatedBoundsLabel(labelText, group.UniqueId, new Nevron.Diagram.NMargins(0, 0, -10, 100));

            group.Labels.AddChild(label);
            group.Labels.DefaultLabelUniqueId = label.UniqueId;

            return(group);
        }