Example #1
0
 /// <summary>
 /// מחזיר מערך של ערכי התאים שהקבוצה מכילה
 /// </summary>
 /// <returns></returns>
 public int[] GetValues()
 {
     int[] tmp = new int[9];
     for (int i = 0; i < 9; i++)
     {
         SudukuCell tmpControl = (SudukuCell)this.Controls[i];
         tmp[i] = tmpControl.GetValue();
     }
     return(tmp);
 }
Example #2
0
        /// <summary>
        /// מחזיר מערך של כל התאים בלוח
        /// </summary>
        /// <returns></returns>
        public SudukuCell[] GetAllCells()
        {
            SudukuCell[] arr     = new SudukuCell[81];
            int          counter = 0;

            for (int i = 0; i < 9; i++)
            {
                for (int k = 0; k < 9; k++)
                {
                    arr[counter] = this.GetGroupByIndex(i).GetCellByIndex(k);
                    counter++;
                }
            }
            return(arr);
        }
Example #3
0
        /// <summary>
        /// מחזיר מערך של כל התאים לפי טור מסויים
        /// </summary>
        /// <param name="groupColume"></param>
        /// <param name="colume"></param>
        /// <returns></returns>
        public SudukuCell[] GetAllCellsFromColume(int groupColume, int colume)
        {
            SudukuCell[] arr = new SudukuCell[9];
            SudukuCell[] tmp;
            int          counter = 0;

            for (int i = 0; i < 9; i++)
            {
                if (this.GetGroupByIndex(i).colume == groupColume)
                {
                    tmp = this.GetGroupByIndex(i).GetAllCellsByColume(colume);
                    for (int j = 0; j < 3; j++)
                    {
                        arr[counter] = tmp[j];
                        counter++;
                    }
                }
            }
            return(arr);
        }
Example #4
0
        /// <summary>
        /// מחזיר מערך של כל התאים לפי שורה מסויימת
        /// </summary>
        /// <param name="groupRow"></param>
        /// <param name="row"></param>
        /// <returns></returns>
        public SudukuCell[] GetAllCellsFromRow(int groupRow, int row)
        {
            SudukuCell[] arr = new SudukuCell[9];
            SudukuCell[] tmp;
            int          counter = 0;

            for (int i = 0; i < 9; i++)
            {
                if (this.GetGroupByIndex(i).row == groupRow)
                {
                    tmp = this.GetGroupByIndex(i).GetAllCellsByRow(row);
                    for (int j = 0; j < 3; j++)
                    {
                        arr[counter] = tmp[j];
                        counter++;
                    }
                }
            }
            return(arr);
        }
Example #5
0
        }                          //השורה שבה הקבוצה נמצאת

        /// <summary>
        /// פעולה בונה שמייצרת את הקבוצה מבחינה גרפית
        /// </summary>
        /// <param name="colume"></param>
        /// <param name="row"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        public SudukuCellGroup(int colume, int row, int width, int height)
        {
            this.row    = row;
            this.colume = colume;

            this.ColumnCount = 3;
            this.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
            this.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
            this.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));

            this.RowCount = 3;
            this.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
            this.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
            this.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));


            this.Location = new System.Drawing.Point(0, 20);
            this.Name     = row.ToString() + colume.ToString();

            this.Size = new System.Drawing.Size(width, height);

            for (int i = 0; i < 3; i++)
            {
                for (int k = 0; k < 3; k++)
                {
                    SudukuCell tmpCell = new SudukuCell(i, k);
                    tmpCell.ForeColor    = Color.DimGray;
                    tmpCell.Font         = new Font(tmpCell.Font.FontFamily, 25);
                    tmpCell.TextAlign    = HorizontalAlignment.Center;
                    tmpCell.AutoSize     = false;
                    tmpCell.Size         = new System.Drawing.Size(width / 3, height / 3);
                    tmpCell.Click       += new EventHandler((s, e) => tmpCell.BackColor = Color.White);
                    tmpCell.TextChanged += new EventHandler((s, e) => tmpCell.SetValue(tmpCell.GetValueFromText()));

                    this.Controls.Add(tmpCell, i, k);
                }
            }
        }