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
{
///
/// MessageWindow.xaml 的交互逻辑
///
public partial class MessageWindow : Window
{
///
/// 提示框
///
/// 取消按钮 1不显示2显示
/// 标题
/// 消息内容
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 = "错误!";
}
}
///
/// 取消
///
///
///
private void BtnCancel_Click(object sender, RoutedEventArgs e)
{
DialogResult = false;
}
///
/// 确定
///
///
///
private void BtnOK_Click(object sender, RoutedEventArgs e)
{
DialogResult = true;
}
///
/// 消息提示框
///
/// 消息
///
public static MessageBoxResult Show(string Message)
{
string Title = "消息提示";
return Show(Message, Title);
}
///
/// 消息提示框
///
/// 消息
///
public static MessageBoxResult Show(string Message,string Title)
{
MessageWindow message = new MessageWindow(1, Title, Message);
message.ShowDialog();
return MessageBoxResult.Cancel;
}
///
/// 消息提示框
///
/// 标题
/// 消息
///
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();
}
}
}
}