예제 #1
0
        internal RadSize MeasureContent(RadSize newAvailableSize)
        {
            var size = this.layoutController.MeasureContent(newAvailableSize);

            if (this.ShouldAutoRequestItems(null))
            {
                LoadMoreDataContext context = new LoadMoreDataContext {
                    View = this.View, DataContext = this.View.GetDataContext()
                };
                this.View.CommandService.ExecuteCommand(CommandId.LoadMoreData, context);
            }

            // NOTE: If we decide that we won't zero the length of collapsed rows then this 'TotalLineCount - 1' will be incorrect.
            // this.desiredSize = new RadSize(this.columnLayout.RenderInfo.OffsetFromIndex(this.columnLayout.TotalLineCount - 1), this.rowLayout.RenderInfo.OffsetFromIndex(this.rowLayout.TotalLineCount - 1));
            // return this.desiredSize;
            return(size);
        }
예제 #2
0
 public void Measure(RadSize availableSize)
 {
     this.desiredWidth  = 0;
     this.desiredHeight = 0;
     for (int i = 0; i < this.axes.Count; i++)
     {
         AxisModel axis = this.axes[i];
         axis.Measure(availableSize);
         this.desiredWidth  = this.desiredWidth + axis.desiredSize.Width;
         this.desiredHeight = this.desiredHeight + axis.desiredSize.Height;
         RadThickness margin = axis.desiredMargin;
         this.desiredMargin.Left   = Math.Max(this.desiredMargin.Left, margin.Left);
         this.desiredMargin.Top    = Math.Max(this.desiredMargin.Top, margin.Top);
         this.desiredMargin.Right  = Math.Max(this.desiredMargin.Right, margin.Right);
         this.desiredMargin.Bottom = Math.Max(this.desiredMargin.Bottom, margin.Bottom);
     }
 }
예제 #3
0
        internal override RadRect ArrangeOverride(RadRect availableRect)
        {
            if (this.presenter == null || !this.presenter.IsVisible)
            {
                this.desiredArrangeRect = RadRect.Empty;
                return(availableRect);
            }
            RadSize availableSize = new RadSize(availableRect.Width, availableRect.Height);

            if (availableSize != this.lastMeasureSize)
            {
                this.Measure(availableSize);
            }
            this.layoutStrategy.Arrange(availableRect);
            this.desiredArrangeRect = availableRect;
            return(availableRect);
        }
예제 #4
0
        private RadSize GetDefaultVisualSize()
        {
            if (this.defaultVisualSize == RadSize.Invalid)
            {
                if (this.defaultVisualStyleCache != null)
                {
                    this.defaultVisualSize = GetSizeFromStyle(this.defaultVisualStyleCache);
                }
            }

            if (this.defaultVisualSize == RadSize.Empty)
            {
                this.defaultVisualSize = this.DefaultVisualSize;
            }

            return(this.defaultVisualSize);
        }
예제 #5
0
        internal override RadSize ComputeDesiredSize(MeasureContext context)
        {
            RadSize desiredSize;

            if (this.IsHorizontal)
            {
                desiredSize        = new RadSize(context.GeneratedLength, context.MaxLength);
                desiredSize.Width  = Math.Min(desiredSize.Width, context.AvailableLength);
                desiredSize.Height = Math.Max(desiredSize.Height, ListViewModel.DoubleArithmetics.Ceiling(this.AvailableSize.Height));
            }
            else
            {
                desiredSize = new RadSize(Math.Max(AvailableSize.Width, context.MaxLength), Math.Min(context.AvailableLength, context.GeneratedLength));
            }

            return(desiredSize);
        }
예제 #6
0
        private MeasureContext MeasureHorizontalFrozenElements(RadSize availableSize, int frozenContainersCount)
        {
            var context = new MeasureContext();

            context.InitializeForHorizontalMeasure(this, availableSize);

            if (frozenContainersCount == 0)
            {
                return(context);
            }

            var firstContainerDesiredSize = new RadSize();
            var lastContainerDesiredSize  = new RadSize();

            using (var itemInfos = this.layout.GetLines(context.FirstVisibleIndex, true).GetEnumerator())
            {
                if (itemInfos.MoveNext())
                {
                    firstContainerDesiredSize      = this.GenerateContainer(itemInfos.Current);
                    context.ForwardGeneratedLength = context.GetLength(firstContainerDesiredSize);
                    context.MaxLength = Math.Max(context.MaxLength, context.GetOppositeLength(firstContainerDesiredSize));

                    // Take the length portion of the indexed element that is not currently in viewport.
                    this.HiddenPixels = GridModel.DoubleArithmetics.Floor(context.ForwardGeneratedLength * (context.Index % 1));
                    context.ForwardGeneratedLength -= this.HiddenPixels;

                    context.ForwardGeneratedLength = GridModel.DoubleArithmetics.Ceiling(context.ForwardGeneratedLength);
                    lastContainerDesiredSize       = firstContainerDesiredSize;

                    this.ViewportItemCount++;
                }

                while (frozenContainersCount - 1 > context.LastVisibleIndex && GridModel.DoubleArithmetics.IsLessThan(context.ForwardGeneratedLength, context.AvailableLength) && itemInfos.MoveNext())
                {
                    context.LastVisibleIndex++;
                    lastContainerDesiredSize        = this.GenerateContainer(itemInfos.Current);
                    context.ForwardGeneratedLength += context.GetLength(lastContainerDesiredSize);
                    context.MaxLength = Math.Max(context.MaxLength, context.GetOppositeLength(lastContainerDesiredSize));

                    this.ViewportItemCount++;
                }
            }

            return(context);
        }
예제 #7
0
        protected override bool BuildTicksAndLabels(RadSize availableSize)
        {
            bool result = base.BuildTicksAndLabels(availableSize);

            // last tick and label should not be visible
            AxisTickModel lastTick = this.LastTick;

            if (lastTick != null)
            {
                lastTick.isVisible = false;
                if (lastTick.associatedLabel != null)
                {
                    lastTick.associatedLabel.isVisible = false;
                }
            }

            return(result);
        }
        private void ArrangeTimerRuler(RadRect viewRect)
        {
            CalendarModel        model       = this.Calendar;
            MultiDayViewSettings settings    = model.multiDayViewSettings;
            DateTime             currentDate = model.DisplayDate.Date;

            double   timeWidth     = this.dayViewLayoutSlot.X - viewRect.X;
            TimeSpan timeSlotTime  = settings.DayStartTime;
            string   textToMeasure = string.Format(this.Calendar.Culture, this.Calendar.TimeFormat, currentDate.Add(timeSlotTime));
            RadSize  timeTextSize  = model.View.MeasureContent(null, textToMeasure);

            this.halfTextHeight = timeTextSize.Height / 2;

            double previousBottom = viewRect.Y - this.halfTextHeight;

            string labelText = string.Empty;
            double heightCoeff;
            double timeItemHeight;
            double oneHourTicks = (double)TimeSpan.FromHours(1).Ticks;

            for (int hourIndex = 0; hourIndex < this.timeRulerItems.Count; hourIndex++)
            {
                CalendarTimeRulerItem timerRulerItem = this.timeRulerItems[hourIndex];
                timerRulerItem.StartTime = timeSlotTime;
                timerRulerItem.Label     = labelText;

                timeSlotTime = timeSlotTime.Add(TimeSpan.FromTicks(settings.TimerRulerTickLength.Ticks));
                if (timeSlotTime > settings.DayEndTime)
                {
                    timeSlotTime = settings.DayEndTime;
                }

                timerRulerItem.EndTime = timeSlotTime;

                heightCoeff    = (timerRulerItem.EndTime - timerRulerItem.StartTime).Ticks / oneHourTicks;
                timeItemHeight = settings.TimeLinesSpacing * heightCoeff;

                timerRulerItem.Arrange(new RadRect(0f, previousBottom, timeWidth, timeItemHeight + this.halfTextHeight));
                previousBottom = timerRulerItem.layoutSlot.Bottom - this.halfTextHeight;

                labelText = string.Format(this.Calendar.Culture, this.Calendar.TimeFormat, currentDate.Add(timeSlotTime));
            }
        }
