コード例 #1
0
        private static Button CreateCtrlButtonWithResult(MessageBoxModule mbox, string content, bool?dialogResult, Action action, bool isDefault = false)
        {
            var btn = CreateCtrlButton(content);

            btn.IsDefault = isDefault;
            Action actionDialogResult = new Action(() =>
            {
                mbox.DialogResult = dialogResult;
                if (null == dialogResult)
                {
                    mbox.Close();
                }
            });

            if (null == action)
            {
                action = new Action(() => { });
            }

            Action mulitcastDelegate = (Action)MulticastDelegate.Combine(actionDialogResult, action);

            if (null != mulitcastDelegate)
            {
                btn.Command = new MessageBoxRelayCommand(mulitcastDelegate);
            }
            return(btn);
        }
コード例 #2
0
 /// <summary>
 /// 在指定窗口的前面显示消息框。该消息框显示消息、标题栏标题、按钮和图标,并接受默认消息框结果和返回结果。
 /// </summary>
 /// <param name="owner">一个 <see cref="System.Windows.Window"/>,表示消息框的所有者窗口。</param>
 /// <param name="messageBoxText">一个 <see cref="System.String"/>,用于指定要显示的文本。</param>
 /// <param name="caption"> 一个 <see cref="System.String"/>,用于指定要显示的标题栏标题。</param>
 /// <param name="button">一个 <see cref="System.Windows.MessageBoxButton"/> 值,用于指定要显示哪个按钮或哪些按钮。</param>
 /// <param name="icon">
 /// 一个 <see cref="System.Windows.MessageBoxImage"/> 值,用于指定要显示的图标。
 /// 未使用,留白.
 /// </param>
 /// <param name="defaultResult"> 一个 <see cref="System.Windows.MessageBoxResult"/> 值,用于指定消息框的默认结果。</param>
 /// <returns> 一个 <see cref="System.Windows.MessageBoxResult"/> 值,用于指定用户单击了哪个消息框按钮。</returns>
 public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)
 {
     if (MessageBoxType == MIVMessageBoxType.System)
     {
         return(System.Windows.MessageBox.Show(owner, messageBoxText, caption, button, icon, defaultResult));
     }
     return(MessageBoxModule.Show(owner, messageBoxText, caption, button, icon, defaultResult));
 }
コード例 #3
0
 /// <summary>
 /// 在指定窗口的前面显示消息框。该消息框显示消息并返回结果。
 /// </summary>
 /// <param name="owner">一个 <see cref="System.Windows.Window"/>,表示消息框的所有者窗口。</param>
 /// <param name="messageBoxText">一个 <see cref="System.String"/>,用于指定要显示的文本。</param>
 /// <returns> 一个 <see cref="System.Windows.MessageBoxResult"/> 值,用于指定用户单击了哪个消息框按钮。</returns>
 public static MessageBoxResult Show(Window owner, string messageBoxText)
 {
     if (MessageBoxType == MIVMessageBoxType.System)
     {
         return(System.Windows.MessageBox.Show(owner, messageBoxText));
     }
     return(MessageBoxModule.Show(owner, messageBoxText));
 }
コード例 #4
0
 /// <summary>
 /// 显示一个消息框,该消息框包含消息、标题栏标题和按钮,并且返回结果。
 /// </summary>
 /// <param name="messageBoxText">一个 <see cref="System.String"/>,用于指定要显示的文本。</param>
 /// <param name="caption"> 一个 <see cref="System.String"/>,用于指定要显示的标题栏标题。</param>
 /// <param name="button">一个 <see cref="System.Windows.MessageBoxButton"/> 值,用于指定要显示哪个按钮或哪些按钮。</param>
 /// <returns>一个 <see cref="System.Windows.MessageBoxResult"/> 值,用于指定用户单击了哪个消息框按钮。</returns>
 public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button)
 {
     if (MessageBoxType == MIVMessageBoxType.System)
     {
         return(System.Windows.MessageBox.Show(messageBoxText, caption, button));
     }
     return(MessageBoxModule.Show(messageBoxText, caption, button));
 }
コード例 #5
0
        public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, IList <MessageBoxButtonInfo> ctrlButtons)
        {
            var mbox = new MessageBoxModule();

            mbox.Message = messageBoxText;
            mbox.Title   = caption;
            mbox.Owner   = owner;

            IsUseCustomInfoDefine(ref mbox);

            if (owner != null)
            {
                mbox.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            }

            if (null != ctrlButtons && ctrlButtons.Count > 0)
            {
                foreach (var btnInfo in ctrlButtons)
                {
                    switch (btnInfo.Result)
                    {
                    case MessageBoxResult.Cancel:
                    case MessageBoxResult.No:
                    {
                        var btn = CreateCtrlButtonWithResult(mbox, btnInfo.ContentText, false, btnInfo.Action, btnInfo.IsDefault);
                        mbox.CtrlButtonCollection.Add(btn);
                    }
                    break;

                    case MessageBoxResult.None:
                    {
                        var btn = CreateCtrlButtonWithResult(mbox, btnInfo.ContentText, null, btnInfo.Action, btnInfo.IsDefault);
                        mbox.CtrlButtonCollection.Add(btn);
                    }
                    break;

                    case MessageBoxResult.OK:
                    case MessageBoxResult.Yes:
                    default:
                    {
                        var btn = CreateCtrlButtonWithResult(mbox, btnInfo.ContentText, true, btnInfo.Action, btnInfo.IsDefault);
                        mbox.CtrlButtonCollection.Add(btn);
                    }
                    break;
                    }
                }

                var result = mbox.ShowDialog();
                return(MessageBoxResult.None);
            }
            else
            {
                return(Show(owner, messageBoxText, caption, MessageBoxButton.OK));
            }
        }
コード例 #6
0
 private static void IsUseCustomInfoDefine(ref MessageBoxModule mbox)
 {
     if (B_USED_CUSTOM_BRUSHES && null != mbox)
     {
         if (MB_CUSTOMINFO.IsBackgroundChanged)
         {
             mbox.Background = MB_CUSTOMINFO.MB_Background;
         }
         if (MB_CUSTOMINFO.IsBorderBrushChanged)
         {
             mbox.BorderBrush = MB_CUSTOMINFO.MB_Borderbrush;
         }
         if (MB_CUSTOMINFO.IsBorderThicknessChanged)
         {
             mbox.BorderThickness = MB_CUSTOMINFO.MB_BorderThickness;
         }
         if (MB_CUSTOMINFO.IsForegroundChanged)
         {
             mbox.Foreground = MB_CUSTOMINFO.MB_Foreground;
         }
         if (MB_CUSTOMINFO.IsTitleForegroundChanged)
         {
             mbox.TitleForeground = MB_CUSTOMINFO.MB_Title_Foreground;
         }
         if (MB_CUSTOMINFO.IsTitleBackgroundChanged)
         {
             mbox.TitleBackground = MB_CUSTOMINFO.MB_Title_Background;
         }
     }
     if (B_USED_CUSTOM_SIZE && null != mbox)
     {
         if (MB_CUSTOMINFO.IsMaxHeightChanged)
         {
             mbox.MaxHeight = MB_CUSTOMINFO.MB_MaxHeight;
         }
         if (MB_CUSTOMINFO.IsMaxWidthChanged)
         {
             mbox.MaxWidth = MB_CUSTOMINFO.MB_MaxWidth;
         }
     }
 }
コード例 #7
0
 /// <summary>
 /// 显示一个消息框,该消息框包含消息并返回结果。
 /// </summary>
 /// <param name="messageBoxText">一个 System.String,用于指定要显示的文本。</param>
 /// <returns>一个 <see cref="System.Windows.MessageBoxResult"/> 值,用于指定用户单击了哪个消息框按钮。</returns>
 public static MessageBoxResult Show(string messageBoxText)
 {
     return(MessageBoxModule.Show(messageBoxText));
 }
