예제 #1
0
        private void IndividualMatrixRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            // If individialMatrixRadioButton is checked
            if (IndividualMatrixRadioButton.Checked)
            {
                // If MatrixDataGridView isn't clear
                if (MatrixDataGridView.GetCellCount(DataGridViewElementStates.Displayed) != 0)
                {
                    ColumnsTextBox.Text = MatrixClass.COUNT_COLUMNS.ToString();
                    RowsTextBox.Text    = MatrixClass.COUNT_ROWS.ToString();
                }
                // ... is clear
                else
                {
                    ColumnsTextBox.Text = COUNT_ROW_COL_DEFAULT.ToString();
                    RowsTextBox.Text    = COUNT_ROW_COL_DEFAULT.ToString();
                }

                // Set visible group boxes
                ColRowGroupBox.Visible = true;
                ResultGroupBox.Visible = false;
            }
            else
            {
                // Set visible group boxes
                ColRowGroupBox.Visible = false;
                ResultGroupBox.Visible = true;
                individualMatrix       = null;
            }
        }
예제 #2
0
        private void dataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            // check that we are in a header cell!
            if (e.RowIndex == -1 && e.ColumnIndex > 0)
            {
                e.PaintBackground(e.ClipBounds, true);
                Rectangle rect      = MatrixDataGridView.GetColumnDisplayRectangle(e.ColumnIndex, true);
                Size      titleSize = TextRenderer.MeasureText(e.Value.ToString(), e.CellStyle.Font);
                int       offset    = 4;
                if (MatrixDataGridView.ColumnHeadersHeight < titleSize.Width + 2 * offset)
                {
                    MatrixDataGridView.ColumnHeadersHeight = titleSize.Width + 2 * offset;
                }

                e.Graphics.TranslateTransform(1, titleSize.Width);
                e.Graphics.RotateTransform(-90.0f);

                e.Graphics.DrawString(e.Value.ToString(), MatrixDataGridView.Font, Brushes.Black,
                                      new PointF(rect.Y - (MatrixDataGridView.ColumnHeadersHeight - titleSize.Width - offset), rect.X));

                e.Graphics.RotateTransform(90.0f);
                e.Graphics.TranslateTransform(-1, -titleSize.Width);

                e.Handled = true;
            }

            if (e.RowIndex != -1 && e.ColumnIndex > 0)
            {
                var state = (ProjectDependency)e.Value;

                /*if (state == ProjectDependency.Invalid)
                 *  e.CellStyle.BackColor = Color.Silver;*/

                e.PaintBackground(e.ClipBounds, true);

                Rectangle rect = MatrixDataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);

                var CheckBoxRegion = new Rectangle(rect.X + box_offset, rect.Y + box_offset, box_size, box_size);
                switch (state)
                {
                case ProjectDependency.None:
                    ControlPaint.DrawCheckBox(e.Graphics, CheckBoxRegion, ButtonState.Normal);
                    break;

                case ProjectDependency.Direct:
                    ControlPaint.DrawCheckBox(e.Graphics, CheckBoxRegion, ButtonState.Checked);
                    break;

                case ProjectDependency.Indirect:
                    ControlPaint.DrawCheckBox(e.Graphics, CheckBoxRegion, ButtonState.Checked | ButtonState.Inactive);
                    break;

                case ProjectDependency.Invalid:
                    ControlPaint.DrawCheckBox(e.Graphics, CheckBoxRegion, ButtonState.Inactive);
                    break;
                }

                e.Handled = true;
            }
        }
예제 #3
0
 private void ProcessButton_Click(object sender, EventArgs e)
 {
     if (MatrixDataGridView.GetCellCount(DataGridViewElementStates.Displayed) == 0)
     {
         MessageBox.Show("Matrix isn't builded. Correct it and try again!");
         return;
     }
     if (BaseMatrixRadioButton.Checked)
     {
         ProcessBaseMatrix();
     }
     else
     {
         ProcessIndividualMatrix();
     }
 }