Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        protected NGroup CreateChildGroup()
        {
            Color color1 = Color.FromArgb(25, 0, 0xbb, 0xbb);
            Color color2 = Color.FromArgb(150, 0, 204, 0);

            NGroup group = new NGroup();

            // create the group frame
            NRectangleF     bounds = base.GetGridCell(0, 0, 1, 1);
            NRectangleShape frame  = new NRectangleShape(bounds);

            frame.Protection      = new NAbilities(AbilitiesMask.Select);
            frame.Style.FillStyle = new NColorFillStyle(color1);
            group.Shapes.AddChild(frame);

            // create the group shapes
            group.Shapes.AddChild(new NRectangleShape(base.GetGridCell(0, 0)));
            group.Shapes.AddChild(new NEllipseShape(base.GetGridCell(0, 1)));
            group.Shapes.AddChild(new NTextShape("Child group", base.GetGridCell(1, 0, 0, 1)));

            // update the group model bounds
            group.UpdateModelBounds();

            // apply styles to the group
            group.Style.FillStyle   = new NColorFillStyle(color2);
            group.Style.StrokeStyle = new NStrokeStyle(1, color2);
            group.Style.TextStyle   = new NTextStyle(new Font("Arial", 10), color2);

            return(group);
        }
Ejemplo n.º 3
0
        private void InitDocument()
        {
            Color color1 = Color.FromArgb(25, 0, 0xaa, 0xaa);
            Color color2 = Color.FromArgb(150, 0, 0, 204);

            NGroup group = new NGroup();

            // create the group frame
            NRectangleF     bounds = base.GetGridCell(0, 0, 2, 3);
            NRectangleShape frame  = new NRectangleShape(bounds);

            frame.Protection      = new NAbilities(AbilitiesMask.Select);
            frame.Style.FillStyle = new NColorFillStyle(color1);
            group.Shapes.AddChild(frame);

            // add some shape to the group
            group.Shapes.AddChild(new NRectangleShape(base.GetGridCell(0, 2)));
            group.Shapes.AddChild(new NEllipseShape(base.GetGridCell(0, 3)));
            group.Shapes.AddChild(new NTextShape("Parent group", GetGridCell(2, 0, 0, 3)));

            // add the child group in the group
            group.Shapes.AddChild(CreateChildGroup());

            // update the group model bounds
            group.UpdateModelBounds();

            // apply styles to the group
            group.Style.FillStyle   = new NColorFillStyle(color2);
            group.Style.StrokeStyle = new NStrokeStyle(color2);
            group.Style.TextStyle   = new NTextStyle(new Font("Arial", 10), color2);

            // add the parent group to the active layer
            document.ActiveLayer.AddChild(group);
        }
Ejemplo n.º 4
0
            protected void UpdateStyles(NStateObject state, NRectangleShape hoverCell)
            {
                bool isCompleted = TestComplete(state);

                NDiagramSessionStateObject diagramState = state as NDiagramSessionStateObject;

                NNodeList allCells = GetAllCells(state);

                for (int i = 0; i < allCells.Count; i++)
                {
                    NRectangleShape cell = allCells[i] as NRectangleShape;
                    if (isCompleted)
                    {
                        cell.Style.FillStyle = completeCellFillStyle;
                    }
                    else
                    {
                        if (hoverCell == null || hoverCell.UniqueId != cell.UniqueId)
                        {
                            cell.Style.FillStyle = emptyCellFillStyle;
                        }
                        else if (TestCanSwap(GetClickedCellCoords(state, cell), GetEmptyCellCoords(state)))
                        {
                            cell.Style.FillStyle = hoverAllowedCellFillStyle;
                        }
                        else
                        {
                            cell.Style.FillStyle = hoverDeniedCellFillStyle;
                        }
                    }
                }

                diagramState.Document.RefreshAllViews();
            }
Ejemplo n.º 5
0
        private void CreateMoveMeShape()
        {
            // create the center shape to which all other shapes connect
            NRectangleF cell = base.GetGridCell(3, 0);

            cell.Inflate(-5, -5);

            NRectangleShape shape = new NRectangleShape(cell);

            shape.Name = "Move Me";
            shape.Text = "Move Me Close to Another Shape";

            shape.Style.FillStyle   = new NColorFillStyle(Color.FromArgb(247, 150, 56));
            shape.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(68, 90, 108));

            // create an outward port
            shape.CreateShapeElements(ShapeElementsMask.Ports);
            NRotatedBoundsPort port = new NRotatedBoundsPort(shape.UniqueId, ContentAlignment.TopCenter);

            port.Type = PortType.Outward;
            shape.Ports.AddChild(port);
            shape.Ports.DefaultOutwardPortUniqueId = port.UniqueId;

            // add it to the active layer and store for reuse
            document.ActiveLayer.AddChild(shape);
            centerShape = shape;
        }
Ejemplo n.º 6
0
            protected NRectangleShape[,] GetLifeMap(NStateObject state)
            {
                NDiagramSessionStateObject diagramState = state as NDiagramSessionStateObject;

                m_Map = new NRectangleShape[boardCellCountWidth, boardCellCountHeight];
                NGroup           cellsGroup = diagramState.Document.ActiveLayer.GetChildByName("cellsGroup", 0) as NGroup;
                NShapeCollection children   = cellsGroup.Shapes;

                if (m_MapShapeIds != null)
                {
                    m_HasReinitialized = false;
                    for (int x = 0; x < boardCellCountWidth; x++)
                    {
                        for (int y = 0; y < boardCellCountHeight; y++)
                        {
                            m_Map[x, y] = children.GetChildFromUniqueId(m_MapShapeIds[x, y]) as NRectangleShape;
                        }
                    }
                    return(m_Map);
                }

                m_MapShapeIds = new Guid[boardCellCountWidth, boardCellCountHeight];
                foreach (NRectangleShape cell in children)
                {
                    string[] tokens = cell.Name.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
                    int      x      = int.Parse(tokens[0]);
                    int      y      = int.Parse(tokens[1]);
                    m_Map[x, y]         = cell;
                    m_MapShapeIds[x, y] = cell.UniqueId;
                }
                ApplyConfigurationCoordinates(m_Map, initialConfigurationCoordinates);
                m_HasReinitialized = true;
                return(m_Map);
            }
Ejemplo n.º 7
0
            protected virtual NDrawingDataObject AdaptMyCustomFormat(NMyDataObject myDataObject)
            {
                if (myDataObject == null)
                {
                    throw new ArgumentNullException("myDataObject");
                }

                // create the respective shape with the specified size
                NShape shape;

                if (myDataObject.shapeType == "Rectangle")
                {
                    shape = new NRectangleShape(new NPointF(0, 0), myDataObject.shapeSize);
                }
                else if (myDataObject.shapeType == "Ellipse")
                {
                    shape = new NEllipseShape(new NPointF(0, 0), myDataObject.shapeSize);
                }
                else
                {
                    return(null);
                }

                // create a drawing data object, which encapsulates the shape
                NDrawingDataObject ddo = new NDrawingDataObject(null, new INDiagramElement[] { shape });

                return(ddo);
            }
Ejemplo n.º 8
0
            public override void OnAsyncClick(string webControlId, System.Web.HttpContext context, NStateObject state, NCallbackMouseEventArgs args)
            {
                // init configuration
                InitializeConfigurationFields(GetBoardCellCount(state));

                // get the shape under the cursor
                NRectangleShape cell = HitTestCell(state, args);

                if (cell == null)
                {
                    return;
                }

                Point clickedCoords = GetClickedCellCoords(state, cell);
                Point emptyCoords   = GetEmptyCellCoords(state);

                bool canSwap = TestCanSwap(clickedCoords, emptyCoords);

                if (!canSwap)
                {
                    return;
                }

                MoveCell(state, cell, clickedCoords);

                UpdateStyles(state, null);
            }
Ejemplo n.º 9
0
            public override void OnAsyncMouseUp(string webControlId, System.Web.HttpContext context, NStateObject state, NCallbackMouseEventArgs args)
            {
                // init configuration
                InitializeConfigurationFields();

                //	toggle the underlying cell
                NRectangleShape cell = HitTestCell(state, args);

                if (cell == null)
                {
                    return;
                }

                if ((CellState)cell.Tag == CellState.PinnedAlive)
                {
                    cell.Tag = CellState.Alive;
                }
                else if ((CellState)cell.Tag == CellState.PinnedDead)
                {
                    cell.Tag = CellState.Dead;
                }
                else
                {
                    return;
                }

                UpdateStyles(state);
            }
Ejemplo n.º 10
0
        private void CreateArchitecturalDocument()
        {
            // set global document styles
            document.Style.TextStyle = new NTextStyle(new Font("Arial", 8.25f));
            document.Style.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Center;
            document.Style.TextStyle.StringFormatStyle.VertAlign = VertAlign.Center;

            // create the rim rect
            NRectangleShape rimRect = new NRectangleShape(new NRectangleF(0, 0, 5, 7));

            rimRect.Style.FillStyle = new NColorFillStyle(Color.FromArgb(0, Color.White));
            document.ActiveLayer.AddChild(rimRect);

            // create the room rects
            NRectangleShape roomRect1 = new NRectangleShape(new NRectangleF(0, 0, 2, 3));

            roomRect1.Text = "Room 1";
            document.ActiveLayer.AddChild(roomRect1);

            NRectangleShape roomRect2 = new NRectangleShape(new NRectangleF(3, 0, 2, 3));

            roomRect2.Text = "Room 2";
            document.ActiveLayer.AddChild(roomRect2);

            NRectangleShape roomRect3 = new NRectangleShape(new NRectangleF(0, 4, 2, 3));

            roomRect3.Text = "Room 3";
            document.ActiveLayer.AddChild(roomRect3);

            // create the stairs case
            NCompositeShape stairCase = new NCompositeShape();

            float stepXSize = 0.7f;
            float stepYSize = 0.25f;

            for (int i = 0; i < 9; i++)
            {
                NRectanglePath step = new NRectanglePath(0, stepYSize * i, stepXSize, stepYSize);
                stairCase.Primitives.AddChild(step);
            }

            stairCase.UpdateModelBounds();
            stairCase.Bounds = new NRectangleF(4, 4, 1, 3);

            stairCase.Text = "Stairs";
            NTextStyle textStyle = (document.Style.TextStyle.Clone() as NTextStyle);

            textStyle.Orientation     = 90;
            stairCase.Style.TextStyle = textStyle;

            document.ActiveLayer.AddChild(stairCase);

            // update the drawing bounds to size to content with some margins
            document.AutoBoundsMinSize = new NSizeF(1, 1);
            document.AutoBoundsPadding = new Nevron.Diagram.NMargins(0.5f);
            document.AutoBoundsMode    = AutoBoundsMode.AutoSizeToContent;
        }
        private void CreateRectangle(int row, int col, AbilitiesMask protection)
        {
            // create a rectangle
            NRectangleShape rect = new NRectangleShape(base.GetGridCell(row, col));

            rect.Protection = new NAbilities(protection);
            rect.Text       = "Protected from: " + protection.ToString();

            document.ActiveLayer.AddChild(rect);
        }
Ejemplo n.º 12
0
 private void CreateTextShape(ref NShape shape)
 {
     shape = new NRectangleShape(0, 0, SEAT_SIZE.Width * 10, SEAT_SIZE.Height);
     NStyle.SetFillStyle(shape, new NColorFillStyle(Color.White));
     NStyle.SetStrokeStyle(shape, new NStrokeStyle(0, Color.White));
     NStyle.SetTextStyle(shape, new NTextStyle());
     shape.Style.TextStyle.StringFormatStyle = new NStringFormatStyle(StringFormatType.GenericTypographic, HorzAlign.Left, VertAlign.Center);
     SetProtections(shape);
     document.ActiveLayer.AddChild(shape);
 }