コード例 #8
0
 public static void ResetMessageBoxCustomDefine()
 {
     MessageBoxModule.ResetMessageBoxCustomDefine();
 }
コード例 #9
0
 /// <summary>
 /// 设置 <see cref="Utility.Controls.LighterMessageBox"/> 的一些自定义信息.
 /// </summary>
 /// <param name="mbCustomIf"><see cref="Utility.Controls.LighterMessageBox"/> 自定义信息结构</param>
 public static void SetMessageBoxCustomDefine(MessageBoxCustomInfo mbCustomIf)
 {
     MessageBoxModule.SetMessageBoxCustomDefine(mbCustomIf);
 }
コード例 #10
0
        //private double maxWidth=350;

        //public double MaxWidth
        //{
        //    get { return maxWidth; }
        //    set { maxWidth = value; }
        //}

        #region custom settings

        /// <summary>
        /// 设置 <see cref="Utility.Controls.LighterMessageBox"/> 的按钮样式.
        /// </summary>
        /// <param name="buttonStyle"></param>
        public static void SetDefaultCtorButtonStyle(Style buttonStyle)
        {
            MessageBoxModule.SetDefaultCtorButtonStyle(buttonStyle);
        }
コード例 #11
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="owner"></param>
		/// <param name="messageBoxText"></param>
		/// <param name="caption"></param>
		/// <param name="button"></param>
		/// <param name="icon">为兼容 System.Windows.MessageBox 的留白.</param>
		/// <param name="defaultResult"></param>
		/// <returns></returns>
		public static MessageBoxResult Show( Window owner, string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult )
		{
			var mbox = new MessageBoxModule();
			mbox.Message = messageBoxText;
			mbox.Title = caption;
			mbox.Owner = owner;

			IsUseCustomInfoDefine( ref mbox );

			if ( owner != null )
			{
				mbox.WindowStartupLocation = WindowStartupLocation.CenterOwner;
			}

			switch ( button )
			{
				case MessageBoxButton.OKCancel:

					mbox.CtrlButtonCollection.Add( CreateCtrlButtonWithResult( mbox, "确定", true, null, defaultResult == MessageBoxResult.OK ) );

					mbox.CtrlButtonCollection.Add( CreateCtrlButtonWithResult( mbox, "取消", false, null, defaultResult == MessageBoxResult.Cancel ) );
					break;
				//break;
				case MessageBoxButton.YesNo:
					mbox.CtrlButtonCollection.Add( CreateCtrlButtonWithResult( mbox, "是", true, null, defaultResult == MessageBoxResult.Yes ) );

					mbox.CtrlButtonCollection.Add( CreateCtrlButtonWithResult( mbox, "否", false, null, defaultResult == MessageBoxResult.No ) );

					break;
				case MessageBoxButton.YesNoCancel:
					mbox.CtrlButtonCollection.Add( CreateCtrlButtonWithResult( mbox, "是", true, null, defaultResult == MessageBoxResult.Yes ) );

					mbox.CtrlButtonCollection.Add( CreateCtrlButtonWithResult( mbox, "否", false, null, defaultResult == MessageBoxResult.No ) );

					mbox.CtrlButtonCollection.Add( CreateCtrlButtonWithResult( mbox, "取消", null, null, defaultResult == MessageBoxResult.Cancel ) );
					break;
				case MessageBoxButton.OK:
				default:
					mbox.CtrlButtonCollection.Add( CreateCtrlButtonWithResult( mbox, "确定", true, null, defaultResult == MessageBoxResult.OK ) );
					break;
			}
			var result = mbox.ShowDialog();
			switch ( button )
			{

				//break;
				case MessageBoxButton.OKCancel:
					{
						return result == true ? MessageBoxResult.OK
							: result == false ? MessageBoxResult.Cancel :
							MessageBoxResult.None;
					}
				//break;
				case MessageBoxButton.YesNo:
					{
						return result == true ? MessageBoxResult.Yes : MessageBoxResult.No;
					}
				//break;
				case MessageBoxButton.YesNoCancel:
					{
						return result == true ? MessageBoxResult.Yes
							: result == false ? MessageBoxResult.No :
							MessageBoxResult.Cancel;
					}

				case MessageBoxButton.OK:
				default:
					{
						return result == true ? MessageBoxResult.OK : MessageBoxResult.None;
					}
			}
		}
