Way to hide compass in case of manual cancel?

2 posts, 0 answers
  1. Jamest
    Jamest avatar
    41 posts
    Member since:
    Apr 2007

    Posted 18 Feb 2010 Link to this post

    I have an htmlplaceholder in my document pane. I hide it when a pane from another group starts floating. I set a timer and check position of the dragging/floating pane. If the position of the floating pane hasn't changed in x seconds I readd the pane to its initial pane group. This allows me to prevent floating panes (which will become obscured by the htmlplaceholder). This is all fine except that if I do redock for the user the compass is still showing. Is there a way I can close/hide/access the compass after its been displayed or another refresh trick? Thanks in advance,
               Jordan
  2. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 19 Feb 2010 Link to this post

    Hi Jordan,

     My suggestion is to create an attached property of bool type and to set it in the CompassStyle, RootCompassStyle and VisualCueStyle. When set to true this property might collect its target object into a collection. When you need to hide all the compasses you might refer to this collection and hide all its elements. Here is an example:

    The helper class with the attached property:

    public class Helper
    {
        private static List<UIElement> dockElements = new List<UIElement>();
     
        public static IEnumerable<UIElement> DockElements { get { return dockElements; } }
     
        public static bool GetIsDockingCompass(DependencyObject obj)
        {
            return (bool)obj.GetValue(IsDockingCompassProperty);
        }
     
        public static void SetIsDockingCompass(DependencyObject obj, bool value)
        {
            obj.SetValue(IsDockingCompassProperty, value);
        }
     
        // Using a DependencyProperty as the backing store for IsDockingCompass.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty IsDockingCompassProperty =
            DependencyProperty.RegisterAttached("IsDockingCompass", typeof(bool), typeof(Helper), new PropertyMetadata(OnIsDockingCompassChanged));
     
        private static void OnIsDockingCompassChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var element = d as UIElement;
            if (element != null)
            {
                if ((bool)(e.NewValue))
                {
                    dockElements.Add(element);
                }
                else
                {
                    dockElements.Remove(element);
                }
            }
        }
    }
    The XAML of the Docking control:

    <telerikDocking:RadDocking x:Name="docking" PaneStateChange="RadDocking_PaneStateChange">
        <telerikDocking:RadDocking.CompassStyle>
            <Style TargetType="dock:Compass">
                <Setter Property="local:Helper.IsDockingCompass" Value="True" />
            </Style>
        </telerikDocking:RadDocking.CompassStyle>
     
        <telerikDocking:RadDocking.RootCompassStyle>
            <Style TargetType="dock:RootCompass">
                <Setter Property="local:Helper.IsDockingCompass" Value="True" />
            </Style>
        </telerikDocking:RadDocking.RootCompassStyle>
     
        <telerikDocking:RadDocking.VisualCueStyle>
            <Style TargetType="dock:VisualCue">
                <Setter Property="local:Helper.IsDockingCompass" Value="True" />
            </Style>
        </telerikDocking:RadDocking.VisualCueStyle>
        <telerikDocking:RadSplitContainer>
            <telerikDocking:RadPaneGroup x:Name="mainGroup">
                <telerikDocking:RadPane Header="asdf">
                    <Button />
                </telerikDocking:RadPane>
                <telerikDocking:RadPane Header="asdf">
                    <Button />
                </telerikDocking:RadPane>
                <telerikDocking:RadPane Header="asdf">
                    <Button />
                </telerikDocking:RadPane>
            </telerikDocking:RadPaneGroup>
        </telerikDocking:RadSplitContainer>
    </telerikDocking:RadDocking>
    And the code I used to try your scenario - if I understood correctly you have better implementation for this:

    private void RadDocking_PaneStateChange(object sender, Telerik.Windows.RadRoutedEventArgs e)
    {
        var pane = e.OriginalSource as RadPane;
        if (pane.IsFloating)
        {
            var timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(1.5) };
            EventHandler handler = null;
            handler = (s, a) =>
                {
                    timer.Stop();
                    timer.Tick -= handler;
                    if (pane.IsFloating)
                    {
                        pane.RemoveFromParent();
                        mainGroup.Items.Add(pane);
     
                        foreach (var c in Helper.DockElements)
                        {
                            c.Visibility = Visibility.Collapsed;
                        }
                    }
                };
            timer.Tick += handler;
            timer.Start();
        }
    }

    Hope this helps!

    Kind regards,
    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.
Back to Top