Ejemplo n.º 13
0
        private void InitDocument()
        {
            NRectangleShape rect1 = new NRectangleShape(new NRectangleF(310, 10, 100, 80));
            NRectangleShape rect2 = new NRectangleShape(new NRectangleF(10, 200, 150, 75));
            NRectangleShape rect3 = new NRectangleShape(new NRectangleF(200, 300, 200, 100));

            document.ActiveLayer.AddChild(rect1);
            document.ActiveLayer.AddChild(rect2);
            document.ActiveLayer.AddChild(rect3);
        }
Ejemplo n.º 14
0
            protected void MoveCell(NStateObject state, NRectangleShape cell, Point clickedCoords)
            {
                Point emptyCellPixelCoords = GetEmptyCellPixelCoords(state);

                //	move the empty cell
                SetEmptyCellPixelCoords(state, new Point((int)cell.Bounds.X, (int)cell.Bounds.Y));
                SetEmptyCellCoords(state, clickedCoords);

                //	move the clicked cell
                cell.Bounds = new NRectangleF(emptyCellPixelCoords.X, emptyCellPixelCoords.Y, cell.Bounds.Width, cell.Bounds.Height);
            }
Ejemplo n.º 15
0
        private void InitDocument()
        {
            NRectangleShape rect1 = new NRectangleShape(new NRectangleF(10, 10, 200, 200));

            rect1.Text = "Change the Auto Bounds Mode and move Me";
            document.ActiveLayer.AddChild(rect1);

            NRectangleShape rect2 = new NRectangleShape(new NRectangleF(310, 310, 200, 200));

            rect2.Text = "Change the Auto Bounds Mode and move Me";
            document.ActiveLayer.AddChild(rect2);
        }
Ejemplo n.º 16
0
            protected void HighliteCell(NStateObject state, NRectangleShape cell)
            {
                NDiagramSessionStateObject diagramState = state as NDiagramSessionStateObject;

                //	obtain/cache life map, create an initial configuration when accessed for the first time
                NRectangleShape[,] map = GetLifeMap(state);

                ClearHighlitsHormatting(map);
                cell.Style.StrokeStyle = highliteCellStrokeStyle;

                diagramState.Document.RefreshAllViews();
            }
Ejemplo n.º 17
0
        protected NGroup CreateCartesianScaleGroup()
        {
            NGroup group = new NGroup();

            // rect 1 uses cartesian scaling
            NRectangleShape rect1 = new NRectangleShape(0, 0, 75, 75);

            rect1.Rotate(CoordinateSystem.Scene, 45, rect1.PinPoint);
            rect1.ResizeInAggregate = ResizeInAggregate.CartesianScale;
            rect1.Text = "Cartesian Scale";
            group.Shapes.AddChild(rect1);

            // rect 2 uses cartesian X scaling and Y reposition
            NRectangleShape rect2 = new NRectangleShape(150, 0, 75, 75);

            rect2.Rotate(CoordinateSystem.Scene, 45, rect2.PinPoint);
            rect2.ResizeInAggregate = ResizeInAggregate.CartesianScaleXRepositionY;
            rect2.Text = "Cartesian Scale X and Reposition Y";
            group.Shapes.AddChild(rect2);

            // rect 3 uses cartesian Y scaling and X reposition
            NRectangleShape rect3 = new NRectangleShape(0, 150, 75, 75);

            rect3.Rotate(CoordinateSystem.Scene, 45, rect3.PinPoint);
            rect3.ResizeInAggregate = ResizeInAggregate.CartesianScaleYRepositionX;
            rect3.Text = "Cartesian Scale Y and Reposition X";
            group.Shapes.AddChild(rect3);

            // rect 4 uses cartesian scale and reposition
            NRectangleShape rect4 = new NRectangleShape(150, 150, 75, 75);

            rect4.Rotate(CoordinateSystem.Scene, 45, rect4.PinPoint);
            rect4.ResizeInAggregate = ResizeInAggregate.CartesianScaleAndReposition;
            rect4.Text = "Cartesian Scale and Reposition";
            group.Shapes.AddChild(rect4);

            // update the group model bounds
            group.UpdateModelBounds();

            // in order to demonstrate the reposition, all shapes
            // are pinned to the bottom rigth corner of the group
            NPointF pin = new NPointF(group.Bounds.Right, group.Bounds.Bottom);

            foreach (NShape shape in group.Shapes)
            {
                shape.PinPoint = pin;
            }

            // add the group to the active layer
            document.ActiveLayer.AddChild(group);
            return(group);
        }
