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

728x90
반응형

TestProject.zip
다운로드

▶ MainWindow.cs

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

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

        #region 생성자 - MainWindow()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainWindow()
        {
            Width      = 800;
            Height     = 600;
            Title      = "Menu 클래스 : 색상 그리드 박스 메뉴에서 색상 선택하기";
            FontFamily = new FontFamily("나눔고딕코딩");
            FontSize   = 16;

            DockPanel dockPanel = new DockPanel();

            Content = dockPanel;

            Menu menu = new Menu();

            dockPanel.Children.Add(menu);

            DockPanel.SetDock(menu, Dock.Top);

            TextBlock textBlock = new TextBlock();

            textBlock.Text          = "색상 선택하기";
            textBlock.FontSize      = 32;
            textBlock.TextAlignment = TextAlignment.Center;

            dockPanel.Children.Add(textBlock);

            #region Color 메뉴

            MenuItem colorMenuItem = new MenuItem();

            colorMenuItem.Header = "_Color";

            menu.Items.Add(colorMenuItem);

            #endregion
                #region Foreground 메뉴

                MenuItem foregroundMenuItem = new MenuItem();

                foregroundMenuItem.Header = "_Foreground";

                colorMenuItem.Items.Add(foregroundMenuItem);

                ColorGridBox foregroundColorGridBox = new ColorGridBox();

                foregroundColorGridBox.SetBinding(ColorGridBox.SelectedValueProperty, "Foreground");

                foregroundColorGridBox.DataContext = this;

                foregroundMenuItem.Items.Add(foregroundColorGridBox);

                #endregion
                #region Background 메뉴

                MenuItem backgroundMenuItem = new MenuItem();

                backgroundMenuItem.Header = "_Background";

                colorMenuItem.Items.Add(backgroundMenuItem);

                ColorGridBox backgroundColorGridBox = new ColorGridBox();

                backgroundColorGridBox.SetBinding(ColorGridBox.SelectedValueProperty, "Background");

                backgroundColorGridBox.DataContext = this;

                backgroundMenuItem.Items.Add(backgroundColorGridBox);

                #endregion
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Public

        #region 프로그램 시작하기 - Main()

        /// <summary>
        /// 프로그램 시작하기
        /// </summary>
        [STAThread]
        public static void Main()
        {
            Application application = new Application();

            application.Run(new MainWindow());
        }

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

댓글을 달아 주세요