コード例 #1
0
        /// <summary>
        /// Provides the behavior for the Measure pass of Silverlight layout. Classes can override this method to define their own Measure pass behavior.
        /// </summary>
        /// <returns>
        /// The size that this object determines it needs during layout, based on its calculations of the allocated sizes for child objects; or based on other considerations, such as a fixed container size.
        /// </returns>
        /// <param name="availableSize">The Available Size</param>
        protected override Size MeasureOverride(Size availableSize)
        {
            var elements = new List <UIElement>();

            Size size = ChartLayoutUtils.CheckSize(availableSize);

            if (Area != null)
            {
                Area.RootPanelDesiredSize = size;
            }

            foreach (UIElement element in Children)
            {
                elements.Add(element);
            }

            IEnumerable <UIElement> uiElements = elements.OrderBy(GetMeasurePriorityIndex);

            foreach (UIElement element in uiElements)
            {
                element.Measure(availableSize);
            }

            return(size);
        }
コード例 #2
0
 /// <summary>
 /// Provides the behavior for the Measure pass of Silverlight layout. Classes can override this method to define their own Measure pass behavior.
 /// </summary>
 /// <returns>
 /// The size that this object determines it needs during layout, based on its calculations of the allocated sizes for child objects; or based on other considerations, such as a fixed container size.
 /// </returns>
 /// <param name="availableSize"></param>
 protected override Size MeasureOverride(Size availableSize)
 {
     availableSize = ChartLayoutUtils.CheckSize(availableSize);
     if (AxisLayout != null)
     {
         AxisLayout.Measure(availableSize);
     }
     return(availableSize);
 }
コード例 #3
0
        /// <summary>
        /// Measures the control.
        /// </summary>
        /// <param name="availableSize">The Available Size</param>
        /// <returns>Returns the measure size.</returns>
        protected override Size MeasureOverride(Size availableSize)
        {
            base.MeasureOverride(availableSize);
            this.availableSize = ChartLayoutUtils.CheckSize(availableSize);
            if (this.Orientation == Orientation.Horizontal && NearHand != null && FarHand != null)
            {
                desiredSize.Width  = this.availableSize.Width;
                desiredSize.Height = ResizableBarSize;
                if (NearHand.Visibility != Visibility.Collapsed)
                {
                    NearHand.Measure(availableSize);
                    Size thumbSize = NearHand.DesiredSize;
                    if (thumbSize.Width == 0)
                    {
                        resizeThumbSize = NearHand.MinWidth;
                    }
                    else
                    {
                        resizeThumbSize = thumbSize.Width;
                    }
                    NearHand.Width = resizeThumbSize;
                    FarHand.Width  = resizeThumbSize;
                }
                else
                {
                    resizeThumbSize = 0d;
                }

                if (this.ScrollButtonVisibility != Visibility.Collapsed)
                {
                    SmallIncrease.Measure(availableSize);
                    Size scrollButtonSize = SmallIncrease.DesiredSize;
                    if (scrollButtonSize.Width == 0)
                    {
                        smallThumbSize = SmallIncrease.MinWidth;
                    }
                    else
                    {
                        smallThumbSize = (smallThumbSize == 0) ? scrollButtonSize.Width : Math.Min(smallThumbSize, scrollButtonSize.Width);
                    }
                    SmallDecrease.Width = smallThumbSize;
                    SmallIncrease.Width = smallThumbSize;
                }
                else
                {
                    SmallDecrease.Width = smallThumbSize = 0;
                    SmallIncrease.Width = smallThumbSize = 0;
                }
            }
            else if (this.Orientation == Orientation.Vertical && FarHand != null && NearHand != null)
            {
                desiredSize.Height = this.availableSize.Height;
                desiredSize.Width  = ResizableBarSize;
                NearHand.Measure(availableSize);
                if (NearHand.Visibility != Visibility.Collapsed)
                {
                    Size thumbSize = NearHand.DesiredSize;
                    if (thumbSize.Height == 0)
                    {
                        resizeThumbSize = NearHand.MinHeight;
                    }
                    else
                    {
                        resizeThumbSize = thumbSize.Height;
                    }
                    NearHand.Height = resizeThumbSize;
                    FarHand.Height  = resizeThumbSize;
                }
                else
                {
                    resizeThumbSize = 0d;
                }

                if (this.ScrollButtonVisibility != Visibility.Collapsed)
                {
                    SmallIncrease.Measure(availableSize);
                    Size scrollButtonSize = SmallIncrease.DesiredSize;
                    if (scrollButtonSize.Width == 0)
                    {
                        smallThumbSize = SmallIncrease.MinHeight;
                    }
                    else
                    {
                        smallThumbSize = smallThumbSize = (smallThumbSize == 0) ? scrollButtonSize.Height : Math.Min(smallThumbSize, scrollButtonSize.Height);
                    }
                    SmallDecrease.Height = smallThumbSize;
                    SmallIncrease.Height = smallThumbSize;
                }
                else
                {
                    SmallDecrease.Height = smallThumbSize = 0;
                    SmallIncrease.Height = smallThumbSize = 0;
                }
            }

            return(desiredSize);
        }
