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

TestProject.zip
0.04MB

▶ NotifyType.cs

namespace TestProject
{
    /// <summary>
    /// 통지 타입
    /// </summary>
    public enum NotifyType
    {
        /// <summary>
        /// 상태 메시지
        /// </summary>
        StatusMessage,

        /// <summary>
        /// 에러 메시지
        /// </summary>
        ErrorMessage
    };
}

 

728x90

 

▶ Scenario.cs

using System;

namespace TestProject
{
    /// <summary>
    /// 시나리오
    /// </summary>
    public class Scenario
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 제목 - Title

        /// <summary>
        /// 제목
        /// </summary>
        public string Title { get; set; }

        #endregion
        #region 클래스 타입 - ClassType

        /// <summary>
        /// 클래스 타입
        /// </summary>
        public Type ClassType { get; set; }

        #endregion
    }
}

 

300x250

 

▶ SamplePage1.xaml

<Page x:Class="TestProject.SamplePage1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <ScrollViewer Margin="10">
            <StackPanel>
                <TextBlock
                    Style="{StaticResource ScenarioDescriptionTextStyle}"
                    TextWrapping="Wrap">
                    달력 표시하기
                </TextBlock>
                <TextBlock
                    Style="{StaticResource BasicTextStyle}"
                    HorizontalAlignment="Left"
                    Margin="0 10 0 0"
                    TextWrapping="Wrap">
현재 날짜 및 시간에 대한 사용자의 디폴트 설정 또는 특정 재정의를 기반으로 달력을 생성합니다.
3 가지 예제 달력의 세부 정보가 아래에 표시됩니다.
                </TextBlock>
                <Button
                    Margin="0 10 0 0"
                    Content="결과 표시"
                    Click="showResultButton_Click" />
                <TextBlock Name="resultTextBlock"
                    Style="{StaticResource BasicTextStyle}"
                    Margin="0 10 0 0"
                    TextWrapping="Wrap" />
            </StackPanel>
        </ScrollViewer>
    </Grid>
</Page>

 

▶ SamplePage1.xaml.cs

using System.Text;
using Windows.Globalization;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace TestProject
{
    /// <summary>
    /// 샘플 페이지 1
    /// </summary>
    public sealed partial class SamplePage1 : Page
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - SamplePage1()

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

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

        #region 결과 표시 버튼 클릭시 처리하기 - showResultButton_Click(sender, e)

        /// <summary>
        /// 결과 표시 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void showResultButton_Click(object sender, RoutedEventArgs e)
        {
            Calendar calendar = new Calendar();

            Calendar japaneseCalendar = new Calendar
            (
                new[] { "ja-JP" },
                CalendarIdentifiers.Japanese,
                ClockIdentifiers.TwelveHour
            );

            Calendar hebrewCalendar = new Calendar
            (
                new[] { "he-IL" },
                CalendarIdentifiers.Hebrew,
                ClockIdentifiers.TwentyFourHour
            );

            this.resultTextBlock.Text = ReportCalendarData(calendar        , "사용자 디폴트 달력 시스템") +
                                        ReportCalendarData(japaneseCalendar, "달력 시스템"              ) +
                                        ReportCalendarData(hebrewCalendar  , "달력 시스템"              );
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////// Function

        #region 달력 데이터 보고하기 - ReportCalendarData(calendar, calendarLabel)

        /// <summary>
        /// 달력 데이터 보고하기
        /// </summary>
        /// <param name="calendar">달력</param>
        /// <param name="calendarLabel">달력 레이블</param>
        /// <returns>달력 데이터</returns>
        private string ReportCalendarData(Calendar calendar, string calendarLabel)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine($"{calendarLabel} : {calendar.GetCalendarSystem()}");
            stringBuilder.AppendLine($"연도 : {calendar.YearAsString()}");
            stringBuilder.AppendLine($"월 : {calendar.MonthAsSoloString()}");
            stringBuilder.AppendLine($"일 : {calendar.DayAsPaddedString(2)}");
            stringBuilder.AppendLine($"요일 : {calendar.DayOfWeekAsSoloString()}");
            stringBuilder.AppendLine();

            return stringBuilder.ToString();
        }

        #endregion
    }
}

 

▶ SamplePage2.xaml

<Page x:Class="TestProject.SamplePage2"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <ScrollViewer Margin="10">
            <StackPanel>
                <TextBlock
                    Style="{StaticResource ScenarioDescriptionTextStyle}"
                    TextWrapping="Wrap">
                    달력 통계 가져오기
                </TextBlock>
                <TextBlock
                    Style="{StaticResource BasicTextStyle}"
                    HorizontalAlignment="Left"
                    Margin="0 10 0 0"
                    TextWrapping="Wrap">
                    현재 달력 날짜 및 시간에 대한 통계를 결정합니다.
                </TextBlock>
                <Button
                    Margin="0 10 0 0"
                    Content="결과 표시"
                    Click="showResultButton_Click" />
                <TextBlock Name="resultTextBlock"
                    Style="{StaticResource BasicTextStyle}"
                    Margin="0 10 0 0"
                    TextWrapping="Wrap" />
            </StackPanel>
        </ScrollViewer>
    </Grid>
</Page>

 

▶ SamplePage2.xaml.cs

using System.Text;
using Windows.Globalization;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace TestProject
{
    /// <summary>
    /// 샘플 페이지 2
    /// </summary>
    public sealed partial class SamplePage2 : Page
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - SamplePage2()

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

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

        #region 결과 표시 버튼 클릭시 처리하기 - showResultButton_Click(sender, e)

        /// <summary>
        /// 결과 표시 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void showResultButton_Click(object sender, RoutedEventArgs e)
        {
            Calendar calendar = new Calendar();

            Calendar japaneseCalendar = new Calendar
            (
                new[] { "ja-JP" },
                CalendarIdentifiers.Japanese,
                ClockIdentifiers.TwelveHour
            );

            Calendar hebrewCalendar = new Calendar
            (
                new[] { "he-IL" },
                CalendarIdentifiers.Hebrew,
                ClockIdentifiers.TwentyFourHour
            );

            this.resultTextBlock.Text = ReportCalendarData(calendar        , "사용자 디폴트 달력 시스템") +
                                        ReportCalendarData(japaneseCalendar, "달력 시스템"              ) +
                                        ReportCalendarData(hebrewCalendar  , "달력 시스템"              );
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////// Function

        #region 달력 데이터 보고하기 - ReportCalendarData(calendar, calendarLabel)

        /// <summary>
        /// 달력 데이터 보고하기
        /// </summary>
        /// <param name="calendar">달력</param>
        /// <param name="calendarLabel">달력 레이블</param>
        /// <returns>달력 데이터</returns>
        private string ReportCalendarData(Calendar calendar, string calendarLabel)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine($"{calendarLabel} : {calendar.GetCalendarSystem()}");
            stringBuilder.AppendLine($"당해 연도 월 수 : {calendar.NumberOfMonthsInThisYear}");
            stringBuilder.AppendLine($"당월 일 수 : {calendar.NumberOfDaysInThisMonth}");
            stringBuilder.AppendLine($"당해 기간의 시간 : {calendar.NumberOfHoursInThisPeriod}");
            stringBuilder.AppendLine($"연대 : {calendar.EraAsString()}");
            stringBuilder.AppendLine();

            return stringBuilder.ToString();
        }

        #endregion
    }
}

 

▶ SamplePage3.xaml

<Page x:Class="TestProject.SamplePage3"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <ScrollViewer Margin="10">
            <StackPanel>
                <TextBlock
                    Style="{StaticResource ScenarioDescriptionTextStyle}"
                    TextWrapping="Wrap">
                    달력 열거 및 계산
                </TextBlock>
                <TextBlock
                    Style="{StaticResource BasicTextStyle}"
                    HorizontalAlignment="Left"
                    Margin="0 10 0 0"
                    TextWrapping="Wrap">
                    달력을 열거하고 달력 계산을 수행합니다.
                </TextBlock>
                <TextBlock
                    Style="{StaticResource BasicTextStyle}"
                    HorizontalAlignment="Left"
                    Margin="0 10 0 0"
                    TextWrapping="Wrap">
달력은 일광 절약 시간 및 윤년과 같은 항목에 대한 주기적 조정을 포함하는 현지 표준 시간대 정보를 사용합니다.
필요한 경우 열거하면 다양한 달력 기간의 기간에 대한 가정을 피하는 데 도움이 됩니다.
                </TextBlock>
                <TextBlock
                    Style="{StaticResource BasicTextStyle}"
                    HorizontalAlignment="Left"
                    Margin="0 10 0 0"
                    TextWrapping="Wrap">
