private void UpdateVisualBrush()
        {
            if (_referenceHeader != null && _visualBrushCanvas != null)
            {
                VisualBrush visualBrush = new VisualBrush(_referenceHeader);

                visualBrush.ViewboxUnits = BrushMappingMode.Absolute;

                double width = Width;
                if (DoubleUtil.IsNaN(width))
                {
                    width = _referenceHeader.ActualWidth;
                }
                else
                {
                    width = width - GetVisualCanvasMarginX();
                }

                double height = Height;
                if (DoubleUtil.IsNaN(height))
                {
                    height = _referenceHeader.ActualHeight;
                }
                else
                {
                    height = height - GetVisualCanvasMarginY();
                }

                Vector offset = VisualTreeHelper.GetOffset(_referenceHeader);
                visualBrush.Viewbox = new Rect(offset.X, offset.Y, width, height);

                _visualBrushCanvas.Background = visualBrush;
            }
        }
Exemplo n.º 2
0
        // Token: 0x060048D3 RID: 18643 RVA: 0x0014A864 File Offset: 0x00148A64
        public static void OnColumnWidthChanged(IProvideDataGridColumn cell, DependencyPropertyChangedEventArgs e)
        {
            UIElement      uielement = (UIElement)cell;
            DataGridColumn column    = cell.Column;
            bool           flag      = cell is DataGridColumnHeader;

            if (column != null)
            {
                DataGridLength width = column.Width;
                if (width.IsAuto || (!flag && width.IsSizeToCells) || (flag && width.IsSizeToHeader))
                {
                    DataGridLength dataGridLength = (DataGridLength)e.OldValue;
                    double         num;
                    if (dataGridLength.UnitType != width.UnitType)
                    {
                        double constraintWidth = column.GetConstraintWidth(flag);
                        if (!DoubleUtil.AreClose(uielement.DesiredSize.Width, constraintWidth))
                        {
                            uielement.InvalidateMeasure();
                            uielement.Measure(new Size(constraintWidth, double.PositiveInfinity));
                        }
                        num = uielement.DesiredSize.Width;
                    }
                    else
                    {
                        num = dataGridLength.DesiredValue;
                    }
                    if (DoubleUtil.IsNaN(width.DesiredValue) || DoubleUtil.LessThan(width.DesiredValue, num))
                    {
                        column.SetWidthInternal(new DataGridLength(width.Value, width.UnitType, num, width.DisplayValue));
                    }
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Overloaded operator, compares 2 DataGridLength's.
 /// </summary>
 /// <param name="gl1">first DataGridLength to compare.</param>
 /// <param name="gl2">second DataGridLength to compare.</param>
 /// <returns>true if specified DataGridLengths have same value
 /// and unit type.</returns>
 public static bool operator ==(DataGridLength gl1, DataGridLength gl2)
 {
     return(gl1.UnitType == gl2.UnitType &&
            gl1.Value == gl2.Value &&
            ((gl1.DesiredValue == gl2.DesiredValue) || (DoubleUtil.IsNaN(gl1.DesiredValue) && DoubleUtil.IsNaN(gl2.DesiredValue))) &&
            ((gl1.DisplayValue == gl2.DisplayValue) || (DoubleUtil.IsNaN(gl1.DisplayValue) && DoubleUtil.IsNaN(gl2.DisplayValue))));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Overloaded operator, compares 2 DataGridLength's.
 /// </summary>
 /// <param name="gl1">first DataGridLength to compare.</param>
 /// <param name="gl2">second DataGridLength to compare.</param>
 /// <returns>true if specified DataGridLengths have either different value or
 /// unit type.</returns>
 public static bool operator !=(DataGridLength gl1, DataGridLength gl2)
 {
     return(gl1.UnitType != gl2.UnitType ||
            gl1.Value != gl2.Value ||
            ((gl1.DesiredValue != gl2.DesiredValue) && !(DoubleUtil.IsNaN(gl1.DesiredValue) && DoubleUtil.IsNaN(gl2.DesiredValue))) ||
            ((gl1.DisplayValue != gl2.DisplayValue) && !(DoubleUtil.IsNaN(gl1.DisplayValue) && DoubleUtil.IsNaN(gl2.DisplayValue))));
 }
        /// <summary>
        /// <see cref="FrameworkElement.MeasureOverride"/>
        /// </summary>
        protected override Size MeasureOverride(Size constraint)
        {
            UVSize curLineSize   = new UVSize(Orientation);
            UVSize panelSize     = new UVSize(Orientation);
            UVSize uvConstraint  = new UVSize(Orientation, constraint.Width, constraint.Height);
            double itemWidth     = ItemWidth;
            double itemHeight    = ItemHeight;
            bool   itemWidthSet  = !DoubleUtil.IsNaN(itemWidth);
            bool   itemHeightSet = !DoubleUtil.IsNaN(itemHeight);

            Size childConstraint = new Size(
                (itemWidthSet ?  itemWidth  : constraint.Width),
                (itemHeightSet ? itemHeight : constraint.Height));

            UIElementCollection children = InternalChildren;

            for (int i = 0, count = children.Count; i < count; i++)
            {
                UIElement child = children[i] as UIElement;
                if (child == null)
                {
                    continue;
                }

                //Flow passes its own constrint to children
                child.Measure(childConstraint);

                //this is the size of the child in UV space
                UVSize sz = new UVSize(
                    Orientation,
                    (itemWidthSet ?  itemWidth  : child.DesiredSize.Width),
                    (itemHeightSet ? itemHeight : child.DesiredSize.Height));

                if (DoubleUtil.GreaterThan(curLineSize.U + sz.U, uvConstraint.U)) //need to switch to another line
                {
                    panelSize.U  = Math.Max(curLineSize.U, panelSize.U);
                    panelSize.V += curLineSize.V;
                    curLineSize  = sz;

                    if (DoubleUtil.GreaterThan(sz.U, uvConstraint.U)) //the element is wider then the constrint - give it a separate line
                    {
                        panelSize.U  = Math.Max(sz.U, panelSize.U);
                        panelSize.V += sz.V;
                        curLineSize  = new UVSize(Orientation);
                    }
                }
                else //continue to accumulate a line
                {
                    curLineSize.U += sz.U;
                    curLineSize.V  = Math.Max(sz.V, curLineSize.V);
                }
            }

            //the last line size, if any should be added
            panelSize.U  = Math.Max(curLineSize.U, panelSize.U);
            panelSize.V += curLineSize.V;

            //go from UV space to W/H space
            return(new Size(panelSize.Width, panelSize.Height));
        }
        /// <summary>
        /// <see cref="FrameworkElement.ArrangeOverride"/>
        /// </summary>
        protected override Size ArrangeOverride(Size finalSize)
        {
            int    firstInLine   = 0;
            double itemWidth     = ItemWidth;
            double itemHeight    = ItemHeight;
            double accumulatedV  = 0;
            double itemU         = (Orientation == Orientation.Horizontal ? itemWidth : itemHeight);
            UVSize curLineSize   = new UVSize(Orientation);
            UVSize uvFinalSize   = new UVSize(Orientation, finalSize.Width, finalSize.Height);
            bool   itemWidthSet  = !DoubleUtil.IsNaN(itemWidth);
            bool   itemHeightSet = !DoubleUtil.IsNaN(itemHeight);
            bool   useItemU      = (Orientation == Orientation.Horizontal ? itemWidthSet : itemHeightSet);

            UIElementCollection children = InternalChildren;

            for (int i = 0, count = children.Count; i < count; i++)
            {
                UIElement child = children[i] as UIElement;
                if (child == null)
                {
                    continue;
                }

                UVSize sz = new UVSize(
                    Orientation,
                    (itemWidthSet ?  itemWidth  : child.DesiredSize.Width),
                    (itemHeightSet ? itemHeight : child.DesiredSize.Height));

                if (DoubleUtil.GreaterThan(curLineSize.U + sz.U, uvFinalSize.U)) //need to switch to another line
                {
                    arrangeLine(accumulatedV, curLineSize.V, firstInLine, i, useItemU, itemU);

                    accumulatedV += curLineSize.V;
                    curLineSize   = sz;

                    if (DoubleUtil.GreaterThan(sz.U, uvFinalSize.U)) //the element is wider then the constraint - give it a separate line
                    {
                        //switch to next line which only contain one element
                        arrangeLine(accumulatedV, sz.V, i, ++i, useItemU, itemU);

                        accumulatedV += sz.V;
                        curLineSize   = new UVSize(Orientation);
                    }
                    firstInLine = i;
                }
                else //continue to accumulate a line
                {
                    curLineSize.U += sz.U;
                    curLineSize.V  = Math.Max(sz.V, curLineSize.V);
                }
            }

            //arrange the last line, if any
            if (firstInLine < children.Count)
            {
                arrangeLine(accumulatedV, curLineSize.V, firstInLine, children.Count, useItemU, itemU);
            }

            return(finalSize);
        }
Exemplo n.º 7
0
 /// <summary>Converts the specified object to an instance of the <see cref="T:System.Windows.Controls.DataGridLength" /> class.</summary>
 /// <param name="context">An object that provides a format context.</param>
 /// <param name="culture">The object to use as the current culture.</param>
 /// <param name="value">The value to convert.</param>
 /// <returns>The converted value.</returns>
 /// <exception cref="T:System.ArgumentNullException">
 ///         <paramref name="value" /> is <see langword="null" />.</exception>
 /// <exception cref="T:System.ArgumentException">
 ///         <paramref name="value" /> is not a valid type that can be converted to type <see cref="T:System.Windows.Controls.DataGridLength" />.</exception>
 // Token: 0x0600491E RID: 18718 RVA: 0x0014B6F4 File Offset: 0x001498F4
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (value != null)
     {
         string text = value as string;
         if (text != null)
         {
             return(DataGridLengthConverter.ConvertFromString(text, culture));
         }
         double num = Convert.ToDouble(value, culture);
         DataGridLengthUnitType type;
         if (DoubleUtil.IsNaN(num))
         {
             num  = 1.0;
             type = DataGridLengthUnitType.Auto;
         }
         else
         {
             type = DataGridLengthUnitType.Pixel;
         }
         if (!double.IsInfinity(num))
         {
             return(new DataGridLength(num, type));
         }
     }
     throw base.GetConvertFromException(value);
 }
 // Token: 0x0600487D RID: 18557 RVA: 0x00149A20 File Offset: 0x00147C20
 private void UpdateVisualBrush()
 {
     if (this._referenceHeader != null && this._visualBrushCanvas != null)
     {
         VisualBrush visualBrush = new VisualBrush(this._referenceHeader);
         visualBrush.ViewboxUnits = BrushMappingMode.Absolute;
         double num = base.Width;
         if (DoubleUtil.IsNaN(num))
         {
             num = this._referenceHeader.ActualWidth;
         }
         else
         {
             num -= this.GetVisualCanvasMarginX();
         }
         double num2 = base.Height;
         if (DoubleUtil.IsNaN(num2))
         {
             num2 = this._referenceHeader.ActualHeight;
         }
         else
         {
             num2 -= this.GetVisualCanvasMarginY();
         }
         Vector offset = VisualTreeHelper.GetOffset(this._referenceHeader);
         visualBrush.Viewbox = new Rect(offset.X, offset.Y, num, num2);
         this._visualBrushCanvas.Background = visualBrush;
     }
 }
Exemplo n.º 9
0
 static internal double ValidateInputOffset(double offset, string parameterName)
 {
     if (DoubleUtil.IsNaN(offset))
     {
         throw new ArgumentOutOfRangeException(parameterName, SR.Get(SRID.ScrollViewer_CannotBeNaN, parameterName));
     }
     return(Math.Max(0.0, offset));
 }
Exemplo n.º 10
0
Arquivo: Canvas.cs Projeto: ash2005/z
        /// <summary>
        /// Canvas computes a position for each of its children taking into account their margin and
        /// attached Canvas properties: Top, Left.
        ///
        /// Canvas will also arrange each of its children.
        /// </summary>
        /// <param name="arrangeSize">Size that Canvas will assume to position children.</param>
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            //Canvas arranges children at their DesiredSize.
            //This means that Margin on children is actually respected and added
            //to the size of layout partition for a child.
            //Therefore, is Margin is 10 and Left is 20, the child's ink will start at 30.

            foreach (UIElement child in InternalChildren)
            {
                if (child == null)
                {
                    continue;
                }

                double x = 0;
                double y = 0;


                //Compute offset of the child:
                //If Left is specified, then Right is ignored
                //If Left is not specified, then Right is used
                //If both are not there, then 0
                double left = GetLeft(child);
                if (!DoubleUtil.IsNaN(left))
                {
                    x = left;
                }
                else
                {
                    double right = GetRight(child);

                    if (!DoubleUtil.IsNaN(right))
                    {
                        x = arrangeSize.Width - child.DesiredSize.Width - right;
                    }
                }

                double top = GetTop(child);
                if (!DoubleUtil.IsNaN(top))
                {
                    y = top;
                }
                else
                {
                    double bottom = GetBottom(child);

                    if (!DoubleUtil.IsNaN(bottom))
                    {
                        y = arrangeSize.Height - child.DesiredSize.Height - bottom;
                    }
                }

                child.Arrange(new Rect(new Point(x, y), child.DesiredSize));
            }
            return(arrangeSize);
        }
Exemplo n.º 11
0
        // Token: 0x0600486E RID: 18542 RVA: 0x0014974C File Offset: 0x0014794C
        private static object OnCoerceWidth(DependencyObject d, object baseValue)
        {
            double value = (double)baseValue;

            if (DoubleUtil.IsNaN(value))
            {
                return(2.0);
            }
            return(baseValue);
        }
Exemplo n.º 12
0
 /// <summary>
 /// rectHasNaN - this returns true if this rect has X, Y , Height or Width as NaN.
 /// </summary>
 /// <param name="r">The rectangle to test
 /// <returns>returns whether the Rect has NaN</returns>
 public static bool RectHasNaN(Rect r)
 {
     if (DoubleUtil.IsNaN(r.X) ||
         DoubleUtil.IsNaN(r.Y) ||
         DoubleUtil.IsNaN(r.Height) ||
         DoubleUtil.IsNaN(r.Width))
     {
         return(true);
     }
     return(false);
 }
        // Token: 0x06004879 RID: 18553 RVA: 0x001499A4 File Offset: 0x00147BA4
        private static object OnCoerceHeight(DependencyObject d, object baseValue)
        {
            double value = (double)baseValue;
            DataGridColumnFloatingHeader dataGridColumnFloatingHeader = (DataGridColumnFloatingHeader)d;

            if (dataGridColumnFloatingHeader._referenceHeader != null && DoubleUtil.IsNaN(value))
            {
                return(dataGridColumnFloatingHeader._referenceHeader.ActualHeight + dataGridColumnFloatingHeader.GetVisualCanvasMarginY());
            }
            return(baseValue);
        }
Exemplo n.º 14
0
        // Token: 0x0600486F RID: 18543 RVA: 0x00149778 File Offset: 0x00147978
        private static object OnCoerceHeight(DependencyObject d, object baseValue)
        {
            double value = (double)baseValue;
            DataGridColumnDropSeparator dataGridColumnDropSeparator = (DataGridColumnDropSeparator)d;

            if (dataGridColumnDropSeparator._referenceHeader != null && DoubleUtil.IsNaN(value))
            {
                return(dataGridColumnDropSeparator._referenceHeader.ActualHeight);
            }
            return(baseValue);
        }
Exemplo n.º 15
0
        private static object OnCoerceWidth(DependencyObject d, object baseValue)
        {
            double width = (double)baseValue;
            DataGridColumnFloatingHeader header = (DataGridColumnFloatingHeader)d;

            if (header._referenceHeader != null && DoubleUtil.IsNaN(width))
            {
                return(header._referenceHeader.ActualWidth + header.GetVisualCanvasMarginX());
            }

            return(baseValue);
        }
Exemplo n.º 16
0
        /// <summary>Arranges the content of a <see cref="T:System.Windows.Controls.WrapPanel" /> element.</summary>
        /// <param name="finalSize">The <see cref="T:System.Windows.Size" /> that this element should use to arrange its child elements.</param>
        /// <returns>The <see cref="T:System.Windows.Size" /> that represents the arranged size of this <see cref="T:System.Windows.Controls.WrapPanel" /> element and its children.</returns>
        // Token: 0x06005B53 RID: 23379 RVA: 0x0019BE90 File Offset: 0x0019A090
        protected override Size ArrangeOverride(Size finalSize)
        {
            int    num        = 0;
            double itemWidth  = this.ItemWidth;
            double itemHeight = this.ItemHeight;
            double num2       = 0.0;
            double itemU      = (this.Orientation == Orientation.Horizontal) ? itemWidth : itemHeight;

            WrapPanel.UVSize    uvsize           = new WrapPanel.UVSize(this.Orientation);
            WrapPanel.UVSize    uvsize2          = new WrapPanel.UVSize(this.Orientation, finalSize.Width, finalSize.Height);
            bool                flag             = !DoubleUtil.IsNaN(itemWidth);
            bool                flag2            = !DoubleUtil.IsNaN(itemHeight);
            bool                useItemU         = (this.Orientation == Orientation.Horizontal) ? flag : flag2;
            UIElementCollection internalChildren = base.InternalChildren;
            int i     = 0;
            int count = internalChildren.Count;

            while (i < count)
            {
                UIElement uielement = internalChildren[i];
                if (uielement != null)
                {
                    WrapPanel.UVSize uvsize3 = new WrapPanel.UVSize(this.Orientation, flag ? itemWidth : uielement.DesiredSize.Width, flag2 ? itemHeight : uielement.DesiredSize.Height);
                    if (DoubleUtil.GreaterThan(uvsize.U + uvsize3.U, uvsize2.U))
                    {
                        this.arrangeLine(num2, uvsize.V, num, i, useItemU, itemU);
                        num2  += uvsize.V;
                        uvsize = uvsize3;
                        if (DoubleUtil.GreaterThan(uvsize3.U, uvsize2.U))
                        {
                            this.arrangeLine(num2, uvsize3.V, i, ++i, useItemU, itemU);
                            num2  += uvsize3.V;
                            uvsize = new WrapPanel.UVSize(this.Orientation);
                        }
                        num = i;
                    }
                    else
                    {
                        uvsize.U += uvsize3.U;
                        uvsize.V  = Math.Max(uvsize3.V, uvsize.V);
                    }
                }
                i++;
            }
            if (num < internalChildren.Count)
            {
                this.arrangeLine(num2, uvsize.V, num, internalChildren.Count, useItemU, itemU);
            }
            return(finalSize);
        }
Exemplo n.º 17
0
        public VirtualizationCacheLength(double cacheBeforeViewport, double cacheAfterViewport)
        {
            if (DoubleUtil.IsNaN(cacheBeforeViewport))
            {
                throw new ArgumentException(SR.Get(SRID.InvalidCtorParameterNoNaN, "cacheBeforeViewport"));
            }

            if (DoubleUtil.IsNaN(cacheAfterViewport))
            {
                throw new ArgumentException(SR.Get(SRID.InvalidCtorParameterNoNaN, "cacheAfterViewport"));
            }

            _cacheBeforeViewport = cacheBeforeViewport;
            _cacheAfterViewport  = cacheAfterViewport;
        }
        // Token: 0x06004876 RID: 18550 RVA: 0x00149878 File Offset: 0x00147A78
        private static void OnWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DataGridColumnFloatingHeader dataGridColumnFloatingHeader = (DataGridColumnFloatingHeader)d;
            double num = (double)e.NewValue;

            if (dataGridColumnFloatingHeader._visualBrushCanvas != null && !DoubleUtil.IsNaN(num))
            {
                VisualBrush visualBrush = dataGridColumnFloatingHeader._visualBrushCanvas.Background as VisualBrush;
                if (visualBrush != null)
                {
                    Rect viewbox = visualBrush.Viewbox;
                    visualBrush.Viewbox = new Rect(viewbox.X, viewbox.Y, num - dataGridColumnFloatingHeader.GetVisualCanvasMarginX(), viewbox.Height);
                }
            }
        }
Exemplo n.º 19
0
        private static void OnHeightChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DataGridColumnFloatingHeader header = (DataGridColumnFloatingHeader)d;
            double height = (double)e.NewValue;

            if (header._visualBrushCanvas != null && !DoubleUtil.IsNaN(height))
            {
                VisualBrush brush = header._visualBrushCanvas.Background as VisualBrush;
                if (brush != null)
                {
                    Rect viewBox = brush.Viewbox;
                    brush.Viewbox = new Rect(viewBox.X, viewBox.Y, viewBox.Width, height - header.GetVisualCanvasMarginY());
                }
            }
        }
Exemplo n.º 20
0
        /// <summary>Measures the child elements of a <see cref="T:System.Windows.Controls.WrapPanel" /> in anticipation of arranging them during the <see cref="M:System.Windows.Controls.WrapPanel.ArrangeOverride(System.Windows.Size)" /> pass.</summary>
        /// <param name="constraint">An upper limit <see cref="T:System.Windows.Size" /> that should not be exceeded.</param>
        /// <returns>The <see cref="T:System.Windows.Size" /> that represents the desired size of the element.</returns>
        // Token: 0x06005B52 RID: 23378 RVA: 0x0019BC88 File Offset: 0x00199E88
        protected override Size MeasureOverride(Size constraint)
        {
            WrapPanel.UVSize    uvsize           = new WrapPanel.UVSize(this.Orientation);
            WrapPanel.UVSize    uvsize2          = new WrapPanel.UVSize(this.Orientation);
            WrapPanel.UVSize    uvsize3          = new WrapPanel.UVSize(this.Orientation, constraint.Width, constraint.Height);
            double              itemWidth        = this.ItemWidth;
            double              itemHeight       = this.ItemHeight;
            bool                flag             = !DoubleUtil.IsNaN(itemWidth);
            bool                flag2            = !DoubleUtil.IsNaN(itemHeight);
            Size                availableSize    = new Size(flag ? itemWidth : constraint.Width, flag2 ? itemHeight : constraint.Height);
            UIElementCollection internalChildren = base.InternalChildren;
            int i     = 0;
            int count = internalChildren.Count;

            while (i < count)
            {
                UIElement uielement = internalChildren[i];
                if (uielement != null)
                {
                    uielement.Measure(availableSize);
                    WrapPanel.UVSize uvsize4 = new WrapPanel.UVSize(this.Orientation, flag ? itemWidth : uielement.DesiredSize.Width, flag2 ? itemHeight : uielement.DesiredSize.Height);
                    if (DoubleUtil.GreaterThan(uvsize.U + uvsize4.U, uvsize3.U))
                    {
                        uvsize2.U  = Math.Max(uvsize.U, uvsize2.U);
                        uvsize2.V += uvsize.V;
                        uvsize     = uvsize4;
                        if (DoubleUtil.GreaterThan(uvsize4.U, uvsize3.U))
                        {
                            uvsize2.U  = Math.Max(uvsize4.U, uvsize2.U);
                            uvsize2.V += uvsize4.V;
                            uvsize     = new WrapPanel.UVSize(this.Orientation);
                        }
                    }
                    else
                    {
                        uvsize.U += uvsize4.U;
                        uvsize.V  = Math.Max(uvsize4.V, uvsize.V);
                    }
                }
                i++;
            }
            uvsize2.U  = Math.Max(uvsize.U, uvsize2.U);
            uvsize2.V += uvsize.V;
            return(new Size(uvsize2.Width, uvsize2.Height));
        }
 /// <summary>Creates a new instance of the <see cref="T:System.Windows.Controls.VirtualizationCacheLength" /> class with the specified cache lengths for each side of the viewport.</summary>
 /// <param name="cacheBeforeViewport">The size of the cache before the viewport.</param>
 /// <param name="cacheAfterViewport">The size of the cache after the viewport.</param>
 // Token: 0x06005401 RID: 21505 RVA: 0x001749D4 File Offset: 0x00172BD4
 public VirtualizationCacheLength(double cacheBeforeViewport, double cacheAfterViewport)
 {
     if (DoubleUtil.IsNaN(cacheBeforeViewport))
     {
         throw new ArgumentException(SR.Get("InvalidCtorParameterNoNaN", new object[]
         {
             "cacheBeforeViewport"
         }));
     }
     if (DoubleUtil.IsNaN(cacheAfterViewport))
     {
         throw new ArgumentException(SR.Get("InvalidCtorParameterNoNaN", new object[]
         {
             "cacheAfterViewport"
         }));
     }
     this._cacheBeforeViewport = cacheBeforeViewport;
     this._cacheAfterViewport  = cacheAfterViewport;
 }
