Exemplo n.º 1
0
        private NLibraryView CreateLibrary()
        {
            NLibraryDocument libDocument = new NLibraryDocument();

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

            NLibraryView libView = new NLibraryView();

            libView.AllowDrop      = false;
            libView.Document       = libDocument;
            libView.ScrollBars     = ScrollBars.None;
            libView.Selection.Mode = DiagramSelectionMode.Single;
            libView.Document       = libDocument;

            NUmlShape shape  = new NUmlShape(0, 0, 100, 25, true);
            NMaster   master = new NMaster(shape, NGraphicsUnit.Pixel, "Class", "Drag me on the drawing");

            libDocument.AddChild(master);
            shape.Name = "Class";

            shape          = new NUmlShape(0, 0, 100, 25, true);
            shape.Abstract = true;
            master         = new NMaster(shape, NGraphicsUnit.Pixel, "Abstract Class", "Drag me on the drawing");
            libDocument.AddChild(master);
            shape.Name = "AbstractClass";

            // Connectors
            master = CreateGeneralizationMaster();
            libDocument.AddChild(master);

            master = CreateAssociationMaster();
            libDocument.AddChild(master);

            master = CreateAggregarionMaster();
            libDocument.AddChild(master);

            master = CreateCompositionMaster();
            libDocument.AddChild(master);

            return(libView);
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
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);
        }