示例#1
0
        private void CreateShapesLayer()
        {
            // create the shapes layer and modify its styles
            shapesLayer      = new NLayer();
            shapesLayer.Name = "Shapes Layer";

            shapesLayer.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(0x00, 0x00, 0xaa));
            shapesLayer.Style.FillStyle   = new NColorFillStyle(Color.FromArgb(0xaa, 0xaa, 0xff));
            shapesLayer.Style.ShadowStyle = new NShadowStyle(
                ShadowType.Solid,
                Color.FromArgb(80, 0, 0, 0),
                new NPointL(3, 3), 1,
                new NLength(1));

            // add it to the document and make it the active one
            document.Layers.AddChild(shapesLayer);
            document.ActiveLayerUniqueId = shapesLayer.UniqueId;

            // create two shapes in it
            NRectangleShape rect = new NRectangleShape(new NRectangleF(60, 60, 70, 70));

            shapesLayer.AddChild(rect);

            NEllipseShape ellipse = new NEllipseShape(new NRectangleF(120, 120, 70, 70));

            shapesLayer.AddChild(ellipse);
        }
示例#2
0
        /// <summary>
        /// Overriden to create the fully connected graph template
        /// </summary>
        /// <param name="document">document in which to create the template</param>
        protected override void CreateTemplate(NDrawingDocument document)
        {
            int       i;
            NShape    vertex;
            NShape    edge;
            NPointF   pt;
            ArrayList vertices = new ArrayList();
            NLayer    layer    = document.ActiveLayer;

            // create the ellipse vertices
            float  curAngle = 0, stepAngle = ((float)Math.PI * 2) / m_nRimNodesCount;
            PointF center = new PointF(Origin.X + m_fRadiusX + VerticesSize.Width / 2,
                                       Origin.Y + m_fRadiusY + VerticesSize.Height / 2);

            for (i = 0; i < m_nRimNodesCount; i++)
            {
                pt = new NPointF(center.X + m_fRadiusX * (float)Math.Cos(curAngle) - VerticesSize.Width / 2,
                                 center.Y + m_fRadiusY * (float)Math.Sin(curAngle) - VerticesSize.Height / 2);

                vertex        = CreateVertex(VerticesShape);
                vertex.Bounds = new NRectangleF(pt, VerticesSize);
                layer.AddChild(vertex);

                vertices.Add(vertex);
                curAngle += stepAngle;
            }

            // connect them
            for (i = 0; i < vertices.Count; i++)
            {
                for (int j = i + 1; j < vertices.Count; j++)
                {
                    edge = CreateEdge(ConnectorType.DynamicPolyline);
                    layer.AddChild(edge);

                    edge.FromShape = (NShape)vertices[i];
                    edge.ToShape   = (NShape)vertices[j];
                }
            }
        }
示例#3
0
        private void InitDocument()
        {
            // we do not need history for this example
            document.HistoryService.Pause();

            // create a layer which to host the desired size rect shape
            NLayer layer = new NLayer();

            document.Layers.AddChild(layer);

            // create the desired size rect shape
            m_DesiredSizeShape = new NRectangleShape(0, 0, 1, 1);
            m_DesiredSizeShape.Style.FillStyle   = new NColorFillStyle(System.Drawing.Color.FromArgb(200, 128, 128, 128));
            m_DesiredSizeShape.Style.StrokeStyle = new NStrokeStyle(1, KnownArgbColorValue.Red);
            m_DesiredSizeShape.Visible           = ShowDesiredSizeCheckBox.Checked;
            layer.AddChild(m_DesiredSizeShape);

            // create a sample diagram
            CreateDiagram();

            // layout it
            LayoutButton.PerformClick();
        }
示例#4
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--;
            }
        }