コード例 #12
0
 /// <summary>
 /// 在指定窗口的前面显示消息框。该消息框显示消息、标题栏标题和按钮,并且支持自定义按钮和动作。
 /// </summary>
 /// <param name="owner"> 一个 <see cref="System.Windows.Window"/>,表示消息框的所有者窗口。</param>
 /// <param name="messageBoxText">一个 <see cref="System.String"/>,用于指定要显示的文本。</param>
 /// <param name="caption"> 一个 <see cref="System.String"/>,用于指定要显示的标题栏标题。</param>
 /// <param name="ctrlButtons">一组自定义的按钮和响应动作。</param>
 /// <returns> <paramref name="ctrlButtons"/> 中点击的 MessageBoxButtonInfo.Result 结果.</returns>
 public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, IList <MessageBoxButtonInfo> ctrlButtons)
 {
     return(MessageBoxModule.Show(owner, messageBoxText, caption, ctrlButtons));
 }
コード例 #13
0
		private static void IsUseCustomInfoDefine( ref MessageBoxModule mbox )
		{
			if ( B_USED_CUSTOM_BRUSHES && null != mbox )
			{
				if ( MB_CUSTOMINFO.IsBackgroundChanged )
				{
					mbox.Background = MB_CUSTOMINFO.MB_Background;
				}
				if ( MB_CUSTOMINFO.IsBorderBrushChanged )
				{
					mbox.BorderBrush = MB_CUSTOMINFO.MB_Borderbrush;
				}
				if ( MB_CUSTOMINFO.IsBorderThicknessChanged )
				{
					mbox.BorderThickness = MB_CUSTOMINFO.MB_BorderThickness;
				}
				if ( MB_CUSTOMINFO.IsForegroundChanged )
				{
					mbox.Foreground = MB_CUSTOMINFO.MB_Foreground;
				}
				if ( MB_CUSTOMINFO.IsTitleForegroundChanged )
				{
					mbox.TitleForeground = MB_CUSTOMINFO.MB_Title_Foreground;
				}
                if ( MB_CUSTOMINFO.IsTitleBackgroundChanged )
				{
					mbox.TitleBackground = MB_CUSTOMINFO.MB_Title_Background;
				}
			}
			if ( B_USED_CUSTOM_SIZE && null != mbox )
			{
				if ( MB_CUSTOMINFO.IsMaxHeightChanged )
				{
					mbox.MaxHeight = MB_CUSTOMINFO.MB_MaxHeight;
				}
				if ( MB_CUSTOMINFO.IsMaxWidthChanged )
				{
					mbox.MaxWidth = MB_CUSTOMINFO.MB_MaxWidth;
				}
			}
		}
コード例 #14
0
		private static Button CreateCtrlButtonWithResult( MessageBoxModule mbox, string content, bool? dialogResult, Action action, bool isDefault = false )
		{
			var btn = CreateCtrlButton( content );
			btn.IsDefault = isDefault;
			Action actionDialogResult = new Action( () =>
			{
				mbox.DialogResult = dialogResult;
				if ( null == dialogResult )
					mbox.Close();
			} );

			if ( null == action )
				action = new Action( () => { } );

			Action mulitcastDelegate = (Action)MulticastDelegate.Combine( actionDialogResult, action );

			if ( null != mulitcastDelegate )
			{
				btn.Command = new MessageBoxRelayCommand( mulitcastDelegate );
			}
			return btn;
		}
