InkDrawingAttributesPencilProperties 类

定义

提供一组静态 InkDrawingAttributes 属性,用于在 InkCanvas 上呈现铅笔划。

通过调用 InkDrawingAttributes.CreateForPencil 并访问 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
继承
Object Platform::Object IInspectable InkDrawingAttributesPencilProperties
属性

Windows 要求

设备系列
Windows 10 Anniversary Edition (在 10.0.14393.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v3.0 中引入)

示例

此示例演示如何使用铅笔属性呈现墨迹笔划。

首先,我们在 XAML 中声明 InkCanvas

在代码隐藏中,我们定义一个 SetPencilInkStyle() 函数来指定铅笔划属性。

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

注解

默认情况下,铅笔绘制软边缘、纹理和半透明笔划, (用于使用圆形笔尖) 分层着色效果。 笔划颜色(暗度)取决于检测到的笔压力。

属性

Opacity

获取或设置用于在 InkCanvas 上呈现铅笔笔划的透明度级别。

Opacity 是 InkDrawingAttributes 的静态属性。

通过调用 InkDrawingAttributes.CreateForPencil 并访问 InkDrawingAttributes.PencilProperties 获取此类的实例。

适用于

另请参阅