Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DockedTabHotArea" /> class.
        /// </summary>
        /// <param name="parent">The parent.</param>
        public DockedTabHotArea(DockContainer parent)
            : base(parent)
        {
            SpecialMouseCursor = Cursors.Hand;

            MouseClick += (sender, args) =>
            {
                switch (Position)
                {
                    case DockPosition.Main:
                        Parent.MainDockSelectedIndex = NewIndex;
                        break;
                    case DockPosition.Left:
                        Parent.LeftDockSelectedIndex = NewIndex;
                        break;
                    case DockPosition.Top:
                        Parent.TopDockSelectedIndex = NewIndex;
                        break;
                    case DockPosition.Right:
                        Parent.RightDockSelectedIndex = NewIndex;
                        break;
                    case DockPosition.Bottom:
                        Parent.BottomDockSelectedIndex = NewIndex;
                        break;
                }
            };

            MouseDown += (sender, args) =>
            {
                if (args.LeftButton != MouseButtonState.Pressed) return;
                var downPosition = args.GetPosition(Parent);
                Mouse.Capture(Parent);

                Parent.MouseDownAndMoveOverride = e =>
                {
                    if (e.LeftButton != MouseButtonState.Pressed) return;
                    var currentPosition = e.GetPosition(Parent);
                    if (currentPosition.X < downPosition.X - 20d || currentPosition.X > downPosition.X + 20d ||
                        currentPosition.Y < downPosition.Y - 20d || currentPosition.Y > downPosition.Y + 20d)
                    {
                        // The mouse moved far enough in the down position for us to consider this a drag operation
                        // Note: We may want to handle this differently in the future
                        if (_currentDragWindow == null)
                        {
                            var dockedElements = Parent.SecondaryDockWell.Where(d => d.Position == Position && d.IsDocked).ToList();
                            if (NewIndex >= dockedElements.Count) return;
                            var dockedElement = dockedElements[NewIndex];
                            if (dockedElement == null) return;
                            _currentDragWindow = new DockWellFloatWindow(Parent, dockedElement, Parent.DockWellRenderer, Parent.DockWellRenderer.DockWellHeaderHeight, Parent.DockWellRenderer.DockWellFooterHeight);
                            switch (Position)
                            {
                                case DockPosition.Left:
                                    _currentDragWindow.Height = Parent.ActualHeight;
                                    _currentDragWindow.Width = Parent.LeftDockWidth;
                                    var totalDocked = Parent.SecondaryDockWell.Count(d => d.Position == Position && d.IsDocked);
                                    if (totalDocked > 0 && Parent.LeftDockSelectedIndex >= totalDocked) Parent.LeftDockSelectedIndex = totalDocked - 1;
                                    break;
                                case DockPosition.Top:
                                    _currentDragWindow.Height = Parent.TopDockHeight;
                                    _currentDragWindow.Width = Parent.ActualWidth - Parent.LeftDockWidth - Parent.RightDockWidth;
                                    var totalDocked2 = Parent.SecondaryDockWell.Count(d => d.Position == Position && d.IsDocked);
                                    if (totalDocked2 > 0 && Parent.TopDockSelectedIndex >= totalDocked2) Parent.TopDockSelectedIndex = totalDocked2 - 1;
                                    break;
                                case DockPosition.Right:
                                    _currentDragWindow.Height = Parent.ActualHeight;
                                    _currentDragWindow.Width = Parent.RightDockWidth;
                                    var totalDocked3 = Parent.SecondaryDockWell.Count(d => d.Position == Position && d.IsDocked);
                                    if (totalDocked3 > 0 && Parent.RightDockSelectedIndex >= totalDocked3) Parent.RightDockSelectedIndex = totalDocked3 - 1;
                                    break;
                                case DockPosition.Bottom:
                                    _currentDragWindow.Height = Parent.BottomDockHeight;
                                    _currentDragWindow.Width = Parent.ActualWidth - Parent.LeftDockWidth - Parent.RightDockWidth;
                                    var totalDocked4 = Parent.SecondaryDockWell.Count(d => d.Position == Position && d.IsDocked);
                                    if (totalDocked4 > 0 && Parent.BottomDockSelectedIndex >= totalDocked4) Parent.BottomDockSelectedIndex = totalDocked4 - 1;
                                    break;
                            }
                            Mouse.Capture(null);
                            _currentDragWindow.DragMove();
                        }
                    }
                };
            };
        }
