예제 #1
0
        public DateTime GetDate(int row, int column)
        {
            int           serialDate = 0;
            CellIndex     cellIndex  = new CellIndex(row, column);
            CellSelection selection  = sheet.Cells[cellIndex];
            ICellValue    cellValue  = selection.GetValue().Value;

            if (cellValue.ValueType == CellValueType.Empty)
            {
                return(new DateTime(2000, 1, 1));
            }
            if (cellValue.ValueType != CellValueType.Number)
            {
                // try datetime.tryparse
                string[] formats = { "dd.MM.yyyy" };
                DateTime d       = DateTime.Now;
                if (DateTime.TryParseExact(cellValue.RawValue, formats,
                                           System.Globalization.CultureInfo.CreateSpecificCulture("de-De"), System.Globalization.DateTimeStyles.None, out d))
                {
                    return(d);
                }

                throw new Exception("Value is not a date");
            }
            if (int.TryParse(cellValue.RawValue, out serialDate))
            {
                return(FromExcelSerialDate((int)serialDate));
            }
            return(DateTime.MinValue);
        }
예제 #2
0
        private void SetCellValue(CellSelection cell, object value)
        {
            if (value == null)
            {
                value = string.Empty;
            }

            switch (Type.GetTypeCode(value.GetType()))
            {
            case TypeCode.Byte:
            case TypeCode.Char:
            case TypeCode.Decimal:
            case TypeCode.Double:
            case TypeCode.Int16:
            case TypeCode.Int32:
            case TypeCode.Int64:
            case TypeCode.SByte:
            case TypeCode.Single:
            case TypeCode.UInt16:
            case TypeCode.UInt32:
            case TypeCode.UInt64: cell.SetValue(Convert.ToDouble(value)); break;

            case TypeCode.DateTime: cell.SetValue((DateTime)value); break;

            case TypeCode.Boolean: cell.SetValue((bool)value); break;

            default: cell.SetValue(value.ToString()); break;
            }
        }
예제 #3
0
        public void GetSetCellValue()
        {
            #region radspreadsheet-features-formatting-cells_7
            Workbook      workbook  = new Workbook();
            Worksheet     worksheet = workbook.Worksheets.Add();
            CellSelection selection = worksheet.Cells[1, 1];

            ICellValue cellValue = selection.GetValue().Value;
            #endregion

            #region radspreadsheet-features-formatting-cells_2
            // set DateTime value
            selection.SetValue(DateTime.Now);

            // set double value
            selection.SetValue(51.345);

            // set ICellValue
            ICellValue value = worksheet.Cells[5, 5].GetValue().Value;
            selection.SetValue(value);

            // set string value
            selection.SetValue("Total");

            // set formula value
            selection.SetValue("=C1+C10");
            #endregion
        }
예제 #4
0
        public double GetAmount(int row, int column)
        {
            CellIndex     cellIndex = new CellIndex(row, column);
            CellSelection selection = sheet.Cells[cellIndex];
            ICellValue    cellValue = selection.GetValue().Value;

            // in case of DBNULL the cell contains a text with content 'NULL'
            // return '0'
            if (cellValue.ValueType == CellValueType.Text)
            {
                if (cellValue.RawValue == "NULL")
                {
                    return(0);
                }
                // An Exception will be thrown
            }

            if (cellValue.ValueType == CellValueType.Empty)
            {
                return(0);
            }
            if (cellValue.ValueType != CellValueType.Number)
            {
                throw new Exception("Value is not a number");
            }
            return(double.Parse(cellValue.RawValue));
        }
