Introduction
In Windows Explorer under Windows XP, when you hide the Folder View, you get a rather snazy bar that contains a series of collapsible panels that provide shortcuts to common tasks based on the context of the current view. What I wanted was a control that emulates this functionality. What I came up with was an extendedSystem.Windows.Forms.Panel
class, CollapsiblePanel
, that provides (as the name suggests) the collapsible panel functionality. CollapsiblePanel
allows you to define a gradient fill for the background of the title bar, an image list for the expand/collapse button and an image to display on the left hand side (if you want). To try and make this hang together as a Windows XP-like bar, I also created the CollapsiblePanelBar
. This is another extended System.Windows.Forms.Panel
, but this one adds some useful design-time support. As you add CollapsiblePanel
s to the CollapsiblePanelBar
, it's anchor properties are set to Left, Right and Top and it's position is set just below the previous panel. I'm currently developing on Windows NT, so properly rendering the panels with the current theme settings was irrelevant and so that feature remains on the TODO list.Full-featured XP Style Collapsible Panel
Updates
Version 1.2 provides the ability to change the LinearGradientMode
of the Caption and Panel gradients, and includes a few small bug fixes. The implementation now overrides DisplayRectangle
which allows Docking and Anchoring of child controls to work as expected.
Version 1.1 provides two new layout controls and a small number of new features that simplify the creation of more sophisticated layouts and effects. The additions and changes for version 1.1 are listed at the end of the article.
Introduction
After reviewing quite a few of the collapsible panel style controls (both Open Source and commercial), I decided to write XPPanel
to achieve a high quality, feature rich control that provided reasonably tight integration with the Visual Studio IDE.
The primary features I need from a Collapsible panel are:
- Animated Expand/Collapse w/ Transparency
- Gradient colors for both caption and panel
- Customizable radius for caption rounded corners
- Multi-line caption text
- Support for images on both the left and right sides of the caption
- Support for four image states (Normal, Highlight, Pressed, and Disabled)
- Image transparency
- Stand-alone panel (not part of a panel group)
- A Panel Group to contain/manage individual panels
- Fixed size and non-collapsible panels
- Intelligent gray-scale rendering when disabled
- Good integration with the Visual Studio IDE
- Resource efficient
TextLayoutPanel
andItemLayoutPanel
controls that dynamically resize based on content
Background
The real compelling reason for writing XPPanel
was that I just needed to write some code. After weeks of writing software requirements, I was definitely having withdrawal. As I had spent a fair amount of time away from UI code, I thought it would be fun to get back into the swing of things by writing a new control. Unlike most of you, my experience with Windows XP has been limited, but by coincidence, I recently moved my primary development system from Windows 2000 Server to Windows XP Professional. Of course, I was bombarded with UI elements containing collapsible panels, and ergo, I figured why not?
Of course, I did my homework on the currently available implementations of collapsible panels, and I found two that were both high quality and had reasonable feature sets. I am happy to say that both projects are hosted on CodeProject and can be found at the following links:
- Just Another C# Collapsing Group Control by Daren May.
- Windows XP Style Collapsible Panel Bar by Derek Lakin.
Still, although I was impressed with various aspects of both, neither really fit the set of requirements that I wanted for my implementation. I actually thought about merging the two different projects to try and get a better control, but in the end, I decided to write my own implementation and borrow good techniques from those articles (as well as a few other CodeProject based articles!).
Even with good starting points for my control, I faced a bit of an uphill battle with getting the level of IDE designer support I desired, and although I struggled to get it all to work, in the end, I am moderately happy with the results.
Copy right http://www.codeproject.com/KB/miscctrl/TgXPPanel.aspx
->Read More...
1 Comment:
Style panel bar using Panel control
Đăng nhận xét