private void DrawValues(Graphics g)
        {
            var colsCount = GridCells.GetLength(1);
            var rowsCount = GridCells.GetLength(0);

            for (int y = 0; y < colsCount; y++)
            {
                for (int x = 0; x < rowsCount; x++)
                {
                    var cell = GridCells[x, y];
                    if (cell != null)
                    {
                        var value = cell.Value;
                        if (value is int)
                        {
                            DrawInt(g, x, y, (int)value);
                        }

                        if (value is CellType)
                        {
                            DrawCell(g, x, y, (CellType)value);
                        }
                    }
                }
            }
        }
        public float Minimax(Grid g, out GridCells best, float alpha, float beta, int depth = 1)
        {
            miniMaxCount++;
            best = GridCells.None;
            var bestResult = -10f;
            GridCells garbage;
            if (g.IsDraw)
                return 0f;

            if (g.CurrentIsWinner)
                return 1f / depth;

            if (g.CurrentIsLoser)
                return -1f / depth;

            foreach (var move in g.GetMoves())
            {
                var other = g.MakeMove(move);
                alpha = -Minimax(other, out garbage, -beta, -alpha, depth + 1);

                if (beta <= alpha)
                    return alpha;

                if (alpha > bestResult)
                {
                    best = move;
                    bestResult = alpha;
                }
            }
            return bestResult;
        }
示例#3
0
        private void AddPluginControls(object sender, PluginEventArgs e)
        {
            GridCells cells = new GridCells();

            foreach (IPlugin plugin in e.Plugins)
            {
                var visualPlugin = plugin as IVisualPlugin;
                if (visualPlugin != null)
                {
                    Point freeCell = cells.GetFreeCell(visualPlugin.ColumnSpan);
                    if (freeCell.Y >= PluginsGrid.RowDefinitions.Count)
                    {
                        PluginsGrid.RowDefinitions.Add(new RowDefinition());
                    }
                    PluginsGrid.Children.Add(visualPlugin.Control);
                    Grid.SetColumnSpan(visualPlugin.Control, visualPlugin.ColumnSpan);
                    Grid.SetColumn(visualPlugin.Control, freeCell.X);
                    Grid.SetRow(visualPlugin.Control, freeCell.Y);
                }

                if (plugin is IButtonPlugin buttonPlugin)
                {
                    var button = buttonPlugin.Button;
                    button.Margin = new Thickness(10, 0, 0, 0);
                    ButtonPluginsPanel.Children.Add(button);
                }
            }
        }
示例#4
0
 public Grid(GridCells current, GridCells opponent, bool isO = false)
     : this()
 {
     this.Current    = current;
     this.Opponent   = opponent;
     this.CurrentIsO = isO;
 }
示例#5
0
        public float Minimax(Grid g, out GridCells best, int depth = 1)
        {
            miniMaxCount++;
            best = GridCells.None;
            var       bestResult = -10f;
            GridCells garbage;

            if (g.IsDraw)
            {
                return(0f);
            }

            if (g.CurrentIsWinner)
            {
                return(1f / depth);
            }

            if (g.CurrentIsLoser)
            {
                return(-1f / depth);
            }

            foreach (var move in g.GetMoves())
            {
                var other  = g.MakeMove(move);
                var result = -Minimax(other, out garbage, depth + 1);

                if (result > bestResult)
                {
                    best       = move;
                    bestResult = result;
                }
            }
            return(bestResult);
        }
示例#6
0
        public int Minimax(Grid g, out GridCells best)
        {
            best = GridCells.None;
            var bestResult = -10;
            GridCells garbage;
            if (g.IsDraw)
                return 0;

            if (g.CurrentIsWinner)
                return 1;

            if (g.CurrentIsLoser)
                return -1;

            foreach (var move in g.GetMoves())
            {
                var other = g.MakeMove(move);
                var result = -Minimax(other, out garbage);

                if (result > bestResult)
                {
                    best = move;
                    bestResult = result;
                }
            }
            return bestResult;
        }
示例#7
0
        public int Minimax(Grid g, out GridCells best)
        {
            best = GridCells.None;
            var       bestResult = -10;
            GridCells garbage;

            if (g.IsDraw)
            {
                return(0);
            }

            if (g.CurrentIsWinner)
            {
                return(1);
            }

            if (g.CurrentIsLoser)
            {
                return(-1);
            }

            foreach (var move in g.GetMoves())
            {
                var other  = g.MakeMove(move);
                var result = -Minimax(other, out garbage);

                if (result > bestResult)
                {
                    best       = move;
                    bestResult = result;
                }
            }
            return(bestResult);
        }
示例#8
0
文件: Grid.cs 项目: crmmvio/TicTacToe
 public Grid(GridCells current, GridCells opponent, bool isO = false)
     : this()
 {
     this.Current = current;
     this.Opponent = opponent;
     this.CurrentIsO = isO;
 }
