国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

在VB.NET中定制一個3D的Label的源碼

2024-07-10 13:03:58
字體:
來源:轉載
供稿:網友
public class lebel3d
    inherits system.windows.forms.usercontrol  
#region " windows 窗體設計器生成的代碼 "  
    public sub new()
        mybase.new()  
        '該調用是 windows 窗體設計器所必需的。
        initializecomponent()  
        '在 initializecomponent() 調用之后添加任何初始化
        mcaption = "label3d"
        malignment = align.centermiddle
        mautosize = false
        meffect = effect3d.raised
        setstyle(controlstyles.resizeredraw, true)
    end sub  
    'usercontrol1 重寫 dispose 以清理組件列表。
    protected overloads overrides sub dispose(byval disposing as boolean)
        if disposing then
            if not (components is nothing) then
                components.dispose()
            end if
        end if
        mybase.dispose(disposing)
    end sub  
    'windows 窗體設計器所必需的
    private components as system.componentmodel.icontainer
    '注意:以下過程是 windows 窗體設計器所必需的
    '可以使用 windows 窗體設計器修改此過程。
    '不要使用代碼編輯器修改它。
    <system.diagnostics.debuggerstepthrough()> private sub initializecomponent()        '
        me.name = "label3d"  
    end sub  
#end region  
    private shared malignment as align
    private shared mautosize as boolean
    private shared meffect as effect3d
    private mcaption as string  
    public property alignment() as align
        get
            return malignment
        end get
        set(byval value as align)
            malignment = value
            invalidate()
        end set
    end property  
    public property autosize() as boolean
        get
            return mautosize
        end get
        set(byval value as boolean)
            mautosize = value
            invalidate()
        end set
    end property  
    public property effect() as effect3d
        get
            return meffect
        end get
        set(byval value as effect3d)
            meffect = value
            invalidate()
        end set
    end property  
    public property caption() as string
        get
            return mcaption
        end get
        set(byval value as string)
            mcaption = value
            invalidate()
        end set
    end property  
    protected overrides sub onpaint(byval e as system.windows.forms.painteventargs)
        dim lblfont as font = me.font
        dim lblbrush as new solidbrush(color.red)
        dim x, y as integer
        dim textsize as sizef  
        textsize = e.graphics.measurestring(mcaption, lblfont)  
        if mautosize then
            me.width = textsize.width
            me.height = textsize.height
        end if  
        select case me.malignment
            case align.bottomleft
                x = 0
                y = me.height - textsize.height
            case align.bottommiddle
                x = cint((me.width - textsize.width) / 2)
                y = me.height - textsize.height
            case align.bottomright
                x = me.width - textsize.width '- 2
                y = me.height - textsize.height
            case align.centerleft
                x = 0
                y = (me.height - textsize.height) / 2
            case align.centermiddle
                x = cint((me.width - textsize.width) / 2)
                y = (me.height - textsize.height) / 2
            case align.centerright
                x = me.width - textsize.width '- 2
                y = (me.height - textsize.height) / 2
            case align.topleft
                x = 0
                y = 0
            case align.topmiddle
                x = cint((me.width - textsize.width) / 2)
                y = 0
            case align.topright
                x = me.width - textsize.width ' - 2
                y = 0
        end select  
        dim dispx, dispy as integer
        select case meffect
            case effect3d.none : dispx = 0 : dispy = 0
            case effect3d.carved : dispx = 1 : dispy = 1
            case effect3d.carvedheavy : dispx = 2 : dispy = 2
            case effect3d.raised : dispx = -1 : dispy = -1
            case effect3d.raisedheavy : dispx = -2 : dispy = -2
        end select  
        e.graphics.clear(me.backcolor)
        lblbrush.color = color.white
        e.graphics.drawstring(mcaption, lblfont, lblbrush, x, y)
        lblbrush.color = me.forecolor
        if me.designmode then
            e.graphics.drawstring("designtime", new font("verdana", 24, fontstyle.bold), new solidbrush(color.fromargb(200, 230, 200, 255)), 0, 0)
        else
            e.graphics.drawstring("runtime", new font("verdana", 24, fontstyle.bold), new solidbrush(color.fromargb(200, 230, 200, 255)), 0, 0)
        end if
        e.graphics.drawstring(mcaption, lblfont, lblbrush, x + dispx, y + dispy)
    end sub  
    private monalignmentchanged as eventhandler
    private monautosizechanged as eventhandler
    private moneffectchanged as eventhandler
    private moncaptionchanged as eventhandler  
    public event alignmentchanged(byval sender as object, byval ev as eventargs)
    public event autosizechanged(byval sender as object, byval ev as eventargs)
    public event effectchanged(byval sender as object, byval ev as eventargs)
    public event captionchanged(byval sender as object, byval ev as eventargs)  
    protected overridable sub onalignmentchanged(byval e as eventargs)
        invalidate()
        if not (monalignmentchanged is nothing) then monalignmentchanged.invoke(me, e)
    end sub
    protected overridable sub oneffectchanged(byval e as eventargs)
        invalidate()
        if not (moneffectchanged is nothing) then moneffectchanged.invoke(me, e)
    end sub
    protected overridable sub onautosizechanged(byval e as eventargs)
        invalidate()
        if not (monautosizechanged is nothing) then monautosizechanged.invoke(me, e)
    end sub
    protected overridable sub oncaptionchanged(byval e as eventargs)
        invalidate()
        if not (moncaptionchanged is nothing) then moncaptionchanged.invoke(me, e)
    end sub
end class  
public enum align
    topleft
    topmiddle
    topright
    centerleft
    centermiddle
    centerright
    bottomleft
    bottommiddle
    bottomright
end enum  
public enum effect3d
    none
    raised
    raisedheavy
    carved
    carvedheavy
end enum
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 灵武市| 枣强县| 丰镇市| 阳原县| 长葛市| 从江县| 确山县| 闵行区| 平邑县| 枞阳县| 朔州市| 洪雅县| 江津市| 阜城县| 清涧县| 宁明县| 安平县| 张家川| 敦化市| 屏山县| 徐汇区| 湄潭县| 舟山市| 大足县| 英山县| 克山县| 万荣县| 洛浦县| 汾阳市| 嘉义县| 昌江| 锦州市| 青阳县| 布拖县| 河北省| 昌宁县| 盐山县| 柳江县| 拉萨市| 长垣县| 阳东县|