?? coolbutton.cs
字號:
?#define Wireless
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Reflection;
using YingShiLib;
namespace PdaButton
{
[DesignerCategory("YSBT")]
[DesignTimeVisible(true)]
[DefaultValue("YSBT")]
public partial class CoolButton : Control
{
private delegate void CBDelegate();
private int ysState = 0; //狀態
private int poll = 0; //人數
private float expenditure = 0; //消費額
private string orderForm = string.Empty; //單號
private int clearDesk = 0; //清臺狀態
private int mulDesk = 0; //一單多臺
private int locationid = 0; //區域
private int varValue = 0;
private int nflag = 0;
private string strText = string.Empty;
private bool MU;
private bool backRed;
private bool roundRect = false;
private EventHandler eh = null;
private bool ysFlag = false;
private Color frameColor=Color.Empty; //邊框顏色
private Color startColor = Color.White; //漸變色開始顏色
private Color endColor = Color.SkyBlue; //漸變色結束顏色
private int roundLength =0;
private Size ysSize =new Size(70, 20);
private IntPtr thePen, theBrush, oldPen, oldBrush = IntPtr.Zero;
private const int GRADIENT_FILL_RECT_H = 0x00000000;
private const int GRADIENT_FILL_RECT_V = 0x00000001;
private const int GRADIENT_FILL_TRIANGLE = 0x00000002;
[DllImport("Coredll.dll", EntryPoint = "GetDC")]
public static extern IntPtr GetDC(IntPtr hWnd);
[DllImport("coredll.dll", SetLastError = true, EntryPoint = "GradientFill")]
public static extern bool GradientFill(IntPtr hdc, TRIVERTEX[] pVertex, uint dwNumVertex, GRADIENT_RECT[] pMesh, uint dwNumMesh, uint dwMode);
[DllImport("Coredll.dll",EntryPoint="RoundRect")]
public static extern bool DrawRoundRect(IntPtr hdc, int nLeftRect, int nTopRect,int nRightRect, int nBottomRect, int nWidth, int nHeight);
[DllImport("Coredll.dll")]
public static extern IntPtr CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect,int nBottomRect);
[DllImport("Coredll.dll")]
public static extern IntPtr CreateSolidBrush(uint crColor);
[DllImport("Coredll.dll")]
public static extern IntPtr CreatePen(int fnPenStyle, int nWidth, uint crColor);
[DllImport("Coredll.dll")]
public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj);
[DllImport("Coredll.dll")]
public static extern bool DeleteObject(IntPtr hObject);
[DllImport("Coredll.dll")]
public static extern uint GetNearestColor(IntPtr hdc,uint crColor);
[DllImport("Coredll.dll")]
public static extern uint GetBkColor(IntPtr hdc);
[DllImport("Coredll.dll")]
public static extern uint SetBkColor(IntPtr hdc,uint color);
[DllImport("Coredll.dll")]
public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc,int nWidth,int nHeight);
[DllImport("Coredll.dll")]
public static extern IntPtr CreatePatternBrush(IntPtr HBITMAP);
[DllImport("Coredll.dll")]
public static extern int SetWindowRgn(IntPtr hWnd, IntPtr hRgn, bool bRedraw);
public static uint YsRgb(Color color)
{
return (uint)(color.R + color.G * 256 + color.B * 256 * 256);
}
public enum FillDirection
{
LeftToRight = GRADIENT_FILL_RECT_H,
TopToBottom = GRADIENT_FILL_RECT_V,
TRIANGLE = GRADIENT_FILL_TRIANGLE
}
public struct TRIVERTEX
{
public int x;
public int y;
public ushort Red;
public ushort Green;
public ushort Blue;
public ushort Alpha;
public TRIVERTEX(int x, int y, Color color):this(x, y, color.R, color.G, color.B, color.A)
{
}
public TRIVERTEX(int x, int y, ushort red, ushort green, ushort blue, ushort alpha)
{
this.x = x;
this.y = y;
this.Red = (ushort)(red << 8);
this.Green = (ushort)(green << 8);
this.Blue = (ushort)(blue << 8);
this.Alpha = (ushort)(alpha << 8);
}
}
public struct GRADIENT_RECT
{
public uint UpperLeft;
public uint LowerRight;
public GRADIENT_RECT(uint ul, uint lr)
{
this.UpperLeft = ul;
this.LowerRight = lr;
}
}
#region 屬性
/// <summary>
/// 屬性
/// </summary>
///
public int RoundLength
{
get { return roundLength; }
set
{
roundLength = value;
OnRoundLengthChanged(new EventArgs());
}
}
protected virtual void OnRoundLengthChanged(EventArgs e)
{
if (eh != null)
eh(this, new EventArgs());
}
public bool RoundRect
{
get { return roundRect; }
set
{
//roundLength = base.Width / 10;
roundRect = value;
OnRoundRectChanged(new EventArgs());
}
}
protected virtual void OnRoundRectChanged(EventArgs e)
{
if (eh != null)
eh(this, new EventArgs());
}
//邊框顏色
public Color FrameColor
{
get { return frameColor; }
set
{
frameColor = value;
OnFrameColorChanged(new EventArgs());
}
}
protected virtual void OnFrameColorChanged(EventArgs e)
{
if (eh != null)
{
eh(this, new EventArgs());
}
}
#if Wireless
/// <summary>
/// 清臺狀態
/// </summary>
public int ClearDesk
{
get { return clearDesk; }
set
{
clearDesk = value;
OnClearDeskChanged(new EventArgs());
}
}
protected virtual void OnClearDeskChanged(EventArgs e)
{
if (eh != null)
{
eh(this, new EventArgs());
}
}
//狀態
public int YsState
{
get { return ysState; }
set { ysState = value; OnYsStateChanged(new EventArgs()); }
}
protected virtual void OnYsStateChanged(EventArgs e)
{
if (eh != null)
{
eh(this, new EventArgs());
}
}
/// <summary>
/// 人數
/// </summary>
[DefaultValue(0)]
public int Poll
{
get { return poll; }
set { poll = value; OnPollChanged(new EventArgs()); }
}
protected virtual void OnPollChanged(EventArgs e)
{
if (eh != null)
{
eh(this, new EventArgs());
}
}
/// <summary>
/// 消費額
/// </summary>
public float Expenditure
{
get { return expenditure; }
set { expenditure = value; OnExpenditureChanged(new EventArgs()); }
}
protected virtual void OnExpenditureChanged(EventArgs e)
{
if (eh != null)
{
eh(this, new EventArgs());
}
}
/// <summary>
/// 單號
/// </summary>
public string OrderForm
{
get { return orderForm; }
set { orderForm = value; OnOrderFormChanged(new EventArgs()); }
}
protected virtual void OnOrderFormChanged(EventArgs e)
{
if (eh != null)
{
eh(this, new EventArgs());
}
}
//一單多臺
public int MulDesk
{
get { return mulDesk; }
set
{
mulDesk = value;
OnMulDeskChanged(new EventArgs());
}
}
protected virtual void OnMulDeskChanged(EventArgs e)
{
if (eh != null)
{
eh(this, new EventArgs());
}
}
public int LocationID
{
get { return locationid; }
set
{
locationid = value;
OnLocationIDChanged(new EventArgs());
}
}
protected virtual void OnLocationIDChanged(EventArgs e)
{
if (eh != null)
eh(this, new EventArgs());
}
#endif
public bool BackRed
{
get { return backRed; }
set { backRed = value; OnBackRed(new EventArgs()); }
}
protected virtual void OnBackRed(EventArgs e)
{
if (eh != null)
{
eh(this, new EventArgs());
}
}
[DefaultValue(false)]
public bool ButtonMU
{
get
{
return MU;
}
set
{
MU = value;
OnButtonMUChanged(new EventArgs());
}
}
protected virtual void OnButtonMUChanged(EventArgs e)
{
if (eh != null)
{
eh(this, new EventArgs());
}
}
/// <summary>
/// 控件顏色
/// </summary>
/// <remarks>控件顏色</remarks>
/// <value>
/// nFlag=0 默認值(藍色)
/// nFlag=1 (金色)
/// nFlag=2 (紅色)
/// </value>
[DefaultValue(0)]
public int ButtonFlag
{
get
{
return nflag;
}
set
{
nflag = value;
OnButtonFlagChanged(new EventArgs());
}
}
protected virtual void OnButtonFlagChanged(EventArgs e)
{
if (eh != null)
{
eh(this, new EventArgs());
}
}
protected virtual void OnButtonValueChanged(EventArgs e)
{
if (eh != null)
{
eh(this, new EventArgs());
}
}
public int ButtonValue
{
get
{
return varValue;
}
set
{
varValue = value;
OnButtonValueChanged(new EventArgs());
}
}
#region 控件文本
/// <summary>
/// 控件文本
/// </summary>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -