Esempio n. 1
0
 private void layoutPanel_TileColors_CellPaint(object sender, TableLayoutCellPaintEventArgs e)
 {
     if ((e.Column + e.Row) % 2 == 1)
     {
         e.Graphics.FillRectangle(Brushes.Black, e.CellBounds);
         if (SandBagIndexes.GetIndex(e.Row, e.Column))
         {
             using (Brush brush = new SolidBrush(Color.FromArgb(180, 223, 205, 0))) {
                 e.Graphics.FillRectangle(brush, e.CellBounds);
             }
             using (Brush brush = new SolidBrush(Color.FromArgb(255, 223, 205, 0))) {
                 e.Graphics.FillEllipse(brush, new Rectangle(e.CellBounds.X + 6, e.CellBounds.Y + 6, e.CellBounds.Width - 12, e.CellBounds.Height - 12));
             }
         }
     }
     else
     {
         e.Graphics.FillRectangle(Brushes.White, e.CellBounds);
         if (SandBagIndexes.GetIndex(e.Row, e.Column))
         {
             using (Brush brush = new SolidBrush(Color.FromArgb(180, 223, 205, 0))) {
                 e.Graphics.FillRectangle(brush, e.CellBounds);
             }
             using (Brush brush = new SolidBrush(Color.FromArgb(255, 223, 205, 0))) {
                 e.Graphics.FillEllipse(brush, new Rectangle(e.CellBounds.X + 6, e.CellBounds.Y + 6, e.CellBounds.Width - 12, e.CellBounds.Height - 12));
             }
         }
     }
 }
Esempio n. 2
0
        private void CheckButtons(bool set)
        {
            if (_currentIndex <= 3)
            {
                foreach (var pb in this.layoutPanel_red.Controls.OfType <CheckBox>())
                {
                    var index = int.Parse(pb.Text.Substring(1)) - 1;
                    if (!set)
                    {
                        //SandBagIndexes.Indexes[_currentIndex].Red[index] = pb.Checked;
                        SandBagIndexes.SetIndex(0, index, _currentIndex, pb.Checked);
                    }
                    else
                    {
                        //pb.Checked = SandBagIndexes.Indexes[_currentIndex].Red[index];
                        pb.Checked = SandBagIndexes.GetIndex(0, index, _currentIndex);
                    }
                }
                foreach (var pb in this.layoutPanel_orange.Controls.OfType <CheckBox>())
                {
                    var index = int.Parse(pb.Text.Substring(1)) - 1;
                    if (!set)
                    {
                        //SandBagIndexes.Indexes[_currentIndex].Orange[index] = pb.Checked;
                        SandBagIndexes.SetIndex(1, index, _currentIndex, pb.Checked);
                    }
                    else
                    {
                        //pb.Checked = SandBagIndexes.Indexes[_currentIndex].Orange[index];
                        pb.Checked = SandBagIndexes.GetIndex(1, index, _currentIndex);
                    }
                }
                foreach (var pb in this.layoutPanel_yellow.Controls.OfType <CheckBox>())
                {
                    var index = int.Parse(pb.Text.Substring(1)) - 1;
                    if (!set)
                    {
                        //SandBagIndexes.Indexes[_currentIndex].Yellow[index] = pb.Checked;
                        SandBagIndexes.SetIndex(2, index, _currentIndex, pb.Checked);
                    }
                    else
                    {
                        //pb.Checked = SandBagIndexes.Indexes[_currentIndex].Yellow[index];
                        pb.Checked = SandBagIndexes.GetIndex(2, index, _currentIndex);
                    }
                }
                foreach (var pb in this.layoutPanel_green.Controls.OfType <CheckBox>())
                {
                    var index = int.Parse(pb.Text.Substring(1)) - 1;
                    if (!set)
                    {
                        //SandBagIndexes.Indexes[_currentIndex].Green[index] = pb.Checked;
                        SandBagIndexes.SetIndex(3, index, _currentIndex, pb.Checked);
                    }
                    else
                    {
                        //pb.Checked = SandBagIndexes.Indexes[_currentIndex].Green[index];
                        pb.Checked = SandBagIndexes.GetIndex(3, index, _currentIndex);
                    }
                }
            }

            // Call the refreshed event
            if (!set)
            {
                SandBagIndexes.RefreshIndexes();
            }
            else
            {
                var sandBags = SandBagIndexes.SandBagCount();
                if (sandBags > 12)
                {
                    MessageBox.Show("You seem to have more than 12 sandbags chosen even though you should have only 12.", "Warning: Too many sandbags chosen.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (sandBags < 12 && _currentIndex == 4)
                {
                    MessageBox.Show("You seem to have less than 12 sandbags chosen even though you should have 12.", "Warning: Too few sandbags chosen.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Esempio n. 3
0
        private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            if (e.ColumnIndex < 0 || e.RowIndex < 0)
            {
                return;
            }
            var dGridView = sender as DataGridView;

            if ((e.ColumnIndex + e.RowIndex) % 2 == 1)
            {
                // Black tile
                if (SandBagIndexes.GetIndex(e.RowIndex, e.ColumnIndex))
                {
                    // Need to be lit
                    dGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.ForeColor          = Color.Green;
                    dGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor          = Color.Black;
                    dGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.SelectionForeColor = Color.DarkGreen;
                    dGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.SelectionBackColor = Color.Silver;
                }
                else
                {
                    dGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.ForeColor          = Color.White;
                    dGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor          = Color.Black;
                    dGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.SelectionForeColor = Color.Black;
                    dGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.SelectionBackColor = Color.White;
                }
            }
            else
            {
                // White tile
                if (SandBagIndexes.GetIndex(e.RowIndex, e.ColumnIndex))
                {
                    // Need to be lit
                    dGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.ForeColor          = Color.Green;
                    dGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor          = Color.White;
                    dGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.SelectionForeColor = Color.DarkGreen;
                    dGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.SelectionBackColor = Color.Silver;
                }
                else
                {
                    dGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.ForeColor          = Color.Black;
                    dGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor          = Color.White;
                    dGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.SelectionForeColor = Color.White;
                    dGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.SelectionBackColor = Color.Black;
                }
            }

            //if ((e.ColumnIndex + e.RowIndex) % 2 == 0) {
            //    dGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Black;
            //    dGridView.Rows[e.RowIndex].DefaultCellStyle.SelectionBackColor = Color.Silver;
            //    dGridView.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.White;
            //    dGridView.Rows[e.RowIndex].DefaultCellStyle.SelectionForeColor = Color.Silver;
            //    if (SandBagIndexes.GetIndex(e.RowIndex, e.ColumnIndex)) {
            //        //dGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.ForeColor = Color.Green;
            //        //dGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.SelectionForeColor = Color.DarkGreen;
            //    }
            //}
            //else {
            //    dGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.White;
            //    dGridView.Rows[e.RowIndex].DefaultCellStyle.SelectionBackColor = Color.Silver;
            //    dGridView.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Black;
            //    dGridView.Rows[e.RowIndex].DefaultCellStyle.SelectionForeColor = Color.Silver;
            //}
        }