Cool Loading Wheel Control - Open Source

Thanks to the original work of @Tomas Jakobs and the smooth math by @Will Shank we have the “Cool Loading Wheel Control”. I have added a behavior type and I was thinking that we could possibly add additional behaviors.

Github Repo:

Thank You!

I changed CoolWheelCanvas.Paint to get better result on reiszing CoolWheelContainer1

  static p As Picture
  if p = nil or p.Width <> Width or p.Height <> Height then
    p = new Picture(Width, Height, 32) //Mask
  dim gg As Graphics = p.Mask.Graphics
  gg.ForeColor = &cFFFFFF                //blank mask
  gg.FillRect(0, 0, Width, Height)
  gg.ForeColor = &c000000         //draw ring outer
  gg.FillOval(0, 0, Width, Height)
  gg.ForeColor = &cFFFFFF         //draw ring inner
  gg.FillOval(g.width / 4, g.height / 4, Width-g.width / 2, Height-g.height / 2)
  gg = p.Graphics
  gg.ForeColor = &cAAAAAA         //fill ring color
  gg.FillRect(0, 0, Width, Height)
  dim xy(0), cx, cy, r As integer //build wedge poly
  cx = Width * 0.5
  cy = Height * 0.5
  r = Width
  xy.Append cx
  xy.Append cy
  for i As integer = 0 to percentage
    xy.Append cx + r * cos(i)
    xy.Append cx - r * sin(i)
  xy.Append cx + r * cos(percentage)
  xy.Append cx - r * sin(percentage)
  gg.ForeColor = kBlue //ChangeRingColor()
  g.DrawPicture p, 0, 0
  // ---------- THANKS WILL
  Dim CenterString as String = "Loading..."
  g.TextFont = "System"
  g.ForeColor = kBlue
  g.TextSize = me.Width / 10
  Dim xPos as Integer =  ((self.Width/2)-(g.stringwidth("Loading...")/2))+2
  Dim yPos as Integer = ((self.Height/2)-(g.textsize/2)) + g.textsize
  g.DrawString(CenterString, xPos, yPos)

Thanks Axel! I just made those changes and committed them.

Thanks Mike for the control. On Windows it is having a heavy flicker. How to avoid that

in CoolWheelContainer set CoolWheelControl DoubleBuffer to ‘ON’

Switch to a Mac? :slight_smile: :slight_smile: Just kidding as Axel has the answer above :wink:

I implemented Axel’s recommendation and committed them to the repo to help theWindows Flicker:

  • Added #IF TARGET statement for Windows to turn on DoubleBuffering (CoolWheelCanvas.Open)
  • Added #IF TARGET statement for Windows to turn on UseGDIPlus = True (App.Open)