// ************************************ create_control_graphic /// <summary> /// deletes any existing control graphic and then creates a /// new one /// </summary> void create_control_graphic() { Rectangle bounding_rectangle; if (control_graphic != null) { control_graphic = control_graphic.DeleteGraphicsBuffer(); } control_graphic = new IndeterminateProgressGraphicsBuffer(); if (control_graphic.CreateGraphicsBuffer( this.CreateGraphics(), ControlWidthHeight, ControlWidthHeight)) { control_graphic.g.SmoothingMode = SmoothingMode.HighQuality; bounding_rectangle = this.ClientRectangle; bounding_rectangle.Inflate(1, 1); control_graphic.g.FillRectangle( new SolidBrush(BackgroundColor), bounding_rectangle); bounding_rectangle.Inflate(-1, -1); } }
// ********************************** create_indicator_graphic /// <summary> /// this method creates a new indicator graphic that is the /// size of the control graphic; it rotates clockwise around /// the center of the control graphic; the indicator graphic /// initially has its leading edge at the x-axis; any existing /// indicator graphic will be deleted /// </summary> void create_indicator_graphic() { // effectively erases the // background if (control_graphic == null) { create_control_graphic(); } if (indicator_graphic != null) { indicator_graphic = indicator_graphic.DeleteGraphicsBuffer(); } indicator_graphic = new IndeterminateProgressGraphicsBuffer(); update_indicator_geometry(); if (indicator_graphic.CreateGraphicsBuffer( this.CreateGraphics(), ControlWidthHeight, ControlWidthHeight)) { Color color = IndicatorColor; Graphics graphics = indicator_graphic.g; Rectangle indicator_bounding_rectangle; Size size = new Size((int)(2.0F * r), (int)(2.0F * r)); indicator_graphic.g.SmoothingMode = SmoothingMode.HighQuality; indicator_bounding_rectangle = this.ClientRectangle; indicator_graphic.g.FillRectangle( new SolidBrush(Color.Transparent), indicator_bounding_rectangle); for (int i = 0; (i < CirclesCount); i++) { float angle; Rectangle bounding_rectangle; Brush brush = new SolidBrush(color); Point top_left = new Point(); int x; int y; angle = (phi + (float)i * theta) + indicator_angle; polar_to_cartesian(R, angle, out x, out y); top_left.X = (int)((float)x - r) + this.Width / 2; top_left.Y = (int)((float)y - r) + this.Height / 2; bounding_rectangle = new Rectangle(top_left, size); graphics.FillEllipse(brush, bounding_rectangle); brush.Dispose(); color = lighter_color(color, 0.25F); } } }