/// <summary>
        /// Called when a vertex shape was created by the NTreeDataSourceImporter for the specified data record
        /// </summary>
        /// <param name="importer"></param>
        /// <param name="shape"></param>
        /// <param name="dataRecord"></param>
        private void OnVertexImported(NDataSourceImporter importer, NShape shape, INDataRecord dataRecord)
        {
            // display the page title in the shape
            object text = dataRecord.GetColumnValue("Title");

            if (text == null)
            {
                shape.Text = "Title not specified";
            }
            else
            {
                shape.Text = text.ToString();
            }

            shape.SizeToText(new NMarginsF(10));

            // make the URL a tooltip of the shape
            object url = dataRecord.GetColumnValue("URL");

            if (url == null || url.ToString().Length == 0)
            {
                shape.Style.InteractivityStyle = new NInteractivityStyle("URL not specified");
            }
            else
            {
                shape.Style.InteractivityStyle = new NInteractivityStyle(url.ToString());
            }
        }
示例#2
0
 private void btnLoad_Click(object sender, EventArgs e)
 {
     try
     {
         OpenFileDialog fileDialog = new OpenFileDialog();
         //fileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
         fileDialog.InitialDirectory = @"C:\Repo\GitHub\NShape Source Files\ElectricalConnectors";
         fileDialog.DefaultExt       = "gdi";
         fileDialog.Filter           = "gdi files (*.gdi)|*.gdi";
         fileDialog.FilterIndex      = 1;
         if (fileDialog.ShowDialog() == DialogResult.OK)
         {
             using (FileStream fs = new FileStream(fileDialog.FileName, FileMode.Open, FileAccess.Read))
             {
                 XmlSerializer serializer = new XmlSerializer(typeof(NShape));
                 _GDI = (NShape)serializer.Deserialize(fs);
                 PaintGDIPathTree();
                 SendGDIShapeUpdatedMessage();
             }
         }
     }
     catch (Exception ex)
     {
         SendErrorMessage(ex.ToString());
         throw;
     }
 }
示例#3
0
        private void UpdateControlsState()
        {
            // handle single selected node only
            if (view.Selection.NodesCount != 1)
            {
                groupPropertiesGroup.Enabled = false;
                shapePropertiesGroup.Enabled = false;
                return;
            }

            // if the selected node is a group -> update group controls
            NGroup group = (view.Selection.AnchorNode as NGroup);

            if (group != null)
            {
                groupPropertiesGroup.Enabled                = true;
                shapePropertiesGroup.Enabled                = false;
                autoUpdateModelBoundsCheckBox.Checked       = group.AutoUpdateModelBounds;
                resizeAggregatedModelsComboBox.SelectedItem = group.ResizeAggregatedModels;
                return;
            }

            // if the selected node is a simple shape -> update shape controls
            NShape shape = (view.Selection.AnchorNode as NShape);

            if (shape != null)
            {
                groupPropertiesGroup.Enabled           = false;
                shapePropertiesGroup.Enabled           = true;
                resizeInAggregateComboBox.SelectedItem = shape.ResizeInAggregate;
                return;
            }
        }
示例#4
0
        protected override void InitDiagram()
        {
            base.InitDiagram();

            NDrawing drawing    = m_DrawingDocument.Content;
            NPage    activePage = drawing.ActivePage;

            // hide the grid
            drawing.ScreenVisibility.ShowGrid = false;

            NBasicShapeFactory basicShapesFactory = new NBasicShapeFactory();

            NShape shape1 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle);

            shape1.SetBounds(10, 10, 600, 1000);

            NTextBlock textBlock = new NTextBlock();

            shape1.TextBlock  = textBlock;
            textBlock.Padding = new NMargins(20);
            textBlock.Content.Blocks.Clear();
            textBlock.Content.HorizontalAlignment = ENAlign.Left;
            AddFormattedTextToContent(textBlock.Content);
            drawing.ActivePage.Items.Add(shape1);
        }
示例#5
0
        private void graphPartCheck_CheckedChanged(object sender, System.EventArgs e)
        {
            if (EventsHandlingPaused)
            {
                return;
            }

            NShape shape = (view.Selection.AnchorNode as NShape);

            if (shape == null)
            {
                return;
            }

            shape.GraphPart = graphPartCheck.Checked;
            if (shape.GraphPart == false)
            {
                shape.Text = "No";
            }
            else
            {
                shape.Text = "";
            }

            UpdateHighlights();
        }
示例#6
0
        private void OnNodeMouseDown(NNodeMouseEventArgs args)
        {
            NShape shape = args.Node as NShape;

            if (shape == null)
            {
                return;
            }

            if (shape.StyleSheetName == "reserved")
            {
                shape.Tag            = false;
                shape.StyleSheetName = "free";
                m_nFreeSeats++;
                m_nReservedSeats--;
                m_nRevenue -= 50;
            }
            else
            {
                shape.StyleSheetName = "reserved";
                m_nFreeSeats--;
                m_nReservedSeats++;
                m_nRevenue += 50;
            }

            UpdateTexts();
            view.Refresh();
        }
示例#7
0
        public static void DrawGrid(Graphics g, Size canvasSize, NShape gdiShape, float multiplier)
        {
            using (GraphicsPath path = new GraphicsPath())
            {
                float xAxis = canvasSize.Width / 2;
                float yAxis = canvasSize.Height / 2;

                if (gdiShape.XAxisGridMultiple > 0)
                {
                    for (float i = xAxis; i > 0; i -= (gdiShape.XAxisGridMultiple * multiplier))
                    {
                        path.StartFigure();
                        path.AddLine(new PointF(i, 0), new PointF(i, canvasSize.Height));
                        path.CloseFigure();
                    }

                    for (float i = xAxis; i < canvasSize.Width; i += (gdiShape.XAxisGridMultiple * multiplier))
                    {
                        path.StartFigure();
                        path.AddLine(new PointF(i, 0), new PointF(i, canvasSize.Height));
                        path.CloseFigure();
                    }
                }

                if (gdiShape.YAxisGridMultiple > 0)
                {
                    for (float i = yAxis; i > 0; i -= (gdiShape.YAxisGridMultiple * multiplier))
                    {
                        path.StartFigure();
                        path.AddLine(new PointF(0, i), new PointF(canvasSize.Width, i));
                        path.CloseFigure();
                    }

                    for (float i = yAxis; i < canvasSize.Height; i += (gdiShape.YAxisGridMultiple * multiplier))
                    {
                        path.StartFigure();
                        path.AddLine(new PointF(0, i), new PointF(canvasSize.Width, i));
                        path.CloseFigure();
                    }
                }

                PaintGraphicsPath(g, path, Color.LightGray, .001f, Color.White);

                path.Reset();

                if (gdiShape.XAxisGridMultiple > 0)
                {
                    path.StartFigure();
                    path.AddLine(new PointF(xAxis, 0), new PointF(xAxis, canvasSize.Height));
                    path.CloseFigure();
                }
                if (gdiShape.YAxisGridMultiple > 0)
                {
                    path.StartFigure();
                    path.AddLine(new PointF(0, yAxis), new PointF(canvasSize.Width, yAxis));
                    path.CloseFigure();
                }
                PaintGraphicsPath(g, path, Color.Black, .001f, Color.White);
            }
        }
示例#8
0
        protected NShape CreateComputer()
        {
            NNetworkShapeFactory networkShapes = new NNetworkShapeFactory();
            NShape computerShape = networkShapes.CreateShape((int)ENNetworkShape.Computer);

            return(computerShape);
        }
        private void protectionListBox_CheckedChanged(object sender, Nevron.UI.WinForm.Controls.NListBoxItemCheckEventArgs e)
        {
            if (EventsHandlingPaused)
            {
                return;
            }

            NShape shape = (view.Selection.AnchorNode as NShape);

            if (shape == null)
            {
                return;
            }

            PauseEventsHandling();

            for (int i = 0; i < protectionListBox.Items.Count; i++)
            {
                NListBoxItem item = protectionListBox.Items[i];

                NAbilities protection = shape.Protection;
                if (item.Checked)
                {
                    protection.Mask = protection.Mask | (AbilitiesMask)item.Tag;
                }
                else
                {
                    protection.Mask = protection.Mask & ~(AbilitiesMask)item.Tag;
                }
                shape.Protection = protection;
            }

            document.SmartRefreshAllViews();
            ResumeEventsHandling();
        }
        private void EventSinkService_NodeSelected(NNodeEventArgs args)
        {
            PauseEventsHandling();

            if (view.Selection.AnchorNode is NRoutableConnector)
            {
                obstacleGroup.Visible = false;
                routeGroup.Visible    = true;

                NRoutableConnector routableConnector = (view.Selection.AnchorNode as NRoutableConnector);
                routeTypeCombo.SelectedIndex = (int)routableConnector.ConnectorType;
                routeModeCombo.SelectedIndex = (int)routableConnector.RerouteAutomatically;
            }
            else if (NFilters.Shape2D.Filter(view.Selection.AnchorNode))
            {
                obstacleGroup.Visible = true;
                routeGroup.Visible    = false;

                NShape obstacle = (view.Selection.AnchorNode as NShape);
                obstacleTypeCombo.SelectedIndex = (int)obstacle.RouteObstacleType;
            }
            else
            {
                obstacleGroup.Visible = false;
                routeGroup.Visible    = false;
            }

            ResumeEventsHandling();
        }
示例#11
0
        private NGroup CreateStartElement(string text)
        {
            NGroup group = new NGroup();

            NDrawingView1.Document.ActiveLayer.AddChild(group);

            // Create the ellipse shape
            NShape ellipseShape = new NEllipseShape(0, 0, 1, 1);

            group.Shapes.AddChild(ellipseShape);
            ellipseShape.Text = text;
            ellipseShape.SizeToText(new NMarginsF(100, 18, 10, 18));
            ellipseShape.Location = new NPointF(0, 0);

            // Create the check shape
            NBrainstormingShapesFactory brainstormingFactory = new NBrainstormingShapesFactory(NDrawingView1.Document);
            NShape checkShape = brainstormingFactory.CreateShape(BrainstormingShapes.Check);

            checkShape.Bounds = new NRectangleF(26, 12, 24, 23);
            group.Shapes.AddChild(checkShape);

            // Create the ports
            CreatePorts(group, ellipseShape);

            // Set the protections
            SetProtections(group);
            group.UpdateModelBounds();

            return(group);
        }
        private NGroup CreateSubgroup(string name)
        {
            NGroup subgroup = new NGroup();

            subgroup.Name = name;

            // Create 2 shapes
            NShape shape1 = CreateShape(name + "a");

            shape1.Location = new NPointF(0, 0);
            subgroup.Shapes.AddChild(shape1);

            NShape shape2 = CreateShape(name + "b");

            shape2.Location = new NPointF(110, 110);
            subgroup.Shapes.AddChild(shape2);

            // Create the decorators
            CreateDecorators(subgroup, subgroup.Name + " Subgroup");

            // Update the model bounds so that the shapes are inside the specified padding
            subgroup.Padding = new Nevron.Diagram.NMargins(5, 5, 30, 5);
            subgroup.UpdateModelBounds();

            return(subgroup);
        }
        private void InitDocument()
        {
            NDrawingDocument document = NDrawingView1.Document;

            document.Width  = 650;
            document.Height = 650;

            // Create the A group
            NGroup groupA = CreateGroup("A");

            groupA.Location = new NPointF(10, 10);
            document.ActiveLayer.AddChild(groupA);

            // Create the B group
            NGroup groupB = CreateGroup("B");

            groupB.Location = new NPointF(10, 350);
            document.ActiveLayer.AddChild(groupB);

            // Connect some shapes
            NGroup subgroupA1 = (NGroup)groupA.Shapes.GetChildAt(0);
            NShape shapeA1a   = (NShape)subgroupA1.Shapes.GetChildAt(0);
            NGroup subgroupA2 = (NGroup)groupA.Shapes.GetChildAt(1);
            NShape shapeA2a   = (NShape)subgroupA2.Shapes.GetChildAt(0);

            Connect(shapeA1a, shapeA2a);

            NGroup subgroupB2 = (NGroup)groupB.Shapes.GetChildAt(1);
            NShape shapeB2a   = (NShape)subgroupB2.Shapes.GetChildAt(0);

            Connect(shapeA2a, shapeB2a);
        }
