• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# MessageBoxButton类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Show

 public static MessageBoxResult Show(
     string messageBoxText,
     string caption,
     MessageBoxButton button)
 {
     return ShowCore(messageBoxText, caption, button, MessageDialogImage.None, 0);
 }
开发者ID:Orange637,项目名称:WpfStudy,代码行数:7,代码来源:MessageDialog.cs


示例2: AlertDialogBackend

 public AlertDialogBackend()
 {
     this.buttons = MessageBoxButton.OKCancel;
     this.icon = MessageBoxImage.None;
     this.options = MessageBoxOptions.None;
     this.defaultResult = MessageBoxResult.Cancel;
 }
开发者ID:garuma,项目名称:xwt,代码行数:7,代码来源:AlertDialogBackend.cs


示例3: Show

        /// <summary>
        /// Displays a message box that has a message, title bar caption, and button; and that returns a result.
        /// </summary>
        /// <param name="messageBoxText">A System.String that specifies the text to display.</param>
        /// <param name="caption">A System.String that specifies the title bar caption to display.</param>
        /// <param name="button">A System.Windows.MessageBoxButton value that specifies which button or buttons to display.</param>
        /// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
        public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button)
        {
            CustomMessageBoxWindow msg = new CustomMessageBoxWindow(messageBoxText, caption, button);
            msg.ShowDialog();

            return msg.Result;
        }
开发者ID:Baajl,项目名称:GestionPresse,代码行数:14,代码来源:CustomMessageBox.cs


示例4: Show

        public static MessageBoxResult Show(
            Action<Window> setOwner,
            string messageBoxText, 
            string caption, 
            MessageBoxButton button, 
            MessageBoxImage icon, 
            MessageBoxResult defaultResult, 
            MessageBoxOptions options)
        {
            if ((options & MessageBoxOptions.DefaultDesktopOnly) == MessageBoxOptions.DefaultDesktopOnly)
            {
                throw new NotImplementedException();
            }

            if ((options & MessageBoxOptions.ServiceNotification) == MessageBoxOptions.ServiceNotification)
            {
                throw new NotImplementedException();
            }

            _messageBoxWindow = new WpfMessageBoxWindow();

            setOwner(_messageBoxWindow);

            PlayMessageBeep(icon);

            _messageBoxWindow._viewModel = new MessageBoxViewModel(_messageBoxWindow, caption, messageBoxText, button, icon, defaultResult, options);
            _messageBoxWindow.DataContext = _messageBoxWindow._viewModel;
            _messageBoxWindow.ShowDialog();
            return _messageBoxWindow._viewModel.Result;
        }
开发者ID:suvjunmd,项目名称:Windows-10-Login-Background-Changer,代码行数:30,代码来源:WPFMessageBoxWindow.xaml.cs


示例5: MessageBoxMessage

 public MessageBoxMessage(string text, string caption, MessageBoxButton button, Action<MessageBoxResult> resultCallback)
 {
     this.Text = text;
     this.Caption = caption;
     this.Button = button;
     this.ResultCallback = resultCallback;
 }
开发者ID:karno,项目名称:Lycanthrope,代码行数:7,代码来源:MessageBoxMessage.cs


示例6: Show

        public static MessageBoxResult Show(Window parent, string msg, string title, MessageBoxButton btns, MessageBoxImage icon)
        {
            // Create a callback delegate
            _hookProcDelegate = new Win32.WindowsHookProc(HookCallback);

            // Remember the title & message that we'll look for.
            // The hook sees *all* windows, so we need to make sure we operate on the right one.
            _msg = msg;
            _title = title;

            // Set the hook.
            // Suppress "GetCurrentThreadId() is deprecated" warning.
            // It's documented that Thread.ManagedThreadId doesn't work with SetWindowsHookEx()
            #pragma warning disable 0618
            _hHook = Win32.SetWindowsHookEx(Win32.WH_CBT, _hookProcDelegate, IntPtr.Zero, AppDomain.GetCurrentThreadId());
            #pragma warning restore 0618

            // Pop a standard MessageBox. The hook will center it.
             MessageBoxResult rslt;
             if (parent == null)
                 rslt = MessageBox.Show(msg, title, btns, icon);
             else
                 rslt = MessageBox.Show(parent, msg, title, btns, icon);

            // Release hook, clean up (may have already occurred)
            Unhook();

            return rslt;
        }
开发者ID:ed4053,项目名称:YDownloader,代码行数:29,代码来源:MsgBox.cs


示例7: MessageBoxMessage

 public MessageBoxMessage(string key, string text, string caption, MessageBoxButton button)
     : base(key)
 {
     this.Text = text;
     this.Caption = caption;
     this.Button = button;
 }
开发者ID:karno,项目名称:NagoyaMetro,代码行数:7,代码来源:MessageBoxMessage.cs


示例8: ShowQuestion

 internal static MessageBoxResult ShowQuestion(string message, MessageBoxButton messageBoxButton)
 {
     return  MessageBox.Show(message,
                            "Question",
                            messageBoxButton,
                            MessageBoxImage.Question);
 }
开发者ID:hudo,项目名称:Pragmatic,代码行数:7,代码来源:UserInteraction.cs


示例9: ShowResponse

        internal static MessageBoxResult ShowResponse(string message, Response response, MessageBoxButton messageBoxButton)
        {
            MessageBoxImage messageBoxImage = MessageBoxImage.Information;
            string caption = "Information";

            if (response.HasErrors)
            {
                messageBoxImage = MessageBoxImage.Error;
                caption = "Error";
            }
            else if (response.HasWarnings)
            {
                messageBoxImage = MessageBoxImage.Warning;
                caption = "Warning";
            }
            else if (response.HasInformation)
            {
                messageBoxImage = MessageBoxImage.Information;
                caption = "Information";
            }

            string responseMessage = (response.Errors.Aggregate(string.Empty, (result, error) => string.Format("{1}{2}{0}", System.Environment.NewLine, result, error.Message)) + System.Environment.NewLine +
                                      response.Warnings.Aggregate(string.Empty, (result, error) => string.Format("{1}{2}{0}", System.Environment.NewLine, result, error.Message)) + System.Environment.NewLine +
                                      response.Information.Aggregate(string.Empty, (result, error) => string.Format("{1}{2}{0}", System.Environment.NewLine, result, error.Message))).Trim();

            return MessageBox.Show((message + System.Environment.NewLine + responseMessage).Trim(), caption, messageBoxButton, messageBoxImage);
        }
开发者ID:hudo,项目名称:Pragmatic,代码行数:27,代码来源:UserInteraction.cs


示例10: ToOleDefault

      private static OLEMSGDEFBUTTON ToOleDefault(MessageBoxResult defaultResult, MessageBoxButton button)
      {
         switch (button)
         {
            case MessageBoxButton.OK:
               return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;

            case MessageBoxButton.OKCancel:
               if (defaultResult == MessageBoxResult.Cancel)
                  return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND;

               return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;

            case MessageBoxButton.YesNoCancel:
               if (defaultResult == MessageBoxResult.No)
                  return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND;
               if (defaultResult == MessageBoxResult.Cancel)
                  return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_THIRD;

               return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;

            case MessageBoxButton.YesNo:
               if (defaultResult == MessageBoxResult.No)
                  return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND;

               return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;
         }

         return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;
      }
开发者ID:modulexcite,项目名称:AlphaVSX,代码行数:30,代码来源:DialogService.cs


示例11: Show

 public static void Show(string msg, string caption, MessageBoxButton button, MessageImage msgImage, Action<MessageBoxResult> callback)
 {
     DialogMessage result = new DialogMessage(null, msg, callback);
     result.Caption = caption + ";" + ((int)msgImage).ToString();
     result.Button = button;
     AppMessages.SendMessage.Send(result);
 }
