using System.Windows;
using System.Windows.Input;
namespace XHWK.WKTool
{
///
/// 消息提示框 .show()
///
public partial class MessageWindow
{
///
/// 提示框
///
/// 取消按钮 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;
}
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 content, string title)
{
MessageWindow message = new MessageWindow(
1,
title,
content
);
message.ShowDialog();
return MessageBoxResult.Cancel;
}
///
/// 消息提示框
///
/// 标题
/// 消息
///
///
public static MessageBoxResult Show
(
string content,
string title,
MessageBoxButton messageBox
)
{
if (string.IsNullOrWhiteSpace(title))
{
title = "消息提示";
}
MessageWindow message = new MessageWindow(
2,
title,
content
);
bool? res = message.ShowDialog();
if (res != null && (bool)res)
{
if (messageBox == MessageBoxButton.OKCancel)
{
return MessageBoxResult.OK;
}
return MessageBoxResult.Yes;
}
if (messageBox == MessageBoxButton.OKCancel)
{
return MessageBoxResult.Cancel;
}
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();
DragMove();
}
}
}
}