첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
본 블로그는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 블로그 콘텐츠 향상을 위해 쓰여집니다.

728x90
반응형
728x170

TestProject.zip
다운로드

▶ 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"
    Width="800"
    Height="600"
    Title="ScaleTransform 클래스 사용하기"
    FontFamily="나눔고딕코딩"
    FontSize="12">
    <Window.Resources>
        <DrawingBrush x:Key="BlueGridDrawingBrushKey"
            ViewportUnits="Absolute"
            Viewport="0 0 10 10"
            TileMode="Tile">
            <DrawingBrush.Drawing>
                <DrawingGroup>
                    <DrawingGroup.Children>
                        <GeometryDrawing Brush="White">
                            <GeometryDrawing.Geometry>
                                <RectangleGeometry Rect="0 0 1 1" />
                            </GeometryDrawing.Geometry>
                        </GeometryDrawing>
                        <GeometryDrawing
                            Geometry="M 0 0 L 1 0 1 0.1 0 0.1 Z"
                            Brush="#ccccff" />
                        <GeometryDrawing
                            Geometry="M 0 0 L 0 1 0.1 1 0.1 0 Z"
                            Brush="#ccccff" />
                    </DrawingGroup.Children>
                </DrawingGroup>
            </DrawingBrush.Drawing>
        </DrawingBrush>
        <Style TargetType="{x:Type Border}">
            <Setter Property="BorderThickness" Value="1"     />
            <Setter Property="BorderBrush"     Value="Black" />
        </Style>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="Padding"    Value="5"    />
            <Setter Property="FontWeight" Value="Bold" />
        </Style>
        <Style TargetType="{x:Type Rectangle}" x:Key="MarkerRectangleStyle">
            <Setter Property="Canvas.Left"     Value="100"       />
            <Setter Property="Canvas.Top"      Value="100"       />
            <Setter Property="Width"           Value="50"        />
            <Setter Property="Height"          Value="50"        />
            <Setter Property="StrokeThickness" Value="2"         />
            <Setter Property="StrokeDashArray" Value="4 1"       />
            <Setter Property="Stroke"          Value="#99000000" />
        </Style>
    </Window.Resources>
    <Border Margin="10">
        <ScrollViewer>
            <WrapPanel Margin="10">
                <Border Margin="10"
                    Background="{StaticResource BlueGridDrawingBrushKey}">
                    <Canvas Width="250" Height="250">
                        <TextBlock>
                            확대/축소 미적용
                        </TextBlock>
                        <Rectangle Canvas.Left="100" Canvas.Top="100"
                            Width="50"
                            Height="50"
                            Fill="#ccccccff" />
                    </Canvas>
                </Border>
                <Border Margin="10"
                    Background="{StaticResource BlueGridDrawingBrushKey}">
                    <Canvas Width="250" Height="250">
                        <TextBlock>
                            X축 확대/축소 : 2<LineBreak />
                            Y축 확대/축소 : 2<LineBreak />
                            중심 : (0, 0)
                        </TextBlock>
                        <Rectangle Canvas.Left="100" Canvas.Top="100"
                            Width="50"
                            Height="50"
                            StrokeThickness="2"
                            Stroke="Blue"
                            Fill="#ccccccff">
                            <Rectangle.RenderTransform>
                                <ScaleTransform
                                    CenterX="0"
                                    CenterY="0"
                                    ScaleX="2"
                                    ScaleY="2" />
                            </Rectangle.RenderTransform>
                        </Rectangle>
                        <Rectangle Style="{StaticResource MarkerRectangleStyle}" />
                    </Canvas>
                </Border>
                <Border Margin="10"
                    Background="{StaticResource BlueGridDrawingBrushKey}">
                    <Canvas Width="250" Height="250">
                        <TextBlock>
                            X축 확대/축소 : 2<LineBreak />
                            Y축 확대/축소 : 2<LineBreak />
                            중심 : (25, 25)
                        </TextBlock>
                        <Rectangle Canvas.Left="100" Canvas.Top="100"
                            Width="50"
                            Height="50"
                            StrokeThickness="2"
                            Stroke="Blue"
                            Fill="#ccccccff">
                            <Rectangle.RenderTransform>
                                <ScaleTransform
                                    CenterX="25"
                                    CenterY="25"
                                    ScaleX="2"
                                    ScaleY="2" />
                            </Rectangle.RenderTransform>
                        </Rectangle>
                        <Rectangle Style="{StaticResource MarkerRectangleStyle}" />
                    </Canvas>
                </Border>
                <Border Margin="10"
                    Background="{StaticResource BlueGridDrawingBrushKey}">
                    <Canvas Width="250" Height="250">
                        <TextBlock>
                            X축 확대/축소 : 0.5<LineBreak />
                            Y축 확대/축소 : 0.5<LineBreak />
                            중심 : (25, 25)
                        </TextBlock>
                        <Rectangle Canvas.Left="100" Canvas.Top="100"
                            Width="50"
                            Height="50"
                            StrokeThickness="2"
                            Stroke="Blue"
                            Fill="#ccccccff">
                            <Rectangle.RenderTransform>
                                <ScaleTransform
                                    CenterX="25"
                                    CenterY="25"
                                    ScaleX="0.5"
                                    ScaleY="0.5" />
                            </Rectangle.RenderTransform>
                        </Rectangle>
                        <Rectangle Style="{StaticResource MarkerRectangleStyle}" />
                    </Canvas>
                </Border>
                <Border Margin="10"
                    Background="{StaticResource BlueGridDrawingBrushKey}">
                    <Canvas Width="250" Height="250">
                        <TextBlock>
                            X축 확대/축소 : 2<LineBreak />
                            Y축 확대/축소 : 2<LineBreak />
                            중심 : (50%, 50%)
                        </TextBlock>
                        <Rectangle Canvas.Left="100" Canvas.Top="100"
                            Width="50"
                            Height="50"
                            Stroke="Blue"
                            StrokeThickness="2"
                            Fill="#ccccccff"
                            RenderTransformOrigin="0.5 0.5">
                            <Rectangle.RenderTransform>
                                <ScaleTransform
                                    ScaleX="2"
                                    ScaleY="2" />
                            </Rectangle.RenderTransform>
                        </Rectangle>
                        <Rectangle Style="{StaticResource MarkerRectangleStyle}" />
                    </Canvas>
                </Border>
                <Border Margin="10"
                    Background="{StaticResource BlueGridDrawingBrushKey}">
                    <Canvas Width="250" Height="250">
                        <TextBlock>
                            X축 확대/축소 : 2<LineBreak />
                            Y축 확대/축소 : 2<LineBreak />
                            중심 : (25%, 25%)
                        </TextBlock>
                        <Rectangle Canvas.Left="100" Canvas.Top="100"
                            Width="50" 
                            Height="50"
                            StrokeThickness="2"
                            Stroke="Blue"
                            Fill="#ccccccff"
                            RenderTransformOrigin="0.25 0.25">
                            <Rectangle.RenderTransform>
                                <ScaleTransform
                                    ScaleX="2"
                                    ScaleY="2" />
                            </Rectangle.RenderTransform>
                        </Rectangle>
                        <Rectangle Style="{StaticResource MarkerRectangleStyle}" />
                    </Canvas>
                </Border>
            </WrapPanel>
        </ScrollViewer>
    </Border>
</Window>
728x90
반응형
그리드형
Posted by 사용자 icodebroker
TAG , , ,

댓글을 달아 주세요