Example #1
0
        Size GetSize(DockPosition p_dock, RelativeSizes p_relativeSizes, Size p_parentSize, Size p_draggedSize)
        {
            Size size = base.RenderSize;

            if (p_dock != DockPosition.Center)
            {
                bool   isDockHor      = (p_dock == DockPosition.Left) || (p_dock == DockPosition.Right);
                bool   isParentHor    = OwnWinItem.Orientation == Orientation.Horizontal;
                bool   findHorizontal = isParentHor == (isDockHor == isParentHor);
                double length         = 0.0;

                if (isDockHor != isParentHor)
                {
                    double relativeSizeSum = TabItemPanel.GetLength(this, isDockHor) + GetLength(p_draggedSize, isDockHor);
                    p_relativeSizes = GetRelativeSizesSum(relativeSizeSum);
                }

                length = GetRenderLength(
                    0.0,
                    GetLength(p_draggedSize, findHorizontal),
                    GetLength(p_parentSize, findHorizontal),
                    p_relativeSizes);

                if (findHorizontal)
                {
                    size.Width = length;
                    return(size);
                }
                size.Height = length;
            }
            return(size);
        }
Example #2
0
        /// <summary>
        /// 拖拽过程中计算在当前Tabs中的可停靠区域
        /// </summary>
        /// <param name="p_dockPos"></param>
        /// <param name="p_dockItem"></param>
        /// <returns></returns>
        internal Rect GetRectDimenstion(DockPosition p_dockPos, Pane p_dockItem)
        {
            Point topLeft    = new Point();
            Size  parentSize = Size.Empty;
            Size  size       = new Size(0.0, 0.0);
            bool  isHor      = false;

            if (OwnWinItem != null)
            {
                parentSize = OwnWinItem.RenderSize;
                isHor      = OwnWinItem.Orientation == Orientation.Horizontal;
                RelativeSizes sumOfSizes = OwnWinItem.GetSumOfRelativeSizes();

                if (isHor)
                {
                    sumOfSizes.LengthSum     += p_dockItem.InitWidth;
                    sumOfSizes.WithoutChange += p_dockItem.InitWidth;
                    size.Width = sumOfSizes.LengthSum;
                }
                else
                {
                    sumOfSizes.LengthSum     += p_dockItem.InitHeight;
                    sumOfSizes.WithoutChange += p_dockItem.InitHeight;
                    size.Height = sumOfSizes.LengthSum;
                }

                size    = GetSize(p_dockPos, sumOfSizes, parentSize, new Size(p_dockItem.InitWidth, p_dockItem.InitHeight));
                topLeft = GetTopLeft(p_dockPos, sumOfSizes, parentSize, size);
            }
            return(new Rect(topLeft, size));
        }
Example #3
0
        Point GetTopLeft(DockPosition dock, RelativeSizes relativeSizes, Size parentRenderSize, Size draggedElementRenderSize)
        {
            Point topLeft         = new Point();
            bool  shouldTransform = true;

            if (dock != DockPosition.Center)
            {
                int index = OwnWinItem.Items.IndexOf(this);
                if ((dock == DockPosition.Right) || (dock == DockPosition.Bottom))
                {
                    index++;
                }

                bool   isDockHor   = (dock == DockPosition.Left) || (dock == DockPosition.Right);
                bool   isParentHor = OwnWinItem.Orientation == Orientation.Horizontal;
                double length      = 0.0;

                if (isParentHor != isDockHor)
                {
                    if ((dock == DockPosition.Right) || (dock == DockPosition.Bottom))
                    {
                        length = GetLength(parentRenderSize, isDockHor) - GetLength(draggedElementRenderSize, isDockHor);
                    }
                }
                else
                {
                    for (int i = 0; i < index; i++)
                    {
                        FrameworkElement element = OwnWinItem.Items[i] as FrameworkElement;
                        if (element.Visibility == Visibility.Visible)
                        {
                            length += GetRenderLength(
                                TabItemPanel.GetSplitterChange(element),
                                TabItemPanel.GetLength(element, isParentHor),
                                GetLength(parentRenderSize, isParentHor),
                                relativeSizes);
                        }
                    }
                    shouldTransform = false;
                }
                if (isParentHor == (isDockHor == isParentHor))
                {
                    topLeft.X = length;
                }
                else
                {
                    topLeft.Y = length;
                }
            }
            if (shouldTransform)
            {
                return(base.TransformToVisual(OwnWinItem).TransformPoint(topLeft));
            }
            UIElement firstChild = OwnWinItem.Items[0] as UIElement;

            return(firstChild.TransformToVisual(OwnWinItem).TransformPoint(topLeft));
        }
Example #4
0
        static RelativeSizes GetRelativeSizesSum(double sum)
        {
            RelativeSizes rs = new RelativeSizes();

            rs.ChangesSum    = 0.0;
            rs.LengthSum     = sum;
            rs.WithChangeSet = 0.0;
            rs.WithoutChange = sum;
            return(rs);
        }
Example #5
0
 static double GetRenderLength(double splitterChange, double p_length, double p_availableLength, RelativeSizes relativeSizes)
 {
     if (splitterChange == 0.0)
     {
         return(p_length * (p_availableLength / (relativeSizes.WithoutChange + relativeSizes.WithChangeSet)));
     }
     return(((splitterChange * relativeSizes.WithChangeSet) / relativeSizes.ChangesSum) * (p_availableLength / (relativeSizes.WithoutChange + relativeSizes.WithChangeSet)));
 }