duilib---TreeView用法---播放列表

转自 http://www.cnblogs.com/Alberl/p/3400577.html

  看到播放列表,可能有各种实现方式:

  1、全部用List实现,可以看到duilib的QQDemo和GameDemo,都是全部用List实现的。不过这种方法要自己写很多很多代码,而且还要非常熟悉List,还要非常熟悉duilib。大神们不是已经写好了么,我们拿来用就行了呗。虽然大神们实现了QQDemo和GameDemo,但是可以看到那两个自己扩展的List都是不通用的,所以如果用那两个扩展List来实现这个播放列表,肯定也要做很多工作。因此也不采用这种方法。

  2、全部用TreeView控件实现,这个有一个TestApp1的Demo,初步看起来还不错,和我们要做的播放列表很接近哦,展开折叠神马的都有。因此就采用这种方法啦。

 

一、TreeView简单用法:

<TreeView bkcolor="#ff00ff00" >
    <TreeNode text="A1" />
    <TreeNode text="B1" >
        <TreeNode text="B2" />
    </TreeNode>
</ TreeView>

  这样就能显示三个节点啦。

  二、TreeView复杂用法:

 这里直接给出迅雷播放列表的代码:

复制代码
复制代码
复制代码
            <TreeView name="treePlaylist" padding="4,0,2,0" itemtextcolor="#FFC8C6CB" itemhottextcolor="#FFC8C6CB" selitemtextcolor="#FFC8C6CB" itemhotbkcolor="#FF1B1B1B" itemselectedbkcolor="#FF151C2C" vscrollbar="true" >
                <TreeNode text="播放列表" height="33" bkimage="skin/treeview_header.png">
                    <TreeNode height="40">
                        <Combo name="comboPlaylist" float="true" pos="15,10,0,0" width="50" height="20" dropboxsize="63,63" itemtextcolor="#FFC8C6CB" itemselectedtextcolor="#FFC8C6CB" itemhottextcolor="#FFC8C6CB" itembkcolor="#FF2E2E2E" itemselectedbkcolor="#FF2E2E2E" itemhotbkcolor="#FF191919" normalimage="file='skin/combo_right.png' source='0,0,20,20' dest='22,0,42,20' " hotimage="file='skin/combo_right.png' source='21,0,41,20' dest='22,0,42,20' " pushedimage="file='skin/combo_right.png' source='42,0,82,20' dest='22,0,42,20' " >
                            <ListLabelElement text="全部"/>
                            <ListLabelElement text="在线"/>
                            <ListLabelElement text="本地" selected="true" />
                        </Combo>
                        <Button name="btnPlayMode" float="true" pos="153,12,0,0" width="18" height="18" textcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" normalimage="file=&apos;skin\btn_play_mode.png&apos; source=&apos;0,0,18,18&apos;" hotimage="file=&apos;skin\btn_play_mode.png&apos; source=&apos;19,0,37,18&apos;" pushedimage="file=&apos;skin\btn_play_mode.png&apos; source=&apos;38,0,56,18&apos;" />
                        <Button name="btnAdd" float="true" pos="174,12,0,0" width="18" height="18" textcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" normalimage="file=&apos;skin\btn_add.png&apos; source=&apos;0,0,18,18&apos;" hotimage="file=&apos;skin\btn_add.png&apos; source=&apos;19,0,37,18&apos;" pushedimage="file=&apos;skin\btn_add.png&apos; source=&apos;38,0,56,18&apos;" />
                        <Button name="btnDelete" float="true" pos="195,12,0,0" width="18" height="18" textcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" normalimage="file=&apos;skin\btn_delete.png&apos; source=&apos;0,0,18,18&apos;" hotimage="file=&apos;skin\btn_delete.png&apos; source=&apos;19,0,37,18&apos;" pushedimage="file=&apos;skin\btn_delete.png&apos; source=&apos;38,0,56,18&apos;" />
                    </TreeNode>
                    <TreeNode text="迅雷下载" height="22" textcolor="#FFC8C6CB" folderattr="padding=&quot;0,4,0,0&quot; width=&quot;14&quot; height=&quot;14&quot; normalimage=&quot;file='skin/treeview_expand.png' source='0,0,14,14' &quot; selectedimage=&quot;file='skin/treeview_expand.png' source='0,24,14,38' &quot;">
                        <TreeNode text="下载1" />
                        <TreeNode text="下载2" />                                    
                    </TreeNode>
                </TreeNode>
                <TreeNode text="在线媒体" height="33" bkimage="skin/treeview_header.png" >
                    <TreeNode text="今日热播" height="22" textcolor="#FFC8C6CB" folderattr="padding=&quot;0,4,0,0&quot; width=&quot;14&quot; height=&quot;14&quot; normalimage=&quot;file='skin/treeview_expand.png' source='0,0,14,14' &quot; selectedimage=&quot;file='skin/treeview_expand.png' source='0,24,14,38' &quot;">
                        <TreeNode text="八公" />
                        <TreeNode text="HACHI" />                                    
                    </TreeNode>
                    <TreeNode text="热点新闻" height="22" textcolor="#FFC8C6CB" folderattr="padding=&quot;0,4,0,0&quot; width=&quot;14&quot; height=&quot;14&quot; normalimage=&quot;file='skin/treeview_expand.png' source='0,0,14,14' &quot; selectedimage=&quot;file='skin/treeview_expand.png' source='0,24,14,38' &quot;">
                        <TreeNode text="八公" />
                        <TreeNode text="HACHI" />                                    
                    </TreeNode>
                </TreeNode>
                <TreeNode text="娱乐中心" height="33" bkimage="skin/treeview_header.png" >
                    <TreeNode text="短视频广场" height="22" textcolor="#FFC8C6CB" folderattr="padding=&quot;0,4,0,0&quot; width=&quot;14&quot; height=&quot;14&quot; normalimage=&quot;file='skin/treeview_expand.png' source='0,0,14,14' &quot; selectedimage=&quot;file='skin/treeview_expand.png' source='0,24,14,38' &quot;">
                        <TreeNode text="热门视频" />
                        <TreeNode text="美女视频" />                                    
                    </TreeNode>
                    <TreeNode text="直播频道" />                                    
                </TreeNode>
            </TreeView>
复制代码
复制代码
复制代码

  需要说明的是,TreeView控件的Bug很多,而且很多属性都无效,比如itemfont、itemalign等等,这个将在下一节介绍,现在主界面和迅雷一模一样,播放列表也看起来差不多啦,离成功不远啦~O(∩_∩)O~

posted @   曦花  阅读(978)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示