Example #1
0
        private void setCurrentWorkspaceFromFile(String fileNameAndPath)
        {
            UserWorkspace lspace = UserWorkspace.LoadWorkspace(fileNameAndPath, this.dataGridView_pixelGrid);

            this.toolStripTextBox_gridSizeX.Text = lspace.axisX + "";
            this.toolStripTextBox_gridSizeY.Text = lspace.axisY + "";
            this.dataGridView_pixelGrid.Invalidate();
        }
Example #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);
        }
Example #3
0
        private void saveCurrentWorkspace(String fileNameAndPath)
        {
            try
            {
                int sizeX = System.Convert.ToInt32(this.toolStripTextBox_gridSizeX.Text);
                int sizeY = System.Convert.ToInt32(this.toolStripTextBox_gridSizeY.Text);

                UserWorkspace nUserWorkspace = new UserWorkspace(sizeX, sizeY, this.dataGridView_pixelGrid);

                nUserWorkspace.SaveWorkspace(fileNameAndPath);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.ToString());
            }
        }