DockSite serialization not working as expected

Docking/MDI for WPF Forum

Posted 16 years ago by vwin
Version: 4.0.0456
Avatar
I am evaluating your docking product and I must say it is quite impressive. I have evaulated 3 so far and your is the best IMHO.

Question 1
I have run into a small issue with serialization. I have a fairly simple DockSite that has a split container where one side has tool windows and the other has a workspace with some document tabs. When I serialize I can see in the xml that the whole layout has been serialized with the exception of the document tab information. Is this by design?

Question 2
In addition, when I deserialize I have to first create the tool windows before the layout would generate. Your documentation hints that I need to do this, I am okay with this, just wanted to confirm it.

Question 3
Finally, the workspace is never deserialized. Only the tool windows come back. Is there a way to have it deserialized with the rest of the layout? Basically I would like for the whole layout to be recreated the same way it was saved. It would be nice if all the Actipro components were deserialized then I could go back and add the content that was in each document. This way you control the layout while I am only responsible for the content.

Thanks again for making such a great product.

Comments (6)

Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi, thanks for evaluating our WPF products and we appreciate the comments.

I believe all your questions are related. For the first release of the product, we concentrated on basic tool window only serialization and restoration. So it doesn't process documents in serialization yet. Also, yes you do need to have the tool windows created now prior to loading a layout.

Both of these are areas we have on the TODO list to improve but if you'd like to talk over email about what features you'd like to see for them, please do email our support team and we'd be happy to discuss them with you. This would be great for you since you could help ensure that we implement the features you need.


Actipro Software Support

Posted 15 years ago by Jason
Avatar
Regarding question #2:

So when I deserialize, I must first have all of my tool windows created (ie, DockSite.ToolWindows should be populated). That's fine. I imagine then that DockSiteLayoutSerializer().LoadFromString just looks at the existing windows, sees if there is any saved layout data for each window, and then just modifies the existing tool windows properties to match the saved data. Since you seem to obfuscate your assemblies, I cannot verify this. This seems like the logical way to apply a layout.

My problem is that the docksite fires WindowClosed events for each tool window in docksite.ToolWindows. Why does this occur? I handle this event and do some stuff when this happens, and I don't want this stuff to happen when the layout is being deserialized. It seems though that this event shouldn't be firing at all?

I am on version 4.5.477.
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Jason,

It should only be firing WindowClosed when a window closes. Now if the window was open before the layout was loaded, then it will probably fire. Then if the layout opens it again, WindowOpened, etc. will fire.

So yes you could potentially see a WindowClosed, then WindowOpened occur in sequence for a tool window if the old and new layouts had it active.


Actipro Software Support

Posted 15 years ago by Cameron MacFarland - Senior Software Engineer, Orelogy Geotechnical
Avatar
I'm having a similar issue currently with version 4.5.487.

When I deserialize a layout I'm only getting WindowClosing/WindowClosed events but not the WindowOpening/WindowOpened events even if the tool window is already open. I'd expect either both sets or neither but not just one set.

Here's a sample app that demonstrates what I mean.
<Window 
    x:Class="ActiproSoftware.Windows.ProductSamples.DockingSamples.QuickStart.ProgrammaticCreation.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking" 
    Title="Programmatic Creation QuickStart"
    Width="800" Height="600"
    >
    <DockPanel LastChildFill="True">
        <docking:DockSite x:Name="dockSite">
            <docking:SplitContainer>
                <docking:Workspace BorderBrush="#D0D0D0" BorderThickness="1">
                    <docking:Workspace.Background>
                        <LinearGradientBrush EndPoint="0,1">
                            <GradientStop Offset="0.5" Color="#FFFFFF" />
                            <GradientStop Offset="1" Color="#F8F8F8" />
                        </LinearGradientBrush>
                    </docking:Workspace.Background>
                    <StackPanel Margin="7">
                        <TextBlock Text="The Workspace" FontWeight="Bold" />
                        <Button Content="Serialize" Click="Serialize_Click" />
                        <Button Content="Deserialize" Click="Deserialize_Click" />
                        <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
                            <TextBlock x:Name="storage" />
                        </ScrollViewer>
                        <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
                            <TextBlock x:Name="events" />
                        </ScrollViewer>
                    </StackPanel>
                </docking:Workspace>
                <docking:ToolWindowContainer>
                    <docking:ToolWindow x:Name="originalToolWindow" Title="Original Tool Window" CanClose="False">
                        <TextBlock Text="Originally-created tool window" />
                    </docking:ToolWindow>
                    <docking:ToolWindow x:Name="anotherToolWindow" Title="Another Tool Window" CanClose="False">
                        <TextBlock Text="Another originally-created tool window" />
                    </docking:ToolWindow>
                </docking:ToolWindowContainer>
            </docking:SplitContainer>
        </docking:DockSite>
    </DockPanel>
</Window>
using System;
using System.Windows;
using ActiproSoftware.Windows.Controls.Docking;
using ActiproSoftware.Windows.Controls.Docking.Serialization;

namespace ActiproSoftware.Windows.ProductSamples.DockingSamples.QuickStart.ProgrammaticCreation
{
    public partial class MainWindow : System.Windows.Window
    {
        public MainWindow()
        {
            InitializeComponent();

            dockSite.WindowOpened += DockSiteEventHandler("WindowOpened");
            dockSite.WindowOpening += DockSiteEventHandler("WindowOpening");
            dockSite.WindowClosed += DockSiteEventHandler("WindowClosed");
            dockSite.WindowClosing += DockSiteEventHandler("WindowClosing");
        }

        private EventHandler<DockingWindowEventArgs> DockSiteEventHandler(string p)
        {
            return delegate(object sender, DockingWindowEventArgs e)
            {
                events.Text += p + Environment.NewLine;
            };
        }

        private void Serialize_Click(object sender, RoutedEventArgs e)
        {
            storage.Text = new DockSiteLayoutSerializer().SaveToString(dockSite);
        }

        private void Deserialize_Click(object sender, RoutedEventArgs e)
        {
            new DockSiteLayoutSerializer().LoadFromString(storage.Text, dockSite);
        }
    }
}
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Cameron,

Thanks for the sample, we've reproed the issue and fixed it for the next release.


Actipro Software Support

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hello,

Just fyi, we've added support for serializing/deserializing the entire DockSite layout (including the Workspace), in addition to a number of other features.

You can see this in action in the current version of WPF Studio.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.