DrawingAttributes Klasa

Definicja

Określa wygląd obiektu Stroke.

public ref class DrawingAttributes : System::ComponentModel::INotifyPropertyChanged
public class DrawingAttributes : System.ComponentModel.INotifyPropertyChanged
type DrawingAttributes = class
    interface INotifyPropertyChanged
Public Class DrawingAttributes
Implements INotifyPropertyChanged
Dziedziczenie
DrawingAttributes
Implementuje

Przykłady

W poniższym przykładzie pokazano, jak używać dwóch DrawingAttributes obiektów do symulowania przy użyciu pióra i wyróżnienia na tym samym obiekcie InkCanvas. W przykładzie założono, że element główny w pliku XAML jest DockPanel nazywany .root Przyjęto również założenie, że istnieje wywołanie switchHighlighter i że Click zdarzenie jest połączone z procedurą Button obsługi zdarzeń zdefiniowaną w tym przykładzie.

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;
    }
}
Private WithEvents inkCanvas1 As New InkCanvas()
Private inkDA As DrawingAttributes
Private highlighterDA As DrawingAttributes
Private useHighlighter As Boolean = 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 Sub WindowLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)

    inkCanvas1.Background = Brushes.DarkSlateBlue
    inkCanvas1.DefaultDrawingAttributes.Color = Colors.SpringGreen

    ' Add the InkCanvas to the DockPanel, named root.
    root.Children.Add(inkCanvas1)

    ' Set up the DrawingAttributes for the pen.
    inkDA = New DrawingAttributes()
    With inkDA
        .Color = Colors.SpringGreen
        .Height = 5
        .Width = 5
        .FitToCurve = True
    End With

    ' Set up the DrawingAttributes for the highlighter.
    highlighterDA = New DrawingAttributes()
    With highlighterDA
        .Color = Colors.Orchid
        .IsHighlighter = True
        .IgnorePressure = True
        .StylusTip = StylusTip.Rectangle
        .Height = 30
        .Width = 10
    End With

    inkCanvas1.DefaultDrawingAttributes = inkDA

End Sub


' 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 when the user clicks on .
Private Sub SwitchHighlighter_Click(ByVal sender As [Object], ByVal e As RoutedEventArgs)

    useHighlighter = Not useHighlighter

    If useHighlighter Then
        switchHighlighter.Content = "Use Pen"
        inkCanvas1.DefaultDrawingAttributes = highlighterDA
    Else

        switchHighlighter.Content = "Use Highlighter"
        inkCanvas1.DefaultDrawingAttributes = inkDA
    End If

End Sub

Uwagi

DrawingAttributes Użyj właściwości , aby określić ustawienia, takie jak kolor, szerokość, przezroczystość i kształt końcówki rysika dla elementu Stroke.

DefaultDrawingAttributes Użyj właściwości , aby określić atrybuty rysunku dla pociągnięć dodanych do obiektu InkCanvas. Tylko pociągnięcia dodawane po DefaultDrawingAttributes zmianie są wyświetlane zaktualizowane atrybuty. Wygląd pociągnięć, które są już na obiekcie InkCanvas , nie zmienia się.

Aby uzyskać listę początkowych wartości właściwości dla wystąpienia DrawingAttributes klasy, zobacz DrawingAttributes konstruktor.

Użycie tekstu w języku XAML

Ta klasa nie jest zwykle używana w języku XAML.

Konstruktory

DrawingAttributes()

Inicjuje nowe wystąpienie klasy DrawingAttributes.

Pola

MaxHeight

Określa największą dozwoloną Height wartość dla właściwości.

MaxWidth

Określa największą dozwoloną Width wartość dla właściwości.

MinHeight

Określa najmniejszą dozwoloną Height wartość dla właściwości .

MinWidth

Określa najmniejszą dozwoloną Width wartość dla właściwości .

Właściwości

Color

Pobiera lub ustawia kolor elementu Stroke.

FitToCurve

Pobiera lub ustawia wartość wskazującą, czy wygładanie Beziera jest używane do renderowania elementu Stroke.

Height

Pobiera lub ustawia wysokość rysika używanego Strokedo rysowania .

IgnorePressure

Pobiera lub ustawia wartość, która wskazuje, czy grubość renderowanych Stroke zmian zgodnie z ilością zastosowanego ciśnienia.

IsHighlighter

Pobiera lub ustawia wartość wskazującą, czy Stroke element wygląda jak wyróżniacz.

StylusTip

Pobiera lub ustawia kształt rysika używanego do rysowania .Stroke

StylusTipTransform

Pobiera lub ustawia Matrix element określający przekształcenie do wykonania na wierzchołku rysika.

Width

Pobiera lub ustawia szerokość rysika używanego Strokedo rysowania .

Metody

AddPropertyData(Guid, Object)

Dodaje właściwość niestandardową DrawingAttributes do obiektu .

Clone()

Kopiuje obiekt DrawingAttributes.

ContainsPropertyData(Guid)

Zwraca wartość wskazującą, czy określony identyfikator danych właściwości znajduje się w DrawingAttributes obiekcie .

Equals(Object)

Określa, czy określony DrawingAttributes obiekt jest równy bieżącemu DrawingAttributes obiektowi.

GetHashCode()

Pełni rolę funkcji skrótu dla określonego typu.

GetPropertyData(Guid)

Pobiera wartość właściwości niestandardowej skojarzonej z określonym Guidelementem .

GetPropertyDataIds()

Zwraca identyfikatory GUID wszelkich właściwości niestandardowych skojarzonych z elementem StrokeCollection.

GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
OnAttributeChanged(PropertyDataChangedEventArgs)

AttributeChanged Zgłasza zdarzenie.

OnPropertyChanged(PropertyChangedEventArgs)

Występuje, gdy zmienia się dowolna DrawingAttributes właściwość.

OnPropertyDataChanged(PropertyDataChangedEventArgs)

PropertyDataChanged Zgłasza zdarzenie.

RemovePropertyData(Guid)

Usuwa właściwość niestandardową skojarzona z określonym Guidelementem .

ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Operatory

Equality(DrawingAttributes, DrawingAttributes)

Określa, czy określone DrawingAttributes obiekty są równe.

Inequality(DrawingAttributes, DrawingAttributes)

Określa, czy określone DrawingAttributes obiekty nie są równe.

Zdarzenia

AttributeChanged

Występuje, gdy zmienia się właściwość w DrawingAttributes obiekcie.

PropertyDataChanged

Występuje, gdy dane właściwości są dodawane lub usuwane z obiektu StrokeCollection.

Jawne implementacje interfejsu

INotifyPropertyChanged.PropertyChanged

Ten interfejs API obsługuje infrastrukturę produktu i nie jest przeznaczony do użycia bezpośrednio z poziomu kodu.

Występuje, gdy wartość dowolnej DrawingAttributes właściwości uległa zmianie.

Dotyczy