当前位置: 首页>>代码示例>>C#>>正文


C# MessageBoxButton.HasFlag方法代码示例

本文整理汇总了C#中MessageBoxButton.HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C# MessageBoxButton.HasFlag方法的具体用法?C# MessageBoxButton.HasFlag怎么用?C# MessageBoxButton.HasFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MessageBoxButton的用法示例。


在下文中一共展示了MessageBoxButton.HasFlag方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowAsync

		public static async Task<MessageBoxResult> ShowAsync ( string messageBoxText,
															 string caption,
															 MessageBoxButton button )
		{

			MessageDialog md = new MessageDialog ( messageBoxText, caption );
			MessageBoxResult result = MessageBoxResult.None;
			if ( button.HasFlag ( MessageBoxButton.OK ) )
			{
				md.Commands.Add ( new UICommand ( "OK",
					new UICommandInvokedHandler ( ( cmd ) => result = MessageBoxResult.OK ) ) );
			}
			if ( button.HasFlag ( MessageBoxButton.Yes ) )
			{
				md.Commands.Add ( new UICommand ( "Yes",
					new UICommandInvokedHandler ( ( cmd ) => result = MessageBoxResult.Yes ) ) );
			}
			if ( button.HasFlag ( MessageBoxButton.No ) )
			{
				md.Commands.Add ( new UICommand ( "No",
					new UICommandInvokedHandler ( ( cmd ) => result = MessageBoxResult.No ) ) );
			}
			if ( button.HasFlag ( MessageBoxButton.Cancel ) )
			{
				md.Commands.Add ( new UICommand ( "Cancel",
					new UICommandInvokedHandler ( ( cmd ) => result = MessageBoxResult.Cancel ) ) );
				md.CancelCommandIndex = ( uint ) md.Commands.Count - 1;
			}
			var op = await md.ShowAsync ();
			return result;
		}
开发者ID:Daramkun,项目名称:LangTrans,代码行数:31,代码来源:Helper.cs

示例2: ShowAsync

        public static async Task<MessageBoxResult> ShowAsync(string messageBoxText,
            string caption,
            MessageBoxButton button = MessageBoxButton.Ok)
        {
            var result = MessageBoxResult.None;
            var md = new MessageDialog(messageBoxText, caption);

            if (button.HasFlag(MessageBoxButton.Ok))
            {
                md.Commands.Add(new UICommand("OK",
                    cmd => result = MessageBoxResult.Ok));
            }
            if (button.HasFlag(MessageBoxButton.Yes))
            {
                md.Commands.Add(new UICommand("Yes",
                    cmd => result = MessageBoxResult.Yes));
            }
            if (button.HasFlag(MessageBoxButton.No))
            {
                md.Commands.Add(new UICommand("No",
                    cmd => result = MessageBoxResult.No));
            }
            if (button.HasFlag(MessageBoxButton.Cancel))
            {
                md.Commands.Add(new UICommand("Cancel",
                    cmd => result = MessageBoxResult.Cancel));
                md.CancelCommandIndex = (uint) md.Commands.Count - 1;
            }
            try
            {
                await md.ShowAsync();
            }
            catch (UnauthorizedAccessException) { }
            return result;
        }
开发者ID:jayharry28,项目名称:Audiotica,代码行数:35,代码来源:MessageBox.cs

示例3: ShowAsync

        public static async Task<MessageBoxResult> ShowAsync(string messageBoxText,
                                                             string caption,
                                                             MessageBoxButton button)
        {
            var dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
            var result = MessageBoxResult.None;
            await dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                async () =>
                {
                    var md = new MessageDialog(messageBoxText, caption);

                    if (button.HasFlag(MessageBoxButton.Ok))
                    {
                        md.Commands.Add(new UICommand("OK",
                            cmd => result = MessageBoxResult.Ok));
                    }
                    if (button.HasFlag(MessageBoxButton.Yes))
                    {
                        md.Commands.Add(new UICommand("Yes",
                            cmd => result = MessageBoxResult.Yes));
                    }
                    if (button.HasFlag(MessageBoxButton.No))
                    {
                        md.Commands.Add(new UICommand("No",
                            cmd => result = MessageBoxResult.No));
                    }
                    if (button.HasFlag(MessageBoxButton.Cancel))
                    {
                        md.Commands.Add(new UICommand("Cancel",
                            cmd => result = MessageBoxResult.Cancel));
                        md.CancelCommandIndex = (uint) md.Commands.Count - 1;
                    }
                    await md.ShowAsync();
                });
            return result;
        }
开发者ID:haroldma,项目名称:DogeMuch,代码行数:36,代码来源:MessageBox.cs


注:本文中的MessageBoxButton.HasFlag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。