Beispiel #1
0
 internal static string ToString(SplitterDistance distance, CultureInfo cultureInfo)
 {
     if (distance.IsAutoPixel)
     {
         return("Auto");
     }
     else if (distance.IsAutoStar)
     {
         return("Auto*");
     }
     else if (distance.UnitType == SplitterUnitType.Star)
     {
         if (distance.Value.IsClose(1.0))
         {
             return("*");
         }
         else
         {
             return(Convert.ToString(distance.Value, cultureInfo) + "*");
         }
     }
     else
     {
         return(Convert.ToString(distance.Value, cultureInfo));
     }
 }
Beispiel #2
0
 public void BeginDrag(SplitContainer splitContainer, MouseEventArgs e)
 {
     _splitContainer           = splitContainer;
     _originalSplitterDistance = _splitContainer.SplitterDistance;
     Debug.Assert(splitContainer.SplitterPresenter != null);
     DragDetect((UIElement)VisualTreeHelper.GetChild(splitContainer.SplitterPresenter, 0), e);
 }
Beispiel #3
0
 /// <exclude/>
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == null)
     {
         throw new ArgumentNullException("destinationType");
     }
     if ((value != null) && (value is SplitterDistance))
     {
         SplitterDistance distance = (SplitterDistance)value;
         if (destinationType == typeof(string))
         {
             return(ToString(distance, culture));
         }
         if (destinationType == typeof(InstanceDescriptor))
         {
             return(new InstanceDescriptor(typeof(SplitterDistance).GetConstructor(new Type[] { typeof(double), typeof(SplitterUnitType) }), new object[] { distance.Value, distance.UnitType }));
         }
     }
     throw base.GetConvertToException(value, destinationType);
 }
Beispiel #4
0
 private void MoveSplitter(SplitterDistance value)
 {
     SplitterDistance = value;
     UpdateLayout();
 }
Beispiel #5
0
        private Size CalculateLengthes(Size availableSize, out double child1Length, out double splitterLength, out double child2Length)
        {
            Orientation      orientation      = Orientation;
            double           originalLength   = orientation == Orientation.Vertical ? availableSize.Height : availableSize.Width;
            SplitterDistance splitterDistance = SplitterDistance;

            splitterLength = IsChild1Collapsed && IsChild2Collapsed ? 0 : SplitterWidth;

            double length1, length2;
            double minLength1   = IsSplitterTopLeft ? Child1MinSize : Child2MinSize;
            double minLength2   = IsSplitterTopLeft ? Child2MinSize : Child1MinSize;
            Size   desiredSize1 = IsSplitterTopLeft ? Child1DesiredSize : Child2DesiredSize;
            Size   desiredSize2 = IsSplitterTopLeft ? Child2DesiredSize : Child1DesiredSize;

            if (originalLength == double.PositiveInfinity)
            {
                if (splitterDistance.IsAbsolute)
                {
                    length1 = splitterDistance.Value;
                }
                else
                {
                    length1 = orientation == Orientation.Vertical ? desiredSize1.Height : desiredSize1.Width;
                }
                if (length1 < minLength1)
                {
                    length1 = minLength1;
                }

                length2 = orientation == Orientation.Vertical ? desiredSize2.Height : desiredSize2.Width;
            }
            else
            {
                double availableLength = originalLength - splitterLength;
                if (splitterDistance.IsAuto)
                {
                    length1 = orientation == Orientation.Vertical ? desiredSize1.Height : desiredSize1.Width;
                }
                else if (splitterDistance.IsStar)
                {
                    length1 = availableLength * splitterDistance.Value / (splitterDistance.Value + 1);
                }
                else
                {
                    length1 = splitterDistance.Value;
                }
                if (length1 > availableLength - minLength2)
                {
                    length1 = availableLength - minLength2;
                }
                if (length1 < minLength1)
                {
                    length1 = minLength1;
                }
                length2 = availableLength - length1;
            }

            if (length2 < minLength2)
            {
                length2 = minLength2;
            }

            child1Length = IsSplitterTopLeft ? length1 : length2;
            child2Length = IsSplitterTopLeft ? length2 : length1;

            double height, width;

            if (orientation == Orientation.Vertical)
            {
                height = length1 + length2 + splitterLength;
                if (double.IsPositiveInfinity(availableSize.Width))
                {
                    width = Math.Max(Child1DesiredSize.Width, Child2DesiredSize.Width);
                }
                else
                {
                    width = availableSize.Width;
                }
            }
            else
            {
                width = length1 + length2 + splitterLength;
                if (double.IsPositiveInfinity(availableSize.Height))
                {
                    height = Math.Max(Child1DesiredSize.Height, Child2DesiredSize.Height);
                }
                else
                {
                    height = availableSize.Height;
                }
            }
            return(new Size(width, height));
        }