This is a migrated thread and some comments may be shown as answers.

Getting the state of a hidden RadPane always return DockedLeft

4 Answers 97 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Sieg
Top achievements
Rank 1
Sieg asked on 17 Mar 2010, 11:39 PM
I think that RadDocking.GetDockState() of an hidden pane should return
  • either HiddenDockedLeft or DockedLeft for a RadPane hidden left
  • either HiddenDockedTop or DockedTop for a RadPane hidden top
  • either HiddenDockedRight or DockedRight for a RadPane hidden right
  • either HiddenDockedBottom or DockedBottom for a RadPane hidden bottom

Also, it would be great to have PaneStateChanged for after the RadPane had changed.

In my code, I used on LayoutUpdate because I was always one step behind the real tree.
My "workaround" is by getting the property name of the Telerik.Windows.Controls.Docking.AutoHideArea

C# sample:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Data; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Imaging; 
using System.Windows.Shapes; 
using Telerik.Windows.Controls; 
 
namespace QView 
    /// <summary> 
    /// Interaction logic for Window3.xaml 
    /// </summary> 
    public partial class Window3 : Window 
    { 
        public Window3() 
        { 
            InitializeComponent(); 
        } 
 
        private void RadDocumentPane_MouseDoubleClick(object sender, MouseButtonEventArgs e) 
        { 
            // Create a FlowDocument 
            FlowDocument mcFlowDoc = new FlowDocument(); 
 
            // Create a paragraph with text 
            Paragraph para = new Paragraph(); 
            para.Inlines.Add(new Run("I am a flow document. Would you like to edit me? ")); 
            para.Inlines.Add(new Bold(new Run("Go ahead."))); 
 
            // Add the paragraph to blocks of paragraph 
            mcFlowDoc.Blocks.Add(para); 
 
            // Set contents 
            rtb.Document = mcFlowDoc; 
 
            TextPointer start = rtb.Document.ContentStart; 
            TextPointer startPos = start.GetPositionAtOffset(2); 
            TextPointer endPos = start.GetPositionAtOffset(8); 
            TextRange textRange = new TextRange(startPos, endPos); 
            Console.WriteLine(textRange.Text); 
            textRange.ApplyPropertyValue(TextElement.ForegroundProperty, 
                new SolidColorBrush(Colors.Blue)); 
            textRange.ApplyPropertyValue(TextElement.FontWeightProperty, 
                FontWeights.Bold); 
 
            start = rtb.Document.ContentStart; 
            startPos = start.GetPositionAtOffset(7); 
            endPos = start.GetPositionAtOffset(18); 
            textRange = new TextRange(startPos, endPos); 
            Console.WriteLine(textRange.Text); 
            textRange.ApplyPropertyValue(TextElement.ForegroundProperty, 
                new SolidColorBrush(Colors.Red)); 
            textRange.ApplyPropertyValue(TextElement.FontWeightProperty, 
                FontWeights.Bold); 
             
            startPos = rtb.Document.ContentStart; 
            endPos = rtb.Document.ContentEnd; 
            textRange = new TextRange(startPos, endPos); 
            textRange.ClearAllProperties(); 
        } 
 
        private TreeViewItem FindItem(String p_sFind, ItemCollection p_oIC) 
        { 
            foreach (TreeViewItem oTVI in p_oIC) 
            { 
                if (oTVI.Header.ToString() == p_sFind) 
                { 
                    return oTVI; 
                } 
            } 
            return null
        } 
 
        private void TreeSet(RadSplitContainer p_oRSC, TreeViewItem p_oTVI) 
        { 
            TreeViewItem oTVIGroup; 
            TreeViewItem oTVIChild; 
            object o; 
            for (int nIdx = 0; nIdx < p_oRSC.Items.Count;) 
            { 
                o = p_oRSC.Items[nIdx]; 
                if (o is RadSplitContainer) 
                { 
                    RadSplitContainer oRSC = o as RadSplitContainer; 
                    oTVIGroup = new TreeViewItem(); 
                    oTVIGroup.Header = "RadSplitContainer"
                    TreeSet(o as RadSplitContainer, oTVIGroup); 
                    p_oTVI.Items.Add(oTVIGroup); 
                } 
                else if (o is RadPaneGroup) 
                { 
                    RadPaneGroup oRPG = o as RadPaneGroup; 
                    oTVIGroup = new TreeViewItem(); 
                    oTVIGroup.Header = "Group"
                    if (oRPG.Items.Count != 0) 
                    { 
                        foreach (RadPane oRD in (o as RadPaneGroup).Items) 
                        { 
                            oTVIChild = new TreeViewItem(); 
                            oTVIChild.Header = oRD.Header.ToString(); 
                            oTVIGroup.Items.Add(oTVIChild); 
                        } 
                        p_oTVI.Items.Add(oTVIGroup); 
                    } 
                } 
                else 
                { 
                    Console.WriteLine(o.GetType()); 
                } 
                ++nIdx; 
            } 
        } 
 
        private void radDocking1_LayoutUpdated(object sender, EventArgs e) 
        { 
            radTreeView.Items.Clear(); 
 
            TreeViewItem oTVIChild; 
            TreeViewItem oTVIGroup; 
            TreeViewItem oTVIParent; 
            foreach (RadPane oRP in radDocking1.Panes) 
            { 
                if (oRP.IsFloating || oRP.IsFloatingOnly) 
                { 
                    oTVIParent = FindItem("Floating", radTreeView.Items); 
                    if (oTVIParent == null
                    { 
                        oTVIParent = new TreeViewItem(); 
                        oTVIParent.Header = "Floating"
                        radTreeView.Items.Add(oTVIParent); 
                    } 
                    oTVIChild = new TreeViewItem(); 
                    oTVIChild.Header = oRP.Header; 
                    oTVIParent.Items.Add(oTVIChild); 
                } 
                else if (oRP.IsInDocumentHost) 
                { 
                    oTVIParent = FindItem("Documents", radTreeView.Items); 
                    if (oTVIParent == null
                    { 
                        oTVIParent = new TreeViewItem(); 
                        oTVIParent.Header = "Documents"
                        radTreeView.Items.Add(oTVIParent); 
                    } 
                    oTVIChild = new TreeViewItem(); 
                    oTVIChild.Header = oRP.Header; 
                    oTVIParent.Items.Add(oTVIChild); 
                } 
                else if (!oRP.IsPinned) 
                { 
                    Console.WriteLine(radDocking1); 
                    //Telerik.Windows.Controls.Docking.AutoHideArea.NameProperty 
                    //oTVIParent = FindItem(RadDocking.GetDockState(oRP.Parent).ToString(), radTreeView.Items); 
                    oTVIParent = FindItem(oRP.Parent.GetValue(Telerik.Windows.Controls.Docking.AutoHideArea.NameProperty).ToString(), radTreeView.Items); 
                    Console.WriteLine("RadDocking.GetDockState() with the RadPanel : " + RadDocking.GetDockState(oRP).ToString()); 
                    Console.WriteLine("RadDocking.GetDockState() with the parent(Telerik.Windows.Controls.Docking.AutoHideArea) of the RadPanel : " + RadDocking.GetDockState(oRP.Parent).ToString()); 
                    Console.WriteLine("Name of the Telerik.Windows.Controls.Docking.AutoHideArea : " + oRP.Parent.GetValue(Telerik.Windows.Controls.Docking.AutoHideArea.NameProperty).ToString()); 
                    if (oTVIParent == null
                    { 
                        oTVIParent = new TreeViewItem(); 
                        oTVIParent.Header = oRP.Parent.GetValue(Telerik.Windows.Controls.Docking.AutoHideArea.NameProperty).ToString(); 
                        radTreeView.Items.Add(oTVIParent); 
                    } 
                    oTVIChild = new TreeViewItem(); 
                    oTVIChild.Header = oRP.Header; 
                    oTVIParent.Items.Add(oTVIChild); 
                } 
            } 
 
            foreach (RadSplitContainer oRSC in radDocking1.Items) 
            { 
                oTVIParent = FindItem(RadDocking.GetDockState(oRSC).ToString(), radTreeView.Items); 
                if (oTVIParent == null
                { 
                    oTVIParent = new TreeViewItem(); 
                    oTVIParent.Header = RadDocking.GetDockState(oRSC).ToString(); 
                    radTreeView.Items.Add(oTVIParent); 
                } 
                TreeSet(oRSC, oTVIParent); 
            } 
        } 
 
        private void radDocking1_PreviewShowCompass(object sender, Telerik.Windows.Controls.Docking.PreviewShowCompassEventArgs e) 
        { 
            /*if (e.TargetGroup != null)
            {
                e.Compass.IsCenterIndicatorVisible = CanDockIn(e.DraggedSplitContainer, e.TargetGroup, DockPosition.Center);
                e.Compass.IsLeftIndicatorVisible = CanDockIn(e.DraggedSplitContainer, e.TargetGroup, DockPosition.Left);
                e.Compass.IsTopIndicatorVisible = CanDockIn(e.DraggedSplitContainer, e.TargetGroup, DockPosition.Top);
                e.Compass.IsRightIndicatorVisible = CanDockIn(e.DraggedSplitContainer, e.TargetGroup, DockPosition.Right);
                e.Compass.IsBottomIndicatorVisible = CanDockIn(e.DraggedSplitContainer, e.TargetGroup, DockPosition.Bottom);
            }
            e.Canceled = !(CompassNeedsToShow(e.Compass));*/ 
        } 
 
        private void radDocking1_PaneStateChange(object sender, Telerik.Windows.RadRoutedEventArgs e) 
        { 
             
        } 
    } 
 

XAML:

<Window x:Class="QView.Window3" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:my="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Docking"  
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
    Title="Window3" Height="300" Width="300" > 
    <Grid> 
        <Grid.RowDefinitions> 
            <RowDefinition Height="auto"/> 
            <RowDefinition /> 
        </Grid.RowDefinitions> 
        <telerik:RadMenu x:Name="radMenu" ClickToOpen="False" Grid.Row="0"
            <telerik:RadMenuItem Header="_File"
                <telerik:RadMenuItem Header="New _Tab" > 
                </telerik:RadMenuItem> 
                <telerik:RadMenuItem Header="New _Window"
                </telerik:RadMenuItem> 
                <telerik:RadMenuItem Header="_Open"
                </telerik:RadMenuItem> 
                <telerik:RadMenuItem Header="_Edit with Microsoft Office Word" /> 
            </telerik:RadMenuItem> 
        </telerik:RadMenu> 
        <Grid Grid.Row="1"
            <my:RadDocking x:Name="radDocking1" Height="auto"  PaneStateChange="radDocking1_PaneStateChange" PreviewShowCompass="radDocking1_PreviewShowCompass" LayoutChangeEnded="radDocking1_LayoutUpdated"
                <my:RadDocking.DocumentHost> 
                    <my:RadSplitContainer> 
                        <my:RadPaneGroup> 
                            <my:RadDocumentPane Header="Document 1" Title="Document 1" IsHidden="False" MouseDoubleClick="RadDocumentPane_MouseDoubleClick"
                                <Grid> 
                                    <RichTextBox x:Name="rtb"
                                        <RichTextBox.Document> 
                                            <FlowDocument x:Name="FlowDoc"
                                                <Paragraph x:Name="Paragraph"
                                                    <Bold>New France (French: Nouvelle-France) 
                                                    <Bold>was the</Bold> 
                                                        <Italic>area</Italic> colonized</Bold> by France in North America during a period extending from the exploration of the Saint Lawrence River, by Jacques Cartier in 1534, to the cession of New France to Spain and Britain in 1763. At its peak in 1712 (before the Treaty of Utrecht), the territory of New France extended from Newfoundland to the Rocky Mountains and from Hudson Bay to the Gulf of Mexico. The territory was then divided in five colonies, each with its own administration: Canada, Acadia, Hudson Bay, Newfoundland (Plaisance),[1]  and Louisiana. The Treaty of Utrecht resulted in the relinquishing of French claims to mainland Acadia, the Hudson Bay and Newfoundland colonies, and the establishment of the colony of Île Royale (Cape Breton Island) as the successor to Acadia.[2][3] 
                                                </Paragraph> 
                                                <Paragraph> 
                                                    Around 1523, the Italian navigator Giovanni da Verrazzano convinced the king, Francis I, to commission an expedition to find a western route to Cathay (China). Late that year, Verrazzano set sail in Dieppe, crossing the Atlantic on a small caravel  with 53 men. After exploring the coast of the present-day Carolinas  early the following year, he headed north along the coast, eventually anchoring in the Narrows of New York Bay. The first European to discover the site of present-day New York, he named it Nouvelle-Angoulême in honour of the king, the former count of Angoulême. Verrazzano’s voyage convinced the king to seek to establish a colony in the newly discovered land. Verrazzano gave the names Francesca and Nova Gallia to that land between New Spain (Mexico) and English Newfoundland.[4] 
                                                </Paragraph> 
                                                <Paragraph> 
                                                    In 1534, Jacques Cartier planted a cross in the Gaspé Peninsula and claimed the land in the name of King Francis I. It was the first province of New France. However, initial French attempts at settling the region met with failure. French fishing fleets, however, continued to sail to the Atlantic coast and into the St. Lawrence River, making alliances with First Nations  that would become important once France began to occupy the land. French merchants soon realized the St. Lawrence region was full of valuable fur-bearing animals, especially the beaver, which was becoming rare in Europe. Eventually, the French crown decided to colonize the territory to secure and expand its influence in America. 
                                                </Paragraph> 
                                                <Paragraph> 
                                                    Another early French attempt at settlement in North America was Fort Caroline, established in what is now Jacksonville, Florida, in 1564. Intended as a haven for Huguenots, Caroline was founded under the leadership of René Goulaine de Laudonnière and Jean Ribault. It was sacked by the Spanish led by Pedro Menéndez de Avilés which then established the settlement of St. Augustine on September 20, 1565. 
                                                </Paragraph> 
                                            </FlowDocument> 
                                        </RichTextBox.Document> 
                                    </RichTextBox> 
                                </Grid> 
                            </my:RadDocumentPane> 
                            <my:RadDocumentPane Header="Document 2" Title="Document 2" IsHidden="False"
                                <Grid /> 
                            </my:RadDocumentPane> 
                            <my:RadDocumentPane Header="Document 3" Title="Document 3" IsHidden="False"
                                <Grid /> 
                            </my:RadDocumentPane> 
                        </my:RadPaneGroup> 
                    </my:RadSplitContainer> 
                </my:RadDocking.DocumentHost> 
                <my:RadSplitContainer Orientation="Vertical" InitialPosition="DockedLeft" Width="150"
                    <my:RadPaneGroup> 
                        <my:RadPane Header="Pane 1" CanDockInDocumentHost="True"
                            <Grid> 
                                <telerik:RadTreeView x:Name="radTreeView"/> 
                            </Grid> 
                        </my:RadPane> 
                        <my:RadPane Header="Pane 2"
                            <Grid> 
                            </Grid> 
                        </my:RadPane> 
                    </my:RadPaneGroup> 
                </my:RadSplitContainer> 
                <my:RadSplitContainer Orientation="Horizontal" InitialPosition="DockedLeft" Width="150"
                    <my:RadPaneGroup> 
                        <my:RadPane Header="Pane 3"
                            <Grid> 
                            </Grid> 
                        </my:RadPane> 
                        <my:RadPane Header="Pane 4"
                            <Grid> 
                            </Grid> 
                        </my:RadPane> 
                    </my:RadPaneGroup> 
                </my:RadSplitContainer> 
            </my:RadDocking> 
        </Grid> 
    </Grid> 
</Window> 
 

4 Answers, 1 is accepted

Sort by
0
RoxanaC
Top achievements
Rank 1
answered on 18 Mar 2010, 08:13 AM
Hello!
This sounds very familiar to me... actually I think I've wrote about something similar in one of my threads:
"How to rise event for dock/orientation change?"
Is there any fix for this problem?
Roxana
0
Rosi
Telerik team
answered on 18 Mar 2010, 12:16 PM
Hello all,

We apologize for the inconvenience this problem causes to you.

The state of this issue you can follow in our PITS system.
You can also use the PaneStateChanged event of the Docking control to find the correct position of the pane  - it is raised whenever a RadPane changes its state. Please refer to the following sample code (the RadDocking_PaneStateChanged method is an event handler for the PaneStateChanged event):
private void RadDocking_PaneStateChange(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    var pane = e.OriginalSource as RadPane;
    pane.Dispatcher.BeginInvoke(() => pane.Content = FindPanePosition(pane));
}
 
private static DockState? FindPanePosition(RadPane pane)
{
    if (pane.IsFloating)
    {
        return pane.IsDockable ? DockState.FloatingDockable : DockState.FloatingOnly;
    }
 
    var p = pane.Parent as ISplitItem;
 
    if (p == null)
    {
        // The pane is in AutoHideArea
        return null;
    }
 
    var container = p.ParentContainer;
    while (container != null)
    {
        p = container;
        container = p.ParentContainer;
    }
 
    container = p as RadSplitContainer;
    return RadDocking.GetDockState(container);
}

Hope this helps.

Regards,
Rosi
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Sieg
Top achievements
Rank 1
answered on 18 Mar 2010, 03:56 PM
Indeed I saw you're post before posting mine but it wasn't resolving my problem about hidden pane so I thought of posting my "workaround" to trace the hidden pane's position with the :

Telerik.Windows.Controls.Docking.AutoHideArea

C# code:

foreach (RadPane oRP in radDocking1.Panes) 
    if (!oRP.IsPinned) 
    { 
        Console.Writeline(oRP.Parent.GetValue(Telerik.Windows.Controls.Docking.AutoHideArea.NameProperty).ToString()); 
    } 
 

Will write either the string : LeftAutoHide, RightAutoHide, TopAutoHide or BottomAutoHide in the case there are hidden.

Sorry, I didn't read the part that said : "Actually after more debug I found out that theRadDocking.GetDockState(container) method always returns the same value equal with the DockedLeft no matter where the container is docked OR the InitialPosition"

I managed to make you're code work in c# but there's an unhanded exception thrown inside Telerik's code when the pane is hidden so I stopped looking there.

Rosi 's code doesn't compile in c# 2008 (I have the RadControl 2010 Q1 installed) at the line : pane.Dispatcher.BeginInvoke(() => pane.Content = FindPanePosition(pane));

Last thing (for Rosi) there is only PaneStateChange that occurs before the pane state are changed and I think about an event after the state are changed.

Thanks anyway,
Siegfrid

0
Accepted
Miroslav Nedyalkov
Telerik team
answered on 19 Mar 2010, 02:04 PM
Hello Siegfrid,

 The code Rosi sent is meant to work only with visible panes that are pinned. If you need to handle the cases when the panes are not pinned or when they are hidden you will need some more cases.

Most probably the code doesn't compile, because you don't have a pane, called 'pane', that is referenced in the sample code.

You are right that this event is fired before the pane is actually moved. You could execute some action after the move is finished using the Dispatcher.BeginInvoke method - it allows you to run a method asynchronously (in this case your action will be executed just after the state change is finished).

If you have further questions don't hesitate to ask.

Greetings,
Miroslav Nedyalkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Docking
Asked by
Sieg
Top achievements
Rank 1
Answers by
RoxanaC
Top achievements
Rank 1
Rosi
Telerik team
Sieg
Top achievements
Rank 1
Miroslav Nedyalkov
Telerik team
Share this question
or