PrintPreviewDialog.UseAntiAlias PrintPreviewDialog.UseAntiAlias PrintPreviewDialog.UseAntiAlias PrintPreviewDialog.UseAntiAlias Property

Definición

Obtiene o establece un valor que indica si la impresión utiliza las características de suavizado de contorno del sistema operativo.Gets or sets a value indicating whether printing uses the anti-aliasing features of the operating system.

public:
 property bool UseAntiAlias { bool get(); void set(bool value); };
public bool UseAntiAlias { get; set; }
member this.UseAntiAlias : bool with get, set
Public Property UseAntiAlias As Boolean

Valor de propiedad

Es true si se utiliza la función de suavizado de contorno; en caso contrario, es false.true if anti-aliasing is used; otherwise, false.

Comentarios

Suavizado de contorno quita las líneas irregulares al generar las fuentes.Anti-aliasing removes jagged lines when fonts are rendered.

En el ejemplo de código siguiente se muestra el PrintPreviewDialog configuración la Document y UseAntiAlias propiedades.The following code example demonstrates the PrintPreviewDialog setting the Document and UseAntiAlias properties. En el ejemplo se da por supuesto que el formulario contiene un TreeView denominado TreeView1 que contiene TreeNode objetos.The example assumes the form contains a TreeView named TreeView1 that contains TreeNode objects. El Tag propiedad de cada uno TreeNode objeto debe establecerse en un nombre completo del documento que puede tener acceso a la máquina que ejecuta el ejemplo.The Tag property of each TreeNode object must be set to a fully qualified document name that can be accessed by the machine running the example. Establezca cada TreeNode.Text propiedad en una cadena que identifica el archivo especificado por el TreeNode.Tag propiedad.Set each TreeNode.Text property to a string that identifies the file specified by the TreeNode.Tag property. Por ejemplo, podría establecer TreeNode1.Tag a "c:\myDocuments\recipe.doc" y TreeNode1.Text en "recipe.doc".For example, you could set TreeNode1.Tag to "c:\myDocuments\recipe.doc" and TreeNode1.Text to "recipe.doc". El ejemplo también supone que el formulario contiene un PrintPreviewDialog denominado PrintPreviewDialog1 y un botón denominado Button1.The example also assumes the form contains a PrintPreviewDialog named PrintPreviewDialog1 and a button named Button1. Para ejecutar este ejemplo, llamar a la InitializePrintPreviewDialog método en el constructor del formulario o Load controlador de eventos.To run this example, call the InitializePrintPreviewDialog method in the form's constructor or Load event handler.

   // Declare the dialog.
internal:
   PrintPreviewDialog^ PrintPreviewDialog1;

private:

   // Declare a PrintDocument object named document.
   System::Drawing::Printing::PrintDocument^ document;

   // Initalize the dialog.
   void InitializePrintPreviewDialog()
   {
      
      // Create a new PrintPreviewDialog using constructor.
      this->PrintPreviewDialog1 = gcnew PrintPreviewDialog;
      
      //Set the size, location, and name.
      this->PrintPreviewDialog1->ClientSize = System::Drawing::Size( 400, 300 );
      this->PrintPreviewDialog1->Location = System::Drawing::Point( 29, 29 );
      this->PrintPreviewDialog1->Name = "PrintPreviewDialog1";
      
      // Associate the event-handling method with the 
      // document's PrintPage event.
      this->document->PrintPage += gcnew System::Drawing::Printing::PrintPageEventHandler( this, &Form1::document_PrintPage );
      
      // Set the minimum size the dialog can be resized to.
      this->PrintPreviewDialog1->MinimumSize = System::Drawing::Size( 375, 250 );
      
      // Set the UseAntiAlias property to true, which will allow the 
      // operating system to smooth fonts.
      this->PrintPreviewDialog1->UseAntiAlias = true;
   }

   void Button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      if ( TreeView1->SelectedNode != nullptr )
      {
         document->DocumentName = TreeView1->SelectedNode->Tag->ToString();
      }

      // Set the PrintPreviewDialog.Document property to
      // the PrintDocument object selected by the user.
      PrintPreviewDialog1->Document = document;
      
      // Call the ShowDialog method. This will trigger the document's
      //  PrintPage event.
      PrintPreviewDialog1->ShowDialog();
   }

   void document_PrintPage( Object^ /*sender*/, System::Drawing::Printing::PrintPageEventArgs^ e )
   {
      
      // Insert code to render the page here.
      // This code will be called when the PrintPreviewDialog.Show 
      // method is called.
      // The following code will render a simple
      // message on the document in the dialog.
      String^ text = "In document_PrintPage method.";
      System::Drawing::Font^ printFont = gcnew System::Drawing::Font( "Arial",35,System::Drawing::FontStyle::Regular );
      e->Graphics->DrawString( text, printFont, System::Drawing::Brushes::Black, 0, 0 );
   }