Ejemplo n.º 18
0
        protected NRectangleShape CreateEmptyCell(int x, int y)
        {
            NRectangleShape cell = factory.CreateShape((int)BasicShapes.Rectangle) as NRectangleShape;

            cell.Bounds            = new NRectangleF(boardMarginLeft + cellPixelWidth * x, boardMarginTop + cellPixelWidth * y, cellPixelWidth, cellPixelHeight);
            cell.Style.StrokeStyle = normalCellStrokeStyle;
            cell.Style.FillStyle   = emptyCellFillStyle;
            cell.Style.ShadowStyle = null;
            cell.Name = string.Format("{0}, {1}", x, y);
            cell.Tag  = CellState.Dead;

            NDrawingView1.Document.ActiveLayer.AddChild(cell);
            return(cell);
        }
Ejemplo n.º 19
0
            public override void OnAsyncMouseMove(string webControlId, System.Web.HttpContext context, NStateObject state, NCallbackMouseEventArgs args)
            {
                // init configuration
                InitializeConfigurationFields(GetBoardCellCount(state));

                NRectangleShape cell = HitTestCell(state, args);

                if (cell == null)
                {
                    return;
                }

                UpdateStyles(state, cell);
            }
Ejemplo n.º 20
0
        private NShape CreateShape(string name)
        {
            NShape shape = new NRectangleShape(0, 0, 100, 100);

            shape.Name = name;
            shape.Text = name + " Node";

            // Create a center port
            shape.CreateShapeElements(ShapeElementsMask.Ports);
            NDynamicPort port = new NDynamicPort(new NContentAlignment(0, 0), DynamicPortGlueMode.GlueToContour);

            shape.Ports.AddChild(port);

            return(shape);
        }
Ejemplo n.º 21
0
            public override void OnAsyncMouseMove(string webControlId, System.Web.HttpContext context, NStateObject state, NCallbackMouseEventArgs args)
            {
                // init configuration
                InitializeConfigurationFields();

                //	highlight underlying cell
                NRectangleShape cell = HitTestCell(state, args);

                if (cell == null)
                {
                    return;
                }

                HighliteCell(state, cell);
            }
Ejemplo n.º 22
0
        private void InitDocument()
        {
            NRectangleShape rect1 = new NRectangleShape(new NRectangleF(10, 10, 100, 100));

            document.ActiveLayer.AddChild(rect1);
            rect1.Style.FillStyle = new NColorFillStyle(Color.Red);
            rect1.Protection      = new NAbilities(rect1.Protection.Mask & ~AbilitiesMask.ChangeStyle);

            NRectangleShape rect2 = new NRectangleShape(new NRectangleF(160, 160, 100, 100));

            document.ActiveLayer.AddChild(rect2);
            rect2.Style.FillStyle = new NColorFillStyle(Color.Green);

            view.Selection.SingleSelect(document.ActiveLayer.Children(NFilters.PermissionSelect));
        }
        protected void AddElement(NDrawingDocument document, NChemicalElement ce)
        {
            string str  = ce.number.ToString();
            NSizeF size = new NSizeF(10, 15);

            str += "<br/><font size='14'><b>" + ce.symbol + "</b></font><br/>";
            str += ce.weight;

            NShape element = null;

            element      = new NRectangleShape(GetElementBounds(ce.col, ce.row));
            element.Text = str;
            element.Style.InteractivityStyle = new NInteractivityStyle(true, null, ce.tooltip);
            element.Style.FillStyle          = ce.fillStyle;
            document.ActiveLayer.AddChild(element);
        }