示例#9
0
        /// <summary>
        /// Checks if the new elements are valid for the given collection.
        /// * Index in range
        /// * Index not in use
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="notifyCollectionChangedEventArgs"></param>
        /// <exception cref="NotImplementedException"></exception>
        private void GridCellsOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs)
        {
            if (notifyCollectionChangedEventArgs.OldItems != null && notifyCollectionChangedEventArgs.OldItems.Count != 0)
            {
                foreach (var oldItem in notifyCollectionChangedEventArgs.OldItems)
                {
                    ((GridCell)oldItem).PropertyChanged -= GridCell_OnPropertyChanged;
                }
            }

            if (notifyCollectionChangedEventArgs.NewItems == null ||
                notifyCollectionChangedEventArgs.NewItems.Count == 0)
            {
                return;
            }

            foreach (var newItem in notifyCollectionChangedEventArgs.NewItems)
            {
                ((GridCell)newItem).PropertyChanged += GridCell_OnPropertyChanged;
            }

            if (GridCells.GroupBy(x => x.Coordinates).Any(x => x.Count() > 1))
            {
                throw new InvalidOperationException($"Cannot add multiple cells with the same coordinates.");
            }

            if (GridCells.Any(
                    c => c.Coordinates.X >= GridColDefinitions.Count && GridColDefinitions.Count != 0 ||
                    c.Coordinates.Y >= GridRowDefinitions.Count && GridRowDefinitions.Count != 0))
            {
                throw new InvalidOperationException("Cannot add cell to a coordinate that doesnt exist.");
            }
        }
示例#10
0
        public void DrawGameBoard()
        {
            string GetBoardCellString(GridPoint gridPoint)
            {
                var  point         = new GameGridCell(gridPoint.X, gridPoint.Y);
                bool isCellPresent = GridCells.TryGetValue(point, out var cell);

                if (isCellPresent)
                {
                    return(cell.DrawCell());
                }
                return(" ");
            }

            if (ClearConsoleWhenDrawingBoard)
            {
                Console.Clear();
            }
            GridHelper.DrawGrid2D(
                gridPoints: GridCells.Select(gc => new GridPoint(gc.X, gc.Y)).ToList(),
                GetPointString: GetBoardCellString);
            Console.WriteLine($"     Blocks Remaining: {NumberOfBlocksRemaining}");
            Console.WriteLine($"     Score: {Score}");
            Console.WriteLine($"     Time index: {_timeIndex}");
            Console.WriteLine();
        }
    private void initData()
    {
        GridWeb1.WorkSheets.Clear();
        GridWeb1.WorkSheets.Add("Custom Format");

        GridCell  cell;
        GridCells cells = GridWeb1.WorkSheets[0].Cells;

        cells["A1"].PutValue("Custom Format");
        cells["A2"].PutValue("0.0");
        cells["A3"].PutValue("0.000");
        cells["A4"].PutValue("#,##0.0");
        cells["A5"].PutValue("US$#,##0;US$-#,##0");
        cells["A6"].PutValue("0.0%");
        cells["A7"].PutValue("0.000E+00");
        cells["A8"].PutValue("yyyy-m-d h:mm");

        cell = cells["B1"];
        cell.PutValue("Format Results");

        cell = cells["B2"];
        cell.PutValue(12345.6789);
        cell.SetCustom("0.0");


        cell = cells["B3"];
        cell.PutValue(12345.6789);
        cell.SetCustom("0.000");


        cell = cells["B4"];
        cell.PutValue(543123456.789);
        cell.SetCustom("#,##0.0");


        cell = cells["B5"];
        cell.PutValue(-543123456.789);
        cell.SetCustom("US$#,##0;US$-#,##0");


        cell = cells["B6"];
        cell.PutValue(0.925687);
        cell.SetCustom("0.0%");


        cell = cells["B7"];
        cell.PutValue(-1234567890.5687);
        cell.SetCustom("0.000E+00");


        cell = cells["B8"];
        cell.PutValue(DateTime.Now);
        cell.SetCustom("yyyy-m-d h:mm");


        cells.SetColumnWidthPixel(0, 220);
        cells.SetColumnWidthPixel(1, 220);
    }
示例#12
0
        public Grid MakeMove(GridCells target)
        {
            if (!this.CanMove(target))
            {
                throw new InvalidOperationException();
            }

            return(new Grid(this.Opponent, this.Current | target, !this.CurrentIsO));
        }
示例#13
0
        static string GetCell(this Grid grid, GridCells target)
        {
            if ((grid.Current & target) != GridCells.None)
                return (grid.CurrentIsO ? "O" : "X");

            if ((grid.Opponent & target) != GridCells.None)
                return (grid.CurrentIsO ? "X" : "O");

            return " ";
        }
        private void InitialiseGameOfLifeWorld()
        {
            int index = 0;

            for (int row = 0; row < TotalRows; row++)
            {
                for (int col = 0; col < TotalColumns; col++)
                {
                    GridCells.Add(new Cell(row, col, index));
                    index++;
                }
            }
        }
