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);
        }
Exemple #2
0
 private void CreateTextShape(ref NShape shape)
 {
     shape = new NRectangleShape(0, 0, SEAT_SIZE.Width * 10, SEAT_SIZE.Height);
     NStyle.SetFillStyle(shape, new NColorFillStyle(Color.White));
     NStyle.SetStrokeStyle(shape, new NStrokeStyle(0, Color.White));
     NStyle.SetTextStyle(shape, new NTextStyle());
     shape.Style.TextStyle.StringFormatStyle = new NStringFormatStyle(StringFormatType.GenericTypographic, HorzAlign.Left, VertAlign.Center);
     SetProtections(shape);
     document.ActiveLayer.AddChild(shape);
 }
        private void CreateScene(NDrawingDocument document)
        {
            document.BackgroundStyle.FrameStyle.Visible = false;
            document.Style.TextStyle.FontStyle.InitFromFont(new Font("Arial Narrow", 8));

            NNetworkShapesFactory factory = new NNetworkShapesFactory(document);

            factory.DefaultSize = new NSizeF(240, 180);

            NShape server   = factory.CreateShape(NetworkShapes.Server);
            NShape computer = factory.CreateShape(NetworkShapes.Computer);
            NShape laptop   = factory.CreateShape(NetworkShapes.Laptop);

            document.ActiveLayer.AddChild(server);
            document.ActiveLayer.AddChild(computer);
            document.ActiveLayer.AddChild(laptop);

            NRoutableConnector link1 = new NRoutableConnector();

            document.ActiveLayer.AddChild(link1);
            link1.FromShape = server;
            link1.ToShape   = computer;

            NRoutableConnector link2 = new NRoutableConnector();

            document.ActiveLayer.AddChild(link2);
            link2.FromShape = server;
            link2.ToShape   = laptop;

            // layout the shapes in the active layer using a table layout
            NLayeredGraphLayout layout = new NLayeredGraphLayout();

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

            // add the data shape
            const float   shapeSize = 10;
            NEllipseShape data      = new NEllipseShape(link2.EndPoint.X - shapeSize / 2, link2.EndPoint.Y - shapeSize, shapeSize, shapeSize);

            document.ActiveLayer.AddChild(data);
            NStyle.SetStrokeStyle(data, new NStrokeStyle(0, KnownArgbColorValue.Transparent));
            NStyle.SetFillStyle(data, new NColorFillStyle(KnownArgbColorValue.Red));

            // set the animations style
            SetAnimationsStyle(data, link1, link2);

            // resize document to fit all shapes
            document.SizeToContent();
        }
        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);
        }
        /// <summary>
        /// Creates the zoom rect
        /// </summary>
        /// <remarks>
        /// This implementation will currently create a zoom rectangle and add it to the preview layer
        /// </remarks>
        protected virtual void CreateZoomRect()
        {
            // create the zoom rect
            m_ZoomRect = new NRectanglePath();
            NStyle.SetFillStyle(m_ZoomRect, new NColorFillStyle(Color.FromArgb(0, 0, 0, 0)));
            NStyle.SetStrokeStyle(m_ZoomRect, new NStrokeStyle(1, Color.Black, LinePattern.Dash));
            View.PreviewLayer.AddChild(m_ZoomRect);

            // start dragging
            View.OnDraggingStarted();
        }
        /// <summary>
        /// Shows the stroke style editor for the specified styleable node
        /// </summary>
        /// <param name="styleable"></param>
        protected void ShowStrokeStyleEditor(INStyleable styleable)
        {
            if (styleable == null)
            {
                return;
            }

            NStrokeStyle strokeStyle    = styleable.ComposeStrokeStyle();
            NStrokeStyle newStrokeStyle = null;

            if (NStrokeStyleTypeEditor.Edit(strokeStyle, out newStrokeStyle))
            {
                NStyle.SetStrokeStyle(styleable, newStrokeStyle);
                document.RefreshAllViews();
            }
        }
        private NMaster CreateAssociationMaster()
        {
            NStep3Connector c = new NStep3Connector(new NPointF(0, 0), new NPointF(100, 50), true);

            c.Name = "UML Association";

            NStrokeStyle    strokeStyle    = (NStrokeStyle)document.ComposeStrokeStyle().Clone();
            NArrowheadStyle arrowheadStyle = new NArrowheadStyle(ArrowheadShape.OpenedArrow, string.Empty, ArrowSize, ConFillStyle, (NStrokeStyle)strokeStyle.Clone());

            NStyle.SetEndArrowheadStyle(c, arrowheadStyle);

            strokeStyle.Pattern = LinePattern.Dash;
            NStyle.SetStrokeStyle(c, strokeStyle);

            return(new NMaster(c, NGraphicsUnit.Pixel, c.Name, "Drag me on the drawing"));
        }
        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;
        }