コード例 #4
0
        /// <summary>
        /// Provides the behavior for the Measure pass of Silverlight layout. Classes can override this method to define their own Measure pass behavior.
        /// </summary>
        /// <returns>
        /// The size that this object determines it needs during layout, based on its calculations of the allocated sizes for child objects; or based on other considerations, such as a fixed container size.
        /// </returns>
        /// <param name="availableSize">The Available Size</param>
        protected override Size MeasureOverride(Size availableSize)
        {
            if (Adornment == null)
            {
                return(ChartLayoutUtils.CheckSize(availableSize));
            }
            PredefinedSymbol.Measure(availableSize);
            m_symbolPresenter.Measure(availableSize);

            Size resultSize = new Size();
            Size lblSz      = Size.Empty;
            Size sblSz;

            if (Adornment.Series.adornmentInfo.Symbol == ChartSymbol.Custom)
            {
                sblSz = m_symbolPresenter.DesiredSize;
            }
            else
            {
                sblSz = PredefinedSymbol.DesiredSize;
            }

            switch (LabelHorizontalAlignment)
            {
            case HorizontalAlignment.Stretch:
            case HorizontalAlignment.Center:
            {
                resultSize.Width = Math.Max(lblSz.Width, sblSz.Width);
                m_symbolOffset.X = 0.5 * resultSize.Width;
            }

            break;

            case HorizontalAlignment.Left:
                resultSize.Width = Math.Max(lblSz.Width, sblSz.Width);
                m_symbolOffset.X = 0.5 * resultSize.Width;
                break;

            case HorizontalAlignment.Right:
                resultSize.Width = Math.Max(lblSz.Width, sblSz.Width);
                m_symbolOffset.X = 0.5 * resultSize.Width;
                break;
            }

            switch (LabelVerticalAlignment)
            {
            case VerticalAlignment.Bottom:
                resultSize.Height = Math.Max(lblSz.Height, sblSz.Height);
                m_symbolOffset.Y  = 0.5 * resultSize.Height;

                break;

            case VerticalAlignment.Stretch:
            case VerticalAlignment.Center:
            {
                resultSize.Height = Math.Max(lblSz.Height, sblSz.Height);
                m_symbolOffset.Y  = 0.5 * resultSize.Height;
            }

            break;

            case VerticalAlignment.Top:
                resultSize.Height = Math.Max(lblSz.Height, sblSz.Height);
                m_symbolOffset.Y  = 0.5 * resultSize.Height;

                break;
            }

            return(resultSize);
        }
