vb.net - 3 way check box (toggle) -


i have custom 'toggle' (using butterscotchtheme) , trying add 3rd option.

this how is: (cant post pictures due being new, here links pictures)

enter image description here

enter image description here

i third option. have checked theme code , done checkbox rules. , know tricheckbox thing, unsure how work. did research , unable figure out in situation.

here themes toggle code:

public class butterscotchtoggle : inherits control  private _check boolean public property checked boolean             return _check     end     set(byval value boolean)         _check = value         invalidate()     end set end property  sub new()     mybase.new()     setstyle(controlstyles.userpaint or controlstyles.resizeredraw or controlstyles.supportstransparentbackcolor, true)     doublebuffered = true     backcolor = color.transparent     size = new size(80, 25) end sub  protected overrides sub onclick(byval e eventargs)     checked = not checked     mybase.onclick(e) end sub  protected overrides sub onpaint(byval e painteventargs)     dim b bitmap = new bitmap(width, height)     dim g graphics = graphics.fromimage(b)     dim outerrect rectangle = new rectangle(0, 0, width - 1, height - 1)     dim maininnerrect rectangle = new rectangle(7, 7, width - 15, height - 15)     dim buttonrect new lineargradientbrush(outerrect, color.fromargb(100, 90, 80), color.fromargb(48, 43, 39), 90s)     mybase.onpaint(e)     g.clear(backcolor)     g.smoothingmode = smoothingmode.highquality     g.interpolationmode = interpolationmode.highqualitybicubic     g.fillpath(new solidbrush(color.fromargb(40, 37, 33)), roundrect(outerrect, 5))     g.drawpath(new pen(color.fromargb(0, 0, 0)), roundrect(outerrect, 5))     g.fillpath(new solidbrush(color.fromargb(26, 25, 21)), roundrect(maininnerrect, 3))     g.drawpath(new pen(color.fromargb(0, 0, 0)), roundrect(maininnerrect, 3))     if checked         g.fillpath(buttonrect, roundrect(new rectangle(3, 3, cint((width / 2) - 3), height - 7), 7))         g.drawstring("on", new font("segoe ui", 10, fontstyle.bold), new solidbrush(color.fromargb(246, 180, 12)), new rectangle(2, 2, cint((width / 2) - 1), height - 5), new stringformat() {.alignment = stringalignment.center, .linealignment = stringalignment.center})     else         g.fillpath(buttonrect, roundrect(new rectangle(cint((width / 2) - 3), 3, cint((width / 2) - 3), height - 7), 7))         g.drawstring("off", new font("segoe ui", 10, fontstyle.bold), new solidbrush(color.fromargb(246, 180, 12)), new rectangle(cint((width / 2) - 2), 2, cint((width / 2) - 1), height - 5), new stringformat() {.alignment = stringalignment.center, .linealignment = stringalignment.center})     end if     e.graphics.drawimage(b, new point(0, 0))     g.dispose() : b.dispose() end sub end class 

any appreciated!

theme downloaded butterscotch theme gdi+

you have change boolean property integer (or better, create enum):

private _check integer  public property checked integer       return _check   end   set(byval value integer)     _check = value     invalidate()   end set end property 

change onclick behavior:

protected overrides sub onclick(byval e eventargs)   if checked + 1 > 2     checked = 0   else     checked += 1   end if   mybase.onclick(e) end sub 

and adjust drawing accordingly (placing third option in middle i'm guessing):

select case checked   case 0     g.fillpath(buttonrect, roundrect(new rectangle(cint((width / 2) - 3), 3, cint((width / 2) - 3), height - 7), 7))     g.drawstring("off", new font("segoe ui", 10, fontstyle.bold), new solidbrush(color.fromargb(246, 180, 12)), new rectangle(cint((width / 2) - 2), 2, cint((width / 2) - 1), height - 5), new stringformat() {.alignment = stringalignment.center, .linealignment = stringalignment.center})   case 1     g.fillpath(buttonrect, roundrect(new rectangle(3, 3, cint((width / 2) - 3), height - 7), 7))     g.drawstring("on", new font("segoe ui", 10, fontstyle.bold), new solidbrush(color.fromargb(246, 180, 12)), new rectangle(2, 2, cint((width / 2) - 1), height - 5), new stringformat() {.alignment = stringalignment.center, .linealignment = stringalignment.center})   case 2     g.fillpath(buttonrect, roundrect(new rectangle((width / 2) - (width / 4), 3, cint((width / 2) - 3), height - 7), 7))     g.drawstring("???", new font("segoe ui", 10, fontstyle.bold), new solidbrush(color.fromargb(246, 180, 12)), new rectangle((width / 2) - (width / 4), 2, cint((width / 2) - 1), height - 5), new stringformat() {.alignment = stringalignment.center, .linealignment = stringalignment.center}) end select 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -