Example #1
0
        private static void WindowFocusChanging(object sender, FocusChangeEventArgs e)
        {
            Func <HwndHost, bool> func = null;

            foreach (DockingManager _manager in FocusElementManager._managers)
            {
                IEnumerable <HwndHost> hwndHosts = _manager.FindLogicalChildren <HwndHost>();
                Func <HwndHost, bool>  func1     = func;
                if (func1 == null)
                {
                    Func <HwndHost, bool> func2 = (HwndHost hw) => Win32Helper.IsChild(hw.Handle, e.GotFocusWinHandle);
                    Func <HwndHost, bool> func3 = func2;
                    func  = func2;
                    func1 = func3;
                }
                HwndHost hwndHost = hwndHosts.FirstOrDefault <HwndHost>(func1);
                if (hwndHost == null)
                {
                    continue;
                }
                LayoutAnchorableControl gotFocusWinHandle = hwndHost.FindVisualAncestor <LayoutAnchorableControl>();
                if (gotFocusWinHandle == null)
                {
                    LayoutDocumentControl layoutDocumentControl = hwndHost.FindVisualAncestor <LayoutDocumentControl>();
                    if (layoutDocumentControl == null)
                    {
                        continue;
                    }
                    FocusElementManager._modelFocusedWindowHandle[layoutDocumentControl.Model] = e.GotFocusWinHandle;
                    if (layoutDocumentControl.Model == null)
                    {
                        continue;
                    }
                    layoutDocumentControl.Model.IsActive = true;
                }
                else
                {
                    FocusElementManager._modelFocusedWindowHandle[gotFocusWinHandle.Model] = e.GotFocusWinHandle;
                    if (gotFocusWinHandle.Model == null)
                    {
                        continue;
                    }
                    gotFocusWinHandle.Model.IsActive = true;
                }
            }
        }