示例#14
0
        private void OnVertexImported(NDataSourceImporter importer, NShape shape, INDataRecord dataRecord)
        {
            // Create a shape to host in the group based on the value of the "Type" column
            NShape innerShape = null;

            switch (dataRecord.GetColumnValue("Type").ToString())
            {
            case "DB":
                innerShape = m_FilesAndFoldersFactory.CreateShape(FilesAndFoldersShapes.Binder);
                break;

            case "File":
                innerShape = m_FilesAndFoldersFactory.CreateShape(FilesAndFoldersShapes.SimpleFolder);
                break;

            case "Report":
                innerShape = m_FilesAndFoldersFactory.CreateShape(FilesAndFoldersShapes.BlankFile);
                break;
            }

            innerShape.Text = dataRecord.GetColumnValue("Id").ToString();

            // Host the created shape in the group
            NGroup group = (NGroup)shape;

            group.Shapes.AddChild(innerShape);
            group.UpdateModelBounds();
        }
        protected override void InitDiagram()
        {
            base.InitDiagram();

            NDrawing drawing    = m_DrawingDocument.Content;
            NPage    activePage = drawing.ActivePage;

            // hide the grid
            drawing.ScreenVisibility.ShowGrid = false;

            string[] tableDescription = new string[] { "Table in Auto Size Mode", "Table in Auto Height Mode", "Table in Fit To Shape Mode" };
            ENTableBlockResizeMode[] tableBlockResizeMode = new ENTableBlockResizeMode[] { ENTableBlockResizeMode.AutoSize, ENTableBlockResizeMode.AutoHeight, ENTableBlockResizeMode.FitToShape };

            double y = 100;

            for (int i = 0; i < 3; i++)
            {
                NShape shape = new NShape();
                shape.SetBounds(new NRectangle(100, y, 300, 300));

                y += 200;

                // create table
                NTableBlock tableBlock = CreateTableBlock(tableDescription[i]);

                tableBlock.Content.AllowSpacingBetweenCells = false;
                tableBlock.ResizeMode = tableBlockResizeMode[i];
                shape.TextBlock       = tableBlock;

                drawing.ActivePage.Items.AddChild(shape);
            }
        }
示例#16
0
        protected override void InitDiagram()
        {
            base.InitDiagram();

            NDrawing drawing    = m_DrawingDocument.Content;
            NPage    activePage = drawing.ActivePage;

            // hide the grid
            drawing.ScreenVisibility.ShowGrid = false;

            // plotter commands
            NBasicShapeFactory basicShapes = new NBasicShapeFactory();

            // create a rounded rect
            NShape rectShape = basicShapes.CreateShape(ENBasicShape.Rectangle);

            rectShape.SetBounds(50, 50, 100, 100);
            rectShape.Text = "Move me close to the star";
            rectShape.GetPortByName("Top").GlueMode = ENPortGlueMode.Outward;
            activePage.Items.Add(rectShape);

            // create a star
            NShape pentagramShape = basicShapes.CreateShape(ENBasicShape.Pentagram);

            pentagramShape.SetBounds(310, 310, 100, 100);
            activePage.Items.Add(pentagramShape);
        }
示例#17
0
        private void anchorIdComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (EventsHandlingPaused)
            {
                return;
            }

            // get the selected shape
            NShape shape = view.Selection.AnchorNode as NShape;

            if (shape == null || shape.Ports == null || shape.Ports.DefaultInwardPort == null)
            {
                return;
            }

            PauseEventsHandling();

            // anchor the default port to the selected element
            NPort port = shape.Ports.DefaultInwardPort as NPort;

            if (anchorIdComboBox.SelectedIndex == -1)
            {
                port.AnchorUniqueId = Guid.Empty;
            }
            else
            {
                port.AnchorUniqueId = (anchorIdComboBox.SelectedItem as NDiagramElement).UniqueId;
            }

            ResumeEventsHandling();
            document.SmartRefreshAllViews();
        }
示例#18
0
        private void portOffsetYNumeric_ValueChanged(object sender, System.EventArgs e)
        {
            if (EventsHandlingPaused)
            {
                return;
            }

            // get the selected shape
            NShape shape = view.Selection.AnchorNode as NShape;

            if (shape == null || shape.Ports == null || shape.Ports.DefaultInwardPort == null)
            {
                return;
            }

            PauseEventsHandling();

            // change the port Y offset
            NPort port = shape.Ports.DefaultInwardPort as NPort;

            port.Offset = new NSizeF(port.Offset.Width, (float)portOffsetYNumeric.Value);

            ResumeEventsHandling();
            document.SmartRefreshAllViews();
        }