コード例 #5
0
        /// <summary>
        /// Computes the size of the <see cref="ChartCartesianAxisPanel"/>.
        /// </summary>
        /// <param name="availableSize">The Available Size</param>
        /// <returns>Returns the computed size.</returns>
        internal Size ComputeSize(Size availableSize)
        {
            Size size = Size.Empty;

            if (Axis.AxisLayoutPanel is ChartPolarAxisLayoutPanel)
            {
                foreach (UIElement element in this.Children)
                {
                    element.Measure(availableSize);
                }
                (this.Children[0] as FrameworkElement).Visibility = Visibility.Collapsed;//Collapsing the visibility of polar/radar series X-Axis header
                foreach (ILayoutCalculator element in this.LayoutCalc)
                {
                    element.Measure(availableSize);
                    size = element.DesiredSize;

                    ChartPolarAxisLayoutPanel axisLayoutPanel   = Axis.AxisLayoutPanel as ChartPolarAxisLayoutPanel;
                    ChartCircularAxisPanel    circularAxisPanel = element as ChartCircularAxisPanel;
                    axisLayoutPanel.Radius = circularAxisPanel.Radius;
                }
            }
            else
            {
                double horizontalPadding = 0;
                double verticalPadding   = 0;
                double width             = 0;
                double height            = 0;
                double angle             = 0d; //double.IsNaN(this.Axis.HeaderRotationAngle) ? 0d : this.Axis.HeaderRotationAngle;
                double direction         = 1;

                if (Axis.headerContent != null)
                {
                    Axis.headerContent.HorizontalAlignment = HorizontalAlignment.Center;
                    Axis.headerContent.VerticalAlignment   = VerticalAlignment.Center;

                    if (Axis.Orientation == Orientation.Vertical)
                    {
                        direction = this.Axis.OpposedPosition ? 1 : -1;
                        angle     = direction * 90;
                        var transform = new RotateTransform {
                            Angle = angle
                        };
                        Axis.headerContent.RenderTransform = transform;
                    }
                    else
                    {
                        Axis.headerContent.RenderTransform = null;
                    }
                }

                foreach (UIElement element in this.Children)
                {
                    bool isHeader = Axis.headerContent == element &&
                                    this.Axis.Orientation == Orientation.Vertical;

                    var measureSize = availableSize;
                    if (isHeader)
                    {
                        measureSize.Width  = Math.Max(availableSize.Width, element.DesiredSize.Width);
                        measureSize.Height = Math.Max(availableSize.Height, element.DesiredSize.Height);
                    }

                    element.Measure(measureSize);

                    if (element is SfChartResizableBar && Axis.EnableTouchMode)
                    {
                        continue;
                    }

                    width  += isHeader ? element.DesiredSize.Height : element.DesiredSize.Width;
                    height += isHeader ? element.DesiredSize.Width : element.DesiredSize.Height;
                }

                foreach (ILayoutCalculator element in LayoutCalc)
                {
                    element.Measure(availableSize);
                    if ((element is ChartCartesianAxisLabelsPanel &&
                         Axis.LabelsPosition == AxisElementPosition.Inside) ||
                        (element is ChartCartesianAxisElementsPanel &&
                         Axis.TickLinesPosition == AxisElementPosition.Inside))
                    {
                        horizontalPadding += element.DesiredSize.Width;
                        verticalPadding   += element.DesiredSize.Height;
                    }
                    width  += element.DesiredSize.Width;
                    height += element.DesiredSize.Height;
                }

                // To measure the multi level labels panel
                if (Axis.MultiLevelLabels != null && Axis.MultiLevelLabels.Count > 0 &&
                    Axis.axisMultiLevelLabelsPanel != null)
                {
                    Axis.axisMultiLevelLabelsPanel.Measure(availableSize);
                    if (Axis.LabelsPosition == AxisElementPosition.Inside)
                    {
                        horizontalPadding += Axis.axisMultiLevelLabelsPanel.DesiredSize.Width;
                        verticalPadding   += Axis.axisMultiLevelLabelsPanel.DesiredSize.Height;
                    }
                    width  += Axis.axisMultiLevelLabelsPanel.DesiredSize.Width;
                    height += Axis.axisMultiLevelLabelsPanel.DesiredSize.Height;
                }

                if (Axis.Orientation == Orientation.Vertical)
                {
                    Axis.InsidePadding = horizontalPadding;
                    size = new Size(width, availableSize.Height);
                }
                else
                {
                    Axis.InsidePadding = verticalPadding;
                    size = new Size(availableSize.Width, height);
                }
            }

            return(ChartLayoutUtils.CheckSize(size));
        }