示例#15
0
        public bool CanMove(GridCells target)
        {
            if (this.Check(this.Current, target))
            {
                return(false);
            }

            if (this.Check(this.Opponent, target))
            {
                return(false);
            }

            return(true);
        }
        static string GetCell(this Grid grid, GridCells target)
        {
            if ((grid.Current & target) != GridCells.None)
            {
                return(grid.CurrentIsO ? "O" : "X");
            }

            if ((grid.Opponent & target) != GridCells.None)
            {
                return(grid.CurrentIsO ? "X" : "O");
            }

            return(" ");
        }
        private void InitData()
        {
            if (!(!IsPostBack && !GridWeb1.IsPostBack))
            {
                return;
            }

            // Create path to xls file
            string path = (this.Master as Site).GetDataDir();

            // Set filename
            string fileName = path + "\\Miscellaneous\\PivotTable.xls";

            // Imports from an excel file.
            GridWeb1.ImportExcelFile(fileName);

            // Extract cells from source sheet
            GridWorksheet sourceSheet = GridWeb1.WorkSheets[0];

            Aspose.Cells.GridWeb.Data.GridCellArea sourceRange = new GridCellArea();
            sourceRange.StartRow    = 0;
            sourceRange.StartColumn = 0;
            sourceRange.EndRow      = 29;
            sourceRange.EndColumn   = 5;

            // Add new sheet
            GridWorksheet sheet = GridWeb1.WorkSheets.Add("PivotTable Report");
            GridCells     cells = GridWeb1.WorkSheets[0].Cells;

            // Add Pivot Table
            int            id         = sheet.PivotTables.Add(sourceSheet, sourceRange, "A1", "PivotTable Report");
            GridPivotTable pivotTable = sheet.PivotTables[id];

            // Apply formatting
            GridWeb1.DefaultFontName = "Arial";
            GridWeb1.DefaultFontSize = new System.Web.UI.WebControls.FontUnit(10);

            pivotTable.AddFieldToArea(GridPivotFieldType.Row, 0);
            pivotTable.AddFieldToArea(GridPivotFieldType.Row, 2);
            pivotTable.AddFieldToArea(GridPivotFieldType.Column, 3);
            pivotTable.AddFieldToArea(GridPivotFieldType.Column, 4);
            pivotTable.AddFieldToArea(GridPivotFieldType.Data, 5);
            pivotTable.Fields(GridPivotFieldType.Data)[0].Function = GridPivotFieldFunction.Sum;

            // Paints PivotTable report
            pivotTable.CalculateData();

            GridWeb1.ActiveSheetIndex = sheet.Index;
        }
    private void InitData()
    {
        if (!(!IsPostBack && !GridWeb1.IsPostBack))
        {
            return;
        }
        //Create path to xls file
        string path = Server.MapPath("~");

        path = path.Substring(0, path.LastIndexOf("\\"));
        string fileName = path + "\\File\\PivotTable.xls";


        // Imports from a excel file.
        GridWeb1.ImportExcelFile(fileName);



        GridWorksheet sourceSheet = GridWeb1.WorkSheets[0];

        Aspose.Cells.GridWeb.Data.GridCellArea sourceRange = new GridCellArea();
        sourceRange.StartRow    = 0;
        sourceRange.StartColumn = 0;
        sourceRange.EndRow      = 29;
        sourceRange.EndColumn   = 5;

        GridWorksheet  sheet      = GridWeb1.WorkSheets.Add("PivotTable Report");
        GridCells      cells      = GridWeb1.WorkSheets[0].Cells;
        int            id         = sheet.PivotTables.Add(sourceSheet, sourceRange, "A1", "PivotTable Report");
        GridPivotTable pivotTable = sheet.PivotTables[id];



        //Apply formatting
        GridWeb1.DefaultFontName = "Arial";
        GridWeb1.DefaultFontSize = new System.Web.UI.WebControls.FontUnit(10);

        pivotTable.AddFieldToArea(GridPivotFieldType.Row, 0);
        pivotTable.AddFieldToArea(GridPivotFieldType.Row, 2);
        pivotTable.AddFieldToArea(GridPivotFieldType.Column, 3);
        pivotTable.AddFieldToArea(GridPivotFieldType.Column, 4);
        pivotTable.AddFieldToArea(GridPivotFieldType.Data, 5);
        pivotTable.Fields(GridPivotFieldType.Data)[0].Function = GridPivotFieldFunction.Sum;

        //Paints PivotTable report
        pivotTable.CalculateData();

        GridWeb1.ActiveSheetIndex = sheet.Index;
    }
示例#19
0
        protected void btnCreateCaption_Click(object sender, EventArgs e)
        {
            CreateRowCaptions();
            CreateColumnCaptions();

            // Accessing the worksheet that is currently active
            GridWorksheet workSheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];

            // Adjusts column width.
            GridCells cells = workSheet.Cells;

            cells.SetColumnWidth(0, 20);
            cells.SetColumnWidth(1, 20);
            cells.SetColumnWidth(2, 20);
        }