コード例 #15
0
 /// <summary>
 /// 显示一个消息框,该消息框包含消息、标题栏标题和按钮,并且返回结果。
 /// </summary>
 /// <param name="messageBoxText">一个 <see cref="System.String"/>,用于指定要显示的文本。</param>
 /// <param name="caption"> 一个 <see cref="System.String"/>,用于指定要显示的标题栏标题。</param>
 /// <param name="button">一个 <see cref="System.Windows.MessageBoxButton"/> 值,用于指定要显示哪个按钮或哪些按钮。</param>
 /// <returns>一个 <see cref="System.Windows.MessageBoxResult"/> 值,用于指定用户单击了哪个消息框按钮。</returns>
 public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button)
 {
     return(MessageBoxModule.Show(messageBoxText, caption, button));
 }
コード例 #16
0
 /// <summary>
 /// 在指定窗口的前面显示消息框。该消息框显示消息并返回结果。
 /// </summary>
 /// <param name="owner">一个 <see cref="System.Windows.Window"/>,表示消息框的所有者窗口。</param>
 /// <param name="messageBoxText">一个 <see cref="System.String"/>,用于指定要显示的文本。</param>
 /// <returns> 一个 <see cref="System.Windows.MessageBoxResult"/> 值,用于指定用户单击了哪个消息框按钮。</returns>
 public static MessageBoxResult Show(Window owner, string messageBoxText)
 {
     return(MessageBoxModule.Show(owner, messageBoxText));
 }
コード例 #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="messageBoxText"></param>
        /// <param name="caption"></param>
        /// <param name="button"></param>
        /// <param name="icon">为兼容 System.Windows.MessageBox 的留白.</param>
        /// <param name="defaultResult"></param>
        /// <returns></returns>
        public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)
        {
            var mbox = new MessageBoxModule();

            mbox.Message = messageBoxText;
            mbox.Title   = caption;
            mbox.Owner   = owner;

            IsUseCustomInfoDefine(ref mbox);

            if (owner != null)
            {
                mbox.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            }

            switch (button)
            {
            case MessageBoxButton.OKCancel:

                mbox.CtrlButtonCollection.Add(CreateCtrlButtonWithResult(mbox, "确定", true, null, defaultResult == MessageBoxResult.OK));

                mbox.CtrlButtonCollection.Add(CreateCtrlButtonWithResult(mbox, "取消", false, null, defaultResult == MessageBoxResult.Cancel));
                break;

            //break;
            case MessageBoxButton.YesNo:
                mbox.CtrlButtonCollection.Add(CreateCtrlButtonWithResult(mbox, "是", true, null, defaultResult == MessageBoxResult.Yes));

                mbox.CtrlButtonCollection.Add(CreateCtrlButtonWithResult(mbox, "否", false, null, defaultResult == MessageBoxResult.No));

                break;

            case MessageBoxButton.YesNoCancel:
                mbox.CtrlButtonCollection.Add(CreateCtrlButtonWithResult(mbox, "是", true, null, defaultResult == MessageBoxResult.Yes));

                mbox.CtrlButtonCollection.Add(CreateCtrlButtonWithResult(mbox, "否", false, null, defaultResult == MessageBoxResult.No));

                mbox.CtrlButtonCollection.Add(CreateCtrlButtonWithResult(mbox, "取消", null, null, defaultResult == MessageBoxResult.Cancel));
                break;

            case MessageBoxButton.OK:
            default:
                mbox.CtrlButtonCollection.Add(CreateCtrlButtonWithResult(mbox, "确定", true, null, defaultResult == MessageBoxResult.OK));
                break;
            }
            var result = mbox.ShowDialog();

            switch (button)
            {
            //break;
            case MessageBoxButton.OKCancel:
            {
                return(result == true ? MessageBoxResult.OK
                                                        : result == false ? MessageBoxResult.Cancel :
                       MessageBoxResult.None);
            }

            //break;
            case MessageBoxButton.YesNo:
            {
                return(result == true ? MessageBoxResult.Yes : MessageBoxResult.No);
            }

            //break;
            case MessageBoxButton.YesNoCancel:
            {
                return(result == true ? MessageBoxResult.Yes
                                                        : result == false ? MessageBoxResult.No :
                       MessageBoxResult.Cancel);
            }

            case MessageBoxButton.OK:
            default:
            {
                return(result == true ? MessageBoxResult.OK : MessageBoxResult.None);
            }
            }
        }
