70 lines
2.5 KiB
C#
70 lines
2.5 KiB
C#
![]() |
using System;
|
|||
|
using CPF.Drawing;
|
|||
|
using CPF.ReoGrid.Graphics;
|
|||
|
using CPF.ReoGrid.Rendering;
|
|||
|
|
|||
|
namespace CPF.ReoGrid.Chart
|
|||
|
{
|
|||
|
public class AxisCategoryLabelView : AxisInfoView
|
|||
|
{
|
|||
|
public AxisCategoryLabelView(AxisChart chart, AxisTypes axisType = AxisTypes.Primary, AxisOrientation orientation = AxisOrientation.Vertical) : base(chart, axisType)
|
|||
|
{
|
|||
|
this.orientation = orientation;
|
|||
|
}
|
|||
|
|
|||
|
protected override void OnPaint(RDrawingContext dc)
|
|||
|
{
|
|||
|
base.OnPaint(dc);
|
|||
|
bool flag = base.Chart == null;
|
|||
|
if (!flag)
|
|||
|
{
|
|||
|
AxisDataInfo axisDataInfo = (base.AxisType == AxisTypes.Primary) ? base.Chart.PrimaryAxisInfo : base.Chart.SecondaryAxisInfo;
|
|||
|
bool flag2 = axisDataInfo == null;
|
|||
|
if (!flag2)
|
|||
|
{
|
|||
|
IGraphics graphics = dc.Graphics;
|
|||
|
WorksheetChartDataSource dataSource = base.Chart.DataSource;
|
|||
|
Rect clientBounds = this.ClientBounds;
|
|||
|
float num = (float)((double)(this.FontSize * PlatformUtility.GetDPI()) / 72.0) + 4f;
|
|||
|
double num2 = axisDataInfo.Minimum;
|
|||
|
bool flag3 = this.orientation == AxisOrientation.Vertical;
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
float num3 = (clientBounds.Height - num) / (float)axisDataInfo.Levels;
|
|||
|
float num4 = 0f;
|
|||
|
float num5 = clientBounds.Bottom - num;
|
|||
|
float num6 = clientBounds.Width;
|
|||
|
Rect rect = new Rect(ref num4, ref num5, ref num6, ref num);
|
|||
|
for (int i = 0; i <= axisDataInfo.Levels; i++)
|
|||
|
{
|
|||
|
graphics.DrawText(Math.Round(num2, Math.Abs(axisDataInfo.Scaler)).ToString(), this.FontName, this.FontSize, base.ForeColor, rect, ReoGridHorAlign.Right, ReoGridVerAlign.Middle);
|
|||
|
rect.Y -= num3;
|
|||
|
num2 += Math.Round(axisDataInfo.LargeStride, Math.Abs(axisDataInfo.Scaler));
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag4 = this.orientation == AxisOrientation.Horizontal;
|
|||
|
if (flag4)
|
|||
|
{
|
|||
|
float num7 = clientBounds.Width / (float)axisDataInfo.Levels;
|
|||
|
float num4 = clientBounds.Left - num7 / 2f;
|
|||
|
float num5 = clientBounds.Top;
|
|||
|
float num6 = clientBounds.Height;
|
|||
|
Rect rect2 = new Rect(ref num4, ref num5, ref num7, ref num6);
|
|||
|
for (int j = 0; j <= axisDataInfo.Levels; j++)
|
|||
|
{
|
|||
|
graphics.DrawText(Math.Round(num2, Math.Abs(axisDataInfo.Scaler)).ToString(), this.FontName, this.FontSize, base.ForeColor, rect2, ReoGridHorAlign.Center, ReoGridVerAlign.Top);
|
|||
|
rect2.X += num7;
|
|||
|
num2 += Math.Round(axisDataInfo.LargeStride, Math.Abs(axisDataInfo.Scaler));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private AxisOrientation orientation;
|
|||
|
}
|
|||
|
}
|