void importBrush(object sender, EventArgs e) { try { FileDialog fileDia = new OpenFileDialog(); fileDia.Filter = filter; fileDia.DefaultExt = saveFormat; if (fileDia.ShowDialog() == DialogResult.OK) { string filename = fileDia.FileName; if (fileDia.CheckFileExists) { textureList.Items.Clear(); data = brushData.importBrush(filename, NUM_TEXTURE_TOTAL); // All the values have been set - now is the time to set the form itself setValuesToFormControls(data); } else { System.Windows.Forms.MessageBox.Show("File \"" + filename + "\" does not exist. Please choose another one"); } } } catch (Exception e2) { Console.WriteLine(e2); } }
public void setData(brushData data) { if (data != null) { textureList.Items.Clear(); setValuesToFormControls(data); this.data = data; } }
void getValuesFromFormControls() { try { data = new brushData(); //Texture brushes foreach (textureData tex in textureList.Items) { data.textures.AddLast(tex); } data.rounds = (int)numericRounds.Value; // Grass data.grassCoverage = grassCoverageTrackbar.Value; data.grassDensity = grassDensityTrackbar.Value; data.grassSize = bladeSize.Value; data.grassSizeVariation = bladeSizeVariation.Value; data.numSelected = grassTextures.numSelected; data.grassTexture = grassTextures.selectedTextures; if (paintGrass.Checked) { data.grassOption = grassOption.Paint; } else { data.grassOption = grassOption.NoGrass; } data.grassTexture = grassTextures.getListOfNames(); // The brush itself data.innerCircle = (int)numInner.Value; data.outerCircle = (int)numOuter.Value; // Colour data.col = colourButton.BackColor; if (paintColour.Checked) { data.colourOption = colourOption.Colour; } else { data.colourOption = colourOption.NoColour; } data.colourCoverage = colourCoverage.Value; data.colourPresure = colourPresure.Value; data.randomize = randomCheck.Checked; } catch (Exception e) { Console.WriteLine(e); } }
public void setValuesToFormControls(brushData localData) { try { // Texture foreach (textureData tex in localData.textures) { textureList.Items.Add(tex); } textureList.SelectedIndex = 0; // Grass grassCoverageTrackbar.Value = localData.grassCoverage; grassDensityTrackbar.Value = localData.grassDensity; foreach (string grassTexture in data.grassTexture) { grassTextures.setListByName(grassTexture); } bladeSize.Value = localData.grassSize; bladeSizeVariation.Value = localData.grassSizeVariation; if (localData.grassOption == grassOption.NoGrass) { paintGrass.Checked = false; } else if (localData.grassOption == grassOption.Paint) { paintGrass.Checked = true; } else { throw new Exception("Wrong grass option in init data"); } // Outer and inner brush size numInner.Value = (decimal)localData.innerCircle; numOuter.Value = (decimal)localData.outerCircle; //Colour colourButton.BackColor = localData.col; colourCoverage.Value = localData.colourCoverage; colourPresure.Value = localData.colourPresure; if (localData.colourOption == colourOption.Colour) { paintColour.Checked = true; } else if (localData.colourOption == colourOption.NoColour) { paintColour.Checked = false; } else { throw new Exception("Wrong colour option in init data"); } randomCheck.Checked = data.randomize; } catch (Exception e) { Console.WriteLine(e); } }
void getValuesFromFormControls() { try { data = new brushData(); //Texture brushes foreach(textureData tex in textureList.Items) { data.textures.AddLast(tex); } data.rounds = (int)numericRounds.Value; // Grass data.grassCoverage = grassCoverageTrackbar.Value; data.grassDensity = grassDensityTrackbar.Value; data.grassSize = bladeSize.Value; data.grassSizeVariation = bladeSizeVariation.Value; data.numSelected = grassTextures.numSelected; data.grassTexture = grassTextures.selectedTextures; if (paintGrass.Checked) { data.grassOption = grassOption.Paint; } else { data.grassOption = grassOption.NoGrass; } data.grassTexture = grassTextures.getListOfNames(); // The brush itself data.innerCircle = (int)numInner.Value; data.outerCircle = (int)numOuter.Value; // Colour data.col = colourButton.BackColor; if (paintColour.Checked) { data.colourOption = colourOption.Colour; } else { data.colourOption = colourOption.NoColour; } data.colourCoverage = colourCoverage.Value; data.colourPresure = colourPresure.Value; data.randomize = randomCheck.Checked; } catch (Exception e) { Console.WriteLine(e); } }
public void setValuesToFormControls(brushData localData) { try { // Texture foreach(textureData tex in localData.textures) { textureList.Items.Add(tex); } textureList.SelectedIndex = 0; // Grass grassCoverageTrackbar.Value = localData.grassCoverage; grassDensityTrackbar.Value = localData.grassDensity; foreach(string grassTexture in data.grassTexture) { grassTextures.setListByName(grassTexture); } bladeSize.Value = localData.grassSize; bladeSizeVariation.Value = localData.grassSizeVariation; if (localData.grassOption == grassOption.NoGrass) { paintGrass.Checked = false; } else if (localData.grassOption == grassOption.Paint) { paintGrass.Checked = true; } else { throw new Exception("Wrong grass option in init data"); } // Outer and inner brush size numInner.Value = (decimal)localData.innerCircle; numOuter.Value = (decimal)localData.outerCircle; //Colour colourButton.BackColor = localData.col; colourCoverage.Value = localData.colourCoverage; colourPresure.Value = localData.colourPresure; if (localData.colourOption == colourOption.Colour) { paintColour.Checked = true; } else if (localData.colourOption == colourOption.NoColour) { paintColour.Checked = false; } else { throw new Exception("Wrong colour option in init data"); } randomCheck.Checked = data.randomize; } catch (Exception e) { Console.WriteLine(e); } }