Exemple #1
0
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal
        /// processes call <see cref="FrameworkElement.ApplyTemplate"/>.
        /// </summary>
        public override void OnApplyTemplate()
        {
            _contentPresenter = null;

            foreach (var autoHideBar in _autoHideBars)
            {
                autoHideBar.TargetArea = null;
            }

            _leftAutoHideBar   = null;
            _rightAutoHideBar  = null;
            _topAutoHideBar    = null;
            _bottomAutoHideBar = null;
            _autoHideBars      = null;

            if (_autoHidePanel != null)
            {
                _autoHidePanel.Children.Clear();
                _autoHidePanel = null;
            }

            base.OnApplyTemplate();

            _contentPresenter  = GetTemplateChild("PART_ContentPresenter") as ContentPresenter;
            _autoHidePanel     = GetTemplateChild("PART_AutoHidePanel") as Panel;
            _leftAutoHideBar   = GetTemplateChild("PART_AutoHideBarLeft") as AutoHideBar;
            _rightAutoHideBar  = GetTemplateChild("PART_AutoHideBarRight") as AutoHideBar;
            _topAutoHideBar    = GetTemplateChild("PART_AutoHideBarTop") as AutoHideBar;
            _bottomAutoHideBar = GetTemplateChild("PART_AutoHideBarBottom") as AutoHideBar;

            var autoHideBars = new List <AutoHideBar>(4);

            if (_leftAutoHideBar != null)
            {
                _leftAutoHideBar.SetBinding(ItemsControl.ItemsSourceProperty, new Binding(nameof(IDockControl.AutoHideLeft)));
                autoHideBars.Add(_leftAutoHideBar);
            }
            if (_rightAutoHideBar != null)
            {
                _rightAutoHideBar.SetBinding(ItemsControl.ItemsSourceProperty, new Binding(nameof(IDockControl.AutoHideRight)));
                autoHideBars.Add(_rightAutoHideBar);
            }
            if (_topAutoHideBar != null)
            {
                _topAutoHideBar.SetBinding(ItemsControl.ItemsSourceProperty, new Binding(nameof(IDockControl.AutoHideTop)));
                autoHideBars.Add(_topAutoHideBar);
            }
            if (_bottomAutoHideBar != null)
            {
                _bottomAutoHideBar.SetBinding(ItemsControl.ItemsSourceProperty, new Binding(nameof(IDockControl.AutoHideBottom)));
                autoHideBars.Add(_bottomAutoHideBar);
            }

            _autoHideBars = autoHideBars.ToArray();

            foreach (var autoHideBar in _autoHideBars)
            {
                autoHideBar.TargetArea = _autoHidePanel;
            }
        }
Exemple #2
0
        /// <summary>
        /// Invoked when an unhandled <strong>Mouse.MouseLeave</strong> attached event is raised on
        /// this element. Implement this method to add class handling for this event.
        /// </summary>
        /// <param name="e">
        /// The <see cref="MouseEventArgs"/> that contains the event data.
        /// </param>
        protected override void OnMouseLeave(MouseEventArgs e)
        {
            _hoverTimer.Stop();
            AutoHideBar?.TabLeave(this);

            base.OnMouseLeave(e);
            UpdateVisualStates(true);
        }
Exemple #3
0
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonDown(e);

            if (!e.Handled)
            {
                AutoHideBar?.TabClicked(this);
                e.Handled = true;
            }
        }
Exemple #4
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            if (!e.Handled)
            {
                if ((e.Key == Key.Enter || e.Key == Key.Space))
                {
                    AutoHideBar?.TabClicked(this);
                }

                e.Handled = true;
            }
        }
Exemple #5
0
 /// <summary>
 /// Called when the mouse cursor has hovered over the tab for a certain amount of time.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="eventArgs">
 /// The <see cref="EventArgs"/> instance containing the event data.
 /// </param>
 private void OnMouseHover(object sender, EventArgs eventArgs)
 {
     _hoverTimer.Stop();
     AutoHideBar?.TabEnter(this);
 }
Exemple #6
0
 /// <summary>
 /// Raises the <see cref="UIElement.LostFocus"/> routed event by using the event data that
 /// is provided.
 /// </summary>
 /// <param name="e">
 /// A <see cref="RoutedEventArgs"/> that contains event data. This event data must contain
 /// the identifier for the <see cref="UIElement.LostFocus"/> event.
 /// </param>
 protected override void OnLostFocus(RoutedEventArgs e)
 {
     AutoHideBar?.TabLeave(this);
     base.OnLostFocus(e);
 }
Exemple #7
0
 /// <summary>
 /// Invoked whenever an unhandled <see cref="UIElement.GotFocus"/> event reaches this
 /// element in its route.
 /// </summary>
 /// <param name="e">
 /// The <see cref="RoutedEventArgs"/> that contains the event data.
 /// </param>
 protected override void OnGotFocus(RoutedEventArgs e)
 {
     AutoHideBar?.TabEnter(this);
     base.OnGotFocus(e);
 }