달력 계산은 시스템의 현지 시간에 따라 다른 결과를 생성할 수 있습니다.
따라서 Calendar 클래스를 사용하는 코드는 사용할 수 있는 다양한 시간대와 날짜 범위에서 테스트해야 합니다.
                </TextBlock>
                <Button
                    Margin="0 10 0 0"
                    Content="결과 표시"
                    Click="showResultButton_Click"/>
                <TextBlock Name="resultTextBlock"
                    Style="{StaticResource BasicTextStyle}"
                    Margin="0 10 0 0"
                    TextWrapping="Wrap" />
            </StackPanel>
        </ScrollViewer>
    </Grid>
</Page>

 

▶ SamplePage3.xaml.cs

using System;
using System.Text;
using Windows.Globalization;
using Windows.Globalization.DateTimeFormatting;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace TestProject
{
    /// <summary>
    /// 샘플 페이지 3
    /// </summary>
    public sealed partial class SamplePage3 : Page
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - SamplePage3()

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

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

        #region 결과 표시 버튼 클릭시 처리하기 - showResultButton_Click(sender, e)

        /// <summary>
        /// 결과 표시 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void showResultButton_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine
            (
                "일본 연호 달력의 각 연도는 일정하지 않습니다. 주어진 제국 연대의 길이에 따라 결정됩니다 : "
            );

            stringBuilder.AppendLine();

            Calendar calendar = new Calendar
            (
                new[] { "en-US" },
                CalendarIdentifiers.Japanese,
                ClockIdentifiers.TwentyFourHour
            );

            for(calendar.Era = calendar.FirstEra; true; calendar.AddYears(1))
            {
                stringBuilder.AppendLine($"연대 {calendar.EraAsString()} : {calendar.NumberOfYearsInThisEra}년");

                for(calendar.Year = calendar.FirstYearInThisEra; true; calendar.AddYears(1))
                {
                    calendar.Month      = calendar.FirstMonthInThisYear;
                    calendar.Day        = calendar.FirstDayInThisMonth;
                    calendar.Period     = calendar.FirstPeriodInThisDay;
                    calendar.Hour       = calendar.FirstHourInThisPeriod;
                    calendar.Minute     = 0;
                    calendar.Second     = 0;
                    calendar.Nanosecond = 0;

                    if(calendar.Year % 1000 == 0)
                    {
                        stringBuilder.AppendLine();
                    }
                    else if(calendar.Year % 10 == 0)
                    {
                        stringBuilder.Append(".");
                    }

                    if(calendar.Year == calendar.LastYearInThisEra)
                    {
                        break;
                    }
                }

                stringBuilder.AppendLine();

                if(calendar.Era == calendar.LastEra)
                {
                    break;
                }
            }

            stringBuilder.AppendLine();

            stringBuilder.AppendLine("하루의 시간 수는 일정하지 않습니다. 2012년 11월 4일 미국 달력이 일광 절약 시간에서 표준 시간으로 전환됩니다 :\n");

            DateTimeFormatter formatter = new DateTimeFormatter("longdate");

            Calendar startCalendar = new Calendar
            (
                new string[] { "en-US" },
                CalendarIdentifiers.Gregorian,
                ClockIdentifiers.TwentyFourHour,
                "America/Los_Angeles"
            );

            DateTime targetDate = new DateTime(2012, 11, 4, 9, 0, 0, DateTimeKind.Utc);

            startCalendar.SetDateTime(targetDate);

            Calendar endCalendar = startCalendar.Clone();

            startCalendar.AddDays(-1);

            endCalendar.AddDays(1);

            while(startCalendar.Day <= endCalendar.Day)
            {
                DateTimeOffset date = startCalendar.GetDateTime();

                stringBuilder.AppendFormat("{0} : {1}시간\n", formatter.Format(date), startCalendar.NumberOfHoursInThisPeriod);

                Calendar nextCalendar = startCalendar.Clone();

                nextCalendar.AddDays(1);

                for(startCalendar.Hour = startCalendar.FirstHourInThisPeriod; true; startCalendar.AddHours(1))
                {
                    stringBuilder.AppendFormat("{0} ", startCalendar.HourAsPaddedString(2));

                    if(startCalendar.Day == nextCalendar.Day && startCalendar.Period == nextCalendar.Period)
                    {
                        break;
                    }
                }

                stringBuilder.AppendLine();
            }

            this.resultTextBlock.Text = stringBuilder.ToString();
        }

        #endregion
    }
}

 