Ejemplo n.º 24
0
        protected void AddElement(NDrawingDocument document, NChemicalElement ce)
        {
            string str  = ce.number.ToString();
            NSizeF size = new NSizeF(10, 15);

            str += "<br/><font size='14'><b>" + ce.symbol + "</b></font><br/>";
            str += ce.weight;

            CursorType ct = CursorType.Default;

            if (ce.fillStyle == fsNonMetals)
            {
                ct = CursorType.Hand;
            }
            else if (ce.fillStyle == fsMetals)
            {
                ct = CursorType.Cross;
            }
            else if (ce.fillStyle == fsMatalloids)
            {
                ct = CursorType.SizeAll;
            }
            else if (ce.fillStyle == fsGases)
            {
                ct = CursorType.VSplit;
            }
            else if (ce.fillStyle == feMoccasin)
            {
                ct = CursorType.HSplit;
            }
            else if (ce.fillStyle == feGold)
            {
                ct = CursorType.Help;
            }
            else if (ce.fillStyle == feCentralGroup)
            {
                ct = CursorType.WaitCursor;
            }

            NShape element = null;

            element      = new NRectangleShape(GetElementBounds(ce.col, ce.row));
            element.Text = str;
            element.Style.InteractivityStyle = new NInteractivityStyle(true, null, null, ct);
            element.Style.FillStyle          = ce.fillStyle;
            document.ActiveLayer.AddChild(element);
        }
Ejemplo n.º 25
0
        private void CreateTree(NGroup group)
        {
            NRectangleShape shape1 = new NRectangleShape(50, 0, 40, 40);
            NRectangleShape shape2 = new NRectangleShape(0, 0, 40, 40);
            NRectangleShape shape3 = new NRectangleShape(50, 50, 40, 40);
            NRectangleShape shape4 = new NRectangleShape(100, 0, 40, 40);

            shape1.Name = "root";

            CreateShapePorts(shape1);
            CreateShapePorts(shape2);
            CreateShapePorts(shape3);
            CreateShapePorts(shape4);

            group.Shapes.AddChild(shape1);
            group.Shapes.AddChild(shape2);
            group.Shapes.AddChild(shape3);
            group.Shapes.AddChild(shape4);

            shape1.Name = group.Name;
            shape1.Text = shape1.Name;

            shape2.Name = group.Name + "1";
            shape2.Text = shape2.Name;

            shape3.Name = group.Name + "2";
            shape3.Text = shape3.Name;

            shape4.Name = group.Name + "3";
            shape4.Text = shape4.Name;

            NRoutableConnector connector = new NRoutableConnector(RoutableConnectorType.DynamicPolyline);

            group.Shapes.AddChild(connector);
            connector.FromShape = shape1;
            connector.ToShape   = shape2;

            connector = new NRoutableConnector(RoutableConnectorType.DynamicPolyline);
            group.Shapes.AddChild(connector);
            connector.FromShape = shape1;
            connector.ToShape   = shape3;

            connector = new NRoutableConnector(RoutableConnectorType.DynamicPolyline);
            group.Shapes.AddChild(connector);
            connector.FromShape = shape1;
            connector.ToShape   = shape4;
        }
Ejemplo n.º 26
0
        private void CreateMetricDocument()
        {
            // set global document styles
            document.Style.TextStyle = new NTextStyle(new Font("Arial", 8.25f));
            document.Style.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Center;
            document.Style.TextStyle.StringFormatStyle.VertAlign = VertAlign.Center;

            // create the rim rect
            NRectangleShape rimRect = new NRectangleShape(0, 0, 140, 140);

            rimRect.Style.FillStyle = new NColorFillStyle(Color.Gray);
            document.ActiveLayer.AddChild(rimRect);

            // create block 1
            NRectangleShape block1 = new NRectangleShape(new NRectangleF(0, 0, 68, 68));

            block1.Style.FillStyle = new NColorFillStyle(Color.Firebrick);
            block1.Text            = "Block 1";
            document.ActiveLayer.AddChild(block1);

            // create block 2
            NRectangleShape block2 = new NRectangleShape(new NRectangleF(72, 0, 68, 68));

            block2.Style.FillStyle = new NColorFillStyle(Color.Firebrick);
            block2.Text            = "Block 2";
            document.ActiveLayer.AddChild(block2);

            // create block 3
            NRectangleShape block3 = new NRectangleShape(new NRectangleF(0, 72, 68, 68));

            block3.Style.FillStyle = new NColorFillStyle(Color.Firebrick);
            block3.Text            = "Block 3";
            document.ActiveLayer.AddChild(block3);

            // create block 3
            NRectangleShape block4 = new NRectangleShape(new NRectangleF(72, 72, 68, 68));

            block4.Style.FillStyle = new NColorFillStyle(Color.Firebrick);
            block4.Text            = "Block 4";
            document.ActiveLayer.AddChild(block4);

            // update the drawing bounds to size to content with some margins
            document.AutoBoundsMinSize = new NSizeF(1, 1);
            document.AutoBoundsPadding = new Nevron.Diagram.NMargins(5f);
            document.AutoBoundsMode    = AutoBoundsMode.AutoSizeToContent;
        }
Ejemplo n.º 27
0
        protected static NRectangleShape CreateCell(NDrawingDocument document, int x, int y, int number)
        {
            NBasicShapesFactory factory = new NBasicShapesFactory(document);

            NRectangleShape cell = factory.CreateShape((int)BasicShapes.Rectangle) as NRectangleShape;

            cell.Bounds            = new NRectangleF(boardMarginLeft + cellPixelWidth * x + boardPadding, boardMarginTop + cellPixelWidth * y + boardPadding, cellPixelWidth, cellPixelHeight);
            cell.Style.StrokeStyle = normalCellStrokeStyle;
            cell.Style.FillStyle   = emptyCellFillStyle;
            cell.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.FromArgb(65, Color.Black), new NPointL(shadowOffset, shadowOffset), 1, new NLength(shadowOffset * 2));
            cell.Name = string.Format("{0}, {1}", x, y);
            cell.Tag  = number;
            cell.Text = number.ToString();

            document.ActiveLayer.AddChild(cell);
            return(cell);
        }
Ejemplo n.º 28
0
        protected void AddElement(NDrawingDocument document, NChemicalElement ce)
        {
            string str  = ce.number.ToString();
            NSizeF size = new NSizeF(10, 15);

            str += "<br/><font size='14'><b>" + ce.symbol + "</b></font><br/>";
            str += ce.weight;

            NShape element = null;

            element      = new NRectangleShape(GetElementBounds(ce.col, ce.row));
            element.Text = str;
            string url = string.Format("http://www.google.com/search?hl=en&q={0}+chemical+element", HttpUtility.UrlEncode(ce.symbol.Replace("*", string.Empty)));

            element.Style.InteractivityStyle = new NInteractivityStyle(true, null, null, CursorType.Default, url);
            element.Style.FillStyle          = ce.fillStyle;
            document.ActiveLayer.AddChild(element);
        }
Ejemplo n.º 29
0
            protected bool TestComplete(NStateObject state)
            {
                Hashtable grid = GetGrid(state);

                NNodeList allCells = GetAllCells(state);

                for (int i = 0; i < allCells.Count; i++)
                {
                    NRectangleShape cell           = allCells[i] as NRectangleShape;
                    Point           coords         = (Point)grid[new Point((int)cell.Bounds.X, (int)cell.Bounds.Y)];
                    int             expectedNumber = coords.X + coords.Y * GetBoardCellCount(state) + 1;
                    if (expectedNumber != (int)cell.Tag)
                    {
                        return(false);
                    }
                }
                return(true);
            }
Ejemplo n.º 30
0
        private void randomRectButton_Click(object sender, System.EventArgs e)
        {
            // create shape
            NRectangleShape shape = null;

            try
            {
                shape = new NRectangleShape(base.GetRandomPoint(view.Viewport), base.GetRandomPoint(view.Viewport));
            }
            catch
            {
                return;
            }

            // add to active layer
            document.ActiveLayer.AddChild(shape);
            document.SmartRefreshAllViews();
        }