Exemplo n.º 22
0
        /// <summary>
        ///     Invalidates a cell's panel if its column's width changes sufficiently.
        /// </summary>
        /// <param name="cell">The cell or header.</param>
        /// <param name="e"></param>
        public static void OnColumnWidthChanged(IProvideDataGridColumn cell, DependencyPropertyChangedEventArgs e)
        {
            Debug.Assert((cell is DataGridCell) || (cell is DataGridColumnHeader), "provideColumn should be one of the cell or header containers.");

            UIElement      element        = (UIElement)cell;
            DataGridColumn column         = cell.Column;
            bool           isColumnHeader = (cell is DataGridColumnHeader);

            if (column != null)
            {
                // determine the desired value of width for auto kind columns
                DataGridLength width = column.Width;
                if (width.IsAuto ||
                    (!isColumnHeader && width.IsSizeToCells) ||
                    (isColumnHeader && width.IsSizeToHeader))
                {
                    DataGridLength oldWidth     = (DataGridLength)e.OldValue;
                    double         desiredWidth = 0.0;
                    if (oldWidth.UnitType != width.UnitType)
                    {
                        double constraintWidth = column.GetConstraintWidth(isColumnHeader);
                        if (!DoubleUtil.AreClose(element.DesiredSize.Width, constraintWidth))
                        {
                            element.InvalidateMeasure();
                            element.Measure(new Size(constraintWidth, double.PositiveInfinity));
                        }

                        desiredWidth = element.DesiredSize.Width;
                    }
                    else
                    {
                        desiredWidth = oldWidth.DesiredValue;
                    }

                    if (DoubleUtil.IsNaN(width.DesiredValue) ||
                        DoubleUtil.LessThan(width.DesiredValue, desiredWidth))
                    {
                        column.SetWidthInternal(new DataGridLength(width.Value, width.UnitType, desiredWidth, width.DisplayValue));
                    }
                }
            }
        }