▶ SamplePage4.xaml

<Page x:Class="TestProject.SamplePage4"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <ScrollViewer Margin="10">
            <StackPanel>
                <TextBlock
                    Style="{StaticResource ScenarioDescriptionTextStyle}"
                    TextWrapping="Wrap">
                    언어별 유니코드 확장을 갖는 달력
                </TextBlock>
                <TextBlock
                    Style="{StaticResource BasicTextStyle}"
                    HorizontalAlignment="Left"
                    Margin="0 10 0 0"
                    TextWrapping="Wrap">
지원되는 유니코드 확장 태그가 있는 언어 이름을 사용하여 캘린더를 만들고 캘린더 개체에서 확장 태그를 사용하는 방법을 보여줍니다.
                </TextBlock>
                <Button
                    Margin="0 10 0 0"
                    Content="결과 표시"
                    Click="showResultButton_Click" />
                <TextBlock Name="resultTextBlock"
                    Style="{StaticResource BasicTextStyle}"
                    Margin="0 10 0 0"
                    TextWrapping="Wrap" />
            </StackPanel>
        </ScrollViewer>
    </Grid>
</Page>

 

▶ SamplePage4.xaml.cs

using System.Text;
using Windows.Globalization;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace TestProject
{
    /// <summary>
    /// 샘플 페이지 4
    /// </summary>
    public sealed partial class SamplePage4 : Page
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - SamplePage4()

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

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

        #region 결과 표시 버튼 클릭시 처리하기 - showResultButton_Click(sender, e)

        /// <summary>
        /// 결과 표시 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void showResultButton_Click(object sender, RoutedEventArgs e)
        {
            Calendar calendar1 = new Calendar();
            Calendar calendar2 = new Calendar(new[] { "ar-SA-u-ca-gregory-nu-Latn"   });
            Calendar calendar3 = new Calendar(new[] { "he-IL-u-nu-arab"              });
            Calendar calendar4 = new Calendar(new[] { "he-IL-u-ca-hebrew-co-phonebk" });

            this.resultTextBlock.Text =
                ReportCalendarData
                (
                    calendar1,
                    "사용자 디폴트 달력 객체"
                ) +
                ReportCalendarData
                (
                    calendar2,
                    "아랍어, 그레고리력 및 라틴 숫자 체계(ar-SA-ca-gregory-nu-Latn)를 갖는 달력 객체"
                ) +
                ReportCalendarData
                (
                    calendar3,
                    "히브리어, 해당 언어의 기본 달력 및 아랍 숫자 체계(he-IL-u-nu-arab)를 갖는 달력 객체"
                ) +
                ReportCalendarData
                (
                    calendar4,
                    "히브리어, 히브리어 달력, 해당 언어에 대한 기본 숫자 체계 및 전화번호부 데이터 정렬(he-IL-u-ca-hebrew-co-phonebk)을 갖는 달력 개체"
                );
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////// Function

        #region 달력 데이터 보고하기 - ReportCalendarData(calendar, calendarLabel)

        /// <summary>
        /// 달력 데이터 보고하기
        /// </summary>
        /// <param name="calendar">달력</param>
        /// <param name="calendarLabel">달력 레이블</param>
        /// <returns>달력 데이터</returns>
        private string ReportCalendarData(Calendar calendar, string calendarLabel)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine($"{calendarLabel} : {calendar.GetCalendarSystem()}");
            stringBuilder.AppendLine($"달력 : {calendar.GetCalendarSystem()}");
            stringBuilder.AppendLine($"숫자 시스템 : {calendar.NumeralSystem}");
            stringBuilder.AppendLine($"결정 언어 : {calendar.ResolvedLanguage}");
            stringBuilder.AppendLine($"연도 : {calendar.YearAsString()}");
            stringBuilder.AppendLine($"월 : {calendar.MonthAsSoloString()}");
            stringBuilder.AppendLine($"일 : {calendar.DayAsPaddedString(2)}");
            stringBuilder.AppendLine($"요일 : {calendar.DayOfWeekAsSoloString()}");
            stringBuilder.AppendLine();

            return stringBuilder.ToString();
        }

        #endregion
    }
}

 

▶ SamplePage5.xaml