コード例 #18
0
 /// <summary>
 /// 在指定窗口的前面显示消息框。该消息框显示消息、标题栏标题、按钮和图标,并接受默认消息框结果和返回结果。
 /// </summary>
 /// <param name="owner">一个 <see cref="System.Windows.Window"/>,表示消息框的所有者窗口。</param>
 /// <param name="messageBoxText">一个 <see cref="System.String"/>,用于指定要显示的文本。</param>
 /// <param name="caption"> 一个 <see cref="System.String"/>,用于指定要显示的标题栏标题。</param>
 /// <param name="button">一个 <see cref="System.Windows.MessageBoxButton"/> 值,用于指定要显示哪个按钮或哪些按钮。</param>
 /// <param name="icon">
 /// 一个 <see cref="System.Windows.MessageBoxImage"/> 值,用于指定要显示的图标。
 /// 未使用,留白.
 /// </param>
 /// <param name="defaultResult"> 一个 <see cref="System.Windows.MessageBoxResult"/> 值,用于指定消息框的默认结果。</param>
 /// <returns> 一个 <see cref="System.Windows.MessageBoxResult"/> 值,用于指定用户单击了哪个消息框按钮。</returns>
 public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)
 {
     return(MessageBoxModule.Show(owner, messageBoxText, caption, button, icon, defaultResult));
 }
コード例 #19
0
		public static MessageBoxResult Show( Window owner, string messageBoxText, string caption, IList<MessageBoxButtonInfo> ctrlButtons )
		{
			var mbox = new MessageBoxModule();
			mbox.Message = messageBoxText;
			mbox.Title = caption;
			mbox.Owner = owner;

			IsUseCustomInfoDefine( ref mbox );

			if ( owner != null )
			{
				mbox.WindowStartupLocation = WindowStartupLocation.CenterOwner;
			}

			if ( null != ctrlButtons && ctrlButtons.Count > 0 )
			{
				foreach ( var btnInfo in ctrlButtons )
				{
					switch ( btnInfo.Result )
					{
						case MessageBoxResult.Cancel:
						case MessageBoxResult.No:
							{
								var btn = CreateCtrlButtonWithResult( mbox, btnInfo.ContentText, false, btnInfo.Action, btnInfo.IsDefault );
								mbox.CtrlButtonCollection.Add( btn );
							}
							break;
						case MessageBoxResult.None:
							{
								var btn = CreateCtrlButtonWithResult( mbox, btnInfo.ContentText, null, btnInfo.Action, btnInfo.IsDefault );
								mbox.CtrlButtonCollection.Add( btn );
							}
							break;
						case MessageBoxResult.OK:
						case MessageBoxResult.Yes:
						default:
							{
								var btn = CreateCtrlButtonWithResult( mbox, btnInfo.ContentText, true, btnInfo.Action, btnInfo.IsDefault );
								mbox.CtrlButtonCollection.Add( btn );
							}
							break;
					}
				}

				var result = mbox.ShowDialog();
				return MessageBoxResult.None;
			}
			else
			{
				return Show( owner, messageBoxText, caption, MessageBoxButton.OK );
			}


		}