Exemplo n.º 23
0
 /// <summary>Arranges the content of a <see cref="T:System.Windows.Controls.Canvas" /> element.</summary>
 /// <param name="arrangeSize">The size that this <see cref="T:System.Windows.Controls.Canvas" /> element should use to arrange its child elements.</param>
 /// <returns>A <see cref="T:System.Windows.Size" /> that represents the arranged size of this <see cref="T:System.Windows.Controls.Canvas" /> element and its descendants.</returns>
 // Token: 0x06004335 RID: 17205 RVA: 0x00133674 File Offset: 0x00131874
 protected override Size ArrangeOverride(Size arrangeSize)
 {
     foreach (object obj in base.InternalChildren)
     {
         UIElement uielement = (UIElement)obj;
         if (uielement != null)
         {
             double x    = 0.0;
             double y    = 0.0;
             double left = Canvas.GetLeft(uielement);
             if (!DoubleUtil.IsNaN(left))
             {
                 x = left;
             }
             else
             {
                 double right = Canvas.GetRight(uielement);
                 if (!DoubleUtil.IsNaN(right))
                 {
                     x = arrangeSize.Width - uielement.DesiredSize.Width - right;
                 }
             }
             double top = Canvas.GetTop(uielement);
             if (!DoubleUtil.IsNaN(top))
             {
                 y = top;
             }
             else
             {
                 double bottom = Canvas.GetBottom(uielement);
                 if (!DoubleUtil.IsNaN(bottom))
                 {
                     y = arrangeSize.Height - uielement.DesiredSize.Height - bottom;
                 }
             }
             uielement.Arrange(new Rect(new Point(x, y), uielement.DesiredSize));
         }
     }
     return(arrangeSize);
 }