示例#19
0
        public static void SaveFiles(NShape nshape, Size canvasSize)
        {
            //string initialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            string initialDirectory = @"C:\Repo\GitHub\NShape Source Files\ElectricalConnectors";
            string fileName         = nshape.Name.Replace(" ", "");

            Action <string> save = (s) =>
            {
                string directory    = Path.GetDirectoryName(s);
                string baseFileName = Path.GetFileNameWithoutExtension(s);
                SaveGDI(nshape, Path.Combine(Path.Combine(directory, "GDI"), baseFileName + ".gdi"));
                float resourceImageMultiple = 1;
                int   maxSize = 60;
                if (((nshape.Paths[0].WidthF / maxSize * resourceImageMultiple) < 1 ||
                     (nshape.Paths[0].HeightF / maxSize * resourceImageMultiple) < 1))
                {
                    while ((nshape.Paths[0].WidthF / maxSize * resourceImageMultiple) < 1 ||
                           (nshape.Paths[0].HeightF / maxSize * resourceImageMultiple) < 1)
                    {
                        resourceImageMultiple += .01F;
                    }
                    while ((nshape.Paths[0].WidthF / maxSize * resourceImageMultiple) > 1 ||
                           (nshape.Paths[0].HeightF / maxSize * resourceImageMultiple) > 1)
                    {
                        resourceImageMultiple -= .01F;
                    }
                }
                SaveResourceImage(nshape, nshape.Paths[0], Path.Combine(Path.Combine(directory, "Resources"), baseFileName + ".bmp"), (int)Math.Ceiling(nshape.Paths[0].WidthF), (int)Math.Ceiling(nshape.Paths[0].HeightF), ImageFormat.Bmp, resourceImageMultiple);
                SaveTxt(Path.Combine(Path.Combine(directory, "Shapes"), baseFileName + ".cs"), DotNet.GetShapeClass(canvasSize, nshape));
                SaveTxt(Path.Combine(directory, "Initializer.cs"), DotNet.GetNShapeLibraryInitializerClass(canvasSize, nshape));
                SaveTxt(Path.Combine(Path.Combine(directory, "Shapes"), "RectangleFBase.cs"), DotNet.GetRectangleFBaseClass(canvasSize, nshape));
            };

            SaveFileDialog(initialDirectory, fileName, "gdi", NFile.GDIFileDialogExtFilter, save);
        }
