|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
-
- namespace XHWK.WKTool
- {
- /// <summary>
- /// MessageWindow.xaml 的交互逻辑
- /// </summary>
- public partial class MessageWindow : Window
- {
- /// <summary>
- /// 提示框
- /// </summary>
- /// <param name="MessageType">取消按钮 1不显示2显示</param>
- /// <param name="Title">标题</param>
- /// <param name="content">消息内容</param>
- public MessageWindow(int MessageType,string Title,string Content)
- {
- InitializeComponent();
- switch (MessageType)
- {
- case 1:
- borCancel.Visibility = Visibility.Hidden;
- break;
- case 2:
- borCancel.Visibility = Visibility.Visible;
- break;
- default:
- break;
- }
- lblTitle.Content = Title;
- if (!string.IsNullOrWhiteSpace(Content))
- {
- if(Content.Length>143)
- {
- Content = Content.Substring(0, 140) + "...";
- }
- tbkContent.Text = Content;
- }
- else
- {
- tbkContent.Text = "错误!";
- }
- }
- /// <summary>
- /// 取消
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnCancel_Click(object sender, RoutedEventArgs e)
- {
- DialogResult = false;
- }
- /// <summary>
- /// 确定
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnOK_Click(object sender, RoutedEventArgs e)
- {
- DialogResult = true;
- }
- /// <summary>
- /// 消息提示框
- /// </summary>
- /// <param name="Message">消息</param>
- /// <returns></returns>
- public static MessageBoxResult Show(string Message)
- {
- string Title = "消息提示";
- return Show(Message, Title);
- }
- /// <summary>
- /// 消息提示框
- /// </summary>
- /// <param name="Message">消息</param>
- /// <returns></returns>
- public static MessageBoxResult Show(string Message,string Title)
- {
- MessageWindow message = new MessageWindow(1, Title, Message);
- message.ShowDialog();
- return MessageBoxResult.Cancel;
- }
- /// <summary>
- /// 消息提示框
- /// </summary>
- /// <param name="Title">标题</param>
- /// <param name="Message">消息</param>
- /// <returns></returns>
- public static MessageBoxResult Show(string Message,string Title, MessageBoxButton messageBox)
- {
- if (string.IsNullOrWhiteSpace(Title))
- {
- Title = "消息提示";
- }
- MessageWindow message = new MessageWindow(2,Title,Message);
- bool? res= message.ShowDialog();
- if ((bool)res)
- {
- if (messageBox == MessageBoxButton.OKCancel)
- {
- return MessageBoxResult.OK;
- }
- else
- {
- return MessageBoxResult.Yes;
- }
- }
- else
- {
- if (messageBox == MessageBoxButton.OKCancel)
- {
- return MessageBoxResult.Cancel;
- }
- else
- {
- return MessageBoxResult.No;
- }
- }
- }
- private static MessageBoxResult Win32ToMessageBoxResult(int value)
- {
- switch (value)
- {
- case 1:
- return MessageBoxResult.OK;
- case 2:
- return MessageBoxResult.Cancel;
- case 6:
- return MessageBoxResult.Yes;
- case 7:
- return MessageBoxResult.No;
- default:
- return MessageBoxResult.No;
- }
- }
-
- private void Window_MouseMove(object sender, MouseEventArgs e)
- {
- if (e.LeftButton == MouseButtonState.Pressed)
- {
- //this.DragMove();
- this.DragMove();
- }
- }
- }
- }
|