Exemplo n.º 24
0
        /// <summary>
        ///     Initializes to a specified value and unit.
        /// </summary>
        /// <param name="value">The value to hold.</param>
        /// <param name="type">The unit of <c>value</c>.</param>
        /// <param name="desiredValue"></param>
        /// <param name="displayValue"></param>
        /// <remarks>
        ///     <c>value</c> is ignored unless <c>type</c> is
        ///     <c>DataGridLengthUnitType.Pixel</c> or
        ///     <c>DataGridLengthUnitType.Star</c>
        /// </remarks>
        /// <exception cref="ArgumentException">
        ///     If <c>value</c> parameter is <c>double.NaN</c>
        ///     or <c>value</c> parameter is <c>double.NegativeInfinity</c>
        ///     or <c>value</c> parameter is <c>double.PositiveInfinity</c>.
        /// </exception>
        public DataGridLength(double value, DataGridLengthUnitType type, double desiredValue, double displayValue)
        {
            if (DoubleUtil.IsNaN(value) || Double.IsInfinity(value))
            {
                throw new ArgumentException(
                          SR.Get(SRID.DataGridLength_Infinity),
                          "value");
            }

            if (type != DataGridLengthUnitType.Auto &&
                type != DataGridLengthUnitType.Pixel &&
                type != DataGridLengthUnitType.Star &&
                type != DataGridLengthUnitType.SizeToCells &&
                type != DataGridLengthUnitType.SizeToHeader)
            {
                throw new ArgumentException(
                          SR.Get(SRID.DataGridLength_InvalidType),
                          "type");
            }

            if (Double.IsInfinity(desiredValue))
            {
                throw new ArgumentException(
                          SR.Get(SRID.DataGridLength_Infinity),
                          "desiredValue");
            }

            if (Double.IsInfinity(displayValue))
            {
                throw new ArgumentException(
                          SR.Get(SRID.DataGridLength_Infinity),
                          "displayValue");
            }

            _unitValue = (type == DataGridLengthUnitType.Auto) ? AutoValue : value;
            _unitType  = type;

            _desiredValue = desiredValue;
            _displayValue = displayValue;
        }