Esempio n. 2
0
 /// <summary>
 /// Sets a reference to the actual doc container
 /// </summary>
 /// <param name="container">Container</param>
 public void SetDockContainer(DockContainer container)
 {
     _parent = container;
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HotArea"/> class.
 /// </summary>
 public HotArea(DockContainer parent)
 {
     Parent = parent;
 }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HotArea" /> class.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="cursor">The cursor.</param>
        /// <param name="splitterIndex">Index of the splitter.</param>
        public SplitterHotArea(DockContainer parent, Cursor cursor, int splitterIndex)
            : base(parent)
        {
            SpecialMouseCursor = cursor;
            _splitterIndex = splitterIndex;

            MouseDown += (sender, args) =>
            {
                Mouse.Capture(Parent);
                args.Handled = true;
                Parent.MouseDownAndMoveOverride = e =>
                {
                    var position = e.GetPosition(Parent);
                    Mouse.SetCursor(SpecialMouseCursor);
                    switch (_splitterIndex)
                    {
                        case 0: // Left splitter
                            var x = Math.Max(position.X, 25d);
                            if (x > Parent.ActualWidth - Parent.RightDockWidth - 25d) x = Parent.ActualWidth - Parent.RightDockWidth - 25d;
                            x = Math.Max(x, 25d);
                            Parent.LeftDockWidth = x;
                            break;
                        case 1: // Top splitter
                            var y = Math.Max(position.Y, 50d);
                            if (y > Parent.ActualHeight - Parent.BottomDockHeight - 40d) y = Parent.ActualHeight - Parent.BottomDockHeight - 40d;
                            y = Math.Max(y, 50d);
                            Parent.TopDockHeight = y;
                            break;
                        case 2: // Right splitter
                            var x2 = Math.Min(position.X, Parent.ActualWidth - 25d);
                            if (x2 < Parent.LeftDockWidth + 25d) x2 = Parent.LeftDockWidth + 25d;
                            x2 = Math.Min(x2, Parent.ActualWidth - 25d);
                            Parent.RightDockWidth = Parent.ActualWidth - x2;
                            break;
                        case 3: // Bottom splitter
                            var y2 = Math.Min(position.Y, Parent.ActualHeight - 50d);
                            if (y2 < Parent.TopDockHeight + 40d) y2 = Parent.TopDockHeight + 40d;
                            y2 = Math.Min(y2, Parent.ActualHeight - 50d);
                            Parent.BottomDockHeight = Parent.ActualHeight - y2;
                            break;
                    }
                };
            };
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DockWellFloatWindow" /> class.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="dockedElement">The docked element.</param>
        /// <param name="renderer">The dock well renderer.</param>
        /// <param name="headerHeight">Height of the header.</param>
        /// <param name="footerHeight">Height of the footer.</param>
        public DockWellFloatWindow(DockContainer parent, DockedUIElement dockedElement, IDockWellRenderer renderer, double headerHeight, double footerHeight)
        {
            WindowStyle = WindowStyle.None;
            AllowsTransparency = true;
            Background = Brushes.Transparent;
            ShowInTaskbar = false;

            _parent = parent;
            _dockedElement = dockedElement;
            _renderer = renderer;
            _headerHeight = headerHeight;
            _footerHeight = footerHeight;

            DataContext = parent.DataContext;

            var oldHost = _parent.FindTemplatedItemsControl();
            if (oldHost != null)
                oldHost.Items.Remove(dockedElement.Element);
            else
                _parent.Children.Remove(dockedElement.Element);

            dockedElement.IsDocked = false;
            Content = dockedElement.Element;
            dockedElement.Element.Visibility = Visibility.Visible;
            Title = dockedElement.Title;

            WindowEx.SetAutoWindowDragEnabled(this, true);
            WindowEx.SetAutoWindowResizingEnabled(this, true);

            Show();
            _parent.InvalidateArrange();
            _parent.InvalidateMeasure();
            _parent.InvalidateVisual();
        }