Office 2007 风格控件(Ribbon)
2008-10-21 21:51
302 查看
A Professional Ribbon you will use
By Jose M. Menendez PoóA serious project on an Office-like Ribbon control
(源程序及演示下载)
Introduction
Because of the lack of good free Ribbon controls on the web, I decided to write one myself. I've analyzed previous work on ribbon-controls, including those on CodeProject. Unfortunately, most existent controls are merely bad tries. Why? well, some lack nice rendering, some lack resizing features, some lack almost everything. Of course, well developed Ribbon controls are available at a price. This ribbon is free.Why not WPF? Well mainly, because I needed the Ribbon to add it to my existing WinForms applications. In my opinion (the short version) this is not a "no" to WPF, is just a "not yet". Anyway, you can host a WinForms control in WPF (See http://msdn.microsoft.com/en-us/library/ms750944.aspx).
Some of the design goals
Performance - This ribbon is contained on a Control window, and every element inside of it is managed as a bunch of bounds inside the control, just as the ToolStrip control does. Altough this is difficult to manage from the ribboon's inside code, this is a way to keep it at the best performed ribbon. Believe me, download the demo, runit and resize the window. It peforms beautifully.Consistency with Office's ribbon - I read once about Jakob Nielsen saying that most users prefer that the programs they use look just like word, excel or powerpoint. This is quite obvious, becouse people use this software every day. Providing visual consistency with the office's ribbon is very important because of that, people already know what to expect and that's an usability advantage. I've tried to every element in the ribbon look and behave exactly like it does in the Office's ribbon.
Ease of use for programmers - The naming of components is consistent with most WinForms naming system, even more with the ToolStrip elements. Property, event and method names for similar elements are named just like in the ToolStrip technology items.
Designer support - I will be adding more and more designer support so you can manage the ribbon 100% from the designer. Give it a try.
I will be providing updates and fixes for bugs, as I discover them or you kindly let me know about them.
Using the Ribbon
The ribbon is located in theSystem.Windows.Formsnamespace, just as every other control, I think it's annoying to use controls named as
MyCoolFirm.MyCoolNameSpace.MyCoolSubNameSpaceand so on (Please do that only for bussiness objects).
You can add a reference to the compiled dll: System.Windows.Forms.Ribbon.dll or you can directly copy the source files to a folder on your project. The code is currently designed so you can just copy the source files, it doesn't need any extra resources.
Hands on: Quick Guide
The ribbon is composed mainly by three kind of elements, the tabs, the panels on the tabs (other developers call them groups) and the items inside the panels.These elements are represented by
RibbonTab,
RibbonPaneland
RibbonItemtypes.
RibbonItemis an abstract class that provides basic functionallity for any item hosted on a
RibbonPanelor on a
RibbonDropDown.
You can add tabs from the smart tag of the Ribbon, you can add panels to the tab by selecting the tab and calling the "AddPanel" verb on the bottom part of the property grid.
The elements on the ribbon are resized according to the available space for the ribbon. This is a key feature of the ribbon. It tries to bring all possible commands to the screen by resizing them, instead of hidding them on an overflow button like the old ToolStrip.
I treat this as three kinds of sizes: Large, Medium and Compact. An additional size is used for panels, because panels can be collapsed, and then they will adopth the Overflow size.
Note: There's no way to directly affect the bounds of the elements on the ribbon, the size will always be determined the layout engine inside the ribbon. In fact, the layout depends on two factors: the available horizontal space on the ribbon and the size modes on the items.
If there's no available space on the ribbon for a panel, panel will be collapsed. If all panels are collapsed and space is not available yet, a scroll button will appear so user can scroll the panels horizontally.
See Image
Buttons
There's only one type of button:RibbonButton. It can be setted to three styles:
RibbonButtonadds the
SmallImageproperty so you can set the image shown when button is in medium or compact mode. Although it's not restricted by functionallity, it's highly recommended to use just 32 x 32 pixels for Image property and 16 x 16 for SmallImageproperty. Results are unexpected when sizes are different.
Note: Use the
DropDownItemsproperty to add items to the dropdown of the button.
The appearance of the buttons vary thru size modes.
ItemGroups
The buttons like those on the Font and Paragraph panels areRibbonButtonbuttons hosted inside a
RibbonItemGroupgroup.
Items added to
RibbonItemGroupwill be always measured and treated in compact size mode.
Important: If a
RibbonPanelwill host
RibbonItemGroupobjects, you must set the
RibbonPanel.FlowsToproperty to
Right. The layout on those items are treated different because groups flow as rows.
Lists
Lists are represented by RibbonButtonListand provides two collections:
Buttonsand
DropDownItems, this is because the list can be scrolled on the ribbon and can dropdown more items. The dropdown of list supports resizing by a grip on the south east corner.
If you want the buttons on the list to be shown on the dropdown, you will have to explicitly add another list with those buttons to the
DropDownItemsproperty
Separators
Separators are represented byRibbonButtonSeparatorand provides the well known separator functionallity. When in a dropdown, separators can actually contain text. When they contain text they will be rendered differently.
Known Bugs
- Multiple dropdowns not managed accurately- Drawing of collapsed panels when mouse down
Things to do
- Contextual tabs- ToolTips
- (OK) TextBox, ComboBox
- Checkbox and NumericUpDown RibbonItems
- Orb and Quickaccess tools
- Vista clientarea docking
- Keyboard quick access thru Alt key
- Font and Color selectors
- Right to left orientation
- Ribbon minimization
History
8 May 2008 - Original Post29 May 2008 - Update
Enabledproperty now working
Added
RibbonTextBox- A regular textbox with label and image
Added
RibbonComboBox- (Interited from
RibbonTextBox) Offers a dropdown
Added
RibbonColorChooser- A button that shows a color bar. See property
Color
License
This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)About the Author
Jose M. Menendez Poó | Jose Manuel Menéndez Poó Mexico I've been programming Windows and Web apps since 1997. My greatest concern nowadays is user interface usability. My blog: www.menendezpoo.com
|
相关文章推荐
- 分享DotNetBar控件制作office 2007风格界面的视频教程(winform office 2007 风格)
- 分享用DotNetBar控件制作office 2007风格界面的视频教程(winform office 2007 风格)
- vs2008 office Ribbon 界面风格初总结
- C# OFFICE 2007控件 第三方控件DotNetBar
- VBA开发Office 2007 Ribbon的方法
- BCGControllBar下设计Office 2007风格时,DEBUG+STATIC状态下的错误提示解决办法.
- RibbonXml Office 2007与Office 2010在装载上的区别
- 图片查看器(bmp、jpg、png、动态gif) office 2007风格
- 2007 Office —— 通过快捷键访问 Ribbon
- RibbonX: Customizing the Office 2007 Ribbon
- DeltaOfficewod在线编辑控件 缺省支持office word 2007
- QuickPart : 用户控件包装器 for Office SharePoint Server 2007
- [CodeProject每日一荐] PopupNotifier: 一个Office 2003风格的通知控件(VB.NET)
- Office 2007 Ribbon开发
- 开源WinForms界面开发框架Management Studio 选项卡文档 插件 Office 2007蓝色风格 后台线程
- Office 2007 Beta2 TR now supports minimize ribbon
- QuickPart : 用户控件包装器 for Office SharePoint Server 2007
- office ribbon风格修改功能区
- Qt的纽带风格界面实现(最新的Office Ribbon风格)
- RibbonXml Office 2007与Office 2010在装载上的区别