Example #1
0
            public override bool OnPolygonCreated(NDiagramElement element, NMapFeature mapFeature)
            {
                NShape shape = element as NShape;

                if (shape != null)
                {
                    NInteractivityStyle iStyle = new NInteractivityStyle(true, null, mapFeature.GetAttributeValue(m_sTooltipColumnName).ToString());
                    NStyle.SetInteractivityStyle(shape, iStyle);
                }

                return(base.OnPolygonCreated(element, mapFeature));
            }
        private void CreateScene(NDrawingDocument document)
        {
            // Initialize the default document style
            document.BackgroundStyle.FrameStyle.Visible = false;
            document.Style.StartArrowheadStyle.Shape    = ArrowheadShape.None;
            document.Style.EndArrowheadStyle.Shape      = ArrowheadShape.None;
            document.Style.FillStyle = new NGradientFillStyle(GradientStyle.DiagonalUp, GradientVariant.Variant1,
                                                              new NArgbColor(155, 184, 209), new NArgbColor(83, 138, 179));

            NDrawingDocumentHelper helper = new NDrawingDocumentHelper(document);

            // Create the shapes
            NShape vision = helper.CreateBasicShape(BasicShapes.Rectangle, new NRectangleF(0, 0, 100, 50), "Nevron Vision", String.Empty);
            NInteractivityStyle iStyle = new NInteractivityStyle();

            iStyle.UrlLink = new NUrlLinkAttribute("http://www.nevron.com", true);
            NStyle.SetInteractivityStyle(vision, iStyle);

            NShape chart = helper.CreateBasicShape(BasicShapes.Rectangle, new NRectangleF(0, 0, 100, 50), "Nevron Chart", String.Empty);

            iStyle         = new NInteractivityStyle();
            iStyle.UrlLink = new NUrlLinkAttribute("http://nevron.com/Products.ChartFor.NET.Overview.aspx", true);
            NStyle.SetInteractivityStyle(chart, iStyle);

            NShape diagram = helper.CreateBasicShape(BasicShapes.Rectangle, new NRectangleF(0, 0, 100, 50), "Nevron Diagram", String.Empty);

            iStyle         = new NInteractivityStyle();
            iStyle.UrlLink = new NUrlLinkAttribute("http://nevron.com/Products.DiagramFor.NET.Overview.aspx", true);
            NStyle.SetInteractivityStyle(diagram, iStyle);

            NShape ui = helper.CreateBasicShape(BasicShapes.Rectangle, new NRectangleF(0, 0, 100, 50), "Nevron User Interface", String.Empty);

            iStyle         = new NInteractivityStyle();
            iStyle.UrlLink = new NUrlLinkAttribute("http://nevron.com/Products.UserInterfaceFor.NET.Overview.aspx", true);
            NStyle.SetInteractivityStyle(ui, iStyle);

            // Create the connectors
            Connect(vision, chart);
            Connect(vision, diagram);
            Connect(vision, ui);

            // Layout the shapes
            NLayeredGraphLayout layout = new NLayeredGraphLayout();

            layout.Direction = LayoutDirection.LeftToRight;
            NNodeList shapes = document.ActiveLayer.Children(null);

            layout.Layout(shapes, new NDrawingLayoutContext(document));
        }
Example #3
0
            public override bool OnPolygonCreated(NDiagramElement element, NMapFeature mapFeature)
            {
                NShape shape = element as NShape;

                if (shape == null)
                {
                    return(true);
                }

                string name       = mapFeature.GetAttributeValue("CNTRY_NAME").ToString();
                int    population = Int32.Parse(mapFeature.GetAttributeValue("POP_CNTRY").ToString());

                NInteractivityStyle interactivityStyle = new NInteractivityStyle(String.Format("{0}'{1} population: {2:N0}", name,
                                                                                               name.EndsWith("s") ? String.Empty : "s", population));

                NStyle.SetInteractivityStyle(shape, interactivityStyle);

                return(true);
            }
Example #4
0
        protected void InitDocument()
        {
            NDrawingDocument document = NDrawingView1.Document;

            // Import the Visio stencil
            NLibraryDocument libDocument = new NLibraryDocument();
            NVisioImporter   importer    = new NVisioImporter(libDocument);

            importer.Import(Server.MapPath(@"~\Examples\Import\Computers.vsx"));

            // Set drawing preferences
            document.GraphicsSettings.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            document.GraphicsSettings.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            document.GraphicsSettings.PixelOffsetMode   = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
            document.BackgroundStyle.FrameStyle.Visible = false;

            // Determine the shape size
            int maxOrdinal = 0;
            int scale      = 1;

            switch (shapeSizeDropDownList.SelectedValue)
            {
            case "Small":
                scale      = 1;
                maxOrdinal = 5;
                break;

            case "Medium":
                scale      = 2;
                maxOrdinal = 3;
                break;

            case "Large":
                scale      = 4;
                maxOrdinal = 1;
                break;

            default:
                throw new NotImplementedException(shapeSizeDropDownList.SelectedValue);
            }

            // Determine the shapes size and layout options
            NNodeList masters = libDocument.Children(NFilters.TypeNMaster);

            for (int i = 0, count = masters.Count; i < count; i++)
            {
                NMaster   master = (NMaster)masters[i];
                NNodeList shapes = master.CreateInstance(document, new NPointF(0, 0));

                NShape shape = (NShape)shapes[0];
                shape.Width  *= scale;
                shape.Height *= scale;
                NStyle.SetInteractivityStyle(shape, new NInteractivityStyle(master.Name));
            }

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

            layout.Direction                  = LayoutDirection.LeftToRight;
            layout.ConstrainMode              = CellConstrainMode.Ordinal;
            layout.MaxOrdinal                 = maxOrdinal;
            layout.VerticalSpacing            = 20;
            layout.HorizontalSpacing          = 20;
            layout.HorizontalContentPlacement = ContentPlacement.Center;
            layout.VerticalContentPlacement   = ContentPlacement.Center;

            layout.Layout(document.ActiveLayer.Children(null), new NDrawingLayoutContext(document));

            // Resize document to fit all shapes
            document.SizeToContent();
        }
Example #5
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();
        }