728x90
반응형
728x170
■ Path 엘리먼트의 Data 속성에서 패스 미니 언어를 사용하는 방법을 보여준다.
▶ MainWindow.xaml
<Window x:Class="TestProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TestProject"
xmlns:options="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
Width="800"
Height="600"
Title="TestProject"
FontFamily="나눔고딕코딩"
FontSize="16">
<Window.Resources>
<Style x:Key="CodeTextBlockStyleKey" TargetType="{x:Type TextBlock}">
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="Padding" Value="10" />
<Setter Property="Background" Value="#33cccccc" />
<Setter Property="FontFamily" Value="Courier New" />
<Setter Property="TextWrapping" Value="Wrap" />
</Style>
<DrawingBrush x:Key="GridDrawingBrushKey"
ViewportUnits="Absolute"
Viewport="0 0 10 10"
TileMode="Tile"
options:Freeze="True">
<DrawingBrush.Drawing>
<DrawingGroup>
<DrawingGroup.Children>
<GeometryDrawing Brush="White">
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0 0 1 1" />
</GeometryDrawing.Geometry>
</GeometryDrawing>
<GeometryDrawing
Brush="#ccccff"
Geometry="M 0 0 L 1 0 1 0.1 0 0.1 Z" />
<GeometryDrawing
Brush="#ccccff"
Geometry="M 0 0 L 0 1 0.1 1 0.1 0 Z" />
</DrawingGroup.Children>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Window.Resources>
<ScrollViewer>
<StackPanel Margin="10">
<TextBlock
FontWeight="Bold">
Line
</TextBlock>
<TextBlock Style="{StaticResource CodeTextBlockStyleKey}">M 10 50 L 200 70</TextBlock>
<Border
Margin="0 10 0 0"
Width="250"
Height="100"
BorderThickness="3"
BorderBrush="Black"
Background="{StaticResource GridDrawingBrushKey}">
<Path
StrokeThickness="3"
Stroke="Black"
Data="M 10 50 L 200 70" />
</Border>
<TextBlock
Margin="0 10 0 0"
FontWeight="Bold">
Horizontal Line
</TextBlock>
<TextBlock Style="{StaticResource CodeTextBlockStyleKey}">M 10 50 H 200</TextBlock>
<Border
Margin="0 10 0 0"
Width="250"
Height="100"
BorderThickness="3"
BorderBrush="Black"
Background="{StaticResource GridDrawingBrushKey}">
<Path
StrokeThickness="3"
Stroke="Black"
Data="M 10 50 H 200" />
</Border>
<TextBlock
Margin="0 10 0 0"
FontWeight="Bold">
Vertical Line
</TextBlock>
<TextBlock Style="{StaticResource CodeTextBlockStyleKey}">M 10 50 V 200</TextBlock>
<Border
Margin="0 10 0 0"
Width="250"
Height="210"
BorderThickness="3"
BorderBrush="Black"
Background="{StaticResource GridDrawingBrushKey}">
<Path
StrokeThickness="3"
Stroke="Black"
Data="M 10 50 V 200" />
</Border>
<TextBlock
Margin="0 10 0 0"
FontWeight="Bold">
Cubic Bezier Curve
</TextBlock>
<TextBlock Style="{StaticResource CodeTextBlockStyleKey}">M 10 100 C 100 0 200 200 300 100</TextBlock>
<Border
Margin="0 10 0 0"
Width="310"
Height="200"
BorderThickness="3"
BorderBrush="Black"
Background="{StaticResource GridDrawingBrushKey}">
<Path
StrokeThickness="3"
Stroke="Black"
Data="M 10 100 C 100 0 200 200 300 100" />
</Border>
<TextBlock
Margin="0 10 0 0"
FontWeight="Bold">
Quadratic Bezier Curve
</TextBlock>
<TextBlock Style="{StaticResource CodeTextBlockStyleKey}">M 10 100 Q 200 200 300 100</TextBlock>
<Border
Margin="0 10 0 0"
Width="310"
Height="200"
BorderThickness="3"
BorderBrush="Black"
Background="{StaticResource GridDrawingBrushKey}">
<Path
StrokeThickness="3"
Stroke="Black"
Data="M 10 100 Q 200 200 300 100" />
</Border>
<TextBlock
Margin="0 10 0 0"
FontWeight="Bold">
Smooth Bezier Curve
</TextBlock>
<TextBlock Style="{StaticResource CodeTextBlockStyleKey}">M 10 100 C 35 0 135 0 160 100 S 285 200 310 100</TextBlock>
<Border
Margin="0 10 0 0"
Width="320"
Height="200"
BorderThickness="3"
BorderBrush="Black"
Background="{StaticResource GridDrawingBrushKey}">
<Path
StrokeThickness="3"
Stroke="Black"
Data="M 10 100 C 35 0 135 0 160 100 S 285 200 310 100" />
</Border>
<TextBlock
Margin="0 10 0 0"
FontWeight="Bold">
Elliptical Arc
</TextBlock>
<TextBlock Style="{StaticResource CodeTextBlockStyleKey}">M 10 100 A 100 50 45 1 0 200 100</TextBlock>
<Border
Margin="0 10 0 0"
Width="310"
Height="300"
BorderThickness="3"
BorderBrush="Black"
Background="{StaticResource GridDrawingBrushKey}">
<Path
StrokeThickness="3"
Stroke="Black"
Data="M 10 100 A 100 50 45 1 0 200 100" />
</Border>
<TextBlock
Margin="0 10 0 0"
FontWeight="Bold">
Close Path Command
</TextBlock>
<TextBlock Style="{StaticResource CodeTextBlockStyleKey}">M 10 100 L 100 100 100 50 Z</TextBlock>
<Border
Margin="0 10 0 0"
Width="250"
Height="200"
BorderThickness="3"
BorderBrush="Black"
Background="{StaticResource GridDrawingBrushKey}">
<Path
StrokeThickness="3"
Stroke="Black"
Data="M 10 100 L 100 100 100 50 Z" />
</Border>
<TextBlock
Margin="0 10 0 0"
FontWeight="Bold">
Multiple Subpaths
</TextBlock>
<TextBlock Style="{StaticResource CodeTextBlockStyleKey}">M 10 100 L 100 100 100 50 Z M 10 10 100 10 100 40 Z</TextBlock>
<Border
Margin="0 10 0 0"
Width="250"
Height="200"
BorderThickness="3"
BorderBrush="Black"
Background="{StaticResource GridDrawingBrushKey}">
<Path
Stroke="Black"
StrokeThickness="3"
Data="M 10 100 L 100 100 100 50 Z M 10 10 100 10 100 40 Z" />
</Border>
</StackPanel>
</ScrollViewer>
</Window>
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] PathGeometry 엘리먼트 : Figures 속성을 사용해 복수 하위 패스 만들기 (0) | 2023.04.01 |
---|---|
[C#/WPF] GeometryGroup 엘리먼트 : FillRule 속성을 EvenOdd로 설정해 동심원 만들기 (0) | 2023.04.01 |
[C#/WPF] SizeAnimation 클래스 : ArcSegment 객체의 크기를 변경하는 애니메이션 만들기 (0) | 2023.04.01 |
[C#/WPF] PointAnimation 클래스 : 공을 일정 구간에서 반복적으로 움직이기 (0) | 2023.04.01 |
[C#/WPF] PointAnimation 엘리먼트 : 공을 일정 구간에서 반복적으로 움직이기 (0) | 2023.04.01 |
[C#/WPF] CombinedGeometry 엘리먼트 : GeometryCombineMode 속성 사용하기 (0) | 2023.03.28 |
[C#/WPF] ImageDrawing 엘리먼트 : Rect/ImageSource 속성을 사용해 이미지 드로잉 그리기 (0) | 2023.03.26 |
[C#/WPF] DrawingGroup 엘리먼트 : BitmapEffect/OpacityMask 속성을 사용해 드로잉 그리기 (0) | 2023.03.26 |
[C#/WPF] DrawingGroup 엘리먼트 : 합성 드로잉 그리기 (0) | 2023.03.26 |
[C#/WPF] DrawingGroup 엘리먼트 : GuidelineSet 객체를 설정해 드로잉 만들기 (0) | 2023.03.26 |
댓글을 달아 주세요