// ***************************** GoogleProgress_memory_cleanup event handler private void GoogleProgress_memory_cleanup(object sender, EventArgs e) { if (GoogleProgress_annulus_graphic != null) { GoogleProgress_annulus_graphic = GoogleProgress_annulus_graphic.DeleteGraphicsBuffer(); } if (GoogleProgress_indicator_graphic != null) { GoogleProgress_indicator_graphic = GoogleProgress_indicator_graphic.DeleteGraphicsBuffer(); } }
// ********************************* GoogleProgress_create_indicator_graphic // GoogleProgress_annulus_graphic MUST HAVE BEEN created before this method // is invoked private void GoogleProgress_create_indicator_graphic() { SolidBrush brush; Rectangle control_bounding_rectangle; GraphicsPath indicator_path = new GraphicsPath(); Rectangle indicator_rectangle = new Rectangle(); Region indicator_region; //Rectangle indicator_rectangle1 = new Rectangle((Width/2) , (Height / 2), 5,5); //Rectangle indicator_rectangle1 = new Rectangle(OuterRadius - GoogleProgress_annulus_thickness, -(GoogleProgress_annulus_thickness / 2), 10, 10); if (GoogleProgress_indicator_graphic != null) { GoogleProgress_indicator_graphic = GoogleProgress_indicator_graphic.DeleteGraphicsBuffer(); } GoogleProgress_indicator_graphic = new ZeroitGoogleProgressGraphicsBuffer(); if (GoogleProgress_indicator_graphic.CreateGraphicsBuffer(this.CreateGraphics(), 2 * OuterRadius, 2 * OuterRadius)) { GoogleProgress_indicator_graphic.g.SmoothingMode = Smoothing; GoogleProgress_indicator_graphic.g.TextRenderingHint = TextRendering; control_bounding_rectangle = this.ClientRectangle; GoogleProgress_indicator_graphic.g.FillRectangle(new SolidBrush(Color.Transparent), control_bounding_rectangle); // compute region geometry indicator_rectangle = new Rectangle( new Point(OuterRadius - GoogleProgress_annulus_thickness, -(GoogleProgress_annulus_thickness / 2)), new Size(GoogleProgress_annulus_thickness - 1, GoogleProgress_annulus_thickness - 1)); //indicator_rectangle = new Rectangle(new Point(this.ClientRectangle.Width - OuterRadius, this.ClientRectangle.Height - OuterRadius), new Size(GoogleProgress_annulus_thickness, GoogleProgress_annulus_thickness)); #region Unused Code //indicator_path.AddEllipse(indicator_rectangle); //GoogleProgress_indicator_graphic.g.DrawPath(new Pen(Color.White), indicator_path); //GoogleProgress_indicator_graphic.g.FillPath(new SolidBrush(Color.White),indicator_path); #endregion indicator_path.AddEllipse(indicator_rectangle); #region Unique Rectangle //GoogleProgress_indicator_graphic.g.FillEllipse(new SolidBrush(Color.Yellow), // indicator_rectangle1); //GoogleProgress_indicator_graphic.g.DrawEllipse(new Pen(Color.Yellow), // indicator_rectangle1); #endregion indicator_region = new Region(indicator_path); //indicator_region = new Region(indicator_rectangle1); // rotate the indicator GoogleProgress_indicator_graphic.g.ResetTransform(); GoogleProgress_indicator_graphic.g.RotateTransform( (float)GoogleProgress_indicator_angle, MatrixOrder.Append); GoogleProgress_indicator_graphic.g.TranslateTransform( (float)OuterRadius, (float)OuterRadius, MatrixOrder.Append); LinearGradientBrush linbrushregion = new LinearGradientBrush(indicator_rectangle, Color1Indicator, Color2Indicator, ColorAngle); brush = new SolidBrush(GoogleProgress_IndicatorColor); //GoogleProgress_indicator_graphic.g.FillRegion(brush, indicator_region); GoogleProgress_indicator_graphic.g.FillRegion(linbrushregion, indicator_region); brush.Dispose(); indicator_region.Dispose(); indicator_path.Dispose(); } }
// *********************************** create_annulus_graphic #endregion #region Paint Arguments and Methods private void create_annulus_graphic() { #region Fields LinearGradientBrush brush; Rectangle control_bounding_rectangle = new Rectangle(); GraphicsPath inner_path; Rectangle inner_rectangle; int inner_rectangle_side; Region inner_region; Region outer_region; GraphicsPath outer_path; int outer_rectangle_side = 2 * OuterRadius; #region Unused Code Bitmap bit = new Bitmap(5, 5); PaintEventArgs e = new PaintEventArgs(Graphics.FromImage(bit), control_bounding_rectangle); control_bounding_rectangle = new Rectangle(0, 0, Width - 3, Height - 3); e.Graphics.SmoothingMode = SmoothingMode.HighQuality; e.Graphics.FillEllipse(new SolidBrush(Color.Green), control_bounding_rectangle); e.Graphics.DrawEllipse(new Pen(Color.Yellow, 2), control_bounding_rectangle); //// compute outer geometry outer_path = new GraphicsPath(); //outer_path.AddEllipse(control_bounding_rectangle); outer_region = new Region(outer_path); // compute inner geometry inner_rectangle_side = 2 * InnerRadius; inner_rectangle = new Rectangle( GoogleProgress_annulus_thickness, GoogleProgress_annulus_thickness, (2 * InnerRadius) - 2, (2 * InnerRadius) - 2); inner_path = new GraphicsPath(); //inner_path.AddEllipse(inner_rectangle); e.Graphics.FillEllipse( new SolidBrush(BackColor), inner_rectangle); e.Graphics.DrawEllipse( new Pen(Color.Black, 1), inner_rectangle); inner_region = new Region(inner_path); //// exclude inner from outer //outer_region.Exclude(inner_region); //// paint the outer //brush = create_linear_gradient_brush( // new Point(OuterRadius, 0), // new Point(OuterRadius, // outer_rectangle_side), // AnnulusColor, // TransitionColor); //e.Graphics.FillRegion(brush, outer_region); //// clean up //brush.Dispose(); //outer_region.Dispose(); //outer_path.Dispose(); //inner_region.Dispose(); //inner_path.Dispose(); #endregion #endregion GoogleProgress_annulus_graphic = new ZeroitGoogleProgressGraphicsBuffer(); if (GoogleProgress_annulus_graphic.CreateGraphicsBuffer( this.CreateGraphics(), this.Width, this.Height)) { GoogleProgress_annulus_graphic.g.SmoothingMode = Smoothing; GoogleProgress_annulus_graphic.g.TextRenderingHint = TextRendering; //control_bounding_rectangle = this.ClientRectangle; control_bounding_rectangle = new Rectangle(0, 0, Width - 2, Height - 2); //control_bounding_rectangle.Inflate(1, 1); GoogleProgress_annulus_graphic.g.FillRectangle( new SolidBrush(BackColor), control_bounding_rectangle); LinearGradientBrush linbrush = new LinearGradientBrush(control_bounding_rectangle, Color1Bigcircle, Color2Bigcircle, ColorAngle); GoogleProgress_annulus_graphic.g.FillEllipse( /*new SolidBrush(Color.Red)*/ linbrush, control_bounding_rectangle); GoogleProgress_annulus_graphic.g.DrawEllipse( new Pen(Color.Transparent, 1), control_bounding_rectangle); //control_bounding_rectangle.Inflate(-10, -10); //// compute outer geometry outer_path = new GraphicsPath(); //outer_path.AddEllipse(control_bounding_rectangle); outer_region = new Region(outer_path); // compute inner geometry inner_rectangle_side = 2 * InnerRadius; inner_rectangle = new Rectangle( GoogleProgress_annulus_thickness, GoogleProgress_annulus_thickness, (2 * InnerRadius) - 2, (2 * InnerRadius) - 2); inner_path = new GraphicsPath(); //inner_path.AddEllipse(inner_rectangle); GoogleProgress_annulus_graphic.g.FillEllipse( new SolidBrush(BackColor), inner_rectangle); GoogleProgress_annulus_graphic.g.DrawEllipse( new Pen(ColorInnerBorder, InnerBorder), inner_rectangle); inner_region = new Region(inner_path); // exclude inner from outer outer_region.Exclude(inner_region); // paint the outer brush = create_linear_gradient_brush( new Point(OuterRadius, 0), new Point(OuterRadius, outer_rectangle_side), AnnulusColor, TransitionColor); GoogleProgress_annulus_graphic.g.FillRegion(brush, outer_region); // clean up brush.Dispose(); outer_region.Dispose(); outer_path.Dispose(); inner_region.Dispose(); inner_path.Dispose(); } }