基于WinForm开发的Ribbon界面案例

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u010585773/article/details/83180432

使用 Winform开发插件或软件时,创建Ribbon界面是比较难的,大部分第三方Ribbon控件不是针对WPF开发的 就是不能免费授权,以下的AERibbonControl库 是自定义开发的 可以免费使用 可以满足大部分的需要,后续将持续扩展 添加更多灵活的按钮类型 和必要的快速访问栏的创建

基于WinForm开发的Ribbon界面案例

基于WinForm开发的Ribbon界面案例

基于WinForm开发的Ribbon界面案例

基于WinForm开发的Ribbon界面案例

 

创建选项卡等方式和revit类似:

           UIApplication uiapp = new UIApplication(this.aeRibbonControl1);

            uiapp.CreateTab("建筑");

            uiapp.CreateTab("附加模块");

           

 

            RibbonPanel panel = uiapp.CreateRibbonPanel("建筑", "项目特征");

            PushButton pb = new PushButton("暖通设计", Properties.Resources.apply, true, "");

 

            pb.Click += new Ribbon.RibbonHandler(() =>

            {

 

                MessageBox.Show("1234567890暖通设计" + aeRibbonControl1.tabList[aeRibbonControl1.CurrentTab].name);

            });

 

            PushButton pb2 = new PushButton("建造楼板及天花板", Properties.Resources.white, true, "1234");

            pb2.Click += new Ribbon.RibbonHandler(() =>

            {

 

                MessageBox.Show("1234567890建造楼板及天花板" + aeRibbonControl1.tabList[aeRibbonControl1.CurrentTab].name);

            });

 

            PushButton pb3 = new PushButton("参数设计", Properties.Resources.white, false, "1234");

            pb3.Click += new Ribbon.RibbonHandler(() =>

            {

 

                MessageBox.Show("1234567890参数设计" + aeRibbonControl1.tabList[aeRibbonControl1.CurrentTab].name);

            });

 

            PushButton pb4 = new PushButton("设计", Properties.Resources.white, false, "5678");

            pb4.Click += new Ribbon.RibbonHandler(() =>

            {

 

                MessageBox.Show("1234567890设计" + aeRibbonControl1.tabList[aeRibbonControl1.CurrentTab].name);

            });

 

            PullDownStack ps = new PullDownStack("用户界面", Properties.Resources.green, true, "5678");

            PullDownStack ps2 = new PullDownStack("本地\n数据", Properties.Resources.green, false, "5678");

 

            PullDownButton pd = new PullDownButton("分离中心文件", Properties.Resources._20, false, null);

            pd.Click += new Ribbon.RibbonHandler(() =>

            {

 

                MessageBox.Show("分离中心文件");

 

            });

            PullDownButton pd2 = new PullDownButton("按工作集导出NWC文件", Properties.Resources.orange, false, null);

            pd2.Click += new Ribbon.RibbonHandler(() =>

            {

                MessageBox.Show("按工作集导出NWC文件");

 

            });

            PullDownButton pd3 = new PullDownButton("按中心文件导出IFC文件", Properties.Resources.orange, false, null);

            pd3.Click += new Ribbon.RibbonHandler(() =>

            {

                MessageBox.Show("按中心文件导出IFC文件");

 

            });

            PullDownButton pd4 = new PullDownButton("模型显隐", Properties.Resources.orange, false, null);

            pd4.Click += new Ribbon.RibbonHandler(() =>

            {

                MessageBox.Show("模型显隐");

 

            });

 

            PullDownButton pd5 = new PullDownButton("模型显隐", Properties.Resources.blue, false, null);

            pd5.Click += new Ribbon.RibbonHandler(() =>

            {

                MessageBox.Show("模型显隐");

                pd5.IsEnabled = false;

            });

            PullDownButton pd6 = new PullDownButton("局部三维", Properties.Resources.blue, false, null);

            pd6.Click += new Ribbon.RibbonHandler(() =>

            {

                MessageBox.Show("局部三维");

 

            });

            PullDownButton pd7 = new PullDownButton("构件定位", Properties.Resources.blue, false, null);

            pd7.Click += new Ribbon.RibbonHandler(() =>

            {

                MessageBox.Show("构件定位");

 

            });

            PullDownButton pd8 = new PullDownButton("轴网创建", Properties.Resources.blue, false, null);

            pd8.Click += new Ribbon.RibbonHandler(() =>

            {

                MessageBox.Show("轴网创建");

 

            });

 

 

            ps.AddItem(pd);

            ps.AddItem(pd2);

            ps.AddItem(pd3);

            ps.AddItem(pd4);

 

 

            ps2.AddItem(pd5);

            ps2.AddItem(pd6);

            ps2.AddItem(pd7);

            ps2.AddItem(pd8);

 

            panel.AddItem(pb);

            panel.AddItem(pb2);

            panel.AddItem(pb4);

            panel.AddItem(pb3);

 

            RibbonPanel panel2 = uiapp.CreateRibbonPanel("建筑", "参数关联");

            panel2.AddItem(pb);

            panel2.AddItem(pb2);

            panel2.AddItem(pb3);

 

            RibbonPanel panel3 = uiapp.CreateRibbonPanel("建筑", "选择测试");

            panel3.AddItem(pb);

            panel3.AddItem(pb2);

            panel3.AddItem(ps);

            panel3.AddItem(pb3);

            panel3.AddItem(ps2);

 

 

            RibbonPanel panel6 = uiapp.CreateRibbonPanel("建筑", "项目测试");

            panel6.AddItem(pb2);

            panel6.AddItem(pb);

            panel6.AddItem(pb3);

            panel6.AddItem(ps);

            panel6.AddItem(pb4);

            panel6.AddItem(pd5);

            panel6.AddItem(pb3);

            panel6.AddItem(ps2);

 

 

            RibbonPanel panel4 = uiapp.CreateRibbonPanel("附加模块", "项目描述");

            RibbonPanel panel5 = uiapp.CreateRibbonPanel("附加模块", "描述参数");

 

            panel4.AddItem(pb);

            panel4.AddItem(pb2);

            panel4.AddItem(pb3);

            panel5.AddItem(pb);

            panel5.AddItem(pb2);

            panel5.AddItem(pb3);

 

 

            //创建应用菜单

            ApplicationMenu menu = uiapp.CreateApplicationMenu("你是我的风景");

 

            ApplicationMenuItem item_1 = new ApplicationMenuItem("新建规则", Properties.Resources.white, false, "思念是一种病,得治!");

            ApplicationMenuItem item_2 = new ApplicationMenuItem("打开规则", Properties.Resources.white, false, "如果云知道,许茹芸");

            ApplicationMenuItem item_3 = new ApplicationMenuItem("导出规则", Properties.Resources.white, false, "思念是一种病,得治!");

            ApplicationMenuItem item_4 = new ApplicationMenuItem("导入规则", Properties.Resources.white, true, "中华上下五千年,厉害");

 

            item_1.Click += new Ribbon.RibbonHandler(() =>

            {

                MessageBox.Show("新建规则");

            });

 

            MenuButton btn0 = new MenuButton("如果云知道", Properties.Resources.blue, false, null);

            MenuButton btn1 = new MenuButton("台北在下雨", Properties.Resources.blue, false, null);

            MenuButton btn2 = new MenuButton("故乡彩云映落日", Properties.Resources.blue, false, null);

            MenuButton btn3 = new MenuButton("他乡秋风寄相思", Properties.Resources.blue, false, null);

            MenuButton btn00 = new MenuButton("兵者,国之大事", Properties.Resources.blue, false, null);

            MenuButton btn11 = new MenuButton("死生之地,存亡之道", Properties.Resources.blue, false, null);

            MenuButton btn22 = new MenuButton("孔子曰:人之初,性本善", Properties.Resources.blue, false, null);

            MenuButton btn33 = new MenuButton("孟子曰:孔子说得对", Properties.Resources.blue, false, null);

            MenuButton btn44 = new MenuButton("老子曰:道可道,非常道", Properties.Resources.blue, false, null);

            btn0.Click += new Ribbon.RibbonHandler(() =>

            {

                MessageBox.Show(btn0.Text);

 

            });

            btn3.Click += new Ribbon.RibbonHandler(() =>

            {

                MessageBox.Show(btn3.Text);

 

            });

 

            item_4.AddItem(btn0);

            item_4.AddItem(btn1);

            item_4.AddItem(btn2);

            item_4.AddItem(btn3);

            item_4.AddItem(btn00);

            item_4.AddItem(btn11);

            item_4.AddItem(btn22);

            item_4.AddItem(btn33);

            item_4.AddItem(btn44);

 

 

            item_2.AddItem(btn0);

            item_2.AddItem(btn1);

            item_2.AddItem(btn2);

            item_2.AddItem(btn3);

          

 

 

            ApplicationMenuItem item_5 = new ApplicationMenuItem("没有规则", Properties.Resources.white, false, "思念是一种病,得治!");

            ApplicationMenuItem item_6 = new ApplicationMenuItem("已有规则", Properties.Resources.white, false, "思念是一种病,得治!");

            ApplicationMenuItem item_7 = new ApplicationMenuItem("放弃规则", Properties.Resources.white, false, "思念是一种病,得治!");

            ApplicationMenuItem item_8 = new ApplicationMenuItem("重启规则", Properties.Resources.white, false, "思念是一种病,得治!");

 

 

            item_5.Click += new Ribbon.RibbonHandler(() =>

            {

                MessageBox.Show("没有规则");

            });

 

            menu.AddMenuItems(item_1);

            menu.AddMenuItems(item_2);

            menu.AddMenuItems(item_3);

            menu.AddMenuItems(item_4);

            menu.AddMenuItems(item_5);

            menu.AddMenuItems(item_6);

            menu.AddMenuItems(item_7);

            menu.AddMenuItems(item_8);

 

            MenuText text_1 = new MenuText("一路过很多城", null);

            MenuText text_2 = new MenuText("飘忽不定这也是一种麻痹", null);

            MenuText text_3 = new MenuText("全部是你微笑的表情", null);

            MenuText text_4 = new MenuText("一整片的森林", null);

            MenuText text_5 = new MenuText("你在树荫里", null);

            MenuText text_6 = new MenuText("复杂的生命因为有你", null);

            MenuText text_7 = new MenuText("你是我的风景", null);

            MenuText text_8 = new MenuText("云高风清不走下去", null);

            MenuText text_9 = new MenuText("爱让悬崖变平地", null);

            MenuText text_10 = new MenuText("看到了你莽莽撞撞靠近", null);

            MenuText text_11 = new MenuText("细节都牵引我放下行李", null);

            text_11.Click += new MenuText.RibbonHandler(() =>

            {

                MessageBox.Show(text_11.Text);

            });

            text_4.Click += new MenuText.RibbonHandler(() =>

            {

                MessageBox.Show(text_4.Text);

            });

            menu.AddTextItems(text_1);

            menu.AddTextItems(text_2);

            menu.AddTextItems(text_3);

            menu.AddTextItems(text_4);

            menu.AddTextItems(text_5);

            menu.AddTextItems(text_6);

            menu.AddTextItems(text_7);

            menu.AddTextItems(text_8);

            menu.AddTextItems(text_9);

            menu.AddTextItems(text_10);

            menu.AddTextItems(text_11);

 

            MenuText btnOne = new MenuText("退出", null);

            btnOne.Click += new MenuText.RibbonHandler(() =>

            {

                MessageBox.Show("退出此程序!");

 

            });

            MenuText btnTwo = new MenuText("设置", null);

            btnTwo.Click += new MenuText.RibbonHandler(() =>

            {

                MessageBox.Show("选项设置");

            });

            menu.bottomBigBtn = btnOne;

            menu.bottomSmallBtn = btnTwo;

            this.aeRibbonControl1.menu = menu;

            aeRibbonControl1.UpdateAndRefresh();

测试案例代码 请到本博客的CSDN资源里下载 

展开阅读全文

没有更多推荐了,返回首页