Leggere in inglese

Condividi tramite


StylusTip Enumerazione

Definizione

Specifica la punta da utilizzare per disegnare un oggetto Stroke.

C#
public enum StylusTip
Ereditarietà
StylusTip

Campi

Nome Valore Descrizione
Ellipse 1

Rappresenta una punta a forma di ellisse.

Rectangle 0

Rappresenta una punta a forma di rettangolo.

Esempio

Nell'esempio seguente viene illustrato come usare due DrawingAttributes oggetti per simulare l'uso di una penna e un evidenziatore nella stessa InkCanvasclasse . La proprietà del StylusTip evidenziatore è impostata su Rettangolo.

L'esempio presuppone che l'elemento radice nel file "XAML" sia un DockPanel denominato root. Si presuppone inoltre che sia presente un Button evento chiamato btnToggleHighlighter e che l'evento Click sia stato connesso al gestore eventi.

C#
InkCanvas inkCanvas1 = new InkCanvas();
DrawingAttributes inkDA;
DrawingAttributes highlighterDA;
bool useHighlighter = false;

// Add an InkCanvas to the window, and allow the user to 
// switch between using a green pen and a purple highlighter 
// on the InkCanvas.
private void WindowLoaded(object sender, EventArgs e)
{
    inkCanvas1.Background = Brushes.DarkSlateBlue;
    inkCanvas1.DefaultDrawingAttributes.Color = Colors.SpringGreen;

    root.Children.Add(inkCanvas1);

    // Set up the DrawingAttributes for the pen.
    inkDA = new DrawingAttributes();
    inkDA.Color = Colors.SpringGreen;
    inkDA.Height = 5;
    inkDA.Width = 5;
    inkDA.FitToCurve = false;

    // Set up the DrawingAttributes for the highlighter.
    highlighterDA = new DrawingAttributes();
    highlighterDA.Color = Colors.Orchid;
    highlighterDA.IsHighlighter = true;
    highlighterDA.IgnorePressure = true;
    highlighterDA.StylusTip = StylusTip.Rectangle;
    highlighterDA.Height = 30;
    highlighterDA.Width = 10;

    inkCanvas1.DefaultDrawingAttributes = inkDA;
}

// Create a button called switchHighlighter and use 
// SwitchHighlighter_Click to handle the Click event.  
// The useHighlighter variable is a boolean that indicates
// whether the InkCanvas renders ink as a highlighter.

// Switch between using the 'pen' DrawingAttributes and the 
// 'highlighter' DrawingAttributes.
void SwitchHighlighter_Click(Object sender, RoutedEventArgs e)
{
    useHighlighter = !useHighlighter;
    
    if (useHighlighter)
    {
        switchHighlighter.Content = "Use Pen";
        inkCanvas1.DefaultDrawingAttributes = highlighterDA;
    }
    else
    {
        switchHighlighter.Content = "Use Highlighter";
        inkCanvas1.DefaultDrawingAttributes = inkDA;
    }
}

Commenti

È possibile specificare la forma della punta utilizzata per disegnare Stroke oggetti impostando la DrawingAttributes.StylusTip proprietà.

Utilizzo del testo XAML

Questa classe non viene in genere usata in XAML.

Si applica a

Prodotto Versioni
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9