|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using DevComponents.DotNetBar;
|
|
|
|
|
using System.ComponentModel.Design;
|
|
|
|
|
|
|
|
|
|
namespace POSV
|
|
|
|
|
{
|
|
|
|
|
[ToolboxItem(false)]
|
|
|
|
|
public partial class BaseUserControl : UserControl
|
|
|
|
|
{
|
|
|
|
|
private NLog.Logger logger = null;
|
|
|
|
|
|
|
|
|
|
public BaseUserControl()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
//减少闪烁
|
|
|
|
|
SetStyles();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnLoad(e);
|
|
|
|
|
|
|
|
|
|
if (this.DesignMode) return;
|
|
|
|
|
|
|
|
|
|
logger = NLog.LogManager.GetLogger(GetType().FullName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 减少闪烁
|
|
|
|
|
private void SetStyles()
|
|
|
|
|
{
|
|
|
|
|
SetStyle(
|
|
|
|
|
ControlStyles.UserPaint |
|
|
|
|
|
ControlStyles.AllPaintingInWmPaint |
|
|
|
|
|
ControlStyles.OptimizedDoubleBuffer |
|
|
|
|
|
ControlStyles.ResizeRedraw |
|
|
|
|
|
ControlStyles.DoubleBuffer , true);
|
|
|
|
|
//强制分配样式重新应用到控件上
|
|
|
|
|
UpdateStyles();
|
|
|
|
|
base.AutoScaleMode = AutoScaleMode.None;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
protected Font GetSystemFont(SystemFont fontSize)
|
|
|
|
|
{
|
|
|
|
|
Font result = Constant.DEFAULT_FONT;
|
|
|
|
|
|
|
|
|
|
switch (fontSize)
|
|
|
|
|
{
|
|
|
|
|
case SystemFont.默认:
|
|
|
|
|
{
|
|
|
|
|
result = Constant.DEFAULT_FONT;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case SystemFont.正常:
|
|
|
|
|
{
|
|
|
|
|
result = Constant.NORMAL_FONT;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case SystemFont.小字:
|
|
|
|
|
{
|
|
|
|
|
result = Constant.SMALL_FONT;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case SystemFont.大字:
|
|
|
|
|
{
|
|
|
|
|
result = Constant.BIG_FONT;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected NLog.Logger LOGGER
|
|
|
|
|
{
|
|
|
|
|
get { return logger; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void ShowMessage(LabelX label , string message)
|
|
|
|
|
{
|
|
|
|
|
if (this.IsDisposed || !this.IsHandleCreated)
|
|
|
|
|
{
|
|
|
|
|
// some exceptional condition:
|
|
|
|
|
// handle in whatever way is appropriate for your app
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
if (this.IsDisposed || (!this.IsHandleCreated && !this.FindForm().IsHandleCreated))
|
|
|
|
|
{
|
|
|
|
|
// some exceptional condition:
|
|
|
|
|
// handle in whatever way is appropriate for your app
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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.Blue;
|
|
|
|
|
label.ForeColor = Color.Blue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
label.Text = message;
|
|
|
|
|
label.Refresh();
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected new bool DesignMode
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
bool returnFlag = false;
|
|
|
|
|
//#if DEBUG
|
|
|
|
|
// if (System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime)
|
|
|
|
|
// {
|
|
|
|
|
// returnFlag = true;
|
|
|
|
|
// }
|
|
|
|
|
// else if (System.Diagnostics.Process.GetCurrentProcess().ProcessName.ToUpper().Equals("DEVENV"))
|
|
|
|
|
// {
|
|
|
|
|
// returnFlag = true;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//#endif
|
|
|
|
|
if (this.GetService(typeof(IDesignerHost)) != null || System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime)
|
|
|
|
|
{
|
|
|
|
|
returnFlag = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
returnFlag = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return returnFlag;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void OnInputGotFocus(object sender , EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//触摸屏模式下自动关闭虚拟键盘
|
|
|
|
|
IntPtr hwnd = WindowsAPI.FindWindow("IPTip_Main_Window" , null);
|
|
|
|
|
if (hwnd != IntPtr.Zero)
|
|
|
|
|
{
|
|
|
|
|
WindowsAPI.SendMessage(hwnd , WindowsAPI.WM_SYSCOMMAND , WindowsAPI.SC_CLOSE , 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|