开发者ID:hieu292,项目名称:hrm-k14vlu,代码行数:7,代码来源:MessageCustomize.cs


示例12: MessageWindow

 public MessageWindow(string text, MessageBoxButton buttons)
 {
     InitializeComponent();
     Message.Text = text;
     if (buttons == MessageBoxButton.OK)
     {
         AcceptButton.Content = "OK";
         AcceptButton.Visibility = Visibility.Visible;
         CancelButton.Visibility = Visibility.Hidden;
         NoButton.Visibility = Visibility.Hidden;
     }
     else if (buttons == MessageBoxButton.OKCancel)
     {
         AcceptButton.Content = "OK";
         AcceptButton.Visibility = Visibility.Visible;
         CancelButton.Visibility = Visibility.Visible;
         NoButton.Visibility = Visibility.Hidden;
     }
     else if (buttons == MessageBoxButton.YesNo)
     {
         AcceptButton.Content = "Yes";
         AcceptButton.Visibility = Visibility.Visible;
         CancelButton.Visibility = Visibility.Hidden;
         NoButton.Visibility = Visibility.Visible;
     }
     else if (buttons == MessageBoxButton.YesNoCancel)
     {
         AcceptButton.Content = "Yes";
         AcceptButton.Visibility = Visibility.Visible;
         CancelButton.Visibility = Visibility.Visible;
         NoButton.Visibility = Visibility.Visible;
     }
 }
开发者ID:Bang-Bang-Studios,项目名称:Big-Sunday,代码行数:33,代码来源:MessageWindow.xaml.cs


示例13: ShowCore

        private static MessageBoxResult ShowCore(
            string messageBoxText,
            string caption,
            MessageBoxButton button,
            MessageDialogImage icon,
            MessageBoxResult defaultResult)
        {
            if (!IsValidMessageBoxButton(button))
            {
                throw new InvalidEnumArgumentException("button", (int)button, typeof(MessageBoxButton));
            }

            if (!IsValidMessageDialogImage(icon))
            {
                throw new InvalidEnumArgumentException("icon", (int)icon, typeof(MessageBoxImage));
            }

            if (!IsValidMessageBoxResult(defaultResult))
            {
                throw new InvalidEnumArgumentException("defaultResult", (int)defaultResult, typeof(MessageBoxResult));
            }

            var dialog = new Dialog(messageBoxText, caption, button, icon, defaultResult);
            var flag = dialog.ShowDialog();
            return flag == true ? MessageBoxResult.No : MessageBoxResult.None;
        }
开发者ID:Orange637,项目名称:WpfStudy,代码行数:26,代码来源:MessageDialog.cs


示例14: IsValidMessageBoxButton

 private static bool IsValidMessageBoxButton(MessageBoxButton value)
 {
     return value == MessageBoxButton.OK
         || value == MessageBoxButton.OKCancel
         || value == MessageBoxButton.YesNo
         || value == MessageBoxButton.YesNoCancel;
 }
开发者ID:Orange637,项目名称:WpfStudy,代码行数:7,代码来源:MessageDialog.cs


示例15: Show

        public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button)
        {
            UIAlertView messageBox;
            if (button == MessageBoxButton.OKCancel)
                messageBox = new UIAlertView (caption, messageBoxText, null, "OK", "Cancel");
            else
                messageBox = new UIAlertView (caption, messageBoxText, null, "OK");
            messageBox.Show ();

            int clicked = -1;

            messageBox.Clicked += (s, buttonArgs) =>
            {
                clicked = buttonArgs.ButtonIndex;
            };
            while (clicked == -1)
            {
                NSRunLoop.Current.RunUntil (NSDate.FromTimeIntervalSinceNow (0.5));
                if (messageBox.BecomeFirstResponder() == false)
                    break;
            }

            if (clicked == 0)
                return MessageBoxResult.OK;
            else
                return MessageBoxResult.Cancel;
        }
开发者ID:ogazitt,项目名称:zaplify,代码行数:27,代码来源:MessageBox.cs


示例16: GetButtons

        public static ICollection<DialogButtonInfo> GetButtons(MessageBoxButton button)
        {
            ICollection<DialogButtonInfo> buttons;
            switch (button)
            {
                case MessageBoxButton.OK:
                    buttons = new[] { ButtonOK };
                    break;

                case MessageBoxButton.OKCancel:
                    buttons = new[] { ButtonOK, ButtonCancel };
                    break;

                case MessageBoxButton.YesNoCancel:
                    buttons = new[] { ButtonYes, ButtonNo, ButtonCancel };
                    break;

                case MessageBoxButton.YesNo:
                    var buttonNo = ButtonNo;
                    buttonNo.IsCancel = true;
                    buttons = new[] { ButtonYes, buttonNo };
                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(button), button, null);
            }
            return buttons;
        }
开发者ID:hsabaleuski,项目名称:paradox,代码行数:27,代码来源:MessageBox.cs


示例17: ShowMetroMessageBox

        /// <summary>
        ///     Extended MetroMessageBox.
        /// </summary>
        /// <param name="this"></param>
        /// <param name="message"></param>
        /// <param name="title"></param>
        /// <param name="buttons"></param>
        /// <param name="messageBoxType"></param>
        /// <returns></returns>
        public static MessageBoxResult ShowMetroMessageBox(this IWindowManager @this, string message, string title,
            MessageBoxButton buttons, BoxType messageBoxType = BoxType.Default)
        {
            MessageBoxResult retval;
            var shellViewModel = IoC.Get<MainViewModel>();

            try
            {
                if (shellViewModel != null)
                {
                    shellViewModel.ShowOverlay();
                }
                var model = new MetroMessageBoxViewModel(message, title, buttons, messageBoxType);
                Execute.OnUIThread(() => @this.ShowDialog(model));
                retval = model.Result;
            }
            finally
            {
                if (shellViewModel != null)
                {
                    shellViewModel.HideOverlay();
                }
            }

            return retval;
        }
开发者ID:verlain3,项目名称:SimpleDnsCrypt,代码行数:35,代码来源:WindowManagerExtensions.cs


示例18: ShowAsync

 public static void ShowAsync(string text, MessageBoxButton button = MessageBoxButton.OK,
     MessageBoxImage image = MessageBoxImage.Information, MessageBoxResult defaultButton = MessageBoxResult.OK)
 {
     new Thread(
         new ThreadStart(delegate { MessageBox.Show(text, Resources.AppName, button, image, defaultButton); }))
         .Start();
 }
开发者ID:danielchalmers,项目名称:DesktopWidgets,代码行数:7,代码来源:Popup.cs


示例19: ShowAsync

        public Task<MessageBoxResult> ShowAsync(string message, string title, MessageBoxButton buttons, MessageBoxImage image)
        {
            var tcs = new TaskCompletionSource<MessageBoxResult>();

            _dispatcherService.CurrentDispatcher.BeginInvoke(new Action(() =>
            {
                MessageBoxResult result;
                Window activeWindow = null;
                for (var i = 0; i < Application.Current.Windows.Count; i++)
                {
                    var win = Application.Current.Windows[i];
                    if ((win != null) && (win.IsActive))
                    {
                        activeWindow = win;
                        break;
                    }
                }

                if (activeWindow != null)
                {
                    result = MessageBox.Show(activeWindow, message, title, buttons, image);
                }
                else
                {
                    result = MessageBox.Show(message, title, buttons, image);
                }

                tcs.SetResult(result);
            }));


            return tcs.Task;
        }
开发者ID:modulexcite,项目名称:nvmsharp,代码行数:33,代码来源:MessageService.cs


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MessageBoxButtons类代码示例发布时间:2022-05-24
下一篇:
C# MessageBox类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap