Пример #1
0
        protected override void ArrangeOverride(AbcArrangeContext context)
        {
            double firstLabelWidth = 0;
            double lastLabelWidth  = 0;

            if (this.labelInfos.Count > 0)
            {
                firstLabelWidth = this.labelsPool.GetOrCreate(0).DesiredMeasure.width;
                lastLabelWidth  = this.labelsPool.GetOrCreate(this.labelInfos.Count - 1).DesiredMeasure.width;
            }

            double  right               = context.arrangeSlot.Right();
            double  axisLineX           = context.arrangeSlot.x + (firstLabelWidth / 2);
            double  axisLineRight       = right - (lastLabelWidth / 2);
            AbcRect axisLineArrangeSlot = new AbcRect(axisLineX, 0, axisLineRight - axisLineX, this.axisLineThickness);

            this.axisLine.SetContextualPropertyValue(AbcCanvasContextualProperties.ArrangeSlotPropertyKey, new AbcContextualPropertyValue.AbcRect {
                value = axisLineArrangeSlot
            });

            this.EnsureTickInfos();
            this.ArrangeTicks(axisLineX, axisLineRight, axisLineArrangeSlot.Bottom());

            this.ArrangeLabels(axisLineX, axisLineRight, axisLineArrangeSlot.Bottom() + this.axisTickLength);

            this.Canvas.Arrange(context);
        }
Пример #2
0
        internal override void PaintOverride(AbcArrangeContext context)
        {
            base.PaintOverride(context);

            IAbcVisual abcVisual   = this;
            AbcRect    arrangeSlot = abcVisual.ArrangeSlot;

            object drawingContextObject;

            context.Bag.TryGetBagObject(WpfRenderingVisualTree.DrawingContextIdentifier, out drawingContextObject);
            DrawingContext drawingContext = (DrawingContext)drawingContextObject;

            drawingContext.DrawRectangle(Brushes.Black, null, new Rect(arrangeSlot.x, arrangeSlot.y, arrangeSlot.size.width, arrangeSlot.size.height));
        }
Пример #3
0
        internal void Paint(AbcArrangeContext context)
        {
            if (!this.isArrangeValid)
            {
                this.Arrange(context);
            }

            this.isPaintPhase = true;
            AbcRect arrangeSlot = context.arrangeSlot;

            this.PaintOverride(context);
            context.arrangeSlot = arrangeSlot;
            this.isPaintPhase   = false;
            this.isPaintValid   = true;
        }
Пример #4
0
        internal override void PaintOverride(AbcArrangeContext context)
        {
            base.PaintOverride(context);

            object paintEventArgsObject;

            context.Bag.TryGetBagObject(WFVisual.PaintEventArgsIdentifier, out paintEventArgsObject);
            PaintEventArgs paintEventArgs = (PaintEventArgs)paintEventArgsObject;
            IAbcRectangle  abcRectangle   = this;
            AbcRect        slot           = abcRectangle.ArrangeSlot;

            using (Pen pen = new Pen(Color.Black))
            {
                paintEventArgs.Graphics.DrawRectangle(pen, (float)slot.x, (float)slot.y, (float)slot.size.width, (float)slot.size.height);
            }
        }
Пример #5
0
        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);
        }
Пример #6
0
        private void ArrangeTicks(double axisLineX, double axisLineRight, double y)
        {
            double axisLineLength    = axisLineRight - axisLineX;
            double halfTickThickness = this.axisTickThickness / 2;
            int    count             = this.tickInfos.Count;

            for (int i = 0; i < count; i++)
            {
                AxisTickInfo  tickInfo   = this.tickInfos[i];
                IAbcRectangle tickVisual = this.ticksPool.GetOrCreate(i);
                double        x          = axisLineX + (tickInfo.relativePosition * axisLineLength);
                AbcRect       tickSlot   = new AbcRect(x - halfTickThickness, y, this.axisTickThickness, this.axisTickLength);
                tickVisual.SetContextualPropertyValue(AbcCanvasContextualProperties.ArrangeSlotPropertyKey, new AbcContextualPropertyValue.AbcRect {
                    value = tickSlot
                });
            }

            this.ticksPool.HideAfter(count);
        }
Пример #7
0
        void IAbcVisual.Arrange(AbcArrangeContext context)
        {
            if (!this.isVisible)
            {
                return;
            }

            if (!this.isMeasureValid)
            {
                IAbcVisual abcVisual = this;
                abcVisual.Measure(new AbcMeasureContext(context.arrangeSlot.size, context));
            }

            this.isArrangePhase = true;
            this.arrangeSlot    = context.arrangeSlot;
            this.ArrangeOverride(context);
            context.arrangeSlot = this.arrangeSlot;
            this.isArrangePhase = false;
            this.isArrangeValid = true;
        }
Пример #8
0
        internal override void PaintOverride(AbcArrangeContext context)
        {
            base.PaintOverride(context);

            if (!this.TryEnsureFormattedText())
            {
                return;
            }

            IAbcVisual abcVisual   = this;
            AbcRect    arrangeSlot = abcVisual.ArrangeSlot;

            object drawingContextObject;

            context.Bag.TryGetBagObject(WpfRenderingVisualTree.DrawingContextIdentifier, out drawingContextObject);
            DrawingContext drawingContext = (DrawingContext)drawingContextObject;

            Point position = new Point(arrangeSlot.x, arrangeSlot.y);

            drawingContext.DrawText(this.nativeFormattedText, position);
        }
Пример #9
0
        internal void Arrange(AbcArrangeContext context)
        {
            if (this.isArrangeValid)
            {
                this.isArrangeValid = this.arrangeSlot == context.arrangeSlot;
            }

            if (this.isArrangeValid)
            {
                return;
            }

            if (!this.isMeasureValid)
            {
                this.Measure(new AbcMeasureContext(context.arrangeSlot.size, context));
            }

            this.isArrangePhase = true;
            this.arrangeSlot    = context.arrangeSlot;
            this.ArrangeOverride(context);
            context.arrangeSlot = this.arrangeSlot;
            this.isArrangePhase = false;
            this.isArrangeValid = true;
        }
Пример #10
0
 internal AbcArrangeContext(AbcRect slot)
 {
     this.arrangeSlot = slot;
 }
Пример #11
0
        internal static Rect ToRect(AbcRect abcRect)
        {
            Rect rect = new Rect(abcRect.x, abcRect.y, abcRect.size.width, abcRect.size.height);

            return(rect);
        }