示例#20
0
        private void percentPositionNumeric_ValueChanged(object sender, System.EventArgs e)
        {
            if (EventsHandlingPaused)
            {
                return;
            }

            // get the selected shape
            NShape shape = view.Selection.AnchorNode as NShape;

            if (shape == null || shape.Ports == null)
            {
                return;
            }

            // get a logical line port
            NLogicalLinePort port = (shape.Ports.DefaultInwardPort as NLogicalLinePort);

            if (port == null)
            {
                return;
            }

            PauseEventsHandling();

            // change the percent position of a logical line port
            port.Percent = (float)percentPositionNumeric.Value;

            ResumeEventsHandling();
            document.SmartRefreshAllViews();
        }
        /// <summary>
        /// Gets the port with the given name or creates one if a port with the given name
        /// does not exist in the specified shape.
        /// </summary>
        /// <param name="shape"></param>
        /// <param name="member"></param>
        /// <returns></returns>
        private NPort GetOrCreatePort(NShape shape, string member)
        {
            NPort port = shape.GetPortByName(member);

            if (port != null)
            {
                return(port);
            }

            // The port does not exist, so create it
            NLabel label = (NLabel)shape.Widget.GetFirstDescendant(new NLabelByTextFilter(member));

            if (label == null)
            {
                return(null);
            }

            NPairBox    pairBox   = (NPairBox)label.GetFirstAncestor(NPairBox.NPairBoxSchema);
            NStackPanel stack     = (NStackPanel)pairBox.ParentNode;
            double      yRelative = (pairBox.GetAggregationInfo().Index + 0.5) / stack.Count;

            port = new NPort(0.5, yRelative, true);
            port.SetDirection(ENBoxDirection.Right);
            shape.Ports.Add(port);

            return(port);
        }
        /// <summary>
        /// Creates a one to many connector from the member1 of shape1 to
        /// member2 of shape2.
        /// </summary>
        /// <param name="shape1"></param>
        /// <param name="member1"></param>
        /// <param name="shape2"></param>
        /// <param name="member2"></param>
        private void Connect(NShape shape1, string member1, NShape shape2, string member2)
        {
            NRoutableConnector connector = new NRoutableConnector();

            connector.UserClass = ConnectorOneToManyClassName;
            m_DrawingDocument.Content.ActivePage.Items.Add(connector);

            // Get or create the ports
            NPort port1 = GetOrCreatePort(shape1, member1);
            NPort port2 = GetOrCreatePort(shape2, member2);

            if (port1 == null)
            {
                throw new ArgumentException("A member with name '" + member1 + "' not found in shape '" + shape1.Name + "'", "member");
            }

            if (port1 == null)
            {
                throw new ArgumentException("A member with name '" + member2 + "' not found in shape '" + shape2.Name + "'", "member");
            }

            // Connect the ports
            connector.GlueBeginToPort(port1);
            connector.GlueEndToPort(port2);
        }
        protected void InitDocument()
        {
            NDrawingView1.Document.BackgroundStyle.FrameStyle.Visible = false;
            NDrawingView1.Document.AutoBoundsPadding = new Nevron.Diagram.NMargins(10f, 10f, 10f, 10f);
            NDrawingView1.Document.Style.FillStyle   = new NColorFillStyle(Color.White);

            NBasicShapesFactory factory = new NBasicShapesFactory(NDrawingView1.Document);

            NShape outerCircle = factory.CreateShape(BasicShapes.Circle);

            outerCircle.Bounds = new NRectangleF(0f, 0f, 200f, 200f);
            NDrawingView1.Document.ActiveLayer.AddChild(outerCircle);

            NShape rect = factory.CreateShape(BasicShapes.Rectangle);

            rect.Bounds          = new NRectangleF(42f, 42f, 50f, 50f);
            rect.Style.FillStyle = new NColorFillStyle(Color.Orange);
            NDrawingView1.Document.ActiveLayer.AddChild(rect);

            NShape triangle = factory.CreateShape(BasicShapes.Triangle);

            triangle.Bounds          = new NRectangleF(121f, 57f, 60f, 55f);
            triangle.Style.FillStyle = new NColorFillStyle(Color.LightGray);
            NDrawingView1.Document.ActiveLayer.AddChild(triangle);

            NShape pentagon = factory.CreateShape(BasicShapes.Pentagon);

            pentagon.Bounds          = new NRectangleF(60f, 120f, 54f, 50f);
            pentagon.Style.FillStyle = new NColorFillStyle(Color.WhiteSmoke);
            NDrawingView1.Document.ActiveLayer.AddChild(pentagon);

            NDrawingView1.Document.SizeToContent();
        }
            protected void OnMouseEvent(string webControlId, System.Web.HttpContext context, NStateObject state, NCallbackMouseEventArgs args)
            {
                NDiagramSessionStateObject diagramState = state as NDiagramSessionStateObject;

                NNodeList allShapes = diagramState.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.Shape2D);

                NNodeList affectedNodes  = diagramState.HitTest(args);
                NNodeList affectedShapes = affectedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D);

                int length;

                length = allShapes.Count;
                for (int i = 0; i < length; i++)
                {
                    NShape shape = allShapes[i] as NShape;
                    shape.Style.ShadowStyle = null;
                    if (shape.Tag != null)
                    {
                        shape.Style.FillStyle = new NColorFillStyle((Color)shape.Tag);
                    }
                }

                length = affectedShapes.Count;
                for (int i = 0; i < length; i++)
                {
                    NShape shape = affectedShapes[i] as NShape;
                    shape.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.FromArgb(96, Color.Black), new NPointL(3, 3), 1, new NLength(10));
                    NColorFillStyle fs = shape.Style.FillStyle as NColorFillStyle;
                    if (fs != null && fs.Color != Color.White)
                    {
                        shape.Tag             = fs.Color;
                        shape.Style.FillStyle = new NColorFillStyle(Color.YellowGreen);
                    }
                }
            }
示例#25
0
        private NShape CreateFlexiArrow2Shape(NPoint from, NPoint to)
        {
            NShape shape = new NShape();

            shape.Init1DShape(EN1DShapeXForm.Vector);

            shape.Height = 0;
            shape.BeginX = from.X;
            shape.BeginY = from.Y;
            shape.EndX   = to.X;
            shape.EndY   = to.Y;

            // add controls
            NControl controlPoint = new NControl();

            controlPoint.SetFx("X", "13.0956");
            controlPoint.SetFx("Y", "Height*0.75");
            controlPoint.Visible   = true;
            controlPoint.XBehavior = ENCoordinateBehavior.OffsetFromMin;
            controlPoint.YBehavior = ENCoordinateBehavior.OffsetFromMid;
            controlPoint.Tooltip   = "Modify arrowhead 1";
            shape.Controls.AddChild(controlPoint);

            controlPoint = new NControl();
            controlPoint.SetFx("X", "Width-40");
            controlPoint.SetFx("Y", "Height*1");
            controlPoint.Visible   = true;
            controlPoint.XBehavior = ENCoordinateBehavior.OffsetFromMax;
            controlPoint.YBehavior = ENCoordinateBehavior.OffsetFromMid;
            controlPoint.Tooltip   = "Modify arrowhead 2";
            shape.Controls.AddChild(controlPoint);

            controlPoint = new NControl();
            controlPoint.SetFx("X", "Width-20");
            controlPoint.SetFx("Y", "Height*1");
            controlPoint.Visible   = true;
            controlPoint.XBehavior = ENCoordinateBehavior.OffsetFromMax;
            controlPoint.YBehavior = ENCoordinateBehavior.OffsetFromMid;
            controlPoint.Tooltip   = "Modify arrowhead 3";
            shape.Controls.AddChild(controlPoint);

            // add a geometry
            NGeometry geometry   = new NGeometry();
            NMoveTo   plotFigure =
                geometry.MoveTo("Width*0", "Height*0.5");

            geometry.LineTo("Controls.0.X", "ABS(Controls.0.Y)");
            geometry.LineTo("Controls.1.X", "ABS(Controls.1.Y)");
            geometry.LineTo("Controls.2.X", "ABS(Controls.2.Y)");
            geometry.LineTo("Width", "Height*0.5");
            geometry.LineTo("Controls.2.X", "Height-Geometry.3.Y");
            geometry.LineTo("Controls.1.X", "Height-Geometry.2.Y");
            geometry.LineTo("Controls.0.X", "Height-Geometry.1.Y");
            geometry.LineTo("Geometry.0.X", "Geometry.0.Y");
            plotFigure.CloseFigure = true;
            shape.Geometry         = geometry;

            return(shape);
        }
示例#26
0
        protected override void InitDiagram()
        {
            const double XStep = 150;
            const double YStep = 100;

            base.InitDiagram();

            m_DrawingDocument.HistoryService.Pause();
            try
            {
                NDrawing drawing    = m_DrawingDocument.Content;
                NPage    activePage = drawing.ActivePage;

                // Hide grid and ports
                drawing.ScreenVisibility.ShowGrid  = false;
                drawing.ScreenVisibility.ShowPorts = false;

                // Create all shapes
                NCalloutShapeFactory factory = new NCalloutShapeFactory();
                factory.DefaultSize = new NSize(70, 70);

                double x = 0;
                double y = 0;

                for (int i = 0; i < factory.ShapeCount; i++)
                {
                    NShape shape = factory.CreateShape(i);
                    shape.HorizontalPlacement = ENHorizontalPlacement.Center;
                    shape.VerticalPlacement   = ENVerticalPlacement.Center;
                    shape.Tooltip             = new NTooltip(factory.GetShapeInfo(i).Name);
                    activePage.Items.Add(shape);

                    if (shape.ShapeType == ENShapeType.Shape1D)
                    {
                        shape.SetBeginPoint(new NPoint(x, y));
                        shape.SetEndPoint(new NPoint(x + shape.Width, y + shape.Height));
                    }
                    else
                    {
                        shape.SetBounds(x, y, shape.Width, shape.Height);
                    }

                    x += XStep;
                    if (x > activePage.Width)
                    {
                        x  = 0;
                        y += YStep;
                    }
                }

                // size page to content
                activePage.Layout.ContentPadding = new NMargins(70, 60, 70, 60);
                activePage.SizeToContent();
            }
            finally
            {
                m_DrawingDocument.HistoryService.Resume();
            }
        }
        protected override void InitDiagram()
        {
            base.InitDiagram();

            const double width    = 40;
            const double height   = 40;
            const double distance = 80;

            NBasicShapeFactory basicShapes = new NBasicShapeFactory();
            NPage activePage = m_DrawingDocument.Content.ActivePage;

            int[]    from = new int[] { 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6 };
            int[]    to = new int[] { 2, 3, 4, 4, 5, 6, 7, 5, 9, 8, 9 };
            NShape[] shapes = new NShape[9];
            int      vertexCount = shapes.Length, edgeCount = from.Length;
            int      i, j, count = vertexCount + edgeCount;

            for (i = 0; i < count; i++)
            {
                if (i < vertexCount)
                {
                    j         = vertexCount % 2 == 0 ? i : i + 1;
                    shapes[i] = basicShapes.CreateShape(ENBasicShape.Rectangle);

                    if (vertexCount % 2 != 0 && i == 0)
                    {
                        shapes[i].SetBounds(new NRectangle(
                                                (width + (distance * 1.5)) / 2,
                                                distance + (j / 2) * (distance * 1.5),
                                                width,
                                                height));
                    }
                    else
                    {
                        shapes[i].SetBounds(new NRectangle(
                                                width / 2 + (j % 2) * (distance * 1.5),
                                                height + (j / 2) * (distance * 1.5),
                                                width,
                                                height));
                    }

                    activePage.Items.Add(shapes[i]);
                }
                else
                {
                    NRoutableConnector edge = new NRoutableConnector();
                    edge.UserClass = "Connector";
                    activePage.Items.Add(edge);
                    edge.GlueBeginToShape(shapes[from[i - vertexCount] - 1]);
                    edge.GlueEndToShape(shapes[to[i - vertexCount] - 1]);
                }
            }

            // arrange diagram
            ArrangeDiagram();

            // fit active page
            m_DrawingDocument.Content.ActivePage.ZoomMode = ENZoomMode.Fit;
        }
示例#28
0
        protected override void InitDiagram()
        {
            base.InitDiagram();

            m_DrawingDocument.HistoryService.Pause();
            try
            {
                NDrawing drawing    = m_DrawingDocument.Content;
                NPage    activePage = drawing.ActivePage;

                // Hide grid and ports
                drawing.ScreenVisibility.ShowGrid  = false;
                drawing.ScreenVisibility.ShowPorts = false;

                // Create all shapes
                NArrowShapeFactory factory = new NArrowShapeFactory();
                factory.DefaultSize = new NSize(60, 60);

                int    row = 0, col = 0;
                double cellWidth  = 180;
                double cellHeight = 120;

                for (int i = 0; i < factory.ShapeCount; i++, col++)
                {
                    NShape shape = factory.CreateShape(i);
                    shape.HorizontalPlacement = ENHorizontalPlacement.Center;
                    shape.VerticalPlacement   = ENVerticalPlacement.Center;
                    shape.Text = factory.GetShapeInfo(i).Name;
                    MoveTextBelowShape(shape);
                    activePage.Items.Add(shape);

                    if (col >= 5)
                    {
                        row++;
                        col = 0;
                    }

                    NPoint beginPoint = new NPoint(50 + col * cellWidth, 50 + row * cellHeight);
                    if (shape.ShapeType == ENShapeType.Shape1D)
                    {
                        NPoint endPoint = beginPoint + new NPoint(cellWidth - 100, cellHeight - 100);
                        shape.SetBeginPoint(beginPoint);
                        shape.SetEndPoint(endPoint);
                    }
                    else
                    {
                        shape.SetBounds(beginPoint.X, beginPoint.Y, shape.Width, shape.Height);
                    }
                }

                // size page to content
                activePage.Layout.ContentPadding = new NMargins(40);
                activePage.SizeToContent();
            }
            finally
            {
                m_DrawingDocument.HistoryService.Resume();
            }
        }
示例#29
0
 public NPerson(string name, NShape shape)
 {
     m_Shape      = shape;
     m_Shape.Text = name;
     m_Name       = name;
     m_Friends    = new List <NPerson>();
     m_Family     = null;
 }
示例#30
0
        protected virtual void OnAddLargeItemButtonClick(NEventArgs args)
        {
            NShape item = CreateShape();

            item.Width  = 60;
            item.Height = 60;
            m_DrawingDocument.Content.ActivePage.Items.Add(item);
            ArrangeDiagram();
        }