protected override void OnPaint(PaintEventArgs e) { using (e) { Rectangle DrawBounds = Rectangle.FromLTRB(Padding.Left, Padding.Top, ClientSize.Width - Padding.Right, ClientSize.Height - Padding.Bottom); ThrobberRenderEventArgs RenderArgs = new ThrobberRenderEventArgs(e.Graphics, DrawBounds, Position, Enabled); Renderer.DrawThrobber(RenderArgs); Position = RenderArgs.Position; } }
protected override void OnPaint(PaintEventArgs e) { using (e) { ToolStripItemRenderEventArgs ItemArgs = new ToolStripItemRenderEventArgs(e.Graphics, this); Parent.Renderer.DrawLabelBackground(ItemArgs); Rectangle DrawBounds = new Rectangle(Padding.Left, Padding.Top, Width - Padding.Horizontal, Height - Padding.Vertical); ThrobberRenderEventArgs RenderArgs = new ThrobberRenderEventArgs(e.Graphics, DrawBounds, Position, Enabled); Renderer.DrawThrobber(RenderArgs); Position = RenderArgs.Position; } }
public void DrawThrobber(ThrobberRenderEventArgs e) { e.Graphics.SmoothingMode = SmoothingMode.HighQuality; PointF CenterPoint = new PointF(e.Bounds.Left + e.Bounds.Width / 2, e.Bounds.Top + e.Bounds.Height / 2 - 1); for (int I = 0; I < FNumberOfSpoke; I++) { e.Position = e.Position % FNumberOfSpoke; DrawLine(e.Graphics, GetCoordinate(CenterPoint, FInnerCircleRadius, FSpokeAngles[e.Position]), GetCoordinate(CenterPoint, FOuterCircleRadius, FSpokeAngles[e.Position]), e.Enabled ? FPalette[I] : FColor, FSpokeThickness); e.Position++; } }
protected override void OnPaint(PaintEventArgs e) { using (e) { switch (DisplayStyle) { case ToolStripItemDisplayStyle.Image: case ToolStripItemDisplayStyle.ImageAndText: Rectangle ThrobberBounds = new Rectangle(Padding.Left, Padding.Top, Width - Padding.Horizontal, Height - Padding.Vertical); Rectangle TextBounds; if (DisplayStyle == ToolStripItemDisplayStyle.ImageAndText) { Size ThrobberSize = Renderer.GetPreferredSize(Size); TextBounds = ThrobberBounds; switch (TextImageRelation) { case TextImageRelation.ImageAboveText: ThrobberBounds.Height = ThrobberSize.Height; TextBounds.Y += ThrobberSize.Height; TextBounds.Height -= ThrobberSize.Height; break; case TextImageRelation.TextAboveImage: ThrobberBounds.Y = ThrobberBounds.Bottom - ThrobberSize.Height; ThrobberBounds.Height = ThrobberSize.Height; TextBounds.Height -= ThrobberSize.Height; break; case TextImageRelation.ImageBeforeText: ThrobberBounds.Width = ThrobberSize.Width; TextBounds.X += ThrobberSize.Width; TextBounds.Width -= ThrobberSize.Width; break; case TextImageRelation.TextBeforeImage: ThrobberBounds.X = ThrobberBounds.Right - ThrobberSize.Width; ThrobberBounds.Width = ThrobberSize.Width; TextBounds.Width -= ThrobberSize.Width; break; } } else { TextBounds = Rectangle.Empty; } ToolStripItemRenderEventArgs ItemArgs = new ToolStripItemRenderEventArgs(e.Graphics, this); Parent.Renderer.DrawButtonBackground(ItemArgs); ThrobberRenderEventArgs RenderArgs = new ThrobberRenderEventArgs(e.Graphics, ThrobberBounds, Position, Enabled); Renderer.DrawThrobber(RenderArgs); Position = RenderArgs.Position; if (!TextBounds.IsEmpty) { ToolStripItemTextRenderEventArgs TextArgs = new ToolStripItemTextRenderEventArgs(e.Graphics, this, Text, TextBounds, ForeColor, Font, TextAlign); Parent.Renderer.DrawItemText(TextArgs); } break; default: base.OnPaint(e); break; } } }