Exemplo n.º 25
0
        /// <summary>
        ///     Attempts to convert to a DataGridLength from the given object.
        /// </summary>
        /// <param name="context">The ITypeDescriptorContext for this call.</param>
        /// <param name="culture">The CultureInfo which is respected when converting.</param>
        /// <param name="value">The object to convert to a DataGridLength.</param>
        /// <returns>The DataGridLength instance which was constructed.</returns>
        /// <exception cref="ArgumentNullException">
        ///     An ArgumentNullException is thrown if the source is null.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     An ArgumentException is thrown if the source is not null
        ///     and is not a valid type which can be converted to a DataGridLength.
        /// </exception>
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value != null)
            {
                string stringSource = value as string;
                if (stringSource != null)
                {
                    // Convert from string
                    return(ConvertFromString(stringSource, culture));
                }
                else
                {
                    // Conversion from numeric type
                    DataGridLengthUnitType type;
                    double doubleValue = Convert.ToDouble(value, culture);

                    if (DoubleUtil.IsNaN(doubleValue))
                    {
                        // This allows for conversion from Width / Height = "Auto"
                        doubleValue = 1.0;
                        type        = DataGridLengthUnitType.Auto;
                    }
                    else
                    {
                        type = DataGridLengthUnitType.Pixel;
                    }

                    if (!Double.IsInfinity(doubleValue))
                    {
                        return(new DataGridLength(doubleValue, type));
                    }
                }
            }

            // The default exception to throw in ConvertFrom
            throw GetConvertFromException(value);
        }
