첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.

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="PathGeometry 클래스 : CreateFromGeometry 정적 메소드를 사용해 패스 지오메트리 구하기"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"    />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Border Grid.Row="0" Grid.Column="0"
            Margin="10"
            BorderBrush="Black"
            BorderThickness="1" />
        <Border Grid.Row="0" Grid.Column="1"
            Margin="10"
            BorderBrush="Black"
            BorderThickness="1" />
        <Path Name="sourcePath" Grid.Row="0" Grid.Column="0"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Stroke="Red"
            StrokeThickness="3">
            <Path.Data>
                <GeometryGroup>
                    <RectangleGeometry Rect="0 0 200 200" />
                    <EllipseGeometry
                        Center="100 100"
                        RadiusX="100"
                        RadiusY="100" />
                </GeometryGroup>
            </Path.Data>        
        </Path>
        <Path Name="targetPath" Grid.Row="0" Grid.Column="1"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Stroke="Blue"
            StrokeThickness="3">
        </Path>
        <Button Name="createButton" Grid.Row="1" Grid.Column="1"
            Margin="10"
            Width="100"
            Height="30"
            Content="생성하기" />
    </Grid>
</Window>

 

728x90

 

▶ MainWindow.xaml.cs

using System.Windows;
using System.Windows.Media;

namespace TestProject
{
    /// <summary>
    /// 메인 윈도우
    /// </summary>
    public partial class MainWindow : Window
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainWindow()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            this.createButton.Click += createButton_Click;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 생성하기 버튼 클릭시 처리하기 - createButton_Click(sender, e)

        /// <summary>
        /// 생성하기 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void createButton_Click(object sender, RoutedEventArgs e)
        {
            if(this.targetPath.Data == null)
            {
                GeometryGroup sourceGeometryGroup = this.sourcePath.Data as GeometryGroup;

                PathGeometry targetPathGeometry = PathGeometry.CreateFromGeometry(sourceGeometryGroup);

                this.targetPath.Data = targetPathGeometry;
            }
        }

        #endregion
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요