private void CmdGo_Click(object sender, EventArgs e) { InitializeRandomNumberGenerator(); int originx = 10; // PicSparkler.Width / 2; int originy = PicSparkler.Height / 2; Graphics g = PicSparkler.CreateGraphics(); g.DrawLine(Pens.White, new Point(originx, originy), new Point(originx + 5000, originy + 1000)); // TBD Create and draw ONE sparkler _Sparkler = CreateSparkler(originx, originy); for (int i = 0; i < _Sparkler._SparkList.Count; i++) { _Sparkler.DrawSpark(_G, i); } _Sparkler.AddLine(new Point(originx, originy), new Point(originx + 5000, originy + 1000)); CmdGo.Enabled = false; // Initialize, then start the timer. //InitializeTimer(); _Timer.Start(); }
private ClsSparkler CreateSparkler(int originx, int originy) { bool diameterokay = int.TryParse(TxtMaxDiameterInPixels.Text, out int diameter); if (!diameterokay) { MessageBox.Show("Diameter (in pixels) must be an integer > 0"); return(null); } bool numsparksokay = int.TryParse(TxtNumberOfSparks.Text, out int numsparks); if (!numsparksokay) { MessageBox.Show("Number of sparks must be an integer > 0"); return(null); } bool sparkdeltaokay = int.TryParse(TxtDeltaNumberOfSparks.Text, out int sparkdelta); if (!sparkdeltaokay) { MessageBox.Show("Delta # of sparks must be an integer > 0"); return(null); } bool sparkvelocityokay = int.TryParse(TxtSparkVelocityPxPerIteration.Text, out int sparkvelocity); if (!sparkvelocityokay) { MessageBox.Show("Spark velocity (in pixels/sec) must be an integer > 0"); return(null); } bool sparklengthokay = int.TryParse(TxtAvgSparkLengthInPixels.Text, out int sparklength); if (!sparklengthokay) { MessageBox.Show("Spark length (in pixels) must be an integer > 0"); return(null); } bool sparklengthvarianceokay = double.TryParse(TxtSparkLengthVariance.Text, out double sparklengthvariance); if (!sparklengthvarianceokay) { MessageBox.Show("Spark length variance (% of total length) must be a real number between 0 and 100"); return(null); } bool iterationrateokay = int.TryParse(TxtIterationRate.Text, out int iterationrate); if (!iterationrateokay) { MessageBox.Show("Iteration rate (refreshes/sec) must be an integer > 0"); return(null); } int pdftype = Math.Max(0, CmbPDFType.SelectedIndex); ClsSparkler sparkler = new ClsSparkler(_Rng, new Point(originx, originy), diameter, numsparks, sparkdelta, sparkvelocity, sparklength, sparklengthvariance, iterationrate, pdftype); return(sparkler); }