Welcome!

Related Topics: PowerBuilder, Microsoft Cloud

PowerBuilder: Article

Using a WPF Docking Manager in a PowerBuilder WPF Target

Everything you need to create state-of-the-art GUI applications

In a previous PBDJ article, we looked at using a third-party control, a ribbon control in particular, in a PowerBuilder WPF target. One of the other "most requested" features people have asked for is the capability to provide docking windows in their PowerBuilder applications. In this article, we're going to look at how we can do that in a PowerBuilder WPF application using a third-party docking manager.

The particular docking manager I'm going to use is the AvalonDock, an open source project on CodePlex (http://avalondock.codeplex.com/). At the time of this writing, the current version is 1.3.3571. However, that one has some dependencies on Visual Studio 2010 and .NET Framework 4.0 libraries. PowerBuilder .NET 12 is based on the Visual Studio 2008 isolated shell, so I'm using an older build (1.1.1509) that doesn't have these dependencies.

First, we'll add the AvalonDock assembly and a reference to a new WPF application. Create a new WPF window and add the AvalonDock namespace to the Usings property for the new window. I called that new window w_frame, and coded the open event of the application object to open it. I then dropped a DockingManager control onto the window. Next create a menu (I called mine m_menu) and associate that menu with the new window as well.

I then edited the XAML for the new window to provide a couple of RowDefinitions and to add a StatusBar to the bottom of the window. My modified window XAML looks like this:

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="24"/>
</Grid.RowDefinitions>
<my:DockingManager x:Name="dockingmanager1" Grid.Row="0">
</my:DockingManager>|
<StatusBar Grid.Row="1">
<StatusBarItem Content="Docking Panel Demo"/>
</StatusBar>
</Grid>

The bottom RowDefinition is 24 units high, and the top RowDefinition takes up whatever remaining space there is (the majority of the window). The DockingManager is located in the top RowDefintion (Rows is a zero-based collection), and the StatusBar is assigned to the bottom RowDefinition.

I'm also going to create three instance variables in the window for the ResizingPanel, a DocumentPanel, and a DockablePanel:

ResizingPanel resPanel
DockablePane dockPane
DocumentPane documentPane

In the open event of the window I'll instantiate those items, associate the DockablePane and the DocumentPane to the ResizingPanel, and finally associate the ResizingPanel to the DockManager we added in the designer:

resPanel = create ResizingPanel
resPanel.Orientation = System.Windows.Controls.Orientation.Horizontal!
dockPane = create DockablePane
documentPane = create DocumentPane
resPanel.Children.Add(dockPane)
resPanel.Children.Add(documentPane)
dockingmanager1.Content = resPanel

In the menu, I'll add two menu items: one to open a document "sheet" into the DocumentPane and another to open a "tab" in the DockablePane. They'll just fire events on the window that will actually do the work though. For example:

ParentWindow.event dynamic ue_opensheet()

Here's where it gets interesting. What the docking manager wants to see opening into the DockablePane and the DocumentPane are objects derived from the DockableContent and DocumentContent classes. What we're going to do is create a couple of PowerBuilder custom visual user objects, and then create an inner control on each of those classes. In an existing application, you would need to modify the XAML for your window ancestor classes to accomplish the same thing. The XAML for the resulting objects, u_document and u_panel, look like this Listings 1 and 2. (Listings 1-3 can be downloaded here.)

Now we can go back to w_frame and code the events that open a "sheet" (u_document) and a "tab" (u_panel) (see Listing 3).

Run the app, select the options to open a sheet and a panel two times each, and you should have something that looks similar to Figure 1. Some things to note:

  • Dockable items are capable of autohiding.
  • Dockable items can also be "floated" and moved outside of the frame, even onto a second monitor, giving multi-monitor support.
  • If an item is given a name, the DockingManager can serialize the layout of those items and store it so that it can be reloaded the next time the application runs. The result is that the user's preference for the pane layouts can be remembered between sessions.
  • At any time you can drag an item and use the layout indicators to create new docking groups or move the item onto an existing docking group (see Figure 2).

There you have it - multiple-monitor support, docking panes, autohiding panes and the ability to store and retrieve layouts. Everything you need to create state-of-the-art GUI applications.

Note: Special thanks go out to Peter Conn of the U.S. Census Bureau. His presentation of how he implemented something similar using a commercial third-party docking manager at TechWave 2010 is what prompted me to look into doing it with an open source implementation. He also helped me through some of the stumbling blocks I ran into as I was putting it together.

More Stories By Bruce Armstrong

Bruce Armstrong is a development lead with Integrated Data Services (www.get-integrated.com). A charter member of TeamSybase, he has been using PowerBuilder since version 1.0.B. He was a contributing author to SYS-CON's PowerBuilder 4.0 Secrets of the Masters and the editor of SAMs' PowerBuilder 9: Advanced Client/Server Development.

Comments (2) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
russf0426 10/31/12 12:40:00 PM EDT

Bruce,

Can you elaborate on your choice of avalon? Is your example not possible with the default dockpanel?

acartagenas 08/21/11 04:45:00 AM EDT

Hi Bruce,

This is a very good article for us PB developers. However, the word doc does not exists on the web server.

Thanks,
Allan

Latest Stories
Why Federal cloud? What is in Federal Clouds and integrations? This session will identify the process and the FedRAMP initiative. But is it sufficient? What is the remedy for keeping abreast of cutting-edge technology? In his session at 21st Cloud Expo, Rasananda Behera will examine the proposed solutions: Private or public or hybrid cloud Responsible governing bodies How can we accomplish?
SYS-CON Events announced today that Ryobi Systems will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Ryobi Systems Co., Ltd., as an information service company, specialized in business support for local governments and medical industry. We are challenging to achive the precision farming with AI. For more information, visit http:...
Cloud-based disaster recovery is critical to any production environment and is a high priority for many enterprise organizations today. Nearly 40% of organizations have had to execute their BCDR plan due to a service disruption in the past two years. Zerto on IBM Cloud offer VMware and Microsoft customers simple, automated recovery of on-premise VMware and Microsoft workloads to IBM Cloud data centers.
SYS-CON Events announced today that mruby Forum will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. mruby is the lightweight implementation of the Ruby language. We introduce mruby and the mruby IoT framework that enhances development productivity. For more information, visit http://forum.mruby.org/.
With the rise of DevOps, containers are at the brink of becoming a pervasive technology in Enterprise IT to accelerate application delivery for the business. When it comes to adopting containers in the enterprise, security is the highest adoption barrier. Is your organization ready to address the security risks with containers for your DevOps environment? In his session at @DevOpsSummit at 21st Cloud Expo, Chris Van Tuin, Chief Technologist, NA West at Red Hat, will discuss: The top security r...
Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
Cloud applications are seeing a deluge of requests to support the exploding advanced analytics market. “Open analytics” is the emerging strategy to deliver that data through an open data access layer, in the cloud, to be directly consumed by external analytics tools and popular programming languages. An increasing number of data engineers and data scientists use a variety of platforms and advanced analytics languages such as SAS, R, Python and Java, as well as frameworks such as Hadoop and Spark...
SYS-CON Events announced today that Mobile Create USA will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Mobile Create USA Inc. is an MVNO-based business model that uses portable communication devices and cellular-based infrastructure in the development, sales, operation and mobile communications systems incorporating GPS capabi...
SYS-CON Events announced today that Enroute Lab will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Enroute Lab is an industrial design, research and development company of unmanned robotic vehicle system. For more information, please visit http://elab.co.jp/.
Is advanced scheduling in Kubernetes achievable? Yes, however, how do you properly accommodate every real-life scenario that a Kubernetes user might encounter? How do you leverage advanced scheduling techniques to shape and describe each scenario in easy-to-use rules and configurations? In his session at @DevOpsSummit at 21st Cloud Expo, Oleg Chunikhin, CTO at Kublr, will answer these questions and demonstrate techniques for implementing advanced scheduling. For example, using spot instances ...
Real IoT production deployments running at scale are collecting sensor data from hundreds / thousands / millions of devices. The goal is to take business-critical actions on the real-time data and find insights from stored datasets. In his session at @ThingsExpo, John Walicki, Watson IoT Developer Advocate at IBM Cloud, will provide a fast-paced developer journey that follows the IoT sensor data from generation, to edge gateway, to edge analytics, to encryption, to the IBM Bluemix cloud, to Wa...
SYS-CON Events announced today that Cedexis will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Cedexis is the leader in data-driven enterprise global traffic management. Whether optimizing traffic through datacenters, clouds, CDNs, or any combination, Cedexis solutions drive quality and cost-effectiveness.
SYS-CON Events announced today that Nihon Micron will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Nihon Micron Co., Ltd. strives for technological innovation to establish high-density, high-precision processing technology for providing printed circuit board and metal mount RFID tags used for communication devices. For more inf...
SYS-CON Events announced today that Suzuki Inc. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Suzuki Inc. is a semiconductor-related business, including sales of consuming parts, parts repair, and maintenance for semiconductor manufacturing machines, etc. It is also a health care business providing experimental research for...
Many companies start their journey to the cloud in the DevOps environment, where software engineers want self-service access to the custom tools and frameworks they need. Machine learning technology can help IT departments keep up with these demands. In his session at 21st Cloud Expo, Ajay Gulati, Co-Founder, CTO and Board Member at ZeroStack, will discuss the use of machine learning for automating provisioning of DevOps resources, taking the burden off IT teams.