示例#20
0
    private void InitData()
    {
        //Create path to xls file
        string path = Server.MapPath("~");

        path = path.Substring(0, path.LastIndexOf("\\"));
        string fileName = path + "\\File\\PivotTable.xls";



        // Imports from a excel file.
        GridWeb1.ImportExcelFile(fileName);



        GridWorksheet sourceSheet = GridWeb1.WorkSheets[0];

        Aspose.Cells.GridWeb.Data.GridCellArea sourceRange = new GridCellArea();
        sourceRange.StartRow    = 0;
        sourceRange.StartColumn = 0;
        sourceRange.EndRow      = 29;
        sourceRange.EndColumn   = 5;


        //Add sheet and get index
        GridWorksheet sheet = GridWeb1.WorkSheets.Add("PivotTable Report");
        GridCells     cells = GridWeb1.WorkSheets[0].Cells;
        int           id    = sheet.PivotTables.Add(sourceSheet, sourceRange, "A1", "PivotTable Report");

        //Apply formatting
        GridWeb1.WorkSheets.DefaultFontName = "Arial";
        GridWeb1.WorkSheets.DefaultFontSize = new System.Web.UI.WebControls.FontUnit(10);


        //Clears all list box
        lbxFields.Items.Clear();
        lbxRowFields.Items.Clear();
        lbxColumnFields.Items.Clear();
        lbxDataFields.Items.Clear();
        // GridPivotTable pivotTable=sheet.PivotTables[id];
        //Adds PivotFields to lbxFields box.
        // GridPivotFieldCollection fields = pivotTable.Fields(GridPivotFieldType.Column);

        for (int i = 0; i < 6; i++)
        {
            lbxFields.Items.Add(new ListItem(cells[0, i].StringValue, cells[0, i].StringValue));
        }
    }
        private void LoadData()
        {
            // Clear GridWeb
            GridWeb1.WorkSheets.Clear();

            // Add a new sheet by name and put some info text in cells
            GridWorksheet sheet = GridWeb1.WorkSheets.Add("Modify-Cells");
            GridCells     cells = sheet.Cells;

            cells["A1"].PutValue("String Value:");
            cells["A3"].PutValue("Int Value:");
            cells["A5"].PutValue("Double Value:");

            cells.SetColumnWidth(0, 30);
            cells.SetColumnWidth(1, 20);
        }
示例#22
0
        /// <summary>
        /// Creates a string representation of this class to be rendered by a renderer.
        /// </summary>
        /// <returns></returns>
        public override List <string> Render()
        {
            var cellWidth  = (int)Math.Floor(ContentWidth / Math.Max(1.0f, GridColDefinitions.Count));
            var cellHeight = (int)Math.Floor(ContentHeight / Math.Max(1.0f, GridRowDefinitions.Count));

            foreach (var cell in GridCells)
            {
                cell.Width  = cellWidth;
                cell.Height = cellHeight;
            }

            var lines = new List <string>(100); // arbitrary value

            for (var y = 0; y < GridRowDefinitions.Count; ++y)
            {
                // create one row of elements

                var cellsForCurrentRow = GridCells.Where(n => n.Coordinates.Y == y).OrderBy(n => n.Coordinates.X).Select(n => n.Render()).ToList(); // Coordinates as name is inferred.
                if (!cellsForCurrentRow.Any())
                {
                    continue;
                }

                var maxLineCount = cellsForCurrentRow.Max(n => n.Count);

                // add placeholder rows if the cells dont match
                foreach (var cell in cellsForCurrentRow)
                {
                    while (cell.Count < maxLineCount)
                    {
                        cell.Add(new string(' ', cellWidth));
                    }
                }

                for (int i = 0; i < cellsForCurrentRow.First().Count; ++i)
                {
                    var combinedLine = "";
                    foreach (var cell in cellsForCurrentRow)
                    {
                        combinedLine += cell[i];
                    }
                    lines.Add(combinedLine);
                }
            }

            return(lines);
        }
示例#23
0
        private void RefreshGridCells()
        {
            // The software draws tiles to the screen with output instructions:
            // every three output instructions specify the x position
            // (distance from the left), y position (distance from the top),
            // and tile id.
            // The arcade cabinet also has a segment display capable of showing
            // a single number that represents the player's current score.
            // When three output instructions specify X=-1, Y=0, the third
            // output instruction is not a tile; the value instead specifies
            // the new score to show in the segment display. For example, a
            // sequence of output values like -1,0,12345 would show 12345 as
            // the player's current score.
            for (int outputIndex = 0; outputIndex < OutputListener.Values.Count; outputIndex += 3)
            {
                var x         = OutputListener.Values[outputIndex];
                var y         = OutputListener.Values[outputIndex + 1];
                var param3Val = OutputListener.Values[outputIndex + 2];
                if (x == -1 && y == 0)
                {
                    Score = (long)param3Val;
                }
                else
                {
                    var gridCell = new GameGridCell((int)x, (int)y, (GameCellType)(int)param3Val);
                    if (GridCells.Contains(gridCell))
                    {
                        GridCells.Remove(gridCell);
                    }
                    GridCells.Add(gridCell);
                    if (GameCellType.Ball.Equals(gridCell.Type))
                    {
                        Last3BallPositions[2] = Last3BallPositions[1];
                        Last3BallPositions[1] = Last3BallPositions[0];
                        Last3BallPositions[0] = gridCell;
                    }
                }
            }
            // Check if this is a ball/paddle contact
            var dX = Math.Abs(Ball.X - HorizontalPaddle.X);
            var dY = Math.Abs(Ball.Y - HorizontalPaddle.Y);

            if (dX <= 1 && dY == 1)
            {
                BallPaddleContactTurns.Add(_timeIndex);
            }
        }
示例#24
0
        private void InitData()
        {
            // Create path to xls file
            string path = (this.Master as Site).GetDataDir();

            // Set filename
            string fileName = path + "\\Miscellaneous\\PivotTable.xls";

            // Imports from a excel file.
            GridWeb1.ImportExcelFile(fileName);

            // Extract cells from source sheet
            GridWorksheet sourceSheet = GridWeb1.WorkSheets[0];

            Aspose.Cells.GridWeb.Data.GridCellArea sourceRange = new GridCellArea();
            sourceRange.StartRow    = 0;
            sourceRange.StartColumn = 0;
            sourceRange.EndRow      = 29;
            sourceRange.EndColumn   = 5;


            // Add sheet and get index
            GridWorksheet sheet = GridWeb1.WorkSheets.Add("PivotTable Report");
            GridCells     cells = GridWeb1.WorkSheets[0].Cells;

            // Add Pivot Table
            int id = sheet.PivotTables.Add(sourceSheet, sourceRange, "A1", "PivotTable Report");

            // Apply formatting
            GridWeb1.WorkSheets.DefaultFontName = "Arial";
            GridWeb1.WorkSheets.DefaultFontSize = new System.Web.UI.WebControls.FontUnit(10);


            //Clears all list box
            lbxFields.Items.Clear();
            lbxRowFields.Items.Clear();
            lbxColumnFields.Items.Clear();
            lbxDataFields.Items.Clear();

            //Adds PivotFields to lbxFields box.
            for (int i = 0; i < 6; i++)
            {
                lbxFields.Items.Add(new ListItem(cells[0, i].StringValue, cells[0, i].StringValue));
            }
        }
示例#25
0
        bool CheckWin(GridCells target)
        {
            if (this.Check(target, GridCells.TopRow))
            {
                return(true);
            }

            if (this.Check(target, GridCells.MiddleRow))
            {
                return(true);
            }

            if (this.Check(target, GridCells.BottomRow))
            {
                return(true);
            }

            if (this.Check(target, GridCells.LeftColumn))
            {
                return(true);
            }

            if (this.Check(target, GridCells.CenterColumn))
            {
                return(true);
            }

            if (this.Check(target, GridCells.RightColumn))
            {
                return(true);
            }

            if (this.Check(target, GridCells.Diagonal1))
            {
                return(true);
            }

            if (this.Check(target, GridCells.Diagonal2))
            {
                return(true);
            }

            return(false);
        }
    protected void Button2_Click(object sender, EventArgs e)
    {
        GridWeb1.WorkSheets.Clear();
        GridWeb1.WorkSheets.Add();

        GridCells cells = GridWeb1.WorkSheets[0].Cells;

        cells["A1"].PutValue("Custom Format");
        cells["B1"].PutValue("Format Results");

        cells["A2"].PutValue(TextBox1.Text.Trim());
        cells["B2"].PutValue(TextBox2.Text.Trim(), true);


        cells["B2"].SetCustom(TextBox1.Text.Trim());

        cells.SetColumnWidthPixel(0, 120);
        cells.SetColumnWidthPixel(1, 220);
    }
        protected void Button2_Click(object sender, EventArgs e)
        {
            GridWeb1.WorkSheets.Clear();
            GridWeb1.WorkSheets.Add();

            GridCells cells = GridWeb1.WorkSheets[0].Cells;

            cells["A1"].PutValue("Number Type");
            cells["B1"].PutValue("Format Results");

            cells["A2"].PutValue(DropDownList1.SelectedItem.Text);


            cells["B2"].SetNumberType((int)(NumberType)Convert.ToInt16(DropDownList1.SelectedItem.Value));

            cells["B2"].PutValue(TextBox1.Text, true);
            cells.SetColumnWidth(0, 40);
            cells.SetColumnWidth(1, 40);
        }
        protected void btnSetColumnWidth_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                // ExStart:SetColumnWidth
                // Get column index entered by user
                int columnIndex = Convert.ToInt16(txtColumnIndex.Text.Trim());

                // Get column width entered by user
                int columnWidth = Convert.ToInt16(txtColumnWidth.Text.Trim());

                // Accessing the cells collection of the worksheet that is currently active
                GridCells cells = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex].Cells;

                // Resize column at specified index to specified width
                cells.SetColumnWidth(columnIndex, columnWidth);
                // ExEnd:SetColumnWidth
            }
        }
        protected void btnSetRowHeight_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                // ExStart:SetRowHeight
                // Get row index entered by user
                int rowIndex = Convert.ToInt16(txtRowIndex.Text.Trim());

                // Get row height entered by user
                int rowHeight = Convert.ToInt16(txtRowHeight.Text.Trim());

                // Accessing the cells collection of the worksheet that is currently active
                GridCells cells = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex].Cells;

                // Resize row at specified index to specified height
                cells.SetRowHeight(rowIndex, rowHeight);
                // ExEnd:SetRowHeight
            }
        }