<Page x:Class="TestProject.SamplePage5"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <ScrollViewer Margin="10">
            <StackPanel>
                <TextBlock
                    Style="{StaticResource ScenarioDescriptionTextStyle}"
                    TextWrapping="Wrap">
                    달력 시간대 지원
                </TextBlock>
                <TextBlock
                    Style="{StaticResource BasicTextStyle}"
                    HorizontalAlignment="Left"
                    Margin="0 10 0 0"
                    TextWrapping="Wrap">
달력 내에서 여러 시간대를 설정하거나 가져오고 달력의 날짜 및 시간 속성에서 시간대 변경의 효과를 표시합니다.
                </TextBlock>
                <Button
                    Margin="0 10 0 0"
                    Content="결과 표시"
                    Click="showResultButton_Click" />
                <TextBlock Name="resultTextBlock"
                    Style="{StaticResource BasicTextStyle}"
                    Margin="0 10 0 0"
                    TextWrapping="Wrap" />
            </StackPanel>
        </ScrollViewer>
    </Grid>
</Page>

 

▶ SamplePage5.xaml.cs

using System.Text;
using Windows.Globalization;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace TestProject
{
    /// <summary>
    /// 샘플 페이지 5
    /// </summary>
    public sealed partial class SamplePage5 : Page
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - SamplePage5()

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

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private
        //////////////////////////////////////////////////////////////////////////////// Event

        #region 결과 표시 버튼 클릭시 처리하기 - showResultButton_Click(sender, e)

        /// <summary>
        /// 결과 표시 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void showResultButton_Click(object sender, RoutedEventArgs e)
        {
            string[] timeZoneArray = new[] { "UTC", "America/New_York", "Asia/Kolkata" };

            StringBuilder stringBuilder = new StringBuilder();

            Calendar calendar = new Calendar();

            string localTimeZone = calendar.GetTimeZone();

            stringBuilder.AppendLine("현재 날짜 및 시각 :");
            stringBuilder.AppendLine(ReportCalendarData(calendar));

            foreach(string timeZone in timeZoneArray)
            {
                calendar.ChangeTimeZone(timeZone);

                stringBuilder.AppendLine(ReportCalendarData(calendar));
            }

            stringBuilder.AppendLine();

            calendar.ChangeTimeZone(localTimeZone);

            stringBuilder.AppendLine("내년 2월 14일의 같은 시각 : ");

            calendar.AddYears(1);
            
            calendar.Month = 2;
            calendar.Day   = 14;

            stringBuilder.AppendLine(ReportCalendarData(calendar));

            foreach(string timeZone in timeZoneArray)
            {
                calendar.ChangeTimeZone(timeZone);

                stringBuilder.AppendLine(ReportCalendarData(calendar));
            }

            stringBuilder.AppendLine();

            calendar.ChangeTimeZone(localTimeZone);

            stringBuilder.AppendLine("내년 10월 14일의 같은 시각 : ");

            calendar.AddMonths(8);

            stringBuilder.AppendLine(ReportCalendarData(calendar));

            foreach(string timeZone in timeZoneArray)
            {
                calendar.ChangeTimeZone(timeZone);

                stringBuilder.AppendLine(ReportCalendarData(calendar));
            }

            stringBuilder.AppendLine();

            this.resultTextBlock.Text = stringBuilder.ToString();
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////// Function

        #region 달력 데이터 보고하기 - ReportCalendarData(calendar)

        /// <summary>
        /// 달력 데이터 보고하기
        /// </summary>
        /// <param name="calendar">달력</param>
        /// <returns>달력 데이터</returns>
        private string ReportCalendarData(Calendar calendar)
        {
            return string.Format
            (
                "시간대 {0} : {1} {2} {3} {4} {5}:{6}:{7} {8} {9}",
                calendar.GetTimeZone(),
                calendar.YearAsString(),
                calendar.MonthAsSoloString(),
                calendar.DayAsPaddedString(2),
                calendar.DayOfWeekAsSoloString(),
                calendar.HourAsPaddedString(2),
                calendar.MinuteAsPaddedString(2),
                calendar.SecondAsPaddedString(2),
                calendar.PeriodAsString(),
                calendar.TimeZoneAsString(3)
            );
        }

        #endregion
    }
}

 

