Пример #1
0
        private void InitFormControls()
        {
            libDocument = new NLibraryDocument();

            libView = new NLibraryView();
            pLibrary.Controls.Add(libView);
            libView.Dock     = DockStyle.Fill;
            libView.Document = libDocument;

            DirectoryInfo directory = new DirectoryInfo(Path.Combine(Application.StartupPath, @"..\..\Resources\Data"));

            dlgOpen.InitialDirectory = directory.FullName;
        }
Пример #2
0
        protected override void LoadExample()
        {
            // attach the library browser to the command bars manager,
            // in order so that it can display context menus
            Form.CommandBarsManager.LibraryBrowser = libraryBrowser;

            // clear all bands (library groups)
            libraryBrowser.ClearBands();

            // create a new library
            NLibraryDocument library = new NLibraryDocument();

            library.Info.Title = "My first library";

            NBasicShapesFactory factory = new NBasicShapesFactory(document);

            // add several masters in the library
            NShape shape = factory.CreateShape((int)BasicShapes.Pentagram);

            shape.Width  = 130;
            shape.Height = 130;
            library.AddChild(new NMaster(shape, NGraphicsUnit.Pixel, "Star", "My star"));

            shape        = factory.CreateShape((int)BasicShapes.Octagram);
            shape.Width  = 130;
            shape.Height = 130;
            library.AddChild(new NMaster(shape, NGraphicsUnit.Pixel, "Octagon", "My octagon"));

            // create a new library group hosting the library
            libraryBrowser.OpenLibraryGroup(library);

            // start view init
            view.BeginInit();

            document.Style.StartArrowheadStyle.Shape = ArrowheadShape.None;
            document.Style.EndArrowheadStyle.Shape   = ArrowheadShape.None;
            view.AllowDrop = true;

            // init document
            document.BeginInit();
            CreateCustomOpenFigureShape();
            CreateCustomClosedFigureShape();
            document.EndInit();

            // init form controls
            InitFormControls();

            // end view init
            view.EndInit();
        }
Пример #3
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);
        }
Пример #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();
        }
Пример #5
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);
        }