示例#30
0
        // Handles creating report from WebWorksheet
        protected void btnWorksheet_Click(object sender, EventArgs e)
        {
            // Extract cells from source sheet
            GridWorksheet sourceSheet = GridWeb1.WorkSheets[0];

            Aspose.Cells.GridWeb.Data.GridCellArea sourceRange = new GridCellArea();
            sourceRange.StartRow    = 0;
            sourceRange.StartColumn = 0;
            sourceRange.EndRow      = 29;
            sourceRange.EndColumn   = 5;

            GridWorksheet sheet = GridWeb1.WorkSheets["From WebWorksheet"];

            if (sheet == null)
            {
                // Add worksheet
                sheet = GridWeb1.WorkSheets.Add("From WebWorksheet");

                GridCells cells = GridWeb1.WorkSheets[0].Cells;

                // Add pivot table
                int            id         = sheet.PivotTables.Add(sourceSheet, sourceRange, "A1", "Form WebWorksheet");
                GridPivotTable pivotTable = sheet.PivotTables[id];

                // Apply formatting
                GridWeb1.DefaultFontName = "Arial";
                GridWeb1.DefaultFontSize = new System.Web.UI.WebControls.FontUnit(10);

                pivotTable.AddFieldToArea(GridPivotFieldType.Row, 0);
                pivotTable.AddFieldToArea(GridPivotFieldType.Row, 2);
                pivotTable.AddFieldToArea(GridPivotFieldType.Column, 3);
                pivotTable.AddFieldToArea(GridPivotFieldType.Column, 4);
                pivotTable.AddFieldToArea(GridPivotFieldType.Data, 5);
                pivotTable.Fields(GridPivotFieldType.Data)[0].Function = GridPivotFieldFunction.Sum;

                // Paints PivotTable report
                pivotTable.CalculateData();
            }

            GridWeb1.ActiveSheetIndex = sheet.Index;
        }
示例#31
0
        private void AddPluginControls(object sender, PluginEventArgs e)
        {
            GridCells cells = new GridCells();

            foreach (IPlugin plugin in e.Plugins)
            {
                var visualPlugin = plugin as IVisualPlugin;
                if (visualPlugin != null)
                {
                    Point freeCell = cells.GetFreeCell(visualPlugin.ColumnSpan);
                    if (freeCell.Y >= PluginsGrid.RowDefinitions.Count)
                    {
                        PluginsGrid.RowDefinitions.Add(new RowDefinition());
                    }
                    PluginsGrid.Children.Add(visualPlugin.Control);
                    Grid.SetColumnSpan(visualPlugin.Control, visualPlugin.ColumnSpan);
                    Grid.SetColumn(visualPlugin.Control, freeCell.X);
                    Grid.SetRow(visualPlugin.Control, freeCell.Y);
                }
            }
        }
