Ejemplo n.º 1
0
        protected void NDrawingView1_AsyncMouseOut(object sender, EventArgs e)
        {
            NCallbackMouseEventArgs args = e as NCallbackMouseEventArgs;

            if (args.ItemId == null)
            {
                return;
            }

            NElementAtomIdentifier id   = new NElementAtomIdentifier(args.ItemId);
            NEllipsePath           path = id.FindInDocument(NDrawingView1.Document) as NEllipsePath;

            if (path == null)
            {
                return;
            }

            NShape shape = NSceneTree.FirstAncestor(path, NFilters.TypeNShape) as NShape;

            shape.Style.FillStyle = new NColorFillStyle(Color.Linen);
        }
Ejemplo n.º 2
0
        protected void NDrawingView1_AsyncCustomCommand(object sender, EventArgs e)
        {
            NCallbackCustomCommandArgs args    = e as NCallbackCustomCommandArgs;
            NCallbackCommand           command = args.Command;

            switch (command.Name)
            {
            case "changeColor":
                string idText = command.Arguments["id"] as string;
                if (idText == null)
                {
                    break;
                }

                NElementAtomIdentifier id   = new NElementAtomIdentifier(idText);
                NEllipsePath           path = id.FindInDocument(NDrawingView1.Document) as NEllipsePath;
                if (path == null)
                {
                    break;
                }

                NShape shape = NSceneTree.FirstAncestor(path, NFilters.TypeNShape) as NShape;

                Color c = Color.Red;
                if (command.Arguments["color"].ToString() == "blue")
                {
                    c = Color.Blue;
                }

                NColorFillStyle fs = shape.Style.FillStyle as NColorFillStyle;
                shape.Style.FillStyle = new NColorFillStyle(c);

                clientSideRedrawRequired = (fs == null || fs.Color != c);
                break;

            case "rotate10Degrees":
                IterateRotatingEllipse(true);
                break;
            }
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
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);
        }