Sdílet prostřednictvím


DrawingAttributes Třída

Definice

Určuje vzhled Stroke.

public ref class DrawingAttributes : System::ComponentModel::INotifyPropertyChanged
public class DrawingAttributes : System.ComponentModel.INotifyPropertyChanged
type DrawingAttributes = class
    interface INotifyPropertyChanged
Public Class DrawingAttributes
Implements INotifyPropertyChanged
Dědičnost
DrawingAttributes
Implementuje

Příklady

Následující příklad ukazuje, jak použít dva DrawingAttributes objekty k simulaci pomocí pera a zvýrazňovač na stejném InkCanvas. Příklad předpokládá, že kořenový prvek v souboru XAML je volána DockPanelroot. Předpokládá se také, že existuje Button volána switchHighlighter a že Click událost je připojena k obslužné rutině události definované v tomto příkladu.

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

Poznámky

DrawingAttributes Pomocí vlastnosti můžete určit nastavení, jako je barva, šířka, průhlednost a tvar peras tipu Stroke.

DefaultDrawingAttributes Pomocí vlastnosti určete atributy výkresu pro tahy přidané do objektu InkCanvas. Aktualizované atributy se zobrazí pouze tahy přidané po DefaultDrawingAttributes provedení změny. Vzhled tahů, které jsou již na InkCanvas této kartě, se nezmění.

Seznam počátečních hodnot vlastností pro instanci DrawingAttributes třídy naleznete v konstruktoru DrawingAttributes .

Použití textu XAML

Tato třída se obvykle nepoužívá v jazyce XAML.

Konstruktory

Name Description
DrawingAttributes()

Inicializuje novou instanci DrawingAttributes třídy.

Pole

Name Description
MaxHeight

Určuje největší povolenou Height hodnotu vlastnosti.

MaxWidth

Určuje největší povolenou Width hodnotu vlastnosti.

MinHeight

Určuje nejmenší povolenou Height hodnotu vlastnosti.

MinWidth

Určuje nejmenší povolenou Width hodnotu vlastnosti.

Vlastnosti

Name Description
Color

Získá nebo nastaví barvu Stroke.

FitToCurve

Získá nebo nastaví hodnotu, která označuje, zda Bezier smoothing je použit k vykreslení Stroke.

Height

Získá nebo nastaví výšku pera použité k kreslení Stroke.

IgnorePressure

Získá nebo nastaví hodnotu, která určuje, zda tloušťka vykreslené Stroke změny podle množství použitého tlaku.

IsHighlighter

Získá nebo nastaví hodnotu, která označuje, zda Stroke vypadá jako zvýrazňovač.

StylusTip

Získá nebo nastaví tvar pera použité k kreslení Stroke.

StylusTipTransform

Získá nebo nastaví Matrix , který určuje transformaci, která se má provést na hrotu pera.

Width

Získá nebo nastaví šířku pera použité k kreslení Stroke.

Metody

Name Description
AddPropertyData(Guid, Object)

Přidá do objektu DrawingAttributes vlastní vlastnost.

Clone()

Zkopíruje DrawingAttributes objekt.

ContainsPropertyData(Guid)

Vrátí hodnotu, která určuje, zda je zadaný identifikátor dat vlastnosti v objektu DrawingAttributes .

Equals(Object)

Určuje, zda je zadaný DrawingAttributes objekt roven aktuálnímu DrawingAttributes objektu.

GetHashCode()

Slouží jako hashovací funkce pro určitý typ.

GetPropertyData(Guid)

Získá hodnotu vlastní vlastnosti přidružené k zadané Guid.

GetPropertyDataIds()

Vrátí identifikátory GUID všech vlastních vlastností přidružených k objektu StrokeCollection.

GetType()

Získá Type aktuální instance.

(Zděděno od Object)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Object.

(Zděděno od Object)
OnAttributeChanged(PropertyDataChangedEventArgs)

AttributeChanged Vyvolá událost.

OnPropertyChanged(PropertyChangedEventArgs)

Nastane, když se změní jakákoli DrawingAttributes vlastnost.

OnPropertyDataChanged(PropertyDataChangedEventArgs)

PropertyDataChanged Vyvolá událost.

RemovePropertyData(Guid)

Odebere vlastní vlastnost přidruženou k zadanému Guidobjektu .

ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Operátory

Name Description
Equality(DrawingAttributes, DrawingAttributes)

Určuje, zda jsou zadané DrawingAttributes objekty stejné.

Inequality(DrawingAttributes, DrawingAttributes)

Určuje, zda zadané DrawingAttributes objekty nejsou stejné.

Událost

Name Description
AttributeChanged

Nastane, když se změní vlastnost v objektu DrawingAttributes .

PropertyDataChanged

Nastane při přidání nebo odebrání dat vlastnosti z objektu StrokeCollection.

Explicitní implementace rozhraní

Name Description
INotifyPropertyChanged.PropertyChanged

Toto rozhraní API podporuje produktovou infrastrukturu a není určené k použití přímo z uživatelského kódu.

Nastane, když hodnota jakékoli DrawingAttributes vlastnosti se změnila.

Platí pro