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

TestProject.zip
0.02MB

▶ Language.cs

namespace TestProject
{
    /// <summary>
    /// 언어
    /// </summary>
    public class Language
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 명칭 - Name

        /// <summary>
        /// 명칭
        /// </summary>
        public string Name { get; set; }

        #endregion
        #region 코드 - Code

        /// <summary>
        /// 코드
        /// </summary>
        public string Code { get; set; }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - Language(name, code)

        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="name">명칭</param>
        /// <param name="code">코드</param>
        public Language(string name, string code)
        {
            Name = name;
            Code = code;
        }

        #endregion
    }
}

 

728x90

 

▶ LanguageList.cs

using System.Collections.Generic;

namespace TestProject
{
    /// <summary>
    /// 언어 리스트
    /// </summary>
    public class LanguageList : List<Language>
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - LanguageList()

        /// <summary>
        /// 생성자
        /// </summary>
        public LanguageList()
        {
            Add(new Language("English"             , "en" ));
            Add(new Language("Arabic"              , "ar" ));
            Add(new Language("Afrikaans"           , "af" ));
            Add(new Language("Albanian"            , "sq" ));
            Add(new Language("Amharic"             , "am" ));
            Add(new Language("Armenian"            , "hy" ));
            Add(new Language("Assamese"            , "as" ));
            Add(new Language("Azerbaijani"         , "az" ));
            Add(new Language("Basque "             , "eu" ));
            Add(new Language("Belarusian"          , "be" ));
            Add(new Language("Bangla"              , "bn" ));
            Add(new Language("Bosnian"             , "bs" ));
            Add(new Language("Bulgarian"           , "bg" ));
            Add(new Language("Catalan"             , "ca" ));
            Add(new Language("Chinese (Simplified)", "zh" ));
            Add(new Language("Croatian"            , "hr" ));
            Add(new Language("Czech"               , "cs" ));
            Add(new Language("Danish"              , "da" ));
            Add(new Language("Dari"                , "prs"));
            Add(new Language("Dutch"               , "nl" ));
            Add(new Language("Estonian"            , "et" ));
            Add(new Language("Filipino"            , "fil"));
            Add(new Language("Finnish"             , "fi" ));
            Add(new Language("French "             , "fr" ));
            Add(new Language("Galician"            , "gl" ));
            Add(new Language("Georgian"            , "ka" ));
            Add(new Language("German"              , "de" ));
            Add(new Language("Greek"               , "el" ));
            Add(new Language("Gujarati"            , "gu" ));
            Add(new Language("Hausa"               , "ha" ));
            Add(new Language("Hebrew"              , "he" ));
            Add(new Language("Hindi"               , "hi" ));
            Add(new Language("Hungarian"           , "hu" ));
            Add(new Language("Icelandic"           , "is" ));
            Add(new Language("Indonesian"          , "id" ));
            Add(new Language("Irish"               , "ga" ));
            Add(new Language("isiXhosa"            , "xh" ));
            Add(new Language("isiZulu"             , "zu" ));
            Add(new Language("Italian"             , "it" ));
            Add(new Language("Japanese "           , "ja" ));
            Add(new Language("Kannada"             , "kn" ));
            Add(new Language("Kazakh"              , "kk" ));
            Add(new Language("Khmer"               , "km" ));
            Add(new Language("Kinyarwanda"         , "rw" ));
            Add(new Language("KiSwahili"           , "sw" ));
            Add(new Language("Konkani"             , "kok"));
            Add(new Language("Korean"              , "ko" ));
            Add(new Language("Lao"                 , "lo" ));
            Add(new Language("Latvian"             , "lv" ));
            Add(new Language("Lithuanian"          , "lt" ));
            Add(new Language("Luxembourgish"       , "lb" ));
            Add(new Language("Macedonian"          , "mk" ));
            Add(new Language("Malay"               , "ms" ));
            Add(new Language("Malayalam"           , "ml" ));
            Add(new Language("Maltese"             , "mt" ));
            Add(new Language("Maori "              , "mi" ));
            Add(new Language("Marathi"             , "mr" ));
            Add(new Language("Nepali"              , "ne" ));
            Add(new Language("Norwegian"           , "nb" ));
            Add(new Language("Odia"                , "or" ));
            Add(new Language("Persian"             , "fa" ));
            Add(new Language("Polish"              , "pl" ));
            Add(new Language("Portuguese"          , "pt" ));
            Add(new Language("Punjabi"             , "pa" ));
            Add(new Language("Quechua"             , "quz"));
            Add(new Language("Romanian"            , "ro" ));
            Add(new Language("Russian"             , "ru" ));
            Add(new Language("Serbian (Latin)"     , "sr" ));
            Add(new Language("Sesotho sa Leboa"    , "nso"));
            Add(new Language("Setswana"            , "tn" ));
            Add(new Language("Sinhala"             , "si" ));
            Add(new Language("Slovak "             , "sk" ));
            Add(new Language("Slovenian"           , "sl" ));
            Add(new Language("Spanish"             , "es" ));
            Add(new Language("Swedish"             , "sv" ));
            Add(new Language("Tamil"               , "ta" ));
            Add(new Language("Telugu"              , "te" ));
            Add(new Language("Thai"                , "th" ));
            Add(new Language("Tigrinya"            , "ti" ));
            Add(new Language("Turkish"             , "tr" ));
            Add(new Language("Ukrainian"           , "uk" ));
            Add(new Language("Urdu"                , "ur" ));
            Add(new Language("Uzbek (Latin)"       , "uz" ));
            Add(new Language("Vietnamese"          , "vi" ));
            Add(new Language("Welsh"               , "cy" ));
            Add(new Language("Wolof"               , "wo" ));
        }

