StylusTip 列挙型
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
Stroke の描画に使用されるスタイラスの先端を指定します。
public enum class StylusTip
public enum StylusTip
type StylusTip =
Public Enum StylusTip
- 継承
名前 | 値 | 説明 |
---|---|---|
Ellipse | 1 | 楕円形の先端を表します。 |
Rectangle | 0 | 四角形の先端を表します。 |
次の例では、2 つの DrawingAttributes オブジェクトを使用して、同じ InkCanvas上でペンと蛍光ペンを使用してシミュレートする方法を示します。 蛍光ペンの StylusTip プロパティは Rectangle に設定されます。
この例では、"XAML" ファイルのルート要素が という名前root
であることをDockPanel前提としています。 また、 が Button 呼び出 btnToggleHighlighter
され、 Click イベントがイベント ハンドラーに接続されていることを前提としています。
InkCanvas inkCanvas1 = new InkCanvas();
DrawingAttributes inkDA;
DrawingAttributes highlighterDA;
bool useHighlighter = false;
// Add an InkCanvas to the window, and allow the user to
// switch between using a green pen and a purple highlighter
// on the InkCanvas.
private void WindowLoaded(object sender, EventArgs e)
{
inkCanvas1.Background = Brushes.DarkSlateBlue;
inkCanvas1.DefaultDrawingAttributes.Color = Colors.SpringGreen;
root.Children.Add(inkCanvas1);
// Set up the DrawingAttributes for the pen.
inkDA = new DrawingAttributes();
inkDA.Color = Colors.SpringGreen;
inkDA.Height = 5;
inkDA.Width = 5;
inkDA.FitToCurve = false;
// Set up the DrawingAttributes for the highlighter.
highlighterDA = new DrawingAttributes();
highlighterDA.Color = Colors.Orchid;
highlighterDA.IsHighlighter = true;
highlighterDA.IgnorePressure = true;
highlighterDA.StylusTip = StylusTip.Rectangle;
highlighterDA.Height = 30;
highlighterDA.Width = 10;
inkCanvas1.DefaultDrawingAttributes = inkDA;
}
// Create a button called switchHighlighter and use
// SwitchHighlighter_Click to handle the Click event.
// The useHighlighter variable is a boolean that indicates
// whether the InkCanvas renders ink as a highlighter.
// Switch between using the 'pen' DrawingAttributes and the
// 'highlighter' DrawingAttributes.
void SwitchHighlighter_Click(Object sender, RoutedEventArgs e)
{
useHighlighter = !useHighlighter;
if (useHighlighter)
{
switchHighlighter.Content = "Use Pen";
inkCanvas1.DefaultDrawingAttributes = highlighterDA;
}
else
{
switchHighlighter.Content = "Use Highlighter";
inkCanvas1.DefaultDrawingAttributes = inkDA;
}
}
Private WithEvents inkCanvas1 As New InkCanvas()
Private inkDA As DrawingAttributes
Private highlighterDA As DrawingAttributes
Private useHighlighter As Boolean = False
' Add an InkCanvas to the window, and allow the user to
' switch between using a green pen and a purple highlighter
' on the InkCanvas.
Private Sub WindowLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
inkCanvas1.Background = Brushes.DarkSlateBlue
inkCanvas1.DefaultDrawingAttributes.Color = Colors.SpringGreen
' Add the InkCanvas to the DockPanel, named root.
root.Children.Add(inkCanvas1)
' Set up the DrawingAttributes for the pen.
inkDA = New DrawingAttributes()
With inkDA
.Color = Colors.SpringGreen
.Height = 5
.Width = 5
.FitToCurve = True
End With
' Set up the DrawingAttributes for the highlighter.
highlighterDA = New DrawingAttributes()
With highlighterDA
.Color = Colors.Orchid
.IsHighlighter = True
.IgnorePressure = True
.StylusTip = StylusTip.Rectangle
.Height = 30
.Width = 10
End With
inkCanvas1.DefaultDrawingAttributes = inkDA
End Sub
' Create a button called switchHighlighter and use
' SwitchHighlighter_Click to handle the Click event.
' The useHighlighter variable is a boolean that indicates
' whether the InkCanvas renders ink as a highlighter.
' Switch between using the 'pen' DrawingAttributes and the
' 'highlighter' DrawingAttributes when the user clicks on .
Private Sub SwitchHighlighter_Click(ByVal sender As [Object], ByVal e As RoutedEventArgs)
useHighlighter = Not useHighlighter
If useHighlighter Then
switchHighlighter.Content = "Use Pen"
inkCanvas1.DefaultDrawingAttributes = highlighterDA
Else
switchHighlighter.Content = "Use Highlighter"
inkCanvas1.DefaultDrawingAttributes = inkDA
End If
End Sub
プロパティを設定することで、オブジェクトの描画 Stroke に使用する先端の形状を DrawingAttributes.StylusTip 指定できます。
このクラスは通常、XAML では使用されません。
製品 | バージョン |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。