Graphics.SmoothingMode 属性  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置此 Graphics 的呈现质量。
public:
 property System::Drawing::Drawing2D::SmoothingMode SmoothingMode { System::Drawing::Drawing2D::SmoothingMode get(); void set(System::Drawing::Drawing2D::SmoothingMode value); };public System.Drawing.Drawing2D.SmoothingMode SmoothingMode { get; set; }member this.SmoothingMode : System.Drawing.Drawing2D.SmoothingMode with get, setPublic Property SmoothingMode As SmoothingMode属性值
SmoothingMode 值之一。
示例
以下方法演示了设置 DashCap、 DashPattern和 SmoothingMode 属性的效果。 该示例的输出如下图所示。
               
              
            
此示例旨在与 Windows 窗体 一起使用。 将代码粘贴到窗体中, ShowPensAndSmoothingMode 并在处理窗体 Paint 的事件时调用 方法,作为 ePaintEventArgs传递。
private:
   void ShowPensAndSmoothingMode( PaintEventArgs^ e )
   {
      // Set the SmoothingMode property to smooth the line.
      e->Graphics->SmoothingMode = System::Drawing::Drawing2D::SmoothingMode::AntiAlias;
      // Create a new Pen object.
      Pen^ greenPen = gcnew Pen( Color::Green );
      // Set the width to 6.
      greenPen->Width = 6.0F;
      // Set the DashCap to round.
      greenPen->DashCap = System::Drawing::Drawing2D::DashCap::Round;
      // Create a custom dash pattern.
      array<Single>^temp0 = {4.0F,2.0F,1.0F,3.0F};
      greenPen->DashPattern = temp0;
      // Draw a line.
      e->Graphics->DrawLine( greenPen, 20.0F, 20.0F, 100.0F, 240.0F );
      // Change the SmoothingMode to none.
      e->Graphics->SmoothingMode = System::Drawing::Drawing2D::SmoothingMode::None;
      // Draw another line.
      e->Graphics->DrawLine( greenPen, 100.0F, 240.0F, 160.0F, 20.0F );
      // Dispose of the custom pen.
      delete greenPen;
   }
private void ShowPensAndSmoothingMode(PaintEventArgs e)
{
    // Set the SmoothingMode property to smooth the line.
    e.Graphics.SmoothingMode = 
        System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
    // Create a new Pen object.
    Pen greenPen = new Pen(Color.Green);
    // Set the width to 6.
    greenPen.Width = 6.0F;
    // Set the DashCap to round.
    greenPen.DashCap = System.Drawing.Drawing2D.DashCap.Round;
    // Create a custom dash pattern.
    greenPen.DashPattern = new float[]{4.0F, 2.0F, 1.0F, 3.0F};
    // Draw a line.
    e.Graphics.DrawLine(greenPen, 20.0F, 20.0F, 100.0F, 240.0F);
    // Change the SmoothingMode to none.
    e.Graphics.SmoothingMode = 
        System.Drawing.Drawing2D.SmoothingMode.None;
    // Draw another line.
    e.Graphics.DrawLine(greenPen, 100.0F, 240.0F, 160.0F, 20.0F);
    // Dispose of the custom pen.
    greenPen.Dispose();
}
Private Sub ShowPensAndSmoothingMode(ByVal e As PaintEventArgs)
    ' Set the SmoothingMode property to smooth the line.
    e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
    ' Create a new Pen object.
    Dim greenPen As New Pen(Color.Green)
    ' Set the width to 6.
    greenPen.Width = 6.0F
    ' Set the DashCap to round.
    greenPen.DashCap = Drawing2D.DashCap.Round
    ' Create a custom dash pattern.
    greenPen.DashPattern = New Single() {4.0F, 2.0F, 1.0F, 3.0F}
    ' Draw a line.
    e.Graphics.DrawLine(greenPen, 20.0F, 20.0F, 100.0F, 240.0F)
    ' Change the SmoothingMode to none.
    e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.None
    ' Draw another line.
    e.Graphics.DrawLine(greenPen, 100.0F, 240.0F, 160.0F, 20.0F)
    ' Dispose of the custom pen.
    greenPen.Dispose()
End Sub
注解
平滑模式指定线条、曲线和填充区域的边缘是否使用平滑 (也称为抗锯齿) 。 一个例外是路径渐变画笔不遵循平滑模式。 无论 属性如何, PathGradientBrush 使用 填充的区域都以 (别名) SmoothingMode 相同的方式呈现。