Share via


InkDrawingAttributesPencilProperties Klasse

Definition

Stellt eine Reihe statischer InkDrawingAttributes-Eigenschaften zum Rendern eines Stiftstrichs auf einem InkCanvas bereit.

Rufen Sie eine instance dieser Klasse ab, indem Sie InkDrawingAttributes.CreateForPencil aufrufen und auf InkDrawingAttributes.PencilProperties zugreifen.

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
Vererbung
Object Platform::Object IInspectable InkDrawingAttributesPencilProperties
Attribute

Windows-Anforderungen

Gerätefamilie
Windows 10 Anniversary Edition (eingeführt in 10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (eingeführt in v3.0)

Beispiele

In diesem Beispiel wird veranschaulicht, wie ein Freihandstrich mithilfe von Stiftattributen gerendert wird.

Zunächst deklarieren wir die InkCanvas in XAML.

Im CodeBehind definieren wir eine SetPencilInkStyle() Funktion zum Angeben der Stiftstrichattribute.

<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);
  }
}

Hinweise

Standardmäßig zeichnet ein Stift einen weichrandigen, strukturierten und halbtransparenten Strich (nützlich für mehrschichtige Schattierungseffekte) mit einem Circle PenTip. Die Strichfarbe (Dunkelheit) hängt vom erkannten Stiftdruck ab.

Eigenschaften

Opacity

Ruft die Transparenzebene ab, die zum Rendern eines Stiftstrichs auf einem InkCanvas verwendet wird, oder legt diese fest.

Deckkraft ist eine statische Eigenschaft von InkDrawingAttributes.

Rufen Sie eine instance dieser Klasse ab, indem Sie InkDrawingAttributes.CreateForPencil aufrufen und auf InkDrawingAttributes.PencilProperties zugreifen.

Gilt für:

Weitere Informationen