示例#32
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        // Only showss 3 columns.
        GridWeb1.MaxColumn = 2;
        GridWorksheet workSheet = GridWeb1.WorkSheets[0];
        GridCells     cells     = workSheet.Cells;

        // Creates Custom Header Caption.
        workSheet.SetColumnCaption(0, "Product");
        workSheet.SetColumnCaption(1, "Category");
        workSheet.SetColumnCaption(2, "Price");
        workSheet.SetRowCaption(2, "row2");
        // Put some values.
        cells["A1"].PutValue("Aniseed Syrup");
        cells["A2"].PutValue("Boston Crab Meat");
        cells["A3"].PutValue("Chang");

        cells["B1"].PutValue("Condiments");
        cells["B2"].PutValue("Seafood");
        cells["B3"].PutValue("Beverages");

        cells["C1"].PutValue(14.95);
        Aspose.Cells.GridWeb.GridTableItemStyle style = cells["C1"].Style;
        style.NumberType      = (int)NumberType.Currency3;
        style.HorizontalAlign = HorizontalAlign.Right;
        cells["C1"].Style     = style;

        cells["C2"].PutValue(24.99);
        cells["C2"].Style = style;

        cells["C3"].PutValue(49.95);
        cells["C3"].Style = style;

        // Adjusts column width.
        cells.SetColumnWidth(0, 20);
        cells.SetColumnWidth(1, 20);
        cells.SetColumnWidth(2, 20);
    }
        private void initData()
        {
            GridWeb1.WorkSheets.Clear();
            GridWeb1.WorkSheets.Add("Number Format");

            GridCell  cell;
            GridCells cells = GridWeb1.WorkSheets[0].Cells;

            cells["A1"].PutValue("Number Type");
            cells["A2"].PutValue("General:");
            cells["A3"].PutValue("Decimal 1:");
            cells["A4"].PutValue("Decimal 2:");
            cells["A5"].PutValue("Decimal 3:");
            cells["A6"].PutValue("Decimal 4:");

            cells["A7"].PutValue("Currency 1:");
            cells["A8"].PutValue("Currency 2:");
            cells["A9"].PutValue("Currency 3:");
            cells["A10"].PutValue("Currency 4:");
            cells["A11"].PutValue("Currency 5:");
            cells["A12"].PutValue("Currency 6:");
            cells["A13"].PutValue("Currency 7:");
            cells["A14"].PutValue("Currency 8:");
            cells["A15"].PutValue("Currency 9:");
            cells["A16"].PutValue("Currency 10:");
            cells["A17"].PutValue("Currency 11:");
            cells["A18"].PutValue("Currency 12:");

            cells["A19"].PutValue("Percentage 1:");
            cells["A20"].PutValue("Percentage 2:");

            cells["A21"].PutValue("Fraction 1:");
            cells["A22"].PutValue("Fraction 2:");

            cells["A23"].PutValue("Accounting 1:");
            cells["A24"].PutValue("Accounting 2:");
            cells["A25"].PutValue("Accounting 31:");
            cells["A26"].PutValue("Accounting 4:");

            cells["A27"].PutValue("Scientific 1:");
            cells["A28"].PutValue("Scientific 2:");

            cells["A29"].PutValue("Text:");


            cell = cells["B1"];
            cell.PutValue("Format Results");

            cell = cells["B2"];
            cell.PutValue(12345.6789);

            cell.SetNumberType((int)NumberType.General);


            cell = cells["B3"];
            cell.PutValue(12345.6789);

            cell.SetNumberType((int)NumberType.Decimal1);


            cell = cells["B4"];
            cell.PutValue(12345.6789);

            cell.SetNumberType((int)NumberType.Decimal2);


            cell = cells["B5"];
            cell.PutValue(12345.6789);

            cell.SetNumberType((int)NumberType.Decimal3);


            cell = cells["B6"];
            cell.PutValue(12345.6789);

            cell.SetNumberType((int)NumberType.Decimal4);


            cell = cells["B7"];
            cell.PutValue(12345.6789);

            cell.SetNumberType((int)NumberType.Currency1);


            cell = cells["B8"];
            cell.PutValue(12345.6789);

            cell.SetNumberType((int)NumberType.Currency2);


            cell = cells["B9"];
            cell.PutValue(12345.6789);

            cell.SetNumberType((int)NumberType.Currency3);


            cell = cells["B10"];
            cell.PutValue(12345.6789);

            cell.SetNumberType((int)NumberType.Currency4);


            cell = cells["B11"];
            cell.PutValue(12345.6789);

            cell.SetNumberType((int)NumberType.Currency5);


            cell = cells["B12"];
            cell.PutValue(12345.6789);

            cell.SetNumberType((int)NumberType.Currency6);


            cell = cells["B13"];
            cell.PutValue(12345.6789);

            cell.SetNumberType((int)NumberType.Currency7);


            cell = cells["B14"];
            cell.PutValue(12345.6789);

            cell.SetNumberType((int)NumberType.Currency8);


            cell = cells["B15"];
            cell.PutValue(12345.6789);

            cell.SetNumberType((int)NumberType.Currency9);


            cell = cells["B16"];
            cell.PutValue(12345.6789);

            cell.SetNumberType((int)NumberType.Currency10);


            cell = cells["B17"];
            cell.PutValue(12345.6789);

            cell.SetNumberType((int)NumberType.Currency11);


            cell = cells["B18"];
            cell.PutValue(12345.6789);

            cell.SetNumberType((int)NumberType.Currency12);


            cell = cells["B19"];
            cell.PutValue(0.56789);

            cell.SetNumberType((int)NumberType.Percentage1);


            cell = cells["B20"];
            cell.PutValue(0.56789);

            cell.SetNumberType((int)NumberType.Percentage2);


            cell = cells["B21"];
            cell.PutValue(1234.56789);

            cell.SetNumberType((int)NumberType.Fraction1);


            cell = cells["B22"];
            cell.PutValue(1234.56789);

            cell.SetNumberType((int)NumberType.Fraction2);


            cell = cells["B23"];
            cell.PutValue(1234.56789);

            cell.SetNumberType((int)NumberType.Accounting1);


            cell = cells["B24"];
            cell.PutValue(1234.56789);

            cell.SetNumberType((int)NumberType.Accounting2);


            cell = cells["B25"];
            cell.PutValue(1234.56789);

            cell.SetNumberType((int)NumberType.Accounting3);


            cell = cells["B26"];
            cell.PutValue(1234.56789);

            cell.SetNumberType((int)NumberType.Accounting4);


            cell = cells["B27"];
            cell.PutValue(1234.56789);

            cell.SetNumberType((int)NumberType.Scientific1);


            cell = cells["B28"];
            cell.PutValue(1234.56789);

            cell.SetNumberType((int)NumberType.Scientific2);


            cell = cells["B29"];
            cell.PutValue(1234.56789);

            cell.SetNumberType((int)NumberType.Text);



            cells.SetColumnWidth(0, 40);
            cells.SetColumnWidth(1, 40);
        }
