102 lines
3.6 KiB
C#
102 lines
3.6 KiB
C#
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;
|
|
using Work.BaseForms;
|
|
|
|
namespace _29WxOrderWpf.BaseWindows
|
|
{
|
|
/// <summary>
|
|
/// BaseMsgWindow.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class BaseMsgWindow : BaseWindow
|
|
{
|
|
public BaseMsgWindow()
|
|
{
|
|
InitializeComponent();
|
|
this.DataContext = this;
|
|
}
|
|
|
|
private static BaseMsgWindow CreateMsgForm(string msg, string caption, MsgWindowLevel wl)
|
|
{
|
|
BaseMsgWindow msgBox = new BaseMsgWindow { lblTitle = { Content = caption }, tbkMsg = { Text = msg } };
|
|
if (wl.Equals(MsgWindowLevel.LARGE))
|
|
{
|
|
msgBox.Width = (int)MsgWindowLevel.LARGE;
|
|
msgBox.Height = 500;
|
|
}
|
|
msgBox.btnOk.Margin = new Thickness(msgBox.btnCancel.Margin.Left, msgBox.btnCancel.Margin.Top, msgBox.btnCancel.Margin.Right, msgBox.btnCancel.Margin.Bottom); // 把确认按钮移到取消按钮上面
|
|
msgBox.btnCancel.Visibility = Visibility.Collapsed;
|
|
return msgBox;
|
|
}
|
|
|
|
public static BaseMsgWindow ShowInfo(Window window, string msg, string caption = "", MsgWindowLevel wl = MsgWindowLevel.MEDIUM)
|
|
{
|
|
string title = string.IsNullOrEmpty(caption) ? "系统提示" : caption;
|
|
BaseMsgWindow msgBox = CreateMsgForm(msg, title, wl);
|
|
msgBox.imgTip.Source = Application.Current.Resources["imgBaseMsgInfo"] as ImageSource;
|
|
if (window != null)
|
|
msgBox.Owner = window;
|
|
msgBox.ShowDialog();
|
|
return msgBox;
|
|
}
|
|
|
|
public static BaseMsgWindow ShowError(Window window, string msg, string caption = "", MsgWindowLevel wl = MsgWindowLevel.MEDIUM)
|
|
{
|
|
string title = string.IsNullOrEmpty(caption) ? "系统错误" : caption;
|
|
BaseMsgWindow msgBox = CreateMsgForm(msg, title, wl);
|
|
msgBox.imgTip.Source = Application.Current.Resources["imgBaseMsgErr"] as ImageSource;
|
|
if (window != null)
|
|
msgBox.Owner = window;
|
|
msgBox.ShowDialog();
|
|
return msgBox;
|
|
}
|
|
|
|
public static BaseMsgWindow ShowConfirm(Window window, string msg, string caption = "", MsgWindowLevel fl = MsgWindowLevel.MEDIUM)
|
|
{
|
|
string title = string.IsNullOrEmpty(caption) ? "确认系统提示" : caption;
|
|
BaseMsgWindow msgBox = new BaseMsgWindow
|
|
{
|
|
lblTitle = { Content = title },
|
|
tbkMsg = { Text = msg },
|
|
imgTip = { Source = Application.Current.Resources["imgBaseMsgQue"] as ImageSource },
|
|
};
|
|
if (fl.Equals(MsgWindowLevel.LARGE))
|
|
{
|
|
msgBox.Width = (int)MsgWindowLevel.LARGE;
|
|
msgBox.Height = 500;
|
|
}
|
|
if (window != null)
|
|
msgBox.Owner = window;
|
|
msgBox.ShowDialog();
|
|
return msgBox;
|
|
}
|
|
|
|
private void btnOk_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
DialogResult = true;
|
|
}
|
|
|
|
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
DialogResult = false;
|
|
}
|
|
}
|
|
|
|
public enum MsgWindowLevel
|
|
{
|
|
SMALL,
|
|
MEDIUM,
|
|
LARGE = 500
|
|
}
|
|
}
|