예제 #9
0
        internal RadSize MeasureEmptyContent(RadSize availableSize, bool displayEmptyContent)
        {
            RadSize measuredSize = RadSize.Empty;

            if (this.emptyContentControl != null)
            {
                if (displayEmptyContent)
                {
                    this.emptyContentControl.Visibility = Visibility.Visible;

                    this.emptyContentControl.Measure(availableSize.ToSize());
                    var width = double.IsInfinity(availableSize.Width) ? this.emptyContentControl.Width : Math.Max(availableSize.Width, this.emptyContentControl.DesiredSize.Width);

                    if (double.IsNaN(width))
                    {
                        width = 0;
                    }

                    var height = 0d;
                    if (double.IsInfinity(availableSize.Height))
                    {
                        height = this.emptyContentControl.DesiredSize.Height;
                    }
                    else
                    {
                        height = Math.Max(availableSize.Height, this.emptyContentControl.DesiredSize.Height);
                    }

                    if (double.IsNaN(height))
                    {
                        height = 0;
                    }

                    measuredSize = new RadSize(width, height);
                }
                else
                {
                    this.emptyContentControl.Visibility = Visibility.Collapsed;
                }
            }

            return(measuredSize);
        }
예제 #10
0
        private RadSize MeasureHorizontally(RadSize availableSize, double offset, int frozenElementsCount)
        {
            var context = new MeasureContext()
            {
                Offset = offset
            };

            if (frozenElementsCount > 0)
            {
                var frozenGeneratedContext = this.MeasureHorizontalFrozenElements(availableSize, frozenElementsCount);
                context.InitializeForHorizontalMeasure(this, availableSize, frozenGeneratedContext);
            }
            else
            {
                context.InitializeForHorizontalMeasure(this, availableSize);
            }

            this.AvailableLength = context.AvailableLength;
            this.MeasureForward(ref context);

            if (context.AvailableLength - context.ForwardGeneratedLength > GridModel.DoubleArithmetics.Ceiling(1d / IndexStorage.PrecisionMultiplier))
            {
                if (context.FirstVisibleIndex + this.ViewportItemCount < this.layout.VisibleLineCount)
                {
                    // perform the measure logic again, since this difference will most probably occur when the Index tree is cleared before the measure pass
                    this.RecycleLocally();
                    context.InitializeForHorizontalMeasure(this, availableSize);
                    this.MeasureForward(ref context);
                }
            }

            context.FirstVisibleIndex -= this.owner.FrozenColumnCount;
            this.MeasureBackwards(ref context);

            var desiredSize = new RadSize(context.GeneratedLength, context.MaxLength);

            desiredSize.Width  = Math.Min(desiredSize.Width, context.AvailableLength);
            desiredSize.Height = Math.Min(desiredSize.Height, GridModel.DoubleArithmetics.Ceiling(availableSize.Height));

            this.Layout.UpdateAverageLength(context.FirstVisibleIndex, context.LastVisibleIndex);

            return(desiredSize);
        }
예제 #11
0
        private RadSize MeasureVertically(RadSize availableSize, double offset, double bufferScale)
        {
            var context = new MeasureContext()
            {
                Offset      = offset,
                BufferScale = bufferScale
            };

            context.InitializeForVerticalMeasure(this, availableSize);

            this.AvailableLength = context.AvailableLength;

            // Always start with frozen containers unitl we generate row with cells.
            this.shouldGenerateFrozenContainer = true;

            if (this.IsBufferNeeded)
            {
                context.FirstVisibleIndex = this.GenerateTopBufferItems(context.FirstVisibleIndex, context.AvailableLength, context.Offset, context);
                context.LastVisibleIndex  = context.FirstVisibleIndex;
            }

            this.MeasureForward(ref context);

            ////TODO: We may need an additional synchronous measure pass in case less generated length (as in the Horizontal measure)

            this.MeasureBackwards(ref context);

            if (this.IsBufferNeeded)
            {
                this.GenerateBottomBufferItems(context.LastVisibleIndex, context.AvailableLength, context);
            }

            this.GenerateFrozenContainers();

            var desiredSize = new RadSize(context.MaxLength, context.GeneratedLength);

            desiredSize.Width  = Math.Min(desiredSize.Width, GridModel.DoubleArithmetics.Ceiling(availableSize.Width));
            desiredSize.Height = Math.Min(desiredSize.Height, context.AvailableLength);

            this.Layout.UpdateAverageLength(context.FirstVisibleIndex, context.LastVisibleIndex);

            return(desiredSize);
        }
예제 #12
0
        internal override RadThickness GetDesiredMargin(RadSize availableSize)
        {
            RadThickness margin = new RadThickness();

            if (this.maxLabelHeight == 0 || this.owner.LastLabelVisibility != AxisLastLabelVisibility.Visible)
            {
                return(margin);
            }

            double labelOffset = 0;

            if (this.owner.ActualPlotMode == AxisPlotMode.OnTicks)
            {
                labelOffset = (int)(this.maxLabelHeight / 2);
                margin.Top  = labelOffset;
            }

            return(margin);
        }
예제 #13
0
        public RadSize MeasureContent(RadSize newAvailableSize)
        {
            RadSize resultSize;

            if (this.strategy.IsHorizontal)
            {
                resultSize = this.MeasureHorizontal(newAvailableSize);
            }
            else
            {
                resultSize = this.MeasureVertical(newAvailableSize);
            }

            this.strategy.RecycleAfterMeasure();
            this.model.View.ItemCheckBoxService.GenerateVisuals();
            this.strategy.GenerateFrozenContainers();

            return(resultSize);
        }
예제 #14
0
        internal virtual RadRect ApplyLayoutSlotAlignment(GridCellModel cell)
        {
            FrameworkElement element = cell.Container as FrameworkElement;

            if (element == null)
            {
                return(cell.layoutSlot);
            }

            RadSize desiredSize = cell.DesiredSize;
            RadRect layoutSlot  = cell.layoutSlot;

            if (desiredSize.Width < layoutSlot.Width)
            {
                switch (element.HorizontalAlignment)
                {
                case HorizontalAlignment.Center:
                    layoutSlot.X += (layoutSlot.Width - desiredSize.Width) / 2;
                    break;

                case HorizontalAlignment.Right:
                    layoutSlot.X = layoutSlot.Right - desiredSize.Width;
                    break;
                }
            }

            if (desiredSize.Height < layoutSlot.Height)
            {
                switch (element.VerticalAlignment)
                {
                case VerticalAlignment.Center:
                    layoutSlot.Y += (layoutSlot.Height - desiredSize.Height) / 2;
                    break;

                case VerticalAlignment.Bottom:
                    layoutSlot.Y = layoutSlot.Bottom - desiredSize.Height;
                    break;
                }
            }

            return(layoutSlot);
        }
예제 #15
0
        private void UpdateTotalLabelHeight(RadSize availableSize)
        {
            // we asume that all labels have almost same width and we take the maximum of all
            // TODO: This is not always true, we need a more extended algorithm which will build lines dynamically
            double totalLabelWidth = this.owner.labels.Count * this.maxLabelWidth;

            this.totalLabelWidthToAvailableWidth = (int)(totalLabelWidth / availableSize.Width) + 1;
            if (this.totalLabelWidthToAvailableWidth > this.owner.labels.Count)
            {
                this.totalLabelWidthToAvailableWidth = this.owner.labels.Count;
            }

            this.shouldFitLabelsMultiLine = this.totalLabelWidthToAvailableWidth > 1 ? 1 : 0;

            this.totalLabelHeight = this.maxLabelHeight;
            if (this.owner.LabelFitMode == AxisLabelFitMode.MultiLine)
            {
                this.totalLabelHeight *= this.totalLabelWidthToAvailableWidth;
            }
        }
예제 #16
0
        private void MeasureCore(RadSize availableSize)
        {
            this.BuildTicksAndLabels(availableSize);

            foreach (AxisLabelModel label in this.labels)
            {
                // We may enter one or more additional measure passes until all axes are best fit,
                // so do not re-measure already measured labels.
                if (label.desiredSize == RadSize.Empty)
                {
                    label.desiredSize = this.presenter.MeasureContent(label, label.Content);
                }
            }
            if (this.title.desiredSize == RadSize.Empty)
            {
                this.title.desiredSize = this.presenter.MeasureContent(this.title, this.title.Content);
            }
            this.desiredSize   = this.layoutStrategy.GetDesiredSize(availableSize);
            this.desiredMargin = this.layoutStrategy.GetDesiredMargin(availableSize);
        }
예제 #17
0
        private RadSize MeasureDataPoint(DataPoint point)
        {
            if (point.desiredSize != RadSize.Invalid)
            {
                return(point.desiredSize);
            }

            DataTemplate template = this.GetDataTemplate(point);

            if (template == null)
            {
                if (this.SupportsDefaultVisuals)
                {
                    return(this.GetDefaultVisualSize());
                }

                return(RadSize.Empty);
            }

            RadSize cachedSize;

            if (this.pointSizeCache.TryGetValue(template, out cachedSize))
            {
                return(cachedSize);
            }

            this.measurementPresenter.Content         = point;
            this.measurementPresenter.ContentTemplate = template;

            this.measurementPresenter.ClearValue(FrameworkElement.WidthProperty);
            this.measurementPresenter.ClearValue(FrameworkElement.HeightProperty);

            this.measurementPresenter.Measure(RadChartBase.InfinitySize);

            RadSize size = new RadSize((int)(this.measurementPresenter.DesiredSize.Width + .5), (int)(this.measurementPresenter.DesiredSize.Height + .5));

            // cache the size
            this.pointSizeCache.Add(template, size);

            return(size);
        }
