You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
4.5 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using POS.Language.Language;
using POSV.Component;
namespace POSV
{
public partial class DialogForm : BusinessForm
{
public DialogForm()
{
InitializeComponent();
}
public DialogForm(string content) : this()
{
this.Text = this.controlBox.Text = LangProxy.ToLang("消息提示");
this.lblContent.Text = content;
this.lblContent.Symbol = "\uf05a";
this.controlBox.ForeColor = Color.White;
}
public DialogForm(string title , string content) : this(content)
{
this.Text = this.controlBox.Text = title;
}
public DialogForm(string title , string content , MessageBoxIcon icon) : this(title , content)
{
switch (icon)
{
case MessageBoxIcon.Information:
this.lblContent.Symbol = "\uf05a";
break;
case MessageBoxIcon.Warning:
this.lblContent.Symbol = "\uf06a";
break;
case MessageBoxIcon.Question:
this.lblContent.Symbol = "\uf059";
break;
case MessageBoxIcon.Error:
this.lblContent.Symbol = "\uf057";
break;
default:
this.lblContent.Symbol = "\uf05a";
break;
}
}
public DialogForm(string title , string content , MessageBoxIcon icon , MessageBoxButtons buttons) : this(title , content , icon)
{
switch (buttons)
{
case MessageBoxButtons.YesNo:
this.ButtonOK.Text = LangProxy.ToLang("是");
this.ButtonClose.Text = LangProxy.ToLang("否");
break;
case MessageBoxButtons.YesNoCancel:
case MessageBoxButtons.OKCancel:
this.ButtonOK.Text = LangProxy.ToLang("确定");
this.ButtonClose.Text = LangProxy.ToLang("取消");
break;
case MessageBoxButtons.OK:
this.ButtonOK.Text = LangProxy.ToLang("确定");
this.ButtonClose.Visible = false;
break;
case MessageBoxButtons.RetryCancel:
this.ButtonOK.Text = LangProxy.ToLang("再查一次");
this.ButtonClose.Text = LangProxy.ToLang("核销订单");
break;
case MessageBoxButtons.AbortRetryIgnore:
default:
this.ButtonOK.Visible = false;
this.ButtonClose.Text = LangProxy.ToLang("关闭");
break;
}
}
protected void OnEscapeClick(object sender , EventArgs e)
{
if (sender is ControlBox)
{
ControlBox item = (ControlBox)sender;
switch (item.Action)
{
case ControlBoxEventAction.Closed:
this.DialogResult = DialogResult.No;
break;
}
}
else
{
ButtonX item = (ButtonX)sender;
if (LangProxy.ToLang("否").Equals(item.Text.Trim()))
{
this.DialogResult = DialogResult.No;
}
else
{
this.DialogResult = DialogResult.Cancel;
}
}
}
protected void OnEnterClick(object sender , EventArgs e)
{
ButtonX item = (ButtonX)sender;
if (LangProxy.ToLang("是").Equals(item.Text.Trim()))
{
this.DialogResult = DialogResult.Yes;
}
else if (LangProxy.ToLang("再查一次").Equals(item.Text.Trim()))
{
this.DialogResult = DialogResult.Retry;
}
else
{
this.DialogResult = DialogResult.OK;
}
}
public static void ShowAlert(IWin32Window owner, string title, string message)
{
var dialog = new DialogForm(title, message, MessageBoxIcon.Information, MessageBoxButtons.OK);
dialog.ShowDialog(owner);
}
}
}