示例#34
0
文件: Grid.cs 项目: crmmvio/TicTacToe
        bool CheckWin(GridCells target)
        {
            if (this.Check(target, GridCells.TopRow))
                return true;

            if (this.Check(target, GridCells.MiddleRow))
                return true;

            if (this.Check(target, GridCells.BottomRow))
                return true;

            if (this.Check(target, GridCells.LeftColumn))
                return true;

            if (this.Check(target, GridCells.CenterColumn))
                return true;

            if (this.Check(target, GridCells.RightColumn))
                return true;

            if (this.Check(target, GridCells.Diagonal1))
                return true;

            if (this.Check(target, GridCells.Diagonal2))
                return true;

            return false;
        }
示例#35
0
文件: Grid.cs 项目: crmmvio/TicTacToe
 bool Check(GridCells state, GridCells target)
 {
     return (state & target) == target;
 }
示例#36
0
文件: Grid.cs 项目: crmmvio/TicTacToe
        public Grid MakeMove(GridCells target)
        {
            if (!this.CanMove(target))
                throw new InvalidOperationException();

            return new Grid(this.Opponent, this.Current | target, !this.CurrentIsO);
        }
示例#37
0
文件: Grid.cs 项目: crmmvio/TicTacToe
        public bool CanMove(GridCells target)
        {
            if (this.Check(this.Current, target))
                return false;

            if (this.Check(this.Opponent, target))
                return false;

            return true;
        }
        private void InitData()
        {
            GridWeb1.WorkSheets.Clear();
            GridWeb1.WorkSheets.Add("Date&Time Format");

            GridCell  cell;
            GridCells cells = GridWeb1.WorkSheets[0].Cells;

            cells["A1"].PutValue("Number Type");
            cells["A2"].PutValue("Date 1:");
            cells["A3"].PutValue("Date 2:");
            cells["A4"].PutValue("Date 3:");
            cells["A5"].PutValue("Date 4:");

            cells["A6"].PutValue("Time 1:");
            cells["A7"].PutValue("Time 2:");
            cells["A8"].PutValue("Time 3:");
            cells["A9"].PutValue("Time 4:");
            cells["A10"].PutValue("Time 5:");
            cells["A11"].PutValue("Time 6:");
            cells["A12"].PutValue("Time 7:");
            cells["A13"].PutValue("Time 8:");

            cells["A14"].PutValue("EasternDate 1:");
            cells["A15"].PutValue("EasternDate 2:");
            cells["A16"].PutValue("EasternDate 3:");
            cells["A17"].PutValue("EasternDate 4:");
            cells["A18"].PutValue("EasternDate 5:");
            cells["A19"].PutValue("EasternDate 6:");
            cells["A20"].PutValue("EasternDate 7:");
            cells["A21"].PutValue("EasternDate 8:");
            cells["A22"].PutValue("EasternDate 9:");
            cells["A23"].PutValue("EasternDate 10:");
            cells["A24"].PutValue("EasternDate 11:");
            cells["A25"].PutValue("EasternDate 12:");
            cells["A26"].PutValue("EasternDate 13:");

            cells["A27"].PutValue("EasternTime 1:");
            cells["A28"].PutValue("EasternTime 2:");
            cells["A29"].PutValue("EasternTime 3:");
            cells["A30"].PutValue("EasternTime 4:");
            cells["A31"].PutValue("EasternTime 5:");
            cells["A32"].PutValue("EasternTime 6:");


            cell = cells["B1"];
            cell.PutValue("Format Results");

            cell = cells["B2"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.Date1);


            cell = cells["B3"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.Date2);

            cell = cells["B4"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.Date3);

            cell = cells["B5"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.Date4);

            cell = cells["B6"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.Time1);

            cell = cells["B7"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.Time2);


            cell = cells["B8"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.Time3);


            cell = cells["B9"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.Time4);


            cell = cells["B10"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.Time5);


            cell = cells["B11"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.Time6);


            cell = cells["B12"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.Time7);


            cell = cells["B13"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.Time8);


            cell = cells["B14"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternDate1);


            cell = cells["B15"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternDate2);


            cell = cells["B16"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternDate3);


            cell = cells["B17"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternDate4);


            cell = cells["B18"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternDate5);


            cell = cells["B19"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternDate6);


            cell = cells["B20"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternDate7);


            cell = cells["B21"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternDate8);


            cell = cells["B22"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternDate9);


            cell = cells["B23"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternDate10);


            cell = cells["B24"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternDate11);


            cell = cells["B25"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternDate12);


            cell = cells["B26"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternDate13);


            cell = cells["B27"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternTime1);


            cell = cells["B28"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternTime2);


            cell = cells["B29"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternTime3);


            cell = cells["B30"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternTime4);


            cell = cells["B31"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternTime5);


            cell = cells["B32"];
            cell.PutValue(DateTime.Now);
            cell.SetNumberType((int)NumberType.EasternTime6);


            cells.SetColumnWidth(0, 40);
            cells.SetColumnWidth(1, 40);
        }