예제 #18
0
        internal override void Arrange(RadRect availableRect)
        {
            double   thickness  = this.owner.TickThickness;
            double   startAngle = this.StartAngle;
            double   radius     = availableRect.Width / 2;
            RadPoint center     = availableRect.Center;

            double   length          = this.owner.MajorTickLength;
            RadPoint labelAxisCenter = RadMath.GetArcPoint(startAngle + 90, center, length * 2);

            double angleInRad = (360 - startAngle) * RadMath.DegToRadFactor;
            double sin        = Math.Sin(angleInRad);
            double cos        = Math.Cos(angleInRad);

            foreach (AxisTickModel tick in this.owner.ticks)
            {
                double   tickRadius   = (double)tick.normalizedValue * radius;
                double   tickLength   = this.owner.GetTickLength(tick);
                RadPoint tickPosition = RadMath.GetArcPoint(startAngle, center, tickRadius);
                tick.Arrange(new RadRect(tickPosition.X, tickPosition.Y, thickness, tickLength));

                if (tick.associatedLabel == null)
                {
                    continue;
                }

                RadSize desiredSize = tick.associatedLabel.desiredSize;
                double  halfWidth   = desiredSize.Width / 2;
                double  halfHeight  = desiredSize.Height / 2;

                RadPoint labelPosition = RadMath.GetArcPoint(startAngle, labelAxisCenter, tickRadius);
                RadRect  bounds        = new RadRect(labelPosition.X - halfWidth, labelPosition.Y - halfHeight, desiredSize.Width, desiredSize.Height);

                bounds.X += sin * halfWidth;
                bounds.Y += cos * halfHeight;

                tick.associatedLabel.Arrange(bounds);
            }
        }
예제 #19
0
        protected override Size MeasureOverride(Size availableSize)
        {
            if (this.owner == null)
            {
                return(availableSize);
            }

            this.measuring = true;

            this.availableSize = this.NormalizeAvailableSize(availableSize);

            this.model.LineThickness = this.owner.Line.StrokeThickness;

            this.model.Measure(new RadSize(this.availableSize.Width, this.availableSize.Height));
            this.lastModelDesiredSize = this.model.DesiredSize;

            this.UpdateLabels();
            this.UpdateTicks();

            Size desiredSize = new Size();

            if (this.owner.Orientation == Orientation.Horizontal)
            {
                double desiredWidth = this.lastModelDesiredSize.Width;
                desiredSize = new Size(desiredWidth, this.lastModelDesiredSize.Height);
            }
            else
            {
                double desiredHeight = this.lastModelDesiredSize.Height;
                desiredSize = new Size(this.lastModelDesiredSize.Width, desiredHeight);
            }

            this.owner.Line.Measure(availableSize);
            this.owner.ChangePropertyInternally(ScalePrimitive.AxisLineOffsetProperty, this.model.AxisLineOffset);

            this.measuring = false;

            return(desiredSize);
        }
예제 #20
0
        private void MeasureForward(ref MeasureContext context)
        {
            var firstContainerDesiredSize = new RadSize();
            var lastContainerDesiredSize  = new RadSize();

            var lengthContext = this.GeneratedLengthContext;

            using (var itemInfos = this.Layout.GetLines(context.FirstVisibleIndex, true).GetEnumerator())
            {
                if (itemInfos.MoveNext())
                {
                    firstContainerDesiredSize = this.GenerateContainer(itemInfos.Current, context);
                    //   context.ForwardGeneratedLength += context.GetLength(firstContainerDesiredSize);
                    context.ForwardGeneratedLength += lengthContext.GenerateLength(context.GetLength(firstContainerDesiredSize));

                    context.MaxLength = Math.Max(context.MaxLength, context.GetOppositeLength(firstContainerDesiredSize));

                    // Take the length portion of the indexed element that is not currently in viewport.
                    this.HiddenPixels = ListViewModel.DoubleArithmetics.Floor(context.GetLength(firstContainerDesiredSize) * (context.Index % 1));
                    context.ForwardGeneratedLength -= this.HiddenPixels;

                    context.ForwardGeneratedLength = ListViewModel.DoubleArithmetics.Ceiling(context.ForwardGeneratedLength);
                    lastContainerDesiredSize       = firstContainerDesiredSize;

                    this.viewportItemsCount++;
                }

                while ((ListViewModel.DoubleArithmetics.IsLessThan(context.ForwardGeneratedLength, context.AvailableLength) /*|| double.IsInfinity(context.AvailableLength)*/) && itemInfos.MoveNext())
                {
                    context.LastVisibleIndex++;
                    lastContainerDesiredSize = this.GenerateContainer(itemInfos.Current, context);
                    //   context.ForwardGeneratedLength += context.GetLength(lastContainerDesiredSize);
                    context.ForwardGeneratedLength += lengthContext.GenerateLength(context.GetLength(lastContainerDesiredSize));
                    context.MaxLength = Math.Max(context.MaxLength, context.GetOppositeLength(lastContainerDesiredSize));

                    this.viewportItemsCount++;
                }
            }
        }
예제 #21
0
        private void MeasureBackwards(ref MeasureContext context)
        {
            if (context.AvailableLength - context.ForwardGeneratedLength > GridModel.DoubleArithmetics.Ceiling(1d / IndexStorage.PrecisionMultiplier))
            {
                if (context.FirstVisibleIndex + this.ViewportItemCount < this.layout.VisibleLineCount)
                {
                    var firstContainerDesiredSize = new RadSize();
                    using (var itemInfos = this.layout.GetLines(context.FirstVisibleIndex - 1, false).GetEnumerator())
                    {
                        while (GridModel.DoubleArithmetics.IsLessThan(context.GeneratedLength, context.AvailableLength) && itemInfos.MoveNext())
                        {
                            context.FirstVisibleIndex--;
                            firstContainerDesiredSize        = this.GenerateContainer(itemInfos.Current);
                            context.BackwardGeneratedLength += context.GetLength(firstContainerDesiredSize);
                            context.MaxLength = Math.Max(context.MaxLength, context.GetOppositeLength(firstContainerDesiredSize));

                            this.ViewportItemCount++;
                        }
                    }
                }
            }
        }
예제 #22
0
        internal RadSize ArrangeCells(RadSize finalSize)
        {
            this.lastArrangeSize = finalSize;
            if ((this.pendingMeasureFlags & InvalidateMeasureFlags.Cells) == InvalidateMeasureFlags.Cells)
            {
                return(finalSize);
            }

            if (this.VisibleColumns.Count() == this.ColumnPool.ViewportItemCount)
            {
                bool columnsStretched = this.CellsController.TryStretchColumns(this.availableSize.Width);
                if (columnsStretched && this.additionalStretchColumnsCount < MaxAdditionalStretchColumnsCount)
                {
                    this.additionalStretchColumnsCount++;
                    this.GridView.RebuildUI();
                    return(finalSize);
                }

                this.additionalStretchColumnsCount = 0;
            }

            var result = this.RowPool.OnArrange(finalSize);

            result = this.CellsController.OnCellsArrange(finalSize);

            this.UpdateEditRow();

            this.ArrangeEditorsPool(finalSize);

            // Wait for cell to be arranged since arranging the frozen decorators need the cells lyaoutslot to arrange.
            this.RowPool.ArrangeFrozenDecorators();

            this.ArrangeLineDecorators(finalSize);

            this.ApplyLayersClipping(result);


            return(result);
        }
예제 #23
0
        internal override void Arrange(RadRect availableRect)
        {
            var polarArea = this.owner.GetChartArea <PolarChartAreaModel>();

            RadRect tickRect  = this.GetTicksArrangeRect(availableRect);
            RadRect labelRect = this.GetLabelsArrangeRect(tickRect);

            RadPoint tickCenter = tickRect.Center;
            double   tickRadius = tickRect.Width / 2;

            RadPoint labelCenter = labelRect.Center;
            double   labelRadius = labelRect.Width / 2;

            double tickThickness = this.owner.TickThickness;

            foreach (AxisTickModel tick in this.owner.ticks)
            {
                if (!tick.isVisible)
                {
                    continue;
                }

                double   angle        = polarArea.NormalizeAngle((double)tick.value);
                RadPoint tickPosition = RadMath.GetArcPoint(angle, tickCenter, tickRadius);
                tick.Arrange(new RadRect(tickPosition.X, tickPosition.Y, tickThickness, this.owner.GetTickLength(tick)));

                if (tick.associatedLabel == null || !tick.associatedLabel.isVisible)
                {
                    continue;
                }

                RadSize  desiredSize   = tick.associatedLabel.desiredSize;
                RadPoint labelPosition = RadMath.GetArcPoint(angle, labelCenter, labelRadius);
                labelPosition.X += desiredSize.Width * Math.Cos(angle * RadMath.DegToRadFactor) / 2;
                labelPosition.Y += desiredSize.Height * Math.Sin(angle * RadMath.DegToRadFactor) / 2;
                tick.associatedLabel.Arrange(new RadRect(labelPosition.X - (desiredSize.Width / 2), labelPosition.Y - (desiredSize.Height / 2), desiredSize.Width, desiredSize.Height));
            }
        }
예제 #24
0
        public RadSize MeasureContent(RadSize newAvailableSize)
        {
            double heightToSubstract = 0;
            var    headerSize        = this.MeasureHeader(newAvailableSize);

            heightToSubstract += headerSize.Height;

            var footerSize = this.MeasureFooter(newAvailableSize);

            heightToSubstract += footerSize.Height;

            this.availableSize = new RadSize(newAvailableSize.Width, newAvailableSize.Height - heightToSubstract);
            var emptyContentSize = this.MeasureEmptyContent(this.availableSize);

            var resultSize = this.strategy.MeasureContent(this.availableSize, this.owner.ScrollOffset, this.model.BufferScale);

            this.strategy.RecycleAfterMeasure();

            var emptyContentPosition = new RadSize(0, this.headerModel.LayoutSlot.Bottom + resultSize.Height);

            this.UpdateEmptyContentLayoutSlotPosition(emptyContentPosition);

            var footerPosition = new RadSize(0, this.emptyContentModel.LayoutSlot.Bottom);

            this.UpdateFooterLayoutSlotPosition(footerPosition);

            this.model.View.ItemCheckBoxService.GenerateVisuals();

            this.strategy.GenerateFrozenContainers();
            if (this.strategy.IsHorizontal)
            {
                return(new RadSize(resultSize.Width + this.emptyContentModel.LayoutSlot.Width, resultSize.Height + this.emptyContentModel.LayoutSlot.Height));
            }
            else
            {
                return(new RadSize(resultSize.Width + this.emptyContentModel.LayoutSlot.Width, resultSize.Height + this.emptyContentModel.LayoutSlot.Height + heightToSubstract));
            }
        }
예제 #25
0
        internal override void TransformTitle(FrameworkElement title)
        {
            if (this.type == AxisType.First)
            {
                title.ClearValue(UIElement.RenderTransformProperty);
            }
            else
            {
                RadSize desiredSize = this.model.title.desiredSize;

                TransformGroup transform = new TransformGroup();
                transform.Children.Add(new RotateTransform()
                {
                    Angle = -90
                });
                transform.Children.Add(new TranslateTransform()
                {
                    Y = (desiredSize.Width / 2) + (desiredSize.Height / 2)
                });

                title.RenderTransform = transform;
            }
        }
예제 #26
0
        private RadSize MeasureCell(GridCellModel cell)
        {
            ContentLayer layer = this.GetContentLayerForColumn(cell.Column);

            // TODO: consider if content needs to be measured with constraint in stretch mode.
            var availableWidth = cell.Column.SizeMode == DataGridColumnSizeMode.Fixed ? cell.Column.Width : double.PositiveInfinity;

            RadSize size = GridModel.DoubleArithmetics.Ceiling(layer.MeasureCell(cell, availableWidth).ToRadSize());

            if (this.HasHorizontalGridLines && !this.decorationLayerCache.IsFirstLine(cell.ParentRow.ItemInfo))
            {
                size.Height += this.GridLinesThickness;
            }
            if (this.HasVerticalGridLines)
            {
                size.Width += this.GridLinesThickness;
            }

            cell.DesiredSize      = size;
            cell.Column.AutoWidth = Math.Max(cell.Column.AutoWidth, size.Width);

            return(cell.DesiredSize);
        }
예제 #27
0
        protected virtual bool BuildTicksAndLabels(RadSize availableSize)
        {
            ValueRange <decimal> newVisibleRange = this.layoutStrategy.GetVisibleRange(availableSize);

            if (newVisibleRange == this.visibleRange)
            {
                return(false);
            }

            this.visibleRange = newVisibleRange;

            // clear labels first, they are at the end of the children collection (performance improvement)
            this.labels.Clear();
            this.ticks.Clear();

            // prepare ticks
            this.UpdateTicks();

            // update labels
            this.UpdateLabels();

            return(true);
        }
예제 #28
0
        internal override RadRect ArrangeOverride(RadRect rect)
        {
            double   radius = rect.Width / 2;
            RadPoint arcPosition;
            RadPoint center = rect.Center;

            foreach (CategoricalDataPoint point in this.DataPoints)
            {
                if (point.numericalPlot == null || point.categoricalPlot == null)
                {
                    continue;
                }

                double pointRadius = point.numericalPlot.NormalizedValue * radius;
                double angle       = point.categoricalPlot.ConvertToAngle(this.GetChartArea() as PolarChartAreaModel);
                arcPosition = RadMath.GetArcPoint(angle, center, pointRadius);

                RadSize pointSize = point.Measure();
                point.Arrange(new RadRect(arcPosition.X - (pointSize.Width / 2), arcPosition.Y - (pointSize.Height / 2), pointSize.Width, pointSize.Height), false);
            }

            return(rect);
        }
예제 #29
0
        public virtual RadSize MeasureContent(RadSize availableSize, double offset, double bufferScale)
        {
            this.RecycleLocally();

            this.AvailableSize = availableSize;

            this.InitializeForMeasure();


            int visibleItemCount = this.Layout.VisibleLineCount;

            if (visibleItemCount == 0)
            {
                this.Generator.FullyRecycleDecorators();
                return(new RadSize());
            }

            if (this.IsHorizontal)
            {
                var resultSize = this.MeasureHorizontally(availableSize, offset, bufferScale);
                //   var width = this.Layout.TotalSlotCount > 0 ? this.Layout.PhysicalOffsetFromSlot(this.Layout.TotalSlotCount - 1) : 0;
                var width  = this.Layout.GetTotalLength();
                var height = double.IsPositiveInfinity(availableSize.Height) ? resultSize.Height : availableSize.Height;


                return(new RadSize(width, height));
            }
            else
            {
                var resultSize = this.MeasureVertically(availableSize, offset, bufferScale);
                //  var height = this.Layout.TotalSlotCount > 0 ? this.Layout.PhysicalOffsetFromSlot(this.Layout.TotalSlotCount - 1) : 0;
                var height = this.Layout.GetTotalLength();
                var width  = double.IsPositiveInfinity(availableSize.Width) ? resultSize.Width : availableSize.Width;

                return(new RadSize(width, height));
            }
        }
예제 #30
0
        private void ArrangeFrozenLineDecorators(RadSize finalSize, ArrangeDataForDecorations verticalArrangement)
        {
            Dictionary <int, double> horizontalCellsData = new Dictionary <int, double>();

            bool   firstColumn = true;
            double leftOffset  = 0;

            var lastColumnLine = 0;

            foreach (var item in this.ColumnPool.GetFrozenDisplayedElements())
            {
                horizontalCellsData.Add(item.Value.Last().ItemInfo.LayoutInfo.Line, this.CellsController.GetSlotWidth(item.Key));

                // NOTE: Remove when/if fallback to logical scrolling only.
                if (firstColumn)
                {
                    firstColumn = false;
                    int columnLine = item.Value.Last().ItemInfo.Slot;
                    leftOffset = columnLine - 1 >= 0 ? this.columnLayout.RenderInfo.OffsetFromIndex(columnLine - 1) : 0;
                }

                lastColumnLine = item.Value.Last().ItemInfo.LayoutInfo.Line;
            }

            if (horizontalCellsData.Count > 0)
            {
                // TODO: refactor to get gridlines thickness into account.
                horizontalCellsData.Add(++lastColumnLine, 100);
            }

            var cellsWidth = finalSize.Width;

            ArrangeDataForDecorations horizontalArrangement =
                new ArrangeDataForDecorations(horizontalCellsData, this.RowPool.GetGroupSizes(), leftOffset, cellsWidth);

            this.FrozenDecorationsController.Arrange(horizontalArrangement, verticalArrangement);
        }