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.

125 lines
3.2 KiB
C#

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 POSV.Component;
using POS.Language.Language;
namespace POSV.Bill
{
[ToolboxItem(true)]
public partial class BillKeyboard : BaseUserControl
{
/// <summary>
/// 是否允许输入小数点
/// </summary>
bool allowDecimalSeparator = true;
public BillKeyboard()
{
InitializeComponent();
foreach (var item in layoutPanel.Controls)
{
var _btn = item as TouchButtonX;
if (_btn != null)
{
_btn.Text = LangProxy.ToLang(_btn.Text);
}
}
}
public bool AllowDecimalSeparator
{
get
{
return allowDecimalSeparator;
}
set
{
allowDecimalSeparator = value;
this.touchButtonX17.Lock = !this.allowDecimalSeparator;
this.touchButtonX17.SymbolSize = 10;
}
}
/// <summary>
/// 锁定
/// </summary>
public void Lock()
{
foreach (Control btn in this.layoutPanel.Controls)
{
if (btn is TouchButtonX)
{
TouchButtonX button = (TouchButtonX)btn;
button.SymbolSize = 10;
button.Lock = true;
}
}
this.touchButtonX17.Lock = !this.allowDecimalSeparator;
}
/// <summary>
/// 解除锁定
/// </summary>
public void UnLock()
{
foreach (Control btn in this.layoutPanel.Controls)
{
if (btn is TouchButtonX)
{
TouchButtonX button = (TouchButtonX)btn;
button.SymbolSize = 10;
button.Lock = false;
}
}
this.touchButtonX17.Lock = !this.allowDecimalSeparator;
}
public event BillKeyboardEventHandler KeyboardBefore;
protected virtual void OnKeyboardBefore(BillKeyboardEventArgs e)
{
KeyboardBefore?.Invoke(this , e);
}
public event BillKeyboardEventHandler KeyboardAfter;
protected virtual void OnKeyboardAfter(BillKeyboardEventArgs e)
{
KeyboardAfter?.Invoke(this , e);
}
private void OnTouchBeforeClick(object sender , TouchEventArgs e)
{
this.OnKeyboardBefore(new BillKeyboardEventArgs(e.Value));
}
private void OnTouchClick(object sender , TouchEventArgs e)
{
this.OnKeyboardAfter(new BillKeyboardEventArgs(e.Value));
}
}
public delegate void BillKeyboardEventHandler(object sender , BillKeyboardEventArgs e);
public class BillKeyboardEventArgs : EventArgs
{
public readonly string KeyCode;
public BillKeyboardEventArgs(string keyCode)
{
this.KeyCode = keyCode;
}
}
}