コード例 #1
0
        private void HighlightCenter(PointCollection col, IEnumerable <TabWellItem> sourceTabs, TabWellItem item)
        {
            var relativeOrigin = (UIElement)DockHost?.ContentHost ?? Window.GetWindow(TargetHost);
            var hostOffset     = TargetHost.TranslatePoint(new Point(), relativeOrigin);

            if (TargetHost is DocumentContainer)
            {
                col.Add(hostOffset);
                col.Add(new Point(hostOffset.X + TargetArea.Width, hostOffset.Y));
                col.Add(new Point(hostOffset.X + TargetArea.Width, hostOffset.Y + TargetArea.Height));
                col.Add(new Point(hostOffset.X, hostOffset.Y + TargetArea.Height));
            }
            else
            {
                var well  = TargetHost as TabWellBase;
                var first = well.FirstContainer;
                if (item == null)
                {
                    item = first;
                }

                var firstOffset = first?.TranslatePoint(new Point(), relativeOrigin) ?? hostOffset;
                var itemOffset  = item?.TranslatePoint(new Point(), relativeOrigin) ?? hostOffset;
                var itemHeight  = sourceTabs.Max(t => t.ActualHeight);
                var itemWidth   = sourceTabs.Sum(t => t.ActualWidth);

                if (TargetHost is DocumentWell)
                {
                    col.Add(new Point(hostOffset.X, firstOffset.Y + itemHeight));                                      //well top-left
                    col.Add(new Point(itemOffset.X, itemOffset.Y + itemHeight));                                       //item bottom-left
                    col.Add(new Point(itemOffset.X, itemOffset.Y));                                                    //item top-left
                    col.Add(new Point(itemOffset.X + itemWidth, itemOffset.Y));                                        //item top-right
                    col.Add(new Point(itemOffset.X + itemWidth, itemOffset.Y + itemHeight));                           //item bottom-right
                    col.Add(new Point(hostOffset.X + TargetHost.ActualWidth, itemOffset.Y + itemHeight));              //well top-right
                    col.Add(new Point(hostOffset.X + TargetHost.ActualWidth, hostOffset.Y + TargetHost.ActualHeight)); //well bottom-right
                    col.Add(new Point(hostOffset.X, hostOffset.Y + TargetHost.ActualHeight));                          //well bottom-left
                }
                else
                {
                    col.Add(new Point(hostOffset.X, hostOffset.Y));                              //well top-left
                    col.Add(new Point(hostOffset.X + TargetHost.ActualWidth, hostOffset.Y));     //well top-right
                    col.Add(new Point(hostOffset.X + TargetHost.ActualWidth, itemOffset.Y));     //well bottom-right
                    if (well.Items.Count > 1)                                                    //tab panel visible
                    {
                        col.Add(new Point(itemOffset.X + itemWidth, itemOffset.Y));              //item top-right
                        col.Add(new Point(itemOffset.X + itemWidth, itemOffset.Y + itemHeight)); //item bottom-right
                        col.Add(new Point(itemOffset.X, itemOffset.Y + itemHeight));             //item bottom-left
                        col.Add(new Point(itemOffset.X, itemOffset.Y));                          //item top-left
                    }
                    col.Add(new Point(hostOffset.X, itemOffset.Y));                              //well bottom-left
                }
            }
        }
コード例 #2
0
        internal void AlignToTarget(TargetArgs args)
        {
            if (args.DockContainer != DockHost)
            {
                DockHost = args.DockContainer;
                if (DockHost == null)
                {
                    DockArea = Rect.Empty;
                }
                else
                {
                    DockArea = new Rect(
                        DockHost.ContentHost.TranslatePoint(new Point(), this),
                        DockHost.ContentHost.RenderSize
                        );
                }
            }

            var host = args.TabWell as FrameworkElement ?? args.DocumentContainer;

            if (host != TargetHost)
            {
                TargetHost = host;
                if (TargetHost == null)
                {
                    TargetArea = Rect.Empty;
                }
                else
                {
                    TargetArea = new Rect(
                        TargetHost.TranslatePoint(new Point(), this),
                        TargetHost.RenderSize
                        );
                }
            }

            var isAllTools = args.SourceItems.All(i => i.ItemType == TabItemType.Tool);

            CanDockOuter = isAllTools;

            if (TargetHost is DocumentWell)
            {
                CanDropCenter = true;
                CanDockTarget = isAllTools;

                var panel = TargetHost.FindVisualAncestor <DocumentContainer>();
                CanSplitHorizontal = panel?.Orientation == Orientation.Horizontal || panel?.Items.Count <= 1;
                CanSplitVertical   = panel?.Orientation == Orientation.Vertical || panel?.Items.Count <= 1;
            }
            else if (TargetHost is DocumentContainer)
            {
                CanDropCenter      = true;
                CanDockTarget      = isAllTools;
                CanSplitHorizontal = CanSplitVertical = false;
            }
            else if (TargetHost is ToolWell)
            {
                CanDockTarget      = false;
                CanSplitHorizontal = CanSplitVertical = CanDropCenter = isAllTools;
            }
            else
            {
                CanDockTarget = CanSplitHorizontal = CanSplitVertical = CanDropCenter = false;
            }

            DockTargetButton.UpdateCursor();
            UpdateHighlightPath(args.SourceItems, args.TabItem);
        }