        #endregion
    }
}

 

300x250

 

▶ MainPage.xaml

<Page x:Class="TestProject.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Grid>
        <Grid
            HorizontalAlignment="Center"
            VerticalAlignment="Center">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="50"   />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <CalendarView Name="calendarView" Grid.Column="0"
                IsGroupLabelVisible="{x:Bind isGroupLabelVisibleCheckBox.IsChecked.Value, Mode=OneWay}"
                IsOutOfScopeEnabled="{x:Bind isOutOfScopeEnabledCheckBox.IsChecked.Value, Mode=OneWay}"
                CalendarIdentifier="{x:Bind calendarIdentifierComboBox.SelectedValue, Mode=OneWay}"
                SelectionMode="Single" />
            <StackPanel Grid.Column="2">
                <CheckBox Name="isGroupLabelVisibleCheckBox"
                    Content="IsGroupLabelVisible 속성"
                    IsChecked="True" />
                <CheckBox Name="isOutOfScopeEnabledCheckBox"
                    Content="IsOutOfScopeEnabled 속성"
                    IsChecked="True" />
                <ComboBox
                    Margin="0 10 0 0"
                    SelectedValue="Single"
                    Header="SelectionMode 속성"
                    SelectionChanged="selectionModeComboBox_SelectionChanged">
                    <x:String>None</x:String>
                    <x:String>Single</x:String>
                    <x:String>Multiple</x:String>
                </ComboBox>
                <ComboBox x:Name="calendarIdentifierComboBox"
                    Margin="0 10 0 0"
                    Width="220"
                    Header="CalendarIdentifier 속성" />
                <ComboBox Name="calendarLanguageComboBox"
                    Margin="0 10 0 0"
                    Width="220"
                    DisplayMemberPath="Name"
                    SelectedValuePath="Code"
                    SelectedIndex="0"
                    Header="Language 속성"
                    SelectionChanged="calendarLanguageComboBox_SelectionChanged" />
            </StackPanel>
        </Grid>
    </Grid>
</Page>

 

▶ MainPage.xaml.cs

using System;
using System.Collections.Generic;
using Windows.Foundation;
using Windows.Globalization;
using Windows.Graphics.Display;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace TestProject
{
    /// <summary>
    /// 메인 페이지
    /// </summary>
    public sealed partial class MainPage : Page
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainPage()

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

            #region 윈도우 크기를 설정한다.

            double width  = 800d;
            double height = 600d;

            double dpi = (double)DisplayInformation.GetForCurrentView().LogicalDpi;

            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;

            Size windowSize = new Size(width * 96d / dpi, height * 96d / dpi);

            ApplicationView.PreferredLaunchViewSize = windowSize;

            Window.Current.Activate();

            ApplicationView.GetForCurrentView().TryResizeView(windowSize);

            #endregion
            #region 윈도우 제목을 설정한다.

            ApplicationView.GetForCurrentView().Title = "CalendarView 엘리먼트 사용하기";

            #endregion

            List<string> calendarIdentifierList = new List<string>()
            {
                CalendarIdentifiers.Gregorian,
                CalendarIdentifiers.Hebrew,
                CalendarIdentifiers.Hijri,
                CalendarIdentifiers.Japanese,
                CalendarIdentifiers.Julian,
                CalendarIdentifiers.Korean,
                CalendarIdentifiers.Persian,
                CalendarIdentifiers.Taiwan,
                CalendarIdentifiers.Thai,
                CalendarIdentifiers.UmAlQura,
            };

            this.calendarIdentifierComboBox.ItemsSource  = calendarIdentifierList;
            this.calendarIdentifierComboBox.SelectedItem = CalendarIdentifiers.Gregorian;

            this.calendarLanguageComboBox.ItemsSource = new LanguageList();
        }

        #endregion

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

        #region 선택 모드 콤보 박스 선택 변경시 처리하기 - selectionModeComboBox_SelectionChanged(sender, e)

        /// <summary>
        /// 선택 모드 콤보 박스 선택 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void selectionModeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if(Enum.TryParse<CalendarViewSelectionMode>((sender as ComboBox).SelectedItem.ToString(), out CalendarViewSelectionMode selectionMode))
            {
                this.calendarView.SelectionMode = selectionMode;
            }
        }

        #endregion
        #region 달력 언어 콤보 박스 선택 변경시 처리하기 - calendarLanguageComboBox_SelectionChanged(sender, e)

        /// <summary>
        /// 달력 언어 콤보 박스 선택 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void calendarLanguageComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string language = this.calendarLanguageComboBox.SelectedValue.ToString();

            if(Windows.Globalization.Language.IsWellFormed("ko"))
            {
                this.calendarView.Language = language;
            }
        }

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

댓글을 달아 주세요