即使应用了GuidelineSet,垂直线也仍然模糊

时间:2018-08-30 16:48:04

标签: c# wpf

我正在用自定义控件的OnRender方法绘制一条垂直线。我应用GuidelineSet,以使该行与物理设备像素对齐。然而,线条仍显得模糊,放大该线条可显示已应用了抗锯齿。我在这里做什么错了?

protected override void OnRender(DrawingContext dc)
{
    Pen axisPen = new Pen(Brushes.Black, 1);
    if (axisPen.CanFreeze)
        axisPen.Freeze();

    double lineLength = RenderSize.Height + 1;
    double thick = axisPen.Thickness * 0.5;
    GuidelineSet guidelines = new GuidelineSet();
    guidelines.GuidelinesX.Add(thick);
    dc.PushGuidelineSet(guidelines);
    dc.DrawLine(axisPen, new Point(0, 0), new Point(0, lineLength));
    dc.Pop();
}

0 个答案:

没有答案