I think that RadDocking.GetDockState() of an hidden pane should return
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:
XAML:
- 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> |