Example #2
0
        private static void manager_PreviewGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
        {
            Visual newFocus = e.NewFocus as Visual;

            if (newFocus != null && !(newFocus is LayoutAnchorableTabItem) && !(newFocus is LayoutDocumentTabItem))
            {
                LayoutAnchorableControl layoutAnchorableControl = newFocus.FindVisualAncestor <LayoutAnchorableControl>();
                if (layoutAnchorableControl != null)
                {
                    FocusElementManager._modelFocusedElement[layoutAnchorableControl.Model] = e.NewFocus;
                    return;
                }
                LayoutDocumentControl layoutDocumentControl = newFocus.FindVisualAncestor <LayoutDocumentControl>();
                if (layoutDocumentControl != null)
                {
                    FocusElementManager._modelFocusedElement[layoutDocumentControl.Model] = e.NewFocus;
                }
            }
        }
        void CreateInternalGrid()
        {
            _internalGrid = new Grid()
            {
                FlowDirection = System.Windows.FlowDirection.LeftToRight
            };
            _internalGrid.SetBinding(Grid.BackgroundProperty, new Binding("Background")
            {
                Source = this
            });


            _internalHost = new LayoutAnchorableControl()
            {
                Model = _model, Style = AnchorableStyle
            };
            _internalHost.SetBinding(FlowDirectionProperty, new Binding("Model.Root.Manager.FlowDirection")
            {
                Source = this
            });

            KeyboardNavigation.SetTabNavigation(_internalGrid, KeyboardNavigationMode.Cycle);

            _resizer = new LayoutGridResizerControl();

            _resizer.DragStarted   += new System.Windows.Controls.Primitives.DragStartedEventHandler(OnResizerDragStarted);
            _resizer.DragDelta     += new System.Windows.Controls.Primitives.DragDeltaEventHandler(OnResizerDragDelta);
            _resizer.DragCompleted += new System.Windows.Controls.Primitives.DragCompletedEventHandler(OnResizerDragCompleted);

            if (_side == AnchorSide.Right)
            {
                _internalGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(_manager.GridSplitterWidth)
                });
                _internalGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = _model.AutoHideWidth == 0.0 ? new GridLength(_model.AutoHideMinWidth) : new GridLength(_model.AutoHideWidth, GridUnitType.Pixel)
                });

                Grid.SetColumn(_resizer, 0);
                Grid.SetColumn(_internalHost, 1);

                _resizer.Cursor = Cursors.SizeWE;

                HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
            }
            else if (_side == AnchorSide.Left)
            {
                _internalGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = _model.AutoHideWidth == 0.0 ? new GridLength(_model.AutoHideMinWidth) : new GridLength(_model.AutoHideWidth, GridUnitType.Pixel),
                });
                _internalGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(_manager.GridSplitterWidth)
                });

                Grid.SetColumn(_internalHost, 0);
                Grid.SetColumn(_resizer, 1);

                _resizer.Cursor = Cursors.SizeWE;

                HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
            }
            else if (_side == AnchorSide.Top)
            {
                _internalGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = _model.AutoHideHeight == 0.0 ? new GridLength(_model.AutoHideMinHeight) : new GridLength(_model.AutoHideHeight, GridUnitType.Pixel),
                });
                _internalGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(_manager.GridSplitterHeight)
                });

                Grid.SetRow(_internalHost, 0);
                Grid.SetRow(_resizer, 1);

                _resizer.Cursor = Cursors.SizeNS;

                VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            }
            else if (_side == AnchorSide.Bottom)
            {
                _internalGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(_manager.GridSplitterHeight)
                });
                _internalGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = _model.AutoHideHeight == 0.0 ? new GridLength(_model.AutoHideMinHeight) : new GridLength(_model.AutoHideHeight, GridUnitType.Pixel),
                });

                Grid.SetRow(_resizer, 0);
                Grid.SetRow(_internalHost, 1);

                _resizer.Cursor = Cursors.SizeNS;

                VerticalAlignment   = System.Windows.VerticalAlignment.Bottom;
                HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            }


            _internalGrid.Children.Add(_resizer);
            _internalGrid.Children.Add(_internalHost);
            _internalHostPresenter.Content = _internalGrid;
        }
        void CreateInternalGrid()
        {
            _internalGrid = new Grid() { FlowDirection = System.Windows.FlowDirection.LeftToRight};
            _internalGrid.SetBinding(Grid.BackgroundProperty, new Binding("Background") { Source = this });


            _internalHost = new LayoutAnchorableControl() { Model = _model, Style = AnchorableStyle };
            _internalHost.SetBinding(FlowDirectionProperty, new Binding("Model.Root.Manager.FlowDirection") { Source = this });

            KeyboardNavigation.SetTabNavigation(_internalGrid, KeyboardNavigationMode.Cycle);

            _resizer = new LayoutGridResizerControl();

            _resizer.DragStarted += new System.Windows.Controls.Primitives.DragStartedEventHandler(OnResizerDragStarted);
            _resizer.DragDelta += new System.Windows.Controls.Primitives.DragDeltaEventHandler(OnResizerDragDelta);
            _resizer.DragCompleted += new System.Windows.Controls.Primitives.DragCompletedEventHandler(OnResizerDragCompleted);

            if (_side == AnchorSide.Right)
            {
                _internalGrid.ColumnDefinitions.Add(new ColumnDefinition(){ Width = new GridLength(_manager.GridSplitterWidth)});
                _internalGrid.ColumnDefinitions.Add(new ColumnDefinition(){
                    Width = _model.AutoHideWidth == 0.0 ? new GridLength(_model.AutoHideMinWidth) : new GridLength(_model.AutoHideWidth, GridUnitType.Pixel)});

                Grid.SetColumn(_resizer, 0);
                Grid.SetColumn(_internalHost, 1);

                _resizer.Cursor = Cursors.SizeWE;

                HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            }
            else if (_side == AnchorSide.Left)
            {
                _internalGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = _model.AutoHideWidth == 0.0 ? new GridLength(_model.AutoHideMinWidth) : new GridLength(_model.AutoHideWidth, GridUnitType.Pixel),
                });
                _internalGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(_manager.GridSplitterWidth) });

                Grid.SetColumn(_internalHost, 0);
                Grid.SetColumn(_resizer, 1);

                _resizer.Cursor = Cursors.SizeWE;

                HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            }
            else if (_side == AnchorSide.Top)
            {
                _internalGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = _model.AutoHideHeight == 0.0 ? new GridLength(_model.AutoHideMinHeight) : new GridLength(_model.AutoHideHeight, GridUnitType.Pixel),
                });
                _internalGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(_manager.GridSplitterHeight) });

                Grid.SetRow(_internalHost, 0);
                Grid.SetRow(_resizer, 1);

                _resizer.Cursor = Cursors.SizeNS;

                VerticalAlignment = System.Windows.VerticalAlignment.Top;
                HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;

            }
            else if (_side == AnchorSide.Bottom)
            {
                _internalGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(_manager.GridSplitterHeight) });
                _internalGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = _model.AutoHideHeight == 0.0 ? new GridLength(_model.AutoHideMinHeight) : new GridLength(_model.AutoHideHeight, GridUnitType.Pixel),
                });

                Grid.SetRow(_resizer, 0);
                Grid.SetRow(_internalHost, 1);

                _resizer.Cursor = Cursors.SizeNS;

                VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
                HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            }


            _internalGrid.Children.Add(_resizer);
            _internalGrid.Children.Add(_internalHost);
            _internalHostPresenter.Content = _internalGrid;
        }
