public void resize(int percentage) { for (int i = 0; i < ParticleArr.Count(); i++) { string l = ParticleArr[i]; if (l.Contains("Radius") && l.Contains("=")) { string part1 = l.Substring(0, l.LastIndexOf('=') + 2); string part2 = l.Substring(l.LastIndexOf('=') + 2); double d = 0; try { d = Double.Parse(part2); } catch (Exception) { // couldn't parse this as a double. continue; } // modify floats differently than ints. if (l.Contains("m_f")) { double newVal = d + (percentage / 100.0) * Math.Abs(d); ParticleArr[i] = part1 + newVal; } else if (l.Contains("m_n")) { int _d = Convert.ToInt32(d); int newVal = _d + (percentage / 100) * Math.Abs(_d); ParticleArr[i] = part1 + newVal; } } } }
public override string ToString() { string str = ""; for (int i = 0; i < ParticleArr.Count(); i++) { str += ParticleArr.ElementAt(i) + "\n"; } return(str); }
private bool containsTrimmed(string line) { for (int i = 0; i < ParticleArr.Count(); i++) { string thisLine = ParticleArr[i]; if (thisLine.Trim() == line) { return(true); } } return(false); }
public void changeColor(string[] rgb) { for (int i = 0; i < ParticleArr.Count(); i++) { string l = ParticleArr[i]; if (l.Contains("ColorMin") || l.Contains("ColorMax") || l.Contains("ConstantColor") || l.Contains("ColorScale") || l.Contains("ColorFade") || l.Contains("TintMin") || l.Contains("TintMax") ) { string part1 = l.Substring(0, l.LastIndexOf('=') + 2); string part2 = l.Substring(l.LastIndexOf('=') + 2); part2 = part2.Replace("(", ""); part2 = part2.Replace(")", ""); char[] dels = { ',', ' ' }; string[] nums = part2.Split(dels); string lastNum = nums[3]; string newPart2 = "(" + " " + rgb[0] + ", " + rgb[1] + ", " + rgb[2] + ", " + lastNum + " )"; ParticleArr[i] = part1 + newPart2; } } }