▶ 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"
    xmlns:local="using:TestProject"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*"    />
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0"
            Orientation="Horizontal">
            <Border Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}">
                <ToggleButton
                    Style="{StaticResource SymbolButton}"
                    VerticalAlignment="Center"
                    Foreground="{ThemeResource ApplicationForegroundThemeBrush}"
                    Click="paneToggleButton_Click">
                    <ToggleButton.Content>
                        <FontIcon
                            FontFamily="Segoe MDL2 Assets"
                            Glyph="&#xE700;" />
                    </ToggleButton.Content>
                </ToggleButton>
            </Border>
            <Image
                VerticalAlignment="Center"
                Margin="5 5 0 0"
                AutomationProperties.AccessibilityView="Raw"
                Stretch="None"
                Source="IMAGE/windows-sdk.png" />
            <TextBlock
                Style="{StaticResource TagLineTextStyle}"
                VerticalAlignment="Center"
                Margin="5 0 0 0"
                Text="유니버셜 윈도우즈 플랫폼" />
        </StackPanel>
        <SplitView Name="splitView" Grid.Row="1"
            DisplayMode="Inline"
            IsPaneOpen="True">
            <SplitView.Pane>
                <RelativePanel Margin="10 0 0 0">
                    <TextBlock Name="sampleTitle"
                        Style="{StaticResource SampleHeaderTextStyle}"
                        Margin="0 10 0 0"
                        TextWrapping="Wrap"
                        Text="C# 달력 예제" />
                    <ListBox Name="listBox"
                        RelativePanel.Below="sampleTitle"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        Margin="0 10 0 0"
                        BorderThickness="0"
                        Background="Transparent"
                        SelectionMode="Single"
                        SelectionChanged="listBox_SelectionChanged">
                        <ListBox.ItemTemplate>
                            <DataTemplate x:DataType="local:Scenario">
                                <TextBlock Text="{x:Bind Title}" />
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </RelativePanel>
            </SplitView.Pane>
            <Frame Name="frame"
                Margin="5" />
        </SplitView>
    </Grid>
</Page>

 

▶ MainPage.xaml.cs

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

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

        #region Field

        /// <summary>
        /// 시나리오 리스트
        /// </summary>
        private List<Scenario> scenarioList = new List<Scenario>
        {
            new Scenario() { Title = "달력 표시하기"                   , ClassType = typeof(SamplePage1) },
            new Scenario() { Title = "달력 통계 가져오기"              , ClassType = typeof(SamplePage2) },
            new Scenario() { Title = "달력 열거 및 계산"               , ClassType = typeof(SamplePage3) },
            new Scenario() { Title = "언어별 유니코드 확장을 갖는 달력", ClassType = typeof(SamplePage4) },
            new Scenario() { Title = "달력 시간대 지원"                , ClassType = typeof(SamplePage5) }
        };

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// 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 = "Calendar 클래스 사용하기";

            #endregion
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Protected

        #region 탐색되는 경우 처리하기 - OnNavigatedTo(e)

        /// <summary>
        /// 탐색되는 경우 처리하기
        /// </summary>
        /// <param name="e">이벤트 인자</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            List<Scenario> sourceList = new List<Scenario>();

            int i = 1;

            foreach(Scenario scenario in scenarioList)
            {
                sourceList.Add
                (
                    new Scenario
                    {
                        Title     = $"{i++}) {scenario.Title}",
                        ClassType = scenario.ClassType
                    }
                );
            }

            this.listBox.ItemsSource = sourceList;

            if(Window.Current.Bounds.Width < 640)
            {
                this.listBox.SelectedIndex = -1;
            }
            else
            {
                this.listBox.SelectedIndex = 0;
            }
        }

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 창 토글 버튼 클릭시 처리하기 - paneToggleButton_Click(sender, e)

        /// <summary>
        /// 창 토글 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void paneToggleButton_Click(object sender, RoutedEventArgs e)
        {
            this.splitView.IsPaneOpen = !splitView.IsPaneOpen;
        }

        #endregion
        #region 리스트 박스 선택 변경시 처리하기 - listBox_SelectionChanged(sender, e)

        /// <summary>
        /// 리스트 박스 선택 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListBox listBox = sender as ListBox;

            Scenario scenario = listBox.SelectedItem as Scenario;

            if(scenario != null)
            {
                this.frame.Navigate(scenario.ClassType);

                if(Window.Current.Bounds.Width < 640)
                {
                    this.splitView.IsPaneOpen = false;
                }
            }
        }

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