Bagikan melalui


InkDrawingAttributesPencilProperties Kelas

Definisi

Menyediakan satu set properti InkDrawingAttributes statis untuk merender goresan pensil pada InkCanvas.

Dapatkan instans kelas ini dengan memanggil InkDrawingAttributes.CreateForPencil dan mengakses 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
Warisan
Object Platform::Object IInspectable InkDrawingAttributesPencilProperties
Atribut

Persyaratan Windows

Rangkaian perangkat
Windows 10 Anniversary Edition (diperkenalkan dalam 10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v3.0)

Contoh

Contoh ini menunjukkan cara merender goresan tinta menggunakan atribut pensil.

Pertama, kami mendeklarasikan InkCanvas di XAML.

Di kode belakang, kami mendefinisikan SetPencilInkStyle() fungsi untuk menentukan atribut stroke pensil.

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

Keterangan

Secara default, pensil menggambar goresan bermata lembut, bertekskus, dan semi transparan (berguna untuk efek bayangan berlapis) dengan PenTip Lingkaran. Warna goresan (kegelapan) tergantung pada tekanan pena yang terdeteksi.

Properti

Opacity

Mendapatkan atau mengatur tingkat transparansi yang digunakan untuk merender stroke pensil pada InkCanvas.

Opacity adalah properti statis dari InkDrawingAttributes.

Dapatkan instans kelas ini dengan memanggil InkDrawingAttributes.CreateForPencil dan mengakses InkDrawingAttributes.PencilProperties.

Berlaku untuk

Lihat juga