첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

■ Path 엘리먼트의 Data 속성에서 패스 미니 언어를 사용하는 방법을 보여준다.

TestProject.zip
0.01MB

▶ 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
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요