Example #5
0
 private void CreateInternalGrid()
 {
     this._internalGrid = new Grid()
     {
         FlowDirection = System.Windows.FlowDirection.LeftToRight
     };
     this._internalGrid.SetBinding(Panel.BackgroundProperty, new Binding("Background")
     {
         Source = this
     });
     this._internalHost = new LayoutAnchorableControl()
     {
         Model = this._model,
         Style = this.AnchorableStyle
     };
     this._internalHost.SetBinding(FrameworkElement.FlowDirectionProperty, new Binding("Model.Root.Manager.FlowDirection")
     {
         Source = this
     });
     System.Windows.Input.KeyboardNavigation.SetTabNavigation(this._internalGrid, KeyboardNavigationMode.Cycle);
     this._resizer                = new LayoutGridResizerControl();
     this._resizer.DragStarted   += new DragStartedEventHandler(this.OnResizerDragStarted);
     this._resizer.DragDelta     += new DragDeltaEventHandler(this.OnResizerDragDelta);
     this._resizer.DragCompleted += new DragCompletedEventHandler(this.OnResizerDragCompleted);
     if (this._side == AnchorSide.Right)
     {
         this._internalGrid.ColumnDefinitions.Add(new ColumnDefinition()
         {
             Width = new GridLength(this._manager.GridSplitterWidth)
         });
         this._internalGrid.ColumnDefinitions.Add(new ColumnDefinition()
         {
             Width = (this._model.AutoHideWidth == 0 ? new GridLength(this._model.AutoHideMinWidth) : new GridLength(this._model.AutoHideWidth, GridUnitType.Pixel))
         });
         Grid.SetColumn(this._resizer, 0);
         Grid.SetColumn(this._internalHost, 1);
         this._resizer.Cursor     = Cursors.SizeWE;
         base.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
         base.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
     }
     else if (this._side == AnchorSide.Left)
     {
         this._internalGrid.ColumnDefinitions.Add(new ColumnDefinition()
         {
             Width = (this._model.AutoHideWidth == 0 ? new GridLength(this._model.AutoHideMinWidth) : new GridLength(this._model.AutoHideWidth, GridUnitType.Pixel))
         });
         this._internalGrid.ColumnDefinitions.Add(new ColumnDefinition()
         {
             Width = new GridLength(this._manager.GridSplitterWidth)
         });
         Grid.SetColumn(this._internalHost, 0);
         Grid.SetColumn(this._resizer, 1);
         this._resizer.Cursor     = Cursors.SizeWE;
         base.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
         base.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
     }
     else if (this._side == AnchorSide.Top)
     {
         this._internalGrid.RowDefinitions.Add(new RowDefinition()
         {
             Height = (this._model.AutoHideHeight == 0 ? new GridLength(this._model.AutoHideMinHeight) : new GridLength(this._model.AutoHideHeight, GridUnitType.Pixel))
         });
         this._internalGrid.RowDefinitions.Add(new RowDefinition()
         {
             Height = new GridLength(this._manager.GridSplitterHeight)
         });
         Grid.SetRow(this._internalHost, 0);
         Grid.SetRow(this._resizer, 1);
         this._resizer.Cursor     = Cursors.SizeNS;
         base.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
         base.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
     }
     else if (this._side == AnchorSide.Bottom)
     {
         this._internalGrid.RowDefinitions.Add(new RowDefinition()
         {
             Height = new GridLength(this._manager.GridSplitterHeight)
         });
         this._internalGrid.RowDefinitions.Add(new RowDefinition()
         {
             Height = (this._model.AutoHideHeight == 0 ? new GridLength(this._model.AutoHideMinHeight) : new GridLength(this._model.AutoHideHeight, GridUnitType.Pixel))
         });
         Grid.SetRow(this._resizer, 0);
         Grid.SetRow(this._internalHost, 1);
         this._resizer.Cursor     = Cursors.SizeNS;
         base.VerticalAlignment   = System.Windows.VerticalAlignment.Bottom;
         base.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
     }
     this._internalGrid.Children.Add(this._resizer);
     this._internalGrid.Children.Add(this._internalHost);
     this._internalHostPresenter.Content = this._internalGrid;
 }