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

■ DrawingBrush 엘리먼트를 사용하는 방법을 보여준다.

TestProject.zip
0.01MB

▶ MainWindow.xaml

<Window Name="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"
    Width="800"
    Height="600"
    Title="TestProject"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <StackPanel
        HorizontalAlignment="Center"
        VerticalAlignment="Center">
        <StackPanel Margin="10">
            <TextBlock>
                A DrawingBrush paints an area with a drawing.<LineBreak />
                It may also be used to create a pattern. The following are some examples.
            </TextBlock>
            <StackPanel
                Margin="10"
                Orientation="Horizontal">
                <Rectangle
                    Margin="10"
                    Width="100"
                    Height="100"
                    StrokeThickness="1"
                    Stroke="Black">
                    <Rectangle.Fill>
                        <DrawingBrush>
                            <DrawingBrush.Drawing>
                                <DrawingGroup>
                                    <DrawingGroup.Children>
                                        <GeometryDrawing
                                            Brush="Gray"
                                            Geometry="M 0 0.1 L 0.1 0 1 0.9 0.9 1 z" />
                                        <GeometryDrawing
                                            Brush="Gray"
                                            Geometry="M 0.9 0 L 1 0.1 0.1 1 0 0.9 z" />
                                        <GeometryDrawing
                                            Brush="#ffff00"
                                            Geometry="M 0.25 0.25 L 0.5 0.125 0.75 0.25 0.5 0.5 z" />
                                        <GeometryDrawing
                                            Brush="Black"
                                            Geometry="M 0.25 0.75 L 0.5 0.875 0.75 0.75 0.5 0.5 z" />
                                        <GeometryDrawing
                                            Brush="#ff0000"
                                            Geometry="M 0.25 0.75 L 0.125 0.5 0.25 0.25 0.5 0.5 z" />
                                        <GeometryDrawing
                                            Brush="MediumBlue"
                                            Geometry="M 0.75 0.25 L 0.875 0.5 0.75 0.75 0.5 0.5 z" />
                                    </DrawingGroup.Children>
                                </DrawingGroup>
                            </DrawingBrush.Drawing>
                        </DrawingBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle
                    Margin="10"
                    Width="100"
                    Height="100"
                    StrokeThickness="1"
                    Stroke="Black">
                    <Rectangle.Fill>
                        <DrawingBrush
                            Viewport="0 0 0.5 0.5"
                            TileMode="Tile">
                            <DrawingBrush.Drawing>
                                <DrawingGroup>
                                    <DrawingGroup.Children>
                                        <GeometryDrawing
                                            Brush="Gray"
                                            Geometry="M 0 0.1 L 0.1 0 1 0.9 0.9 1 z" />
                                        <GeometryDrawing
                                            Brush="Gray"
                                            Geometry="M 0.9 0 L 1 0.1 0.1 1 0 0.9 z" />
                                        <GeometryDrawing
                                            Brush="#ffff00"
                                            Geometry="M 0.25 0.25 L 0.5 0.125 0.75 0.25 0.5 0.5 z" />
                                        <GeometryDrawing
                                            Brush="Black"
                                            Geometry="M 0.25 0.75 L 0.5 0.875 0.75 0.75 0.5 0.5 z" />
                                        <GeometryDrawing
                                            Brush="#ff0000"
                                            Geometry="M 0.25 0.75 L 0.125 0.5 0.25 0.25 0.5 0.5 z" />
                                        <GeometryDrawing
                                            Brush="MediumBlue"
                                            Geometry="M 0.75 0.25 L 0.875 0.5 0.75 0.75 0.5 0.5 z" />
                                    </DrawingGroup.Children>
                                </DrawingGroup>
                            </DrawingBrush.Drawing>
                        </DrawingBrush>

            </Rectangle.Fill>
                </Rectangle>
                <Rectangle
                    Margin="10"
                    Width="100"
                    Height="100"
                    StrokeThickness="1"
                    Stroke="Black">
                    <Rectangle.Fill>
                        <DrawingBrush
                            Viewport="0 0 0.1 0.1"
                            TileMode="Tile">
                            <DrawingBrush.Drawing>
                                <DrawingGroup>
                                    <DrawingGroup.Children>
                                        <GeometryDrawing
                                            Brush="Gray"
                                            Geometry="M 0 0.1 L 0.1 0 1 0.9 0.9 1 z" />
                                        <GeometryDrawing
                                            Brush="Gray"
                                            Geometry="M 0.9 0 L 1 0.1 0.1 1 0 0.9 z" />
                                        <GeometryDrawing
                                            Brush="#ffff00"
                                            Geometry="M 0.25 0.25 L 0.5 0.125 0.75 0.25 0.5 0.5 z" />
                                        <GeometryDrawing
                                            Brush="Black"
                                            Geometry="M 0.25 0.75 L 0.5 0.875 0.75 0.75 0.5 0.5 z" />
                                        <GeometryDrawing
                                            Brush="#ff0000"
                                            Geometry="M 0.25 0.75 L 0.125 0.5 0.25 0.25 0.5 0.5 z" />
                                        <GeometryDrawing
                                            Brush="MediumBlue"
                                            Geometry="M 0.75 0.25 L 0.875 0.5 0.75 0.75 0.5 0.5 z" />
                                    </DrawingGroup.Children>
                                </DrawingGroup>
                            </DrawingBrush.Drawing>
                        </DrawingBrush>

            </Rectangle.Fill>
                </Rectangle>
            </StackPanel>
            <TextBlock
                Margin="0 10 0 0">
                The following rectangles are filled with a drawing brush.<LineBreak />
                Notice how the patterns defined by the DrawingBrush expand to fill the area of the rectangle.
            </TextBlock>
            <StackPanel
                Margin="10"
                Orientation="Horizontal">
                <Rectangle
                    Margin="10"
                    Width="100"
                    Height="100"
                    StrokeThickness="1"
                    Stroke="Black">
                    <Rectangle.Fill>
                        <DrawingBrush>
                            <DrawingBrush.Drawing>
                                <GeometryDrawing Brush="MediumBlue">
                                    <GeometryDrawing.Geometry>
                                        <GeometryGroup>
                                            <EllipseGeometry Center="0.5 0.5" RadiusX="0.2"  RadiusY="0.45" />
                                            <EllipseGeometry Center="0.5 0.5" RadiusX="0.45" RadiusY="0.2"  />
                                        </GeometryGroup>
                                    </GeometryDrawing.Geometry>
                                    <GeometryDrawing.Pen>
                                        <Pen
                                            Thickness="0.1"
                                            Brush="Black" />
                                    </GeometryDrawing.Pen>
                                </GeometryDrawing>
                            </DrawingBrush.Drawing>
                        </DrawingBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle
                    Margin="10"
                    Width="200"
                    Height="100"
                    StrokeThickness="1"
                    Stroke="Black">
                    <Rectangle.Fill>
                        <DrawingBrush>
                            <DrawingBrush.Drawing>
                                <GeometryDrawing Brush="MediumBlue">
                                    <GeometryDrawing.Geometry>
                                        <GeometryGroup>
                                            <EllipseGeometry Center="0.5 0.5" RadiusX="0.2"  RadiusY="0.45" />
                                            <EllipseGeometry Center="0.5 0.5" RadiusX="0.45" RadiusY="0.2"  />
                                        </GeometryGroup>
                                    </GeometryDrawing.Geometry>
                                    <GeometryDrawing.Pen>
                                        <Pen
                                            Thickness="0.1"
                                            Brush="Black" />
                                    </GeometryDrawing.Pen>
                                </GeometryDrawing>
                            </DrawingBrush.Drawing>
                        </DrawingBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle
                    Margin="10"
                    Width="100"
                    Height="200"
                    StrokeThickness="1"
                    Stroke="Black">
                    <Rectangle.Fill>
                        <DrawingBrush>
                            <DrawingBrush.Drawing>
                                <GeometryDrawing Brush="MediumBlue">
                                    <GeometryDrawing.Geometry>
                                        <GeometryGroup>
                                            <EllipseGeometry Center="0.5 0.5" RadiusX="0.2"  RadiusY="0.45" />
                                            <EllipseGeometry Center="0.5 0.5" RadiusX="0.45" RadiusY="0.2"  />
                                        </GeometryGroup>
                                    </GeometryDrawing.Geometry>
                                    <GeometryDrawing.Pen>
                                        <Pen
                                            Thickness="0.1"
                                            Brush="Black" />
                                    </GeometryDrawing.Pen>
                                </GeometryDrawing>
                            </DrawingBrush.Drawing>
                        </DrawingBrush>
                    </Rectangle.Fill>
                </Rectangle>
            </StackPanel>
        </StackPanel>
    </StackPanel>
</Window>
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요