Beispiel #1
0
        private NTableShape CreateTableShape()
        {
            NTableShape shape = new NTableShape();

            shape.Name = "Table";
            document.ActiveLayer.AddChild(shape);

            shape.InitTable(TABLE_COLS, TABLE_ROWS);
            shape.BeginUpdate();

            int    i, j, index;
            int    colorCount = COLORS.Length;
            Random random     = new Random();

            for (i = 0; i < TABLE_ROWS; i++)
            {
                for (j = 0; j < TABLE_COLS; j++)
                {
                    shape[j, i].Text = CELL_TEXT;
                    index            = random.Next(colorCount);
                    cells[index]++;
                    shape[j, i].StyleSheetName = COLORS[index].ToString();
                }
            }

            shape.EndUpdate();
            return(shape);
        }
Beispiel #2
0
        private NTableShape CreateTableShape()
        {
            NTableShape shape = new NTableShape();

            document.ActiveLayer.AddChild(shape);

            shape.InitTable(ColCount, RowCount);
            shape.BeginUpdate();

            int    i, j, index;
            int    colorCount = GradientSchemes.Length;
            Random random     = new Random();

            for (i = 0; i < RowCount; i++)
            {
                for (j = 0; j < ColCount; j++)
                {
                    shape[j, i].Text = CellText;
                    index            = random.Next(colorCount);
                    cells[index]++;
                    shape[j, i].StyleSheetName = GradientSchemes[index].ToString();
                }
            }

            shape.EndUpdate();
            ApplyProtections(shape);

            return(shape);
        }
        private void InitTableShape(NTableShape shape, NEmployee employee)
        {
            string stylesheetName = employee.Position.ToUpper();

            if (stylesheetName.StartsWith("VP"))
            {
                stylesheetName = "VP";
            }

            shape.Name = employee.Name;
            shape.Tag  = employee;
            shape.InitTable(2, 2);
            shape.BeginUpdate();
            shape.ShowGrid    = false;
            shape.CellMargins = new Nevron.Diagram.NMargins(2);

            NTableColumn column = (NTableColumn)shape.Columns.GetChildAt(1);

            column.SizeMode = TableColumnSizeMode.Fixed;
            column.Width    = 108;

            shape[0, 0].Margins        = new Nevron.Diagram.NMargins(5);
            shape[0, 0].RowSpan        = 2;
            shape[0, 0].Bitmap         = new Bitmap(this.MapPathSecure(employee.PhotoFileName));
            shape[0, 0].Borders        = TableCellBorder.All;
            shape[1, 0].Text           = employee.Position;
            shape[1, 1].Text           = employee.Name;
            shape[1, 0].StyleSheetName = "POSITION";
            shape[1, 1].StyleSheetName = "NAME";
            shape.StyleSheetName       = stylesheetName;
            shape.EndUpdate();

            shape.Ports.DefaultInwardPortUniqueId = ((NPort)shape.Ports.GetChildByName("Bottom")).UniqueId;
        }
        private NTableShape CreateBoardShape(NDrawingDocument document, NClickomaniaGame game)
        {
            NTableShape shape = new NTableShape();

            shape.Name = "Table";

            shape.InitTable(TableColumns, TableRows);
            shape.BeginUpdate();

            int    i, j, index;
            int    colorCount = GradientSchemes.Length;
            Random random     = new Random();

            for (i = 0; i < TableRows; i++)
            {
                for (j = 0; j < TableColumns; j++)
                {
                    shape[j, i].Text = CellText;
                    index            = random.Next(colorCount);
                    game.CellCount[index]++;
                    shape[j, i].StyleSheetName = GradientSchemes[index].ToString();
                }
            }

            game.BoardShape = shape;
            document.ActiveLayer.AddChild(shape);

            shape.EndUpdate();
            return(shape);
        }
        private NTableShape CreateShape(Match m)
        {
            NDrawingDocument document = DrawingView.Document;
            NTableShape      table    = new NTableShape();

            document.ActiveLayer.AddChild(table);

            table.InitTable(3, 2);
            table.BeginUpdate();

            table.CellPadding = new Nevron.Diagram.NMargins(2);
            table.ShowGrid    = false;

            NTableColumn column = (NTableColumn)table.Columns.GetChildAt(1);

            column.SizeMode = TableColumnSizeMode.Fixed;
            column.Width    = 90;

            table[0, 0].Bitmap = FLAGS[m.team1];
            table[1, 0].Text   = m.team1;
            table[2, 0].Text   = m.score1.ToString();

            table[0, 1].Bitmap = FLAGS[m.team2];
            table[1, 1].Text   = m.team2;
            table[2, 1].Text   = m.score2.ToString();

            // write the winner in bold
            if (m.score1 > m.score2)
            {
                table[1, 0].Text = "<b>" + table[1, 0].Text + "</b>";
                table[2, 0].Text = "<b>" + table[2, 0].Text + "</b>";
            }
            else
            {
                table[1, 1].Text = "<b>" + table[1, 1].Text + "</b>";
                table[2, 1].Text = "<b>" + table[2, 1].Text + "</b>";
            }

            // make all cells transparent so that the background of the table is visible
            int i, j;
            int rowCount = table.RowCount, colCount = table.ColumnCount;

            for (i = 0; i < rowCount; i++)
            {
                for (j = 0; j < colCount; j++)
                {
                    table[j, i].StyleSheetName = "transparent";
                }
            }

            table.EndUpdate();
            table.Ports.DefaultInwardPortUniqueId = ((NPort)table.Ports.GetChildByName("Right")).UniqueId;

            return(table);
        }
