InkToolbarCustomPen 클래스

정의

잉크 색상표와 펜 팁 속성(예: 도형, 회전 및 크기)이 호스트 앱에서 정의되는 InkToolbar 펜을 나타냅니다.

public ref class InkToolbarCustomPen : DependencyObject
/// [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 InkToolbarCustomPen : DependencyObject
[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 class InkToolbarCustomPen : DependencyObject
Public Class InkToolbarCustomPen
Inherits DependencyObject
상속
Object Platform::Object IInspectable DependencyObject InkToolbarCustomPen
특성

Windows 요구 사항

디바이스 패밀리
Windows 10 Anniversary Edition (10.0.14393.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v3.0에서 도입되었습니다.)

예제

사용자 지정 서예 펜의 정의는 다음과 같습니다.

  1. 코드 숨김에서는 먼저 InkToolbarCustomPen에서 파생된 사용자 지정 펜 클래스를 만듭니다.

사용자 지정 펜 클래스는 CreateInkDrawingAttributesCore 메서드를 재정의하고 사용자 지정 구성에 대한 InkDrawingAttributes 를 제공해야 합니다. 이 예제에서는 다음 InkDrawingAttributes를 사용자 지정합니다.

using System.Numerics;
using Windows.UI;
using Windows.UI.Input.Inking;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;

namespace Ink_Basic_InkToolbar
{
    class CalligraphicPen : InkToolbarCustomPen
    {

        public CalligraphicPen()
        {
        }

        protected override InkDrawingAttributes CreateInkDrawingAttributesCore(Brush brush, double strokeWidth)
        {
            InkDrawingAttributes inkDrawingAttributes = new InkDrawingAttributes();
            inkDrawingAttributes.PenTip = PenTipShape.Circle;
            inkDrawingAttributes.Size = new Windows.Foundation.Size(strokeWidth, strokeWidth * 20);
            SolidColorBrush solidColorBrush = brush as SolidColorBrush;
            if (solidColorBrush != null)
            {
                inkDrawingAttributes.Color = solidColorBrush.Color;
            }
            else
            {
                inkDrawingAttributes.Color = Colors.Black;
            }
            Matrix3x2 matrix = Matrix3x2.CreateRotation(.785f);
            inkDrawingAttributes.PenTipTransform = matrix;

            return inkDrawingAttributes;
        }
    }
}
  1. 태그에서 InkToolbarCustomPenButton 요소의 CustomPen 특성에 있는 {StaticResource} 태그 확장 참조를 사용하여 사용자 지정 펜 클래스를 바인딩합니다(또는 사용자 지정 펜을 인스턴스화하고 코드에서 InkToolbarCustomPenButton.CustomPen에 할당할 수 있음).

기본 제공 InkToolbarPenConfigurationControl을 사용하거나 표준 InkToolbar 펜 선언에서 사용자 지정 InkToolbarPenConfigurationControl 정의를 지정할 수 있습니다.

다음은 이전 코드 조각에 정의된 사용자 지정 펜에 대한 선언입니다.

<!-- Set up locally defined resource dictionary. -->
<Page.Resources>
    <!-- Add the custom CalligraphicPen to the page resources. -->
    <local:CalligraphicPen x:Key="CalligraphicPen" />
    <!-- Specify the colors for the palette of the custom pen. -->
    <BrushCollection x:Key="CalligraphicPenPalette">
        <SolidColorBrush Color="Blue" />
        <SolidColorBrush Color="Red" />
    </BrushCollection>
</Page.Resources>

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <StackPanel x:Name="HeaderPanel" Orientation="Horizontal" Grid.Row="0">
        <TextBlock x:Name="Header" 
                   Text="Basic ink sample" 
                   Style="{ThemeResource HeaderTextBlockStyle}" 
                   Margin="10,0,0,0" />
    </StackPanel>
    <Grid Grid.Row="1">
        <Image Source="Assets\StoreLogo.png" />
        <InkCanvas x:Name="inkCanvas" />
        <InkToolbar x:Name="inkToolbar" 
                    VerticalAlignment="Top" 
                    TargetInkCanvas="{x:Bind inkCanvas}">
            <InkToolbarCustomPenButton 
                CustomPen="{StaticResource CalligraphicPen}"
                MinStrokeWidth="1" MaxStrokeWidth="3" SelectedStrokeWidth="2"
                Palette="{StaticResource CalligraphicPenPalette}"
                SelectedBrushIndex ="1"
                ToolTipService.ToolTip="Calligraphic pen">                    
                <SymbolIcon Symbol="{x:Bind CalligraphicPenIcon}"/>                    
                <InkToolbarCustomPenButton.ConfigurationContent>
                    <InkToolbarPenConfigurationControl />
                </InkToolbarCustomPenButton.ConfigurationContent>
            </InkToolbarCustomPenButton>                
        </InkToolbar>
    </Grid>
</Grid>

이 예제의 파일에서 의 정의 CalligraphicPenIconMainPage.xaml.cs 다음과 같습니다.

namespace Ink_Basic_InkToolbar
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage_AddCustomPen : Page
    {
        // Icon for calligraphic pen custom button.
        Symbol CalligraphicPenIcon = (Symbol)0xEDFB;

        public MainPage_AddCustomPen()
        {
            this.InitializeComponent();
        }
    }
}

설명

InkToolbar에서 앱 정의 펜 및 해당 단추를 만들려면 InkToolbarCustomPenButton과 함께 이 클래스를 사용합니다.

생성자

InkToolbarCustomPen()

InkToolbarCustomPen 클래스의 새 instance 초기화합니다.

속성

Dispatcher

이 개체가 연결된 CoreDispatcher 를 가져옵니다. CoreDispatcher는 코드가 비 UI 스레드에서 시작되더라도 UI 스레드에서 DependencyObject에 액세스할 수 있는 기능을 나타냅니다.

(다음에서 상속됨 DependencyObject)

메서드

ClearValue(DependencyProperty)

종속성 속성의 로컬 값을 지웁니다.

(다음에서 상속됨 DependencyObject)
CreateInkDrawingAttributes(Brush, Double)

InkToolbarPenConfigurationControl에 사용되는 InkToolbarCustomPen 특성을 검색합니다.

CreateInkDrawingAttributesCore(Brush, Double)

파생 클래스에서 재정의된 경우 InkToolbarCustomPen에 대한 ConfigurationContent를 지정하는 데 사용되는 InkDrawingAttributes 개체를 검색합니다.

애플리케이션 코드에서이 메서드가 호출 되지 않습니다.

GetAnimationBaseValue(DependencyProperty)

애니메이션이 활성화되지 않은 경우에 적용되는 종속성 속성에 대해 설정된 기본 값을 반환합니다.

(다음에서 상속됨 DependencyObject)
GetValue(DependencyProperty)

DependencyObject에서 종속성 속성의 현재 유효 값을 반환합니다.

(다음에서 상속됨 DependencyObject)
ReadLocalValue(DependencyProperty)

로컬 값이 설정된 경우 종속성 속성의 로컬 값을 반환합니다.

(다음에서 상속됨 DependencyObject)
RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback)

DependencyObject instance 특정 DependencyProperty에 대한 변경 내용을 수신 대기하기 위한 알림 함수를 등록합니다.

(다음에서 상속됨 DependencyObject)
SetValue(DependencyProperty, Object)

DependencyObject에 대한 종속성 속성의 로컬 값을 설정합니다.

(다음에서 상속됨 DependencyObject)
UnregisterPropertyChangedCallback(DependencyProperty, Int64)

RegisterPropertyChangedCallback을 호출하여 이전에 등록된 변경 알림을 취소합니다.

(다음에서 상속됨 DependencyObject)

적용 대상

추가 정보