// Description: Given the current settings in the global setup dialog objects, creates // the items to run the server with the current settings. public void DoSetup() { byte [,] colors = { { 255, 0, 0 }, { 0, 255, 0 }, { 0, 0, 255 }, { 255, 255, 0 }, { 255, 0, 255 }, { 0, 255, 255 }, { 0, 128, 255 }, { 0, 255, 128 }, { 255, 0, 128 }, { 128, 0, 255 }, { 255, 128, 0 }, { 128, 255, 0 } }; if (graphics != null) { graphics.Dispose(); } graphics = Graphics.FromHwnd((IntPtr)handle); Ball.SetWindow(graphics, setup); Ball.TheForm = form; /* * Figure out the size (& mass) distribution of the balls... */ Distribute distribute = new Distribute(setup.sizeMin, setup.sizeMax, setup.distribution); balls = new Ball[setup.ballCount]; float perColor = (float)setup.ballCount / (float)colors.GetLength(0); for (int index = 0; index < setup.ballCount; index++) { int color = (int)((float)index / perColor); balls[index] = new Ball(distribute.GetNextSize(), colors[color, 0], colors[color, 1], colors[color, 2]); } init = true; cycleCount = 0; titleDraw = false; if (setup.strTitle == null) { return; } if (setup.strTitle == "") { return; } if (setup.strFont == null) { return; } titleDraw = true; //Console.WriteLine("{0} {1} {2}", setup.strTitle, setup.strFont, setup.titleSize); Font font = new Font(setup.strFont, setup.titleSize); SizeF size = graphics.MeasureString(setup.strTitle, font); PointF location = new PointF(form.Size.Width / 2 - size.Width / 2, form.Size.Height / 2 - size.Height / 2); titleRectangle = new Rectangle( (int)(form.Size.Width / 2 - size.Width / 2), (int)(form.Size.Height / 2 - size.Height / 2), (int)size.Width, (int)size.Height); titleDrawSpot = new Point(titleRectangle.X, titleRectangle.Y); font.Dispose(); }