예제 #5
0
        private Workbook GenerateWorkbook()
        {
            var export = pivot.GenerateExport();

            Workbook workbook = new Workbook();

            workbook.History.IsEnabled = false;

            var worksheet = workbook.Worksheets.Add();

            workbook.SuspendLayoutUpdate();
            int rowCount    = export.RowCount;
            int columnCount = export.ColumnCount;

            var allCells = worksheet.Cells[0, 0, rowCount - 1, columnCount - 1];

            allCells.SetFontFamily(new ThemableFontFamily(pivot.FontFamily));
            allCells.SetFontSize(12);
            allCells.SetFill(GenerateFill(pivot.Background));

            foreach (var cellInfo in export.Cells)
            {
                int rowStartIndex    = cellInfo.Row;
                int rowEndIndex      = rowStartIndex + cellInfo.RowSpan - 1;
                int columnStartIndex = cellInfo.Column;
                int columnEndIndex   = columnStartIndex + cellInfo.ColumnSpan - 1;

                CellSelection cellSelection = worksheet.Cells[rowStartIndex, columnStartIndex];

                var value = cellInfo.Value;
                if (value != null)
                {
                    cellSelection.SetValue(Convert.ToString(value));
                    cellSelection.SetVerticalAlignment(RadVerticalAlignment.Center);
                    cellSelection.SetHorizontalAlignment(GetHorizontalAlignment(cellInfo.TextAlignment));
                    int indent = cellInfo.Indent;
                    if (indent > 0)
                    {
                        cellSelection.SetIndent(indent);
                    }
                }

                cellSelection = worksheet.Cells[rowStartIndex, columnStartIndex, rowEndIndex, columnEndIndex];

                SetCellProperties(cellInfo, cellSelection);
            }

            for (int i = 0; i < columnCount; i++)
            {
                var columnSelection = worksheet.Columns[i];
                columnSelection.AutoFitWidth();

                //NOTE: workaround for incorrect autofit.
                var newWidth = worksheet.Columns[i].GetWidth().Value.Value + 15;
                columnSelection.SetWidth(new ColumnWidth(newWidth, false));
            }

            workbook.ResumeLayoutUpdate();
            return(workbook);
        }
예제 #6
0
        private static void SetCellProperties(PivotExportCellInfo cellInfo, CellSelection cellSelection)
        {
            var fill = GenerateFill(cellInfo.Background);

            if (fill != null)
            {
                cellSelection.SetFill(fill);
            }

            SolidColorBrush solidBrush = cellInfo.Foreground as SolidColorBrush;

            if (solidBrush != null)
            {
                cellSelection.SetForeColor(new ThemableColor(solidBrush.Color));
            }

            if (cellInfo.FontWeight.HasValue && cellInfo.FontWeight.Value != FontWeights.Normal)
            {
                cellSelection.SetIsBold(true);
            }

            SolidColorBrush solidBorderBrush = cellInfo.BorderBrush as SolidColorBrush;

            if (solidBorderBrush != null && cellInfo.BorderThickness.HasValue)
            {
                var borderThickness = cellInfo.BorderThickness.Value;
                var color           = new ThemableColor(solidBorderBrush.Color);
                //var leftBorder = new CellBorder(GetBorderStyle(borderThickness.Left), color);
                //var topBorder = new CellBorder(GetBorderStyle(borderThickness.Top), color);
                var rightBorder  = new CellBorder(GetBorderStyle(borderThickness.Right), color);
                var bottomBorder = new CellBorder(GetBorderStyle(borderThickness.Bottom), color);
                var insideBorder = cellInfo.Background != null ? new CellBorder(CellBorderStyle.None, color) : null;
                cellSelection.SetBorders(new CellBorders(null, null, rightBorder, bottomBorder, insideBorder, insideBorder, null, null));
            }
        }
예제 #7
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, would you like to create a workbook? [Y/y][N/n]:");

            var result = Console.ReadLine();

            if (result?.ToLower() == "y")
            {
                Workbook  workbook  = new Workbook();
                Worksheet worksheet = workbook.Worksheets.Add();

                CellSelection selection = worksheet.Cells[1, 1]; //B2 cell
                selection.SetValue("Hello RadSpreadProcessing");

                string fileName = "SampleFile.xlsx";

                IWorkbookFormatProvider formatProvider = new XlsxFormatProvider();

                using Stream output = new FileStream(fileName, FileMode.Create);

                formatProvider.Export(workbook, output);

                Console.WriteLine("Done!");
            }
        }
예제 #8
0
        /// <summary>
        /// Binds the click handler for opening records from the grid attributes -see the formatters for attributes provided
        /// </summary>
        /// <param name="grid"></param>
        public void BindClickHandler(Grid grid)
        {
            Action <string, string> openEntityRecord = delegate(string logicalName, string id)
            {
                Utility.OpenEntityForm(logicalName, id, null);
            };

            grid.OnClick.Subscribe(delegate(EventData e, object sender)
            {
                CellSelection cell = (CellSelection)sender;

                bool handled             = false;
                Element element          = e.SrcElement;
                object logicalName       = element.GetAttribute("logicalName");
                object id                = element.GetAttribute("id");
                object primaryNameLookup = element.GetAttribute("primaryNameLookup");
                if (logicalName != null & id != null)
                {
                    // Open the related record
                    handled = true;
                }
                else if (primaryNameLookup != null)
                {
                    // Open the primary entity record
                    handled       = true;
                    Entity entity = (Entity)cell.Grid.GetDataItem(cell.Row.Value);
                    logicalName   = entity.LogicalName;
                    // If there is an activitytypecode then use that
                    string activitytypecode = entity.GetAttributeValueString("activitytypecode");
                    if (activitytypecode != null)
                    {
                        logicalName = activitytypecode;
                    }
                    id = entity.Id;
                }

                if (handled)
                {
                    openEntityRecord((string)logicalName, (string)id);
                    e.StopImmediatePropagation();
                    e.StopPropagation();
                }
            });
            grid.OnDblClick.Subscribe(delegate(EventData e, object sender)
            {
                CellSelection cell = (CellSelection)sender;
                Entity entity      = (Entity)cell.Grid.GetDataItem(cell.Row.Value);
                string logicalName = entity.LogicalName;
                // If there is an activitytypecode then use that
                string activitytypecode = entity.GetAttributeValueString("activitytypecode");
                if (activitytypecode != null)
                {
                    logicalName = activitytypecode;
                }
                openEntityRecord(logicalName, entity.Id);
                e.StopImmediatePropagation();
                e.StopPropagation();
            });
        }
예제 #9
0
 // Start is called before the first frame update
 void Start()
 {
     OnGameStart();
     EventManager.Get().EventTrigger(EventTypes.Game_OnStart);
     EventManager.Get().AddListener<CubeCell>(EventTypes.Cell_OnSelected,CellSelection.Get().CellSelected);
     Debug.Log("[消息]游戏开始");
     MonoBase.Get().GetMono().AddUpdateListener(CheckFocus);
 }
예제 #10
0
 public void Demo()
 {
     #region radspreadprocessing-working-with-cells-get-set-clear-properties_0
     Workbook      workbook  = new Workbook();
     Worksheet     worksheet = workbook.Worksheets.Add();
     CellSelection selection = worksheet.Cells[0, 0, 5, 5];
     #endregion
 }
예제 #11
0
 public void Demo()
 {
     #region radspreadsheet-features-formatting-cells_0
     Workbook      workbook  = new Workbook();
     Worksheet     worksheet = workbook.Worksheets.Add();
     CellSelection selection = worksheet.Cells[0, 0, 5, 5];
     #endregion
 }
예제 #12
0
        public void CreateSelection6()
        {
            #region radspreadsheet-active-cell-selection_5
            Workbook  workbook  = new Workbook();
            Worksheet worksheet = workbook.Worksheets.Add();

            CellSelection selection6 = worksheet.Cells[0, 0, 5, 5];
            #endregion
        }
예제 #13
0
        public void CreateSelection6()
        {
            #region radspreadprocessing-working-with-cells-accessing-cells-of-worksheet_5
            Workbook  workbook  = new Workbook();
            Worksheet worksheet = workbook.Worksheets.Add();

            CellSelection selection6 = worksheet.Cells[0, 0, 5, 5];
            #endregion
        }
        private void SetCellValue(string value, CellIndex cellIndex, string fontFamilyName, bool isItalic, bool isBold)
        {
            CellSelection cell = this.Worksheet.Cells[cellIndex];

            cell.SetValue(value);
            cell.SetFontFamily(new ThemableFontFamily(fontFamilyName));
            cell.SetIsItalic(isItalic);
            cell.SetIsBold(isBold);
        }
예제 #15
0
        public void CreateSelection2()
        {
            #region radspreadsheet-active-cell-selection_1
            Workbook  workbook  = new Workbook();
            Worksheet worksheet = workbook.Worksheets.Add();

            CellRange     cellRange  = new CellRange(0, 0, 5, 5);
            CellSelection selection2 = worksheet.Cells[cellRange];
            #endregion
        }
예제 #16
0
        public void CreateSelection2()
        {
            #region radspreadprocessing-working-with-cells-accessing-cells-of-worksheet_1
            Workbook  workbook  = new Workbook();
            Worksheet worksheet = workbook.Worksheets.Add();

            CellRange     cellRange  = new CellRange(0, 0, 5, 5);
            CellSelection selection2 = worksheet.Cells[cellRange];
            #endregion
        }
예제 #17
0
        public void CreateSelection1()
        {
            #region radspreadsheet-active-cell-selection_0
            Workbook  workbook  = new Workbook();
            Worksheet worksheet = workbook.Worksheets.Add();

            CellIndex     cellIndex  = new CellIndex(0, 5);
            CellSelection selection1 = worksheet.Cells[cellIndex];
            #endregion
        }
예제 #18
0
        public void CreateSelection1()
        {
            #region radspreadprocessing-working-with-cells-accessing-cells-of-worksheet_0
            Workbook  workbook  = new Workbook();
            Worksheet worksheet = workbook.Worksheets.Add();

            CellIndex     cellIndex  = new CellIndex(0, 5);
            CellSelection selection1 = worksheet.Cells[cellIndex];
            #endregion
        }
예제 #19
0
        public void CreateSelection4()
        {
            #region radspreadprocessing-working-with-cells-accessing-cells-of-worksheet_3
            Workbook  workbook  = new Workbook();
            Worksheet worksheet = workbook.Worksheets.Add();

            CellIndex     fromIndex  = new CellIndex(0, 0);
            CellIndex     toIndex    = new CellIndex(5, 5);
            CellSelection selection4 = worksheet.Cells[fromIndex, toIndex];
            #endregion
        }
예제 #20
0
        public void IncreaseDecreaseIndent()
        {
            #region radspreadprocessing-working-with-cells-get-set-clear-properties_6
            Workbook      workbook  = new Workbook();
            Worksheet     worksheet = workbook.Worksheets.Add();
            CellSelection selection = worksheet.Cells[0, 0, 5, 5];

            selection.IncreaseIndent();
            selection.DecreaseIndent();
            #endregion
        }
예제 #21
0
        public void CreateSelection4()
        {
            #region radspreadsheet-active-cell-selection_3
            Workbook  workbook  = new Workbook();
            Worksheet worksheet = workbook.Worksheets.Add();

            CellIndex     fromIndex  = new CellIndex(0, 0);
            CellIndex     toIndex    = new CellIndex(5, 5);
            CellSelection selection4 = worksheet.Cells[fromIndex, toIndex];
            #endregion
        }
예제 #22
0
        public void IncreaseDecreaseIndent()
        {
            #region radspreadsheet-features-formatting-cells_6
            Workbook      workbook  = new Workbook();
            Worksheet     worksheet = workbook.Worksheets.Add();
            CellSelection selection = worksheet.Cells[0, 0, 5, 5];

            selection.IncreaseIndent();
            selection.DecreaseIndent();
            #endregion
        }
예제 #23
0
        public void GetFormat()
        {
            Workbook  workbook  = new Workbook();
            Worksheet worksheet = workbook.Worksheets.Add();

            CellSelection cellSelectionA1   = worksheet.Cells[new CellIndex(0, 0)];
            CellSelection cellSelectionA2B3 = worksheet.Cells[new CellRange(new CellIndex(1, 0), new CellIndex(2, 1))];

            CellValueFormat cellSelectioA1Format = cellSelectionA1.GetFormat().Value;
            CellValueFormat cellSelectioA2Format = cellSelectionA2B3.GetFormat().Value;
        }
예제 #24
0
        public void CreateSelection3()
        {
            #region radspreadsheet-active-cell-selection_2
            Workbook  workbook  = new Workbook();
            Worksheet worksheet = workbook.Worksheets.Add();

            List <CellRange> ranges = new List <CellRange>();
            ranges.Add(new CellRange(0, 0, 5, 5));
            ranges.Add(new CellRange(0, 10, 5, 15));
            CellSelection selection3 = worksheet.Cells[ranges];
            #endregion
        }
예제 #25
0
        public void GetSetClearIsBold()
        {
            #region radspreadprocessing-working-with-cells-get-set-clear-properties_1
            Workbook      workbook  = new Workbook();
            Worksheet     worksheet = workbook.Worksheets.Add();
            CellSelection selection = worksheet.Cells[0, 0, 5, 5];

            selection.SetIsBold(true);
            bool isBold = selection.GetIsBold().Value;
            selection.ClearIsBold();
            #endregion
        }
예제 #26
0
        public void CreateSelection3()
        {
            #region radspreadprocessing-working-with-cells-accessing-cells-of-worksheet_2
            Workbook  workbook  = new Workbook();
            Worksheet worksheet = workbook.Worksheets.Add();

            List <CellRange> ranges = new List <CellRange>();
            ranges.Add(new CellRange(0, 0, 5, 5));
            ranges.Add(new CellRange(0, 10, 5, 15));
            CellSelection selection3 = worksheet.Cells[ranges];
            #endregion
        }
 public void GenerateUnit(UnitType unitType)
 {
     ResManager.Get().LoadAsync <GameObject>(unitPrefabDic[unitType], (obj) =>
     {
         UnitBase unitBase = obj.GetComponent <UnitBase>();
         obj.transform.SetParent(GameObject.Find("Units").transform);
         obj.transform.position = CellSelection.Get().GetCurrentSelected().transform.position;
         unitBase.SetPosition(CellSelection.Get().GetCurrentSelected());
         CellSelection.Get().GetCurrentSelected().CurrentUnit = unitBase;
         Pop();
     });
 }
예제 #28
0
        public bool IsText(int row, int column)
        {
            CellIndex     cellIndex = new CellIndex(row, column);
            CellSelection selection = sheet.Cells[cellIndex];
            ICellValue    cellValue = selection.GetValue().Value;

            if (cellValue.ValueType == CellValueType.Text)
            {
                return(true);
            }
            return(false);
        }
예제 #29
0
        public void GetSetClearIsBold()
        {
            #region radspreadsheet-features-formatting-cells_1
            Workbook      workbook  = new Workbook();
            Worksheet     worksheet = workbook.Worksheets.Add();
            CellSelection selection = worksheet.Cells[0, 0, 5, 5];

            selection.SetIsBold(true);
            bool isBold = selection.GetIsBold().Value;
            selection.ClearIsBold();
            #endregion
        }
예제 #30
0
        public void ApplyFormat()
        {
            Workbook  workbook  = new Workbook();
            Worksheet worksheet = workbook.Worksheets.Add();

            CellSelection   cellSelectionA1  = worksheet.Cells[new CellIndex(0, 0)];
            CellValueFormat scientificFormat = new CellValueFormat("0.00E+00");

            cellSelectionA1.SetFormat(scientificFormat);

            CellSelection   cellSelectionA2B3 = worksheet.Cells[new CellRange(new CellIndex(1, 0), new CellIndex(2, 1))];
            CellValueFormat percentageFormat  = new CellValueFormat("0.00%");

            cellSelectionA2B3.SetFormat(percentageFormat);
        }
예제 #31
0
 private bool check_For_Win_or_Tie(CellSelection player)
 {
     if (game.isWin(player))
     {
         this.Invalidate();
         if (player == CellSelection.X) { System.Windows.Forms.MessageBox.Show("Congratulations! You win!"); }
         else { System.Windows.Forms.MessageBox.Show("Uh oh! You lost!"); }
         return true;
     }
     else if (game.isTie())
     {
         this.Invalidate();
         System.Windows.Forms.MessageBox.Show("It's a tie!");
         return true;
     }
     return false;
 }
        //-----------------------------------------------------------
        // This function checks if the player given by 'player' input
        // won the game.
        //
        // Input:
        //		player - the player to check for a win
        //
        // Returns:
        //		true  - 'player' won
        //		false - 'player' didn't win
        //-----------------------------------------------------------
        public bool isWin(CellSelection player)
        {
            // check horizontals
            for (int i=0; i<dim; i++)
            {
                if (board[i, 0] == player)
                {
                    for (int j=1; j<dim; j++)
                    {
                        if (board[i, j] != player) { break; }

                        if (j == (dim - 1))
                        {
                            gameover = true;
                            return true;
                        }
                    }
                }
            }

            // check verticals
            for (int j=0; j<dim; j++)
            {
                if (board[0, j] == player)
                {
                    for (int i=1; i<dim; i++)
                    {
                        if (board[i, j] != player) { break; }

                        if (i == (dim - 1))
                        {
                            gameover = true;
                            return true;
                        }
                    }
                }
            }

            // check diagonals
            for (int i=0; i<dim; i++)
            {
                if (board[i, i] != player) { break; }

                if (i == (dim - 1))
                {
                    gameover = true;
                    return true;
                }
            }

            for (int i=0; i<dim; i++)
            {
                if (board[dim - 1 - i, i] != player) { break; }

                if (i == (dim - 1))
                {
                    gameover = true;
                    return true;
                }
            }

            return false;
        }
 //-----------------------------------------------------------
 // This function makes a move for the given 'player' in the
 // given 'square'.
 //
 // Input:
 //		row - cell row
 //      col - cell column
 //      player - player making the move
 //-----------------------------------------------------------
 public void makeMove(int row, int col, CellSelection player)
 {
     board[row, col] = player;
 }
        //-----------------------------------------------------------
        // This function determines if the computer can either win
        // the game, or block the user from winning the game.
        //
        // Input:
        //		player - CellSelection.X or CellSelection.O.
        //               This is the player to check if they're one
        //               away.
        //
        // Returns:
        //		Point - coordinate point that the computer should
        //              play in to win or block the player from winning.
        //              This will be (-1, -1) if the computer cannot
        //              win or block.
        //-----------------------------------------------------------
        private Point isOneAway(CellSelection player)
        {
            Point coord = new Point();
            bool canWin = false;

            CellSelection opponent;
            if (player == CellSelection.O) { opponent = CellSelection.X; }
            else { opponent = CellSelection.O; }

            for (int i=0; i<dim; i++)
            {
                for (int j=0; j<dim; j++)
                {
                    if ( board[i, j] == player )
                    {
                        // check the verticals
                        for (int k=0; k<dim; k++)
                        {
                            if ( k == i )
                                continue;

                            if ( board[k, j] == opponent )
                            {
                                canWin = false;
                                break;
                            }
                            else if ( board[k, j] == CellSelection.N )
                            {
                                if ( canWin )
                                {
                                    canWin = false;
                                    break;
                                }
                                canWin = true;
                                coord.X = k;
                                coord.Y = j;
                            }
                        }
                        if ( canWin )
                            break;

                        // check the horizontals
                        for (int k=0; k<dim; k++)
                        {
                            if ( k == j )
                                continue;

                            if ( board[i, k] == opponent )
                            {
                                canWin = false;
                                break;
                            }
                            else if ( board[i, k] == CellSelection.N )
                            {
                                if ( canWin )
                                {
                                    canWin = false;
                                    break;
                                }
                                canWin = true;
                                coord.X = i;
                                coord.Y = k;
                            }
                        }
                        if ( canWin )
                            break;

                        // if the square is on a diagonal, check it
                        if ( i == j )
                        {
                            // upper-left to bottom-right diagonal
                            for (int k=0; k<dim; k++)
                            {
                                if ( k == i )
                                    continue;

                                if ( board[k, k] == opponent )
                                {
                                    canWin = false;
                                    break;
                                }
                                else if ( board[k, k] == CellSelection.N )
                                {
                                    if ( canWin )
                                    {
                                        canWin = false;
                                        break;
                                    }
                                    canWin = true;
                                    coord.X = k;
                                    coord.Y = k;
                                }
                            }
                        }
                        if ( canWin )
                            break;

                        // bottom-left to upper-right diagonal
                        if ( ( i + j ) == ( dim - 1) )
                        {
                            for (int k=0; k<dim; k++)
                            {
                                if ( k == j )
                                {
                                    continue;
                                }

                                if ( board[dim - 1 - k, k] == opponent )
                                {
                                    canWin = false;
                                    break;
                                }
                                else if ( board[dim - 1 - k, k] == CellSelection.N )
                                {
                                    if ( canWin )
                                    {
                                        canWin = false;
                                        break;
                                    }
                                    canWin = true;
                                    coord.X = dim - 1 - k;
                                    coord.Y = k;
                                }
                            }
                        }
                    }
                }
                if (canWin) { break; }
            }

            if (!canWin) {
                coord.X = -1;
                coord.Y = -1;
            }
            return coord;
        }
예제 #35
0
        private static void SetCellProperties(PivotExportCellInfo cellInfo, CellSelection cellSelection)
        {
            var fill = GenerateFill(cellInfo.Background);
            if (fill != null)
            {
                cellSelection.SetFill(fill);
            }

            SolidColorBrush solidBrush = cellInfo.Foreground as SolidColorBrush;
            if (solidBrush != null)
            {
                cellSelection.SetForeColor(new ThemableColor(solidBrush.Color));
            }

            if (cellInfo.FontWeight.HasValue && cellInfo.FontWeight.Value != FontWeights.Normal)
            {
                cellSelection.SetIsBold(true);
            }

            SolidColorBrush solidBorderBrush = cellInfo.BorderBrush as SolidColorBrush;
            if (solidBorderBrush != null && cellInfo.BorderThickness.HasValue)
            {
                var borderThickness = cellInfo.BorderThickness.Value;
                var color = new ThemableColor(solidBorderBrush.Color);
                //var leftBorder = new CellBorder(GetBorderStyle(borderThickness.Left), color);
                //var topBorder = new CellBorder(GetBorderStyle(borderThickness.Top), color);
                var rightBorder = new CellBorder(GetBorderStyle(borderThickness.Right), color);
                var bottomBorder = new CellBorder(GetBorderStyle(borderThickness.Bottom), color);
                var insideBorder = cellInfo.Background != null ? new CellBorder(CellBorderStyle.None, color) : null;
                cellSelection.SetBorders(new CellBorders(null, null, rightBorder, bottomBorder, insideBorder, insideBorder, null, null));
            }
        }
예제 #36
0
        //Random move
        private CellSelection[,] randMove(CellSelection[,] inGrid)
        {
            Random random = new Random();
            int x, y;

            while (true)
            {
                x = random.Next(0, 3);
                y = random.Next(0, 3);

                if ( moveIsValid(x,y) )
                {
                    inGrid[x, y] = moveType;
                    return inGrid;
                }
            }
        }