// Declare the dialog.
internal PrintPreviewDialog PrintPreviewDialog1;

// Declare a PrintDocument object named document.
private System.Drawing.Printing.PrintDocument document =
	new System.Drawing.Printing.PrintDocument();

// Initalize the dialog.
private void InitializePrintPreviewDialog()
{

	// Create a new PrintPreviewDialog using constructor.
	this.PrintPreviewDialog1 = new PrintPreviewDialog();

	//Set the size, location, and name.
	this.PrintPreviewDialog1.ClientSize = 
		new System.Drawing.Size(400, 300);
	this.PrintPreviewDialog1.Location = 
		new System.Drawing.Point(29, 29);
	this.PrintPreviewDialog1.Name = "PrintPreviewDialog1";
	
	// Associate the event-handling method with the 
	// document's PrintPage event.
	this.document.PrintPage += 
		new System.Drawing.Printing.PrintPageEventHandler
		(document_PrintPage);

	// Set the minimum size the dialog can be resized to.
	this.PrintPreviewDialog1.MinimumSize = 
		new System.Drawing.Size(375, 250);

	// Set the UseAntiAlias property to true, which will allow the 
	// operating system to smooth fonts.
	this.PrintPreviewDialog1.UseAntiAlias = true;
}

private void Button1_Click(object sender, System.EventArgs e)
{

	if (TreeView1.SelectedNode != null)

		// Set the PrintDocument object's name to the selectedNode
		// object's  tag, which in this case contains the 
		// fully-qualified name of the document. This value will 
		// show when the dialog reports progress.
	{
		document.DocumentName = TreeView1.SelectedNode.Tag.ToString();
	}

	// Set the PrintPreviewDialog.Document property to
	// the PrintDocument object selected by the user.
	PrintPreviewDialog1.Document = document;

	// Call the ShowDialog method. This will trigger the document's
	//  PrintPage event.
	PrintPreviewDialog1.ShowDialog();
}

private void document_PrintPage(object sender, 
	System.Drawing.Printing.PrintPageEventArgs e)
{

	// Insert code to render the page here.
	// This code will be called when the PrintPreviewDialog.Show 
	// method is called.

	// The following code will render a simple
	// message on the document in the dialog.
	string text = "In document_PrintPage method.";
	System.Drawing.Font printFont = 
		new System.Drawing.Font("Arial", 35, 
		System.Drawing.FontStyle.Regular);

	e.Graphics.DrawString(text, printFont, 
		System.Drawing.Brushes.Black, 0, 0);

}

' Declare the dialog.
Friend WithEvents PrintPreviewDialog1 As PrintPreviewDialog

' Declare a PrintDocument object named document.
Private WithEvents document As New System.Drawing.Printing.PrintDocument

' Initalize the dialog.
Private Sub InitializePrintPreviewDialog()

    ' Create a new PrintPreviewDialog using constructor.
    Me.PrintPreviewDialog1 = New PrintPreviewDialog

    'Set the size, location, and name.
    Me.PrintPreviewDialog1.ClientSize = New System.Drawing.Size(400, 300)
    Me.PrintPreviewDialog1.Location = New System.Drawing.Point(29, 29)
    Me.PrintPreviewDialog1.Name = "PrintPreviewDialog1"

    ' Set the minimum size the dialog can be resized to.
    Me.PrintPreviewDialog1.MinimumSize = New System.Drawing.Size(375, 250)

    ' Set the UseAntiAlias property to true, which will allow the 
    ' operating system to smooth fonts.
    Me.PrintPreviewDialog1.UseAntiAlias = True
End Sub

Private Sub Button1_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button1.Click

    If (TreeView1.SelectedNode IsNot Nothing) Then

        ' Set the PrintDocument object's name to the selectedNode
        ' object's  tag, which in this case contains the 
        ' fully-qualified name of the document. This value will 
        ' show when the dialog reports progress.
        document.DocumentName = TreeView1.SelectedNode.Tag
    End If

    ' Set the PrintPreviewDialog.Document property to
    ' the PrintDocument object selected by the user.
    PrintPreviewDialog1.Document = document

    ' Call the ShowDialog method. This will trigger the document's
    '  PrintPage event.
    PrintPreviewDialog1.ShowDialog()
End Sub

Private Sub document_PrintPage(ByVal sender As Object, _
    ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
        Handles document.PrintPage

    ' Insert code to render the page here.
    ' This code will be called when the PrintPreviewDialog.Show 
    ' method is called.

    ' The following code will render a simple
    ' message on the document in the dialog.
    Dim text As String = "In document_PrintPage method."
    Dim printFont As New System.Drawing.Font _
        ("Arial", 35, System.Drawing.FontStyle.Regular)

    e.Graphics.DrawString(text, printFont, _
        System.Drawing.Brushes.Black, 0, 0)

End Sub

Se aplica a