InkDrawingAttributesPencilProperties Classe

Définition

Fournit un ensemble de propriétés InkDrawingAttributes statiques pour le rendu d’un trait de crayon sur un InkCanvas.

Obtenez un instance de cette classe en appelant InkDrawingAttributes.CreateForPencil et en accédant à InkDrawingAttributes.PencilProperties.

public ref class InkDrawingAttributesPencilProperties sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 196608)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class InkDrawingAttributesPencilProperties final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 196608)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class InkDrawingAttributesPencilProperties
Public NotInheritable Class InkDrawingAttributesPencilProperties
Héritage
Object Platform::Object IInspectable InkDrawingAttributesPencilProperties
Attributs

Configuration requise pour Windows

Famille d’appareils
Windows 10 Anniversary Edition (introduit dans 10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduit dans v3.0)

Exemples

Cet exemple montre comment afficher un trait d’encre à l’aide d’attributs de crayon.

Tout d’abord, nous déclarons inkCanvas en XAML.

Dans le code-behind, nous définissons une SetPencilInkStyle() fonction pour spécifier les attributs de trait de crayon.

<InkCanvas x:Name="inkCanvas"/>
public sealed partial class Sample : Page
{
  public SetPencilInkStyle()
  {
    // Initialize the pencil stroke attributes.
    InkDrawingAttributes pencilAttributes = InkDrawingAttributes.CreateForPencil();
    pencilAttributes.Color = Windows.UI.Colors.Red;
    pencilAttributes.Size = new Windows.Foundation.Size(3, 3);
    Debug.Assert(attributes.Kind == InkDrawingAttributesKind.Pencil);
    pencilAttributes.PencilProperties.Opacity = 0.5f;
    // Update InkPresenter with the pencil attributes.
    inkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(pencilAttributes);
  }
}
struct MainPage : MainPageT<MainPage>
{
    void SetPencilInkStyle()
    {
        // Initialize the pencil stroke attributes.
        auto pencilAttributes{ Windows::UI::Input::Inking::InkDrawingAttributes::CreateForPencil() };
        pencilAttributes.Color(Windows::UI::Colors::Red());
        pencilAttributes.Size({ 3, 3 });
        WINRT_ASSERT(pencilAttributes.Kind() == Windows::UI::Input::Inking::InkDrawingAttributesKind::Pencil);
        pencilAttributes.PencilProperties().Opacity(.5f);
        // Update the InkPresenter with the pencil attributes.
        m_inkCanvas.InkPresenter().UpdateDefaultDrawingAttributes(pencilAttributes);
    }
}
public sealed partial class Sample : Page
{
  public SetPencilInkStyle()
  {
    // Initialize the pencil stroke attributes.
    InkDrawingAttributes^ pencilAttributes = InkDrawingAttributes::CreateForPencil();
    pencilAttributes->Color = Windows::UI::Colors::Red;
    pencilAttributes->Size = Windows::Foundation::Size(3, 3);
    assert(pencilAttributes->Kind == InkDrawingAttributesKind::Pencil);
    pencilAttributes->PencilProperties->Opacity = 0.5f;
    // Update the InkPresenter with the pencil attributes.
    inkCanvas->InkPresenter->UpdateDefaultDrawingAttributes(pencilAttributes);
  }
}

Remarques

Par défaut, un crayon dessine un trait doux, texturé et semi-transparent (utile pour les effets d’ombrage en couches) avec un stylet Circle. La couleur du trait dépend de la pression du stylet détectée.

Propriétés

Opacity

Obtient ou définit le niveau de transparence utilisé pour le rendu d’un trait de crayon sur un InkCanvas.

Opacity est une propriété statique de InkDrawingAttributes.

Obtenez un instance de cette classe en appelant InkDrawingAttributes.CreateForPencil et en accédant à InkDrawingAttributes.PencilProperties.

S’applique à

Voir aussi