using Windows.Foundation;
using Windows.UI;
using Windows.UI.Core;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
namespace TestProject
{
/// <summary>
/// 메인 페이지
/// </summary>
public sealed partial class MainPage : Page
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region Field
/// <summary>
/// 색상
/// </summary>
private Color color;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainPage
/// <summary>
/// 생성자
/// </summary>
public MainPage()
{
this.InitializeComponent();
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
#region 버튼 클릭시 처리하기 - button_Click(sender, e)
/// <summary>
/// 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void button_Click(object sender, RoutedEventArgs e)
{
MessageDialog messageDialog = new MessageDialog("색상을 선택해 주시기 바랍니다.", "색상 선택");
messageDialog.Commands.Add(new UICommand("빨강", null, Colors.Red ));
messageDialog.Commands.Add(new UICommand("녹색", null, Colors.Green));
messageDialog.Commands.Add(new UICommand("파랑", null, Colors.Blue ));
IAsyncOperation<IUICommand> asyncOperation = messageDialog.ShowAsync();
asyncOperation.Completed = messageDialog_asyncOperation_Completed;
}
#endregion
#region 메시지 대화 상자 비동기 작업 완료시 처리하기 - messageDialog_asyncOperation_Completed(asyncOperation, asyncStatus)
/// <summary>
/// 메시지 대화 상자 비동기 작업 완료시 처리하기
/// </summary>
/// <param name="asyncOperation">비동기 작업</param>
/// <param name="asyncStatus">비동기 상태</param>
private void messageDialog_asyncOperation_Completed(IAsyncOperation<IUICommand> asyncOperation, AsyncStatus asyncStatus)
{
IUICommand uiCommand = asyncOperation.GetResults();
this.color = (Color)uiCommand.Id;
IAsyncAction asyncAction = this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, dispatcherRunAsyncCallback);
}
#endregion
#region 디스패처 비동기 콜백 처리하기 - dispatcherRunAsyncCallback()
/// <summary>
/// 디스패처 비동기 콜백 처리하기
/// </summary>
private void dispatcherRunAsyncCallback()
{
this.contentGrid.Background = new SolidColorBrush(this.color);
}
#endregion
}
}