Пример #1
0
        private void DrawHorizontalLine(IGridState state, IDrawing drawing, Structs.Size canvasSize, IMargin margin, ref SizeF strY, double valueData, double stepData, bool calcWidth, ref double maxTextSize, StringAlignment align, ref int lastTextPos)
        {
            double y = this.scaleService.ToScreenY(valueData);

            if (y >= 0 && y <= canvasSize.Height - margin.Bottom - margin.Top)
            {
                if (calcWidth)
                {
                    var strValue = state.ItemFormatter.ToString(Axis.Y, new DataItem(0, valueData), stepData);
                    var strSize  = drawing.MeasureText(strValue);
                    maxTextSize = maxTextSize < strSize.Width ? strSize.Width : maxTextSize;
                    strY.Height = strSize.Height;
                }
                else
                {
                    double lineYPos = canvasSize.Height - margin.Bottom - y; // Invert graphic
                    var    color    = valueData != 0 ? state.GridColor : state.AxeColor;
                    drawing.Line(color, margin.Left, lineYPos, canvasSize.Width - margin.Right, lineYPos);

                    if (CalcAndCheckLabelRectY(state, canvasSize, margin, ref strY, valueData, align, lineYPos, out Rectangle rect, out bool borderValue))
                    {
                        var strValue = state.ItemFormatter.ToString(Axis.Y, new DataItem(0, valueData), stepData);
                        drawing.Text(state.TextYColor, rect, strValue, StringAlignment.Far, align);

                        lastTextPos = rect.Top;
                    }
                }
            }
        }
Пример #2
0
        private static void DrawVerticalLine(IGridState state, IDrawing drawing, Structs.Size canvasSize, IMargin margin, SizeF strX, double screenPos, double valueData, double maxData, double stepData, StringAlignment align, ref int lastTextPos)
        {
            if (screenPos >= 0 &&
                (align == StringAlignment.Center && (screenPos <= canvasSize.Width - margin.Left - margin.Right - strX.Width / 2) ||
                 (align == StringAlignment.Far && (screenPos - strX.Width <= canvasSize.Width - margin.Left - margin.Right))))
            {
                double lineXPos = screenPos + margin.Left;
                var    color    = valueData != 0 ? state.GridColor : state.AxeColor;
                drawing.Line(color, lineXPos, margin.Top, lineXPos, canvasSize.Height - margin.Bottom);

                if (CalcAndCheckLabelRectX(state, ref canvasSize, margin, ref strX, valueData, maxData, align, lineXPos, ref lastTextPos, out Rectangle rect))
                {
                    double linePos2 = canvasSize.Height - margin.Bottom;
                    drawing.Line(color, lineXPos, linePos2, lineXPos, linePos2 + state.LabelPadding.Top + 1);

                    var strValue = state.ItemFormatter.ToString(Axis.X, new DataItem(valueData, 0), stepData);
                    drawing.Text(state.TextXColor, rect, strValue, align, StringAlignment.Center);

                    lastTextPos = rect.Right;
                }
            }
        }