Exemplo n.º 26
0
        /// <summary>
        /// <see cref="DependencyProperty.ValidateValueCallback"/>
        /// </summary>
        /// <remarks>
        /// This method needs to be internal to be accessable from derived classes.
        /// </remarks>
        internal static bool IsUserMaxSizePropertyValueValid(object value)
        {
            double v = (double)value;

            return(!DoubleUtil.IsNaN(v) && v >= 0.0d);
        }
Exemplo n.º 27
0
        /// <summary>
        /// <see cref="DependencyProperty.ValidateValueCallback"/>
        /// </summary>
        /// <remarks>
        /// This method needs to be internal to be accessable from derived classes.
        /// </remarks>
        internal static bool IsUserMinSizePropertyValueValid(object value)
        {
            double v = (double)value;

            return(!DoubleUtil.IsNaN(v) && v >= 0.0d && !Double.IsPositiveInfinity(v));
        }
        // Token: 0x06004A5E RID: 19038 RVA: 0x0014FB78 File Offset: 0x0014DD78
        internal static bool IsUserMaxSizePropertyValueValid(object value)
        {
            double num = (double)value;

            return(!DoubleUtil.IsNaN(num) && num >= 0.0);
        }
        // Token: 0x06004A5C RID: 19036 RVA: 0x0014FB14 File Offset: 0x0014DD14
        internal static bool IsUserMinSizePropertyValueValid(object value)
        {
            double num = (double)value;

            return(!DoubleUtil.IsNaN(num) && num >= 0.0 && !double.IsPositiveInfinity(num));
        }
Exemplo n.º 30
0
        //-------------------------------------------------------------------
        //
        //  Public Methods
        //
        //-------------------------------------------------------------------

        #region Public Methods


        #endregion

        //-------------------------------------------------------------------
        //
        //  Public Properties + Dependency Properties's
        //
        //-------------------------------------------------------------------

        #region Public Properties

        private static bool IsWidthHeightValid(object value)
        {
            double v = (double)value;

            return((DoubleUtil.IsNaN(v)) || (v >= 0.0d && !Double.IsPositiveInfinity(v)));
        }