Beispiel #6
0
        private void InitDocument()
        {
            document.Style.TextStyle.FontStyle.InitFromFont(new Font("Arial Narrow", 8));

            NBasicShapesFactory factory = new NBasicShapesFactory(document);

            factory.DefaultSize = new NSizeF(80, 60);

            int    count = factory.ShapesCount;
            NShape shape = null;

            for (int i = 0; i < count; i++)
            {
                // create a basic shape
                shape      = factory.CreateShape(i);
                shape.Text = shape.Name;

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

            // Add some content to the table shape
            NTableShape table = (NTableShape)shape;

            table.InitTable(2, 2);
            table.BeginUpdate();
            table.CellMargins          = new Nevron.Diagram.NMargins(8);
            table[0, 0].Text           = "Cell 1";
            table[1, 0].Text           = "Cell 2";
            table[0, 1].Text           = "Cell 3";
            table[1, 1].Text           = "Cell 4";
            table.PortDistributionMode = TablePortDistributionMode.CellBased;
            table.EndUpdate();

            // layout the shapes in the active layer using a table layout
            NTableLayout layout = new NTableLayout();

            // setup the table layout
            layout.Direction     = LayoutDirection.LeftToRight;
            layout.ConstrainMode = CellConstrainMode.Ordinal;
            layout.MaxOrdinal    = 5;
            layout.HorizontalContentPlacement = ContentPlacement.Center;
            layout.VerticalContentPlacement   = ContentPlacement.Center;
            layout.VerticalSpacing            = 20;
            layout.HorizontalSpacing          = 20;

            // get the shapes to layout
            NNodeList shapes = document.ActiveLayer.Children(NFilters.Shape2D);

            // layout the shapes
            layout.Layout(shapes, new NDrawingLayoutContext(document));

            // resize document to fit all shapes
            document.SizeToContent();
        }
        private NTableShape CreateInfoShape(NDrawingDocument document, NClickomaniaGame game)
        {
            NTableShape shape = new NTableShape();

            shape.Name = "Info";

            int i;
            int count = GradientSchemes.Length;

            shape.InitTable(2, count + 2);
            shape.BeginUpdate();

            shape.ShowGrid = false;

            NTableCell headerCell = shape[0, 0];

            headerCell.ColumnSpan = 2;
            headerCell.Padding    = new Nevron.Diagram.NMargins(2, 2, 2, 0);
            headerCell.Borders    = TableCellBorder.Bottom;
            headerCell.Text       = "Cells:";

            for (i = 0; i < count; i++)
            {
                NTableCell colorCell = shape[0, i + 1];
                colorCell.Text           = CellText;
                colorCell.StyleSheetName = GradientSchemes[i].ToString();
                colorCell.Margins        = new Nevron.Diagram.NMargins(4, 4, 4, 4);
                colorCell.Borders        = TableCellBorder.All;

                NTableCell countCell = shape[1, i + 1];
                countCell.Text = game.CellCount[i].ToString();
            }

            NTableCell scoreCell = shape[0, i + 1];

            scoreCell.ColumnSpan = 2;
            scoreCell.Padding    = new Nevron.Diagram.NMargins(2, 2, 2, 0);
            scoreCell.Borders    = TableCellBorder.Top;
            scoreCell.Text       = String.Format("Score:{0}{1}", Environment.NewLine, game.Score);

            game.InfoShape = shape;
            document.ActiveLayer.AddChild(shape);

            shape.EndUpdate();
            return(shape);
        }
Beispiel #8
0
        private void CreateSourceScene()
        {
            sourceDocument.AutoBoundsMode = AutoBoundsMode.CustomNonConstrained;

            NRectangleF cell;
            int         row = 0, col = 0;
            int         width = (sourceView.Width - 40) / 3;

            NShape shape = null;
            NBasicShapesFactory factory = new NBasicShapesFactory(document);

            factory.DefaultSize = new NSizeF(50, 50);

            foreach (BasicShapes basicShape in Enum.GetValues(typeof(BasicShapes)))
            {
                shape        = factory.CreateShape((int)basicShape);
                shape.Bounds = GetGridCell(row, col, new NPointF(0, 0), new NSizeF(50, 50), new NSizeF(10, 10));

                sourceDocument.ActiveLayer.AddChild(shape);
                col++;

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

            // Add some content to the table shape
            NTableShape table = (NTableShape)shape;

            table.InitTable(2, 2);
            table.BeginUpdate();
            table.CellMargins          = new Nevron.Diagram.NMargins(8);
            table[0, 0].Text           = "1";
            table[1, 0].Text           = "2";
            table[0, 1].Text           = "3";
            table[1, 1].Text           = "4";
            table.PortDistributionMode = TablePortDistributionMode.CellBased;
            table.EndUpdate();

            sourceDocument.AutoBoundsMode = AutoBoundsMode.AutoSizeToContent;
            sourceDocument.RefreshAllViews();
        }
Beispiel #9
0
        private NTableShape CreateInfoShape()
        {
            NTableShape shape = new NTableShape();

            document.ActiveLayer.AddChild(shape);

            int i, count = GradientSchemes.Length;

            shape.InitTable(2, count + 2);
            shape.BeginUpdate();

            shape.ShowGrid = false;
            ((NTableColumn)shape.Columns.GetChildAt(0)).SizeMode = TableColumnSizeMode.Fixed;

            shape[0, 0].ColumnSpan = 2;
            shape[0, 0].Padding    = new Nevron.Diagram.NMargins(2, 2, 2, 0);
            shape[0, 0].Borders    = TableCellBorder.Bottom;
            shape[0, 0].Text       = "Cells:";

            for (i = 0; i < count; i++)
            {
                shape[0, i + 1].Text           = " ";
                shape[0, i + 1].StyleSheetName = GradientSchemes[i].ToString();
                shape[0, i + 1].Margins        = new Nevron.Diagram.NMargins(2, 2, 5, 5);
                shape[0, i + 1].Borders        = TableCellBorder.All;
                shape[1, i + 1].Text           = cells[i].ToString();
                shape[1, i + 1].Padding        = new Nevron.Diagram.NMargins(0, 0, 1, 0);
            }

            shape[0, i + 1].ColumnSpan = 2;
            shape[0, i + 1].Padding    = new Nevron.Diagram.NMargins(2, 2, 2, 0);
            shape[0, i + 1].Borders    = TableCellBorder.Top;
            shape[0, i + 1].Text       = string.Format("Score:{0}{1}", Environment.NewLine, score);

            shape.EndUpdate();
            ApplyProtections(shape);

            return(shape);
        }
        protected void InitDocument()
        {
            NDrawingDocument document = NDrawingView1.Document;

            // 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.Style.FillStyle = new NColorFillStyle(Color.Linen);
            document.Style.TextStyle.FontStyle.InitFromFont(new Font("Arial Narrow", 8));
            document.BackgroundStyle.FrameStyle.Visible = false;

            // determine the shapes size and layout options
            NBasicShapesFactory factory = new NBasicShapesFactory(document);
            int maxOrdinal = 0;

            switch (shapeSizeDropDownList.SelectedValue)
            {
            case "Small":
                factory.DefaultSize = new NSizeF(40, 30);
                maxOrdinal          = 7;
                break;

            case "Medium":
                factory.DefaultSize = new NSizeF(80, 60);
                maxOrdinal          = 4;
                break;

            case "Large":
                factory.DefaultSize = new NSizeF(200, 150);
                maxOrdinal          = 1;
                break;

            default:
                throw new NotImplementedException(shapeSizeDropDownList.SelectedValue);
            }

            // create the basic shapes in the active layer
            int    count = factory.ShapesCount;
            NShape shape = null;

            for (int i = 0; i < count; i++)
            {
                // create a basic shape
                shape      = factory.CreateShape(i);
                shape.Text = shape.Name;

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

            // Add some content to the table shape
            NTableShape table = (NTableShape)shape;

            table.InitTable(2, 2);
            table.BeginUpdate();
            table.CellMargins          = new Nevron.Diagram.NMargins(8);
            table[0, 0].Text           = "Cell 1";
            table[1, 0].Text           = "Cell 2";
            table[0, 1].Text           = "Cell 3";
            table[1, 1].Text           = "Cell 4";
            table.PortDistributionMode = TablePortDistributionMode.CellBased;
            table.EndUpdate();

            // 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;

            NLayoutContext layoutContext = new NLayoutContext();

            layoutContext.GraphAdapter         = new NShapeGraphAdapter();
            layoutContext.BodyAdapter          = new NShapeBodyAdapter(document);
            layoutContext.BodyContainerAdapter = new NDrawingBodyContainerAdapter(document);

            layout.Layout(document.ActiveLayer.Children(null), layoutContext);

            // resize document to fit all shapes
            document.SizeToContent();
        }
Beispiel #11
0
        protected void NDrawingView1_AsyncClick(object sender, EventArgs e)
        {
            NCallbackMouseEventArgs args = e as NCallbackMouseEventArgs;

            NNodeList nodes  = NDrawingView1.HitTest(args);
            NNodeList shapes = nodes.Filter(CELL_FILTER);

            if (shapes.Count == 0)
            {
                return;
            }

            NTableCell cell = (NTableCell)shapes[0];

            if (cell.ParentNode.ParentNode != table)
            {
                return;
            }

            if (cell.StyleSheetName != null && cell.StyleSheetName != string.Empty)
            {
                if (CellClicked(cell))
                {
                    UpdateInfo();

                    // Check for end of the game
                    string status = string.Empty;
                    if (AllClear())
                    {
                        score *= 2;
                        status = "You've cleared all cells !!!" + Environment.NewLine;
                    }

                    if (status == string.Empty && GameOver())
                    {
                        status = "Game Over !" + Environment.NewLine;
                    }

                    if (status != string.Empty)
                    {
                        status += "Your score is " + score.ToString();
                        NTableShape gameOver = new NTableShape();
                        document.ActiveLayer.AddChild(gameOver);

                        gameOver.BeginUpdate();
                        gameOver.CellPadding = new Nevron.Diagram.NMargins(2, 2, 8, 8);
                        gameOver[0, 0].Text  = status;

                        NStyle.SetFillStyle(gameOver, new NAdvancedGradientFillStyle(AdvancedGradientScheme.Ocean1, 0));
                        NStyle.SetStrokeStyle(gameOver, new NStrokeStyle(Color.DarkBlue));

                        NTextStyle textStyle = (NTextStyle)table.ComposeTextStyle().Clone();
                        textStyle.FillStyle = new NColorFillStyle(Color.DarkBlue);
                        NStyle.SetTextStyle(gameOver, textStyle);

                        gameOver.EndUpdate();
                        gameOver.Center = table.Center;
                    }
                }
            }
        }
            /// <summary>
            /// Clears all highlighted cells.
            /// </summary>
            public void ClearHighlightedCells()
            {
                int cellCount = m_CellsToClear.Count;

                if (cellCount == 0)
                {
                    return;
                }

                string colorString = BoardShape[m_CellsToClear[0].X, m_CellsToClear[0].Y].StyleSheetName;

                colorString = colorString.Remove(colorString.Length - HighlightedSuffix.Length);
                CellCount[IndexOf(colorString)] -= cellCount;
                Score += cellCount * cellCount;

                for (int i = 0; i < cellCount; i++)
                {
                    NPoint p = m_CellsToClear[i];
                    BoardShape[p.X, p.Y].StyleSheetName = String.Empty;
                }

                // Apply gravity
                ApplyGravity();

                // Update the cell count info
                UpdateInfo();

                // Clear the cells to clear list
                m_CellsToClear.Clear();

                // Check for end of the game
                string status = String.Empty;

                if (AllClear())
                {
                    Score *= 2;
                    status = "You've cleared all cells !!!" + Environment.NewLine;
                }

                if (status == String.Empty && GameOver())
                {
                    status = "Game Over !" + Environment.NewLine;
                }

                if (status != String.Empty)
                {
                    status += "Your score is " + Score.ToString();
                    NTableShape gameOver = new NTableShape();
                    ((NDrawingDocument)BoardShape.Document).ActiveLayer.AddChild(gameOver);

                    gameOver.BeginUpdate();
                    gameOver.CellPadding = new Nevron.Diagram.NMargins(2, 2, 8, 8);
                    gameOver[0, 0].Text  = status;

                    NStyle.SetFillStyle(gameOver, new NAdvancedGradientFillStyle(AdvancedGradientScheme.Mahogany2, 5));
                    NTextStyle textStyle = (NTextStyle)InfoShape.ComposeTextStyle().Clone();
                    textStyle.FillStyle = new NColorFillStyle(Color.White);
                    NStyle.SetTextStyle(gameOver, textStyle);

                    gameOver.EndUpdate();
                    gameOver.Center = BoardShape.Center;
                }
            }