Exemple #9
0
        private void CreateAnimatedGrid(int rows, int columns, float cellFadeDuration)
        {
            NDrawingDocument document = DrawingView.Document;

            // Create the grid layer
            NLayer grid = new NLayer();

            grid.Name = "grid";
            document.Layers.AddChild(grid);

            // Create the cells style sheet
            NStyleSheet style = new NStyleSheet("gridCell");

            NStyle.SetFillStyle(style, new NColorFillStyle(KnownArgbColorValue.White));
            NStyle.SetStrokeStyle(style, new NStrokeStyle(1, KnownArgbColorValue.Black));
            document.StyleSheets.AddChild(style);

            int   i, j, count;
            float x, y, time = 0;
            float cellWidth  = document.Width / rows;
            float cellHeight = document.Height / columns;

            NFadeAnimation         fade;
            NRectangleShape        rect;
            List <NRectangleShape> cells = new List <NRectangleShape>();

            // Create the shapes
            for (i = 0, y = 0; i < rows; i++, y += cellHeight)
            {
                for (j = 0, x = 0; j < columns; j++, x += cellWidth)
                {
                    rect = new NRectangleShape(x, y, cellWidth, cellHeight);
                    cells.Add(rect);
                    grid.AddChild(rect);
                    rect.StyleSheetName = style.Name;
                }
            }

            // Create the fade animations
            count = cells.Count;
            Random random = new Random();

            int counter = 1;

            while (count > 0)
            {
                i    = random.Next(count);
                rect = cells[i];
                rect.Style.AnimationsStyle = new NAnimationsStyle();

                if (time > 0)
                {
                    fade            = new NFadeAnimation(0, time);
                    fade.StartAlpha = 1;
                    fade.EndAlpha   = 1;
                    rect.Style.AnimationsStyle.AddAnimation(fade);
                }

                fade            = new NFadeAnimation(time, cellFadeDuration);
                fade.StartAlpha = 1;
                fade.EndAlpha   = 0;
                rect.Style.AnimationsStyle.AddAnimation(fade);

                if (counter == 3)
                {
                    // Show 3 cells at a time
                    time   += cellFadeDuration;
                    counter = 1;
                }
                else
                {
                    counter++;
                }

                cells.RemoveAt(i);
                count--;
            }
        }
        private void ImportData()
        {
            NDrawingDocument document = NDrawingView1.Document;

            document.BackgroundStyle.FrameStyle.Visible = false;

            // create two stylesheets - one for the vertices and one for the edges
            NStyleSheet vertexStyleSheet = new NStyleSheet();

            vertexStyleSheet.Name = "Vertices";
            NStyle.SetFillStyle(vertexStyleSheet, new NColorFillStyle(Color.FromArgb(236, 97, 49)));
            document.StyleSheets.AddChild(vertexStyleSheet);

            NStyleSheet edgeStyleSheet = new NStyleSheet();

            edgeStyleSheet.Name = "Edges";
            NStyle.SetStrokeStyle(edgeStyleSheet, new NStrokeStyle(Color.Blue));
            NStyle.SetEndArrowheadStyle(edgeStyleSheet, new NArrowheadStyle(ArrowheadShape.OpenedArrow, null, new NSizeL(6, 4), null, new NStrokeStyle(Color.Blue)));
            NTextStyle textStyle = (NTextStyle)document.ComposeTextStyle().Clone();

            textStyle.StringFormatStyle.VertAlign = Nevron.VertAlign.Bottom;
            NStyle.SetTextStyle(edgeStyleSheet, textStyle);
            document.StyleSheets.AddChild(edgeStyleSheet);

            // create the graph data source importer
            NGraphDataSourceImporter graphImporter = new NGraphDataSourceImporter();

            // set the document in the active layer of which the shapes will be imported
            graphImporter.Document = document;

            // SET THE DATA SOURCE
            // the tree data source importer supports the following data sources
            //      DataTable
            //      DataView
            //      OleDbDataAdapter
            //      SqlDataAdapter
            //      OdbcDataAdapter
            //      OleDbCommand
            //      SqlCommand
            //      OdbcCommand
            // in this example we have created an OleDbDataAdapter,
            // which selects all columns and records from the Sources and Links tables of the Data.xlsx file
            string databasePath     = Server.MapPath(@"..\Examples\Import\Data.xlsx");
            string connectionString = @"Data Source=""" + databasePath + @""";Provider=""Microsoft.ACE.OLEDB.12.0""; Extended Properties=""Excel 12.0 Xml;HDR=YES"";";

            graphImporter.VertexDataSource = new OleDbDataAdapter("SELECT * FROM [Sources$]", connectionString);
            graphImporter.EdgeDataSource   = new OleDbDataAdapter("SELECT * FROM [Links$]", connectionString);

            // vertex records are uniquely identified by their Id (in the Sources table)
            // edges link the vertices with the Fro and ToPageId (in the Links table)
            graphImporter.VertexIdColumnName     = "Id";
            graphImporter.FromVertexIdColumnName = "From";
            graphImporter.ToVertexIdColumnName   = "To";

            // create vertices as group shapes, with default size
            NShapesFactory shapesFactory = new GroupShapesFactory();

            shapesFactory.DefaultSize         = VertexSize;
            graphImporter.VertexShapesFactory = shapesFactory;
            graphImporter.VertexShapesName    = GroupShapes.Group.ToString();

            // set stylesheets to be applied to imported vertices and edges
            graphImporter.VertexStyleSheetName = "Vertices";
            graphImporter.EdgeStyleSheetName   = "Edges";

            // use layered graph layout
            NLayeredGraphLayout layout = new NLayeredGraphLayout();

            layout.LayerSpacing   = 70;
            layout.Direction      = LayoutDirection.LeftToRight;
            layout.LayerAlignment = RelativeAlignment.Near;
            graphImporter.Layout  = layout;

            // subscribe for the vertex and edge imported events,
            // which are raised when a shape was created for a data source record
            graphImporter.VertexImported += new ShapeImportedDelegate(OnVertexImported);
            graphImporter.EdgeImported   += new ShapeImportedDelegate(OnEdgeImported);

            // import
            graphImporter.Import();
        }
        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();
            }
        }
        void InitDocument()
        {
            // set up visual formatting
            NDrawingView1.Document.Style.FillStyle = new NColorFillStyle(Color.White);
            NDrawingView1.Document.BackgroundStyle.FrameStyle.Visible = false;

            NCustomToolsData.NBookEntry[] books = NCustomToolsData.CreateBooks();

            //	set up the shape factories
            NBasicShapesFactory bookItemsFactory = new NBasicShapesFactory(NDrawingView1.Document);

            bookItemsFactory.DefaultSize = new NSizeF(150, 100);

            //	create a table layout, which will align te thumbnail and the text within a group
            NTableLayout bookThumbLayout = new NTableLayout();

            bookThumbLayout.Direction     = LayoutDirection.LeftToRight;
            bookThumbLayout.ConstrainMode = CellConstrainMode.Ordinal;
            bookThumbLayout.MaxOrdinal    = 1;

            //	create a table layout, which will align all books in a grid
            NTableLayout tableLayout = new NTableLayout();

            tableLayout.Direction         = LayoutDirection.LeftToRight;
            tableLayout.ConstrainMode     = CellConstrainMode.Ordinal;
            tableLayout.MaxOrdinal        = 4;
            tableLayout.HorizontalSpacing = 7;
            tableLayout.VerticalSpacing   = 7;

            NLayoutContext layoutContext = new NLayoutContext();

            layoutContext.GraphAdapter         = new NShapeGraphAdapter();
            layoutContext.BodyAdapter          = new NShapeBodyAdapter(NDrawingView1.Document);
            layoutContext.BodyContainerAdapter = new NDrawingBodyContainerAdapter(NDrawingView1.Document);

            int length = books.Length;

            for (int i = 0; i < length; i++)
            {
                NCustomToolsData.NBookEntry book = books[i];

                NShape          bookThumbnailShape = bookItemsFactory.CreateShape(BasicShapes.Rectangle);
                NImageFillStyle fs1 = new NImageFillStyle(this.MapPathSecure(@"..\..\..\..\Images\CustomTools\" + book.ThumbnailFile));
                fs1.TextureMappingStyle.MapLayout = MapLayout.Centered;
                NStyle.SetFillStyle(bookThumbnailShape, fs1);
                NStyle.SetStrokeStyle(bookThumbnailShape, new NStrokeStyle(0, Color.White));

                NShape bookTextShape = bookItemsFactory.CreateShape(BasicShapes.Rectangle);
                NStyle.SetStrokeStyle(bookTextShape, new NStrokeStyle(0, Color.White));
                bookTextShape.Text   = book.Title;
                bookTextShape.Height = 50f;

                bookThumbnailShape.Style.InteractivityStyle = new NInteractivityStyle(true, book.Id.ToString(), null, CursorType.Hand);
                bookTextShape.Style.InteractivityStyle      = new NInteractivityStyle(true, book.Id.ToString(), null, CursorType.Hand);

                //	create the book tumbnail group
                NGroup      g      = new NGroup();
                NBatchGroup bgroup = new NBatchGroup(NDrawingView1.Document);
                NNodeList   shapes = new NNodeList();

                shapes.Add(bookThumbnailShape);
                shapes.Add(bookTextShape);

                // perform layout
                bookThumbLayout.Layout(shapes, layoutContext);

                // group shapes
                bgroup.Build(shapes);
                bgroup.Group(null, false, out g);

                NDrawingView1.Document.ActiveLayer.AddChild(g);
            }

            // layout the books
            tableLayout.Layout(NDrawingView1.Document.ActiveLayer.Children(null), layoutContext);
        }
Exemple #13
0
        protected void NDrawingView1_AsyncClick(object sender, EventArgs e)
        {
            NCallbackMouseEventArgs args = e as NCallbackMouseEventArgs;

            NNodeList nodes  = NDrawingView1.HitTest(args);
            NNodeList shapes = nodes.Filter(CELL_FILTER);

            if (shapes.Count == 0)
            {
                return;
            }

            NTableCell cell = (NTableCell)shapes[0];

            if (cell.ParentNode.ParentNode != table)
            {
                return;
            }

            if (cell.StyleSheetName != null && cell.StyleSheetName != string.Empty)
            {
                if (CellClicked(cell))
                {
                    UpdateInfo();

                    // Check for end of the game
                    string status = string.Empty;
                    if (AllClear())
                    {
                        score *= 2;
                        status = "You've cleared all cells !!!" + Environment.NewLine;
                    }

                    if (status == string.Empty && GameOver())
                    {
                        status = "Game Over !" + Environment.NewLine;
                    }

                    if (status != string.Empty)
                    {
                        status += "Your score is " + score.ToString();
                        NTableShape gameOver = new NTableShape();
                        document.ActiveLayer.AddChild(gameOver);

                        gameOver.BeginUpdate();
                        gameOver.CellPadding = new Nevron.Diagram.NMargins(2, 2, 8, 8);
                        gameOver[0, 0].Text  = status;

                        NStyle.SetFillStyle(gameOver, new NAdvancedGradientFillStyle(AdvancedGradientScheme.Ocean1, 0));
                        NStyle.SetStrokeStyle(gameOver, new NStrokeStyle(Color.DarkBlue));

                        NTextStyle textStyle = (NTextStyle)table.ComposeTextStyle().Clone();
                        textStyle.FillStyle = new NColorFillStyle(Color.DarkBlue);
                        NStyle.SetTextStyle(gameOver, textStyle);

                        gameOver.EndUpdate();
                        gameOver.Center = table.Center;
                    }
                }
            }
        }
Exemple #14
0
        private void InitDocument()
        {
            Bitmap bitmap = NResourceHelper.BitmapFromResource(GetType(), "Airplane.png", "Nevron.Examples.Diagram.WinForm.Resources");

            document.Width  = bitmap.Width;
            document.Height = bitmap.Height + 62;

            document.BackgroundStyle.FillStyle = new NImageFillStyle(bitmap);

            // Create the style sheets
            NStyleSheet free = new NStyleSheet("free");

            NStyle.SetInteractivityStyle(free, new NInteractivityStyle(string.Empty, CursorType.Hand));
            NStyle.SetFillStyle(free, new NColorFillStyle(SEAT_COLOR));
            NStyle.SetStrokeStyle(free, new NStrokeStyle(1, Color.Black));
            NStyle.SetTextStyle(free, new NTextStyle(new Font(view.Font, FontStyle.Bold), Color.Blue));
            document.StyleSheets.AddChild(free);

            NStyleSheet     reserved = new NStyleSheet("reserved");
            NHatchFillStyle hatch    = new NHatchFillStyle(HatchStyle.LightUpwardDiagonal, Color.Red, SEAT_COLOR);

            hatch.TextureMappingStyle.MapMode = MapMode.RelativeToViewer;
            NStyle.SetFillStyle(reserved, hatch);
            NStyle.SetStrokeStyle(reserved, new NStrokeStyle(1, Color.Black));
            document.StyleSheets.AddChild(reserved);

            float  x, y;
            float  distance = DISTANCE;
            NShape shape;
            Point  startPoint = LINE1_LEFT;

            m_Seats = new List <NShape>();

            // Draw the seats
            for (y = LINE1_LEFT.Y; y < 350; y += SEAT_SIZE.Height)
            {
                if (y > 260 && y < LINE2_LEFT.Y)
                {
                    y          = LINE2_LEFT.Y;
                    startPoint = LINE2_LEFT;
                }

                if (y >= LINE2_LEFT.Y)
                {
                    distance = 5.25f;
                }

                for (x = startPoint.X; x < 970; x += SEAT_SIZE.Width + distance)
                {
                    if (x > 460 && x < LINE1_RIGHT.X)
                    {
                        x        = LINE1_RIGHT.X;
                        distance = DISTANCE;
                    }

                    m_nFreeSeats++;
                    shape = new NRectangleShape(x, y, SEAT_SIZE.Width, SEAT_SIZE.Height);
                    shape.StyleSheetName = "free";
                    SetProtections(shape);
                    document.ActiveLayer.AddChild(shape);
                    m_Seats.Add(shape);
                }
            }

            // Free seats
            shape = new NRectangleShape(MARGINS, MARGINS, SEAT_SIZE.Width, SEAT_SIZE.Height);
            shape.StyleSheetName = "free";
            SetProtections(shape);
            document.ActiveLayer.AddChild(shape);

            CreateTextShape(ref m_FreeSeats);
            m_FreeSeats.Location = new NPointF(shape.Bounds.Right + MARGINS, shape.Bounds.Y);

            // Reserved seats
            shape = new NRectangleShape(MARGINS, 2 * MARGINS + SEAT_SIZE.Height, SEAT_SIZE.Width, SEAT_SIZE.Height);
            shape.StyleSheetName = "reserved";
            SetProtections(shape);
            document.ActiveLayer.AddChild(shape);

            CreateTextShape(ref m_ReservedSeats);
            m_ReservedSeats.Location = new NPointF(shape.Bounds.Right + MARGINS, shape.Bounds.Y);

            // Total revenue
            CreateTextShape(ref m_Revenue);
            m_Revenue.Location = new NPointF(shape.Bounds.Right + MARGINS, shape.Bounds.Bottom + MARGINS);
            m_Revenue.Style.TextStyle.FontStyle.Style = FontStyle.Bold;
            m_Revenue.Style.TextStyle.FillStyle       = new NColorFillStyle(Color.MediumBlue);

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