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.
167 lines
4.2 KiB
C#
167 lines
4.2 KiB
C#
using DevComponents.DotNetBar;
|
|
using JwKdsV.Entity.Common;
|
|
using NLog;
|
|
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;
|
|
|
|
namespace JwKdsV
|
|
{
|
|
public partial class BaseForm : Form
|
|
{
|
|
|
|
protected Logger logger = null;
|
|
|
|
public BaseForm()
|
|
{
|
|
InitializeComponent();
|
|
|
|
logger = NLog.LogManager.GetLogger(GetType().FullName);
|
|
}
|
|
|
|
protected virtual void AppHookKeyDown(object sender, KeyEventArgs e) { }
|
|
|
|
protected virtual void OnEnterClick(object sender, EventArgs e) { logger.Debug("键盘Enter事件未处理"); }
|
|
|
|
|
|
/// <summary>
|
|
/// 显示label消息
|
|
/// </summary>
|
|
/// <param name="control"></param>
|
|
/// <param name="message"></param>
|
|
/// <param name="error"></param>
|
|
protected virtual void ShowMessage(Label control, string message, bool error = false)
|
|
{
|
|
|
|
if (IsDisposed || !control.Parent.IsHandleCreated) return;
|
|
|
|
logger.Debug(message);
|
|
|
|
this.Invoke(new Action(() => {
|
|
control.ForeColor = SystemColors.ControlText;
|
|
if (error)
|
|
{
|
|
control.ForeColor = Color.Red;
|
|
}
|
|
|
|
control.Text = message;
|
|
control.Refresh();
|
|
}));
|
|
|
|
}
|
|
|
|
protected void ShowMessage(LabelX label, string message)
|
|
{
|
|
logger.Debug(message);
|
|
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
label.Symbol = "\uf05a";
|
|
label.SymbolColor = Color.RoyalBlue;
|
|
label.ForeColor = SystemColors.ControlText;
|
|
|
|
label.Text = message;
|
|
label.Refresh();
|
|
}));
|
|
|
|
}
|
|
|
|
protected void ShowMessage(LabelX label, string message, bool error)
|
|
{
|
|
logger.Debug(message);
|
|
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
label.Symbol = "\uf05a";
|
|
label.SymbolColor = Color.RoyalBlue;
|
|
label.ForeColor = SystemColors.ControlText;
|
|
if (error)
|
|
{
|
|
label.Symbol = "\uf05c";
|
|
label.SymbolColor = Color.Red;
|
|
label.ForeColor = Color.Red;
|
|
}
|
|
|
|
label.Text = message;
|
|
label.Refresh();
|
|
}));
|
|
|
|
}
|
|
|
|
public event TransparentEventHandler AcceptButtonClick;
|
|
protected virtual void OnAcceptButtonClick(TransparentEventArgs e)
|
|
{
|
|
AcceptButtonClick?.Invoke(this, e);
|
|
}
|
|
|
|
public event TransparentEventHandler CancelButtonClick;
|
|
protected virtual void OnCancelButtonClick(TransparentEventArgs e)
|
|
{
|
|
CancelButtonClick?.Invoke(this, e);
|
|
}
|
|
}
|
|
|
|
public delegate void TransparentEventHandler(object sender, TransparentEventArgs e);
|
|
|
|
public enum TransparentAction
|
|
{
|
|
None = 0,
|
|
Cancel = 1,
|
|
Accept = 2,
|
|
Replace = 3
|
|
}
|
|
|
|
public class TransparentEventArgs : EventArgs
|
|
{
|
|
private readonly TransparentAction _action;
|
|
private readonly string _keyCode;
|
|
private readonly object _data;
|
|
|
|
public Tuple<decimal, decimal, List<string>, Worker> Authz;
|
|
public TransparentEventArgs(TransparentAction action, string keyCode, object data) : this(action, keyCode, data, null)
|
|
{
|
|
|
|
}
|
|
|
|
public TransparentEventArgs(TransparentAction action, string keyCode, object data, Tuple<decimal, decimal, List<string>, Worker> authz = null)
|
|
{
|
|
this._keyCode = keyCode;
|
|
this._data = data;
|
|
this._action = action;
|
|
|
|
this.Authz = authz;
|
|
}
|
|
|
|
|
|
public TransparentAction Action
|
|
{
|
|
get
|
|
{
|
|
return this._action;
|
|
|
|
}
|
|
}
|
|
|
|
public object Data
|
|
{
|
|
get
|
|
{
|
|
return this._data;
|
|
}
|
|
}
|
|
|
|
public string KeyCode
|
|
{
|
|
get
|
|
{
|
|
return this._keyCode;
|
|
}
|
|
}
|
|
}
|
|
}
|