private void toolStripButton_generateGrid_Click(object sender, EventArgs e)
        {
            try
            {
                int sizeX = System.Convert.ToInt32(this.toolStripTextBox_gridSizeX.Text);
                int sizeY = System.Convert.ToInt32(this.toolStripTextBox_gridSizeY.Text);

                GenericGridFunctions.InitPixelGrid(this.dataGridView_pixelGrid, sizeX, sizeY);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.ToString());
            }
        }
Exemple #2
0
        public static UserWorkspace LoadWorkspace(String textFilePathAndName, DataGridView dgv)
        {
            int sizeX = 0;
            int sizeY = 0;

            try
            {
                string[] lines = System.IO.File.ReadAllLines(textFilePathAndName);

                for (int a = 0; a < lines.Count(); a++)
                {
                    if (lines[a].Contains("AxisX"))
                    {
                        sizeX = System.Convert.ToInt32(lines[a].Split(':')[1]);
                    }
                    else if (lines[a].Contains("AxisY"))
                    {
                        sizeY = System.Convert.ToInt32(lines[a].Split(':')[1]);

                        //got what we need to build the grid
                        GenericGridFunctions.InitPixelGrid(dgv, sizeX, sizeY);
                    }
                    else if (lines[a].Contains("Grid"))
                    {
                        String[] gridrow = lines[a].Split(':');

                        int row  = System.Convert.ToInt32(gridrow[1]);
                        int cell = System.Convert.ToInt32(gridrow[2]);
                        int argb = System.Convert.ToInt32(gridrow[3]);

                        dgv.Rows[row].Cells[cell].Style.BackColor = Color.FromArgb(argb);
                    }
                }
            }
            catch (Exception ex)
            {
            }

            //force an update
            dgv.Invalidate();
            dgv.Refresh();

            //no selection
            dgv.ClearSelection();

            UserWorkspace nWorkspace = new UserWorkspace(sizeX, sizeY, dgv);

            return(nWorkspace);
        }
        private void toolStripButton_ShiftDown_Click(object sender, EventArgs e)
        {
            DataGridView shadowDgv = GenericGridFunctions.DataGridViewColAndRowDataCopy(this.dataGridView_pixelGrid);

            for (int b = 0; b < this.dataGridView_pixelGrid.RowCount; b++)
            {
                for (int a = 0; a < this.dataGridView_pixelGrid.ColumnCount; a++)
                {
                    if (b == 0)
                    {
                        this.dataGridView_pixelGrid.Rows[b].Cells[a].Style.BackColor = shadowDgv.Rows[(this.dataGridView_pixelGrid.RowCount - 1)].Cells[a].Style.BackColor;
                    }
                    else
                    {
                        this.dataGridView_pixelGrid.Rows[b].Cells[a].Style.BackColor = shadowDgv.Rows[b - 1].Cells[a].Style.BackColor;
                    }
                }
            }
        }
        private void toolStripButton_ShiftLeft_Click(object sender, EventArgs e)
        {
            //shift coloumn data left 1 coloumn
            DataGridView shadowDgv = GenericGridFunctions.DataGridViewColAndRowDataCopy(this.dataGridView_pixelGrid);

            for (int a = 0; a < this.dataGridView_pixelGrid.ColumnCount; a++)
            {
                for (int b = 0; b < this.dataGridView_pixelGrid.RowCount; b++)
                {
                    if (a == (this.dataGridView_pixelGrid.ColumnCount - 1))
                    {
                        //get the first column data
                        this.dataGridView_pixelGrid.Rows[b].Cells[a].Style.BackColor = shadowDgv.Rows[b].Cells[0].Style.BackColor;
                    }
                    else
                    {
                        this.dataGridView_pixelGrid.Rows[b].Cells[a].Style.BackColor = shadowDgv.Rows[b].Cells[a + 1].Style.BackColor;
                    }
                }
            }
        }