private AbcSize MeasureLabels(AbcMeasureContext context) { int count = this.labelInfos.Count; //double desiredWidth = 0; //double desiredHeight = 0; for (int i = 0; i < count; i++) { AxisLabelInfo labelInfo = this.labelInfos[i]; IAbcLabel labelVisual = this.labelsPool.GetOrCreate(i); labelVisual.Text = labelInfo.labelContent; labelVisual.Measure(context); //desiredWidth += labelVisual.DesiredMeasure.width; //desiredHeight = Math.Max(0, labelVisual.DesiredMeasure.height); } this.labelsPool.HideAfter(count); if (count > 0) { IAbcLabel firstLabel = this.labelsPool.GetOrCreate(0); IAbcLabel lastLabel = this.labelsPool.GetOrCreate(count - 1); double desiredWidth = firstLabel.DesiredMeasure.width + lastLabel.DesiredMeasure.width; double desiredHeight = Math.Max(firstLabel.DesiredMeasure.height, lastLabel.DesiredMeasure.height); return(new AbcSize(desiredWidth, desiredHeight)); } else { return(AbcSize.Zero); } }
private void ArrangeLabels(double axisLineX, double axisLineRight, double y) { double axisLineLength = axisLineRight - axisLineX; int count = this.labelInfos.Count; for (int i = 0; i < count; i++) { AxisLabelInfo labelInfo = this.labelInfos[i]; IAbcLabel labelVisual = this.labelsPool.GetOrCreate(i); double x = axisLineX + (labelInfo.relativePosition * axisLineLength); AbcRect tickSlot = new AbcRect(x - (labelVisual.DesiredMeasure.width / 2), y, labelVisual.DesiredMeasure.width, labelVisual.DesiredMeasure.height); labelVisual.SetContextualPropertyValue(AbcCanvasContextualProperties.ArrangeSlotPropertyKey, new AbcContextualPropertyValue.AbcRect { value = tickSlot }); } this.labelsPool.HideAfter(count); }