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

TestProject.zip
다운로드

▶ MainWindow.xaml.cs

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

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

        #region 생성자 - MainWindow()

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

            this.openButton.Click += openButton_Click;
        }

        #endregion

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

        #region 듀얼 모니터 보조 화면 창 열기 버튼 클릭시 처리하기 - openButton_Click(sender, e)

        /// <summary>
        /// 듀얼 모니터 보조 화면 창 열기 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void openButton_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Rectangle rectangle = System.Windows.Forms.Screen.AllScreens[1].WorkingArea;

            Window window = new Window();

            window.Left                  = rectangle.Left;
            window.Top                   = rectangle.Top;
            window.Width                 = rectangle.Width;
            window.Height                = rectangle.Height;
            window.WindowStartupLocation = WindowStartupLocation.Manual;
            window.WindowState           = WindowState.Normal;
            window.WindowStyle           = WindowStyle.None;
            window.Topmost               = true;
            window.Owner                 = this;
            window.FontFamily            = new FontFamily("나눔고딕코딩");
            window.FontSize              = 16;

            Grid grid = new Grid();

            window.Content = grid;

            Button closeButton = new Button();

            closeButton.HorizontalAlignment = HorizontalAlignment.Center;
            closeButton.VerticalAlignment   = VerticalAlignment.Center;
            closeButton.Width               = 100;
            closeButton.Height              = 30;
            closeButton.Content             = "닫기";

            closeButton.Click += closeButton_Click;

            grid.Children.Add(closeButton);

            window.Show();

            window.WindowState = WindowState.Maximized;
        }

        #endregion
        #region 닫기 버튼 클릭시 처리하기 - closeButton_Click(sender, e)

        /// <summary>
        /// 닫기 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void closeButton_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            ((button.Parent as Grid).Parent as Window).Close();
        }

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

댓글을 달아 주세요