private void ClickButton(Button.ButtonType type) { if (type == Button.ButtonType.Start) { if (ValidatePuzzle()) { doSetup = true; } } else if (type == Button.ButtonType.Reset) { Reset(); } else if (type == Button.ButtonType.Undo) { Undo(); } else if (type == Button.ButtonType.Next) { Next(); } else if (type == Button.ButtonType.Finish) { Finish(); } else if (type == Button.ButtonType.Clean) { doClean = true; } else if (type == Button.ButtonType.Save) { Save(); } else if (type == Button.ButtonType.Load) { Load(); } else if (type >= Button.ButtonType.Fill_1 && type <= Button.ButtonType.Fill_9) { if (selectedCell != null) { selectedCell.info = new Number(type - Button.ButtonType.Fill_1, true); } } else if (type == Button.ButtonType.Backspace) { if (selectedCell != null) { selectedCell.info = null; } } else if (type == Button.ButtonType.UndoHelp) { UndoHelp(); } else if (type == Button.ButtonType.NextHelp) { NextHelp(); } }
private void InitializeButtons() { for (int k = 0; k < 10; k++) { Button.ButtonType type = Button.ButtonType.Fill_1 + k; buttons.Add(new Button(type, Main.Width / 2 + (int)(44 * (k - 4.5f)), Main.Height - 180)); } buttons.Add(new Button(Button.ButtonType.Start, Main.Width / 2, Main.Height - 100)); buttons.Add(new Button(Button.ButtonType.Save, Main.Width / 2 - 80, Main.Height - 100)); buttons.Add(new Button(Button.ButtonType.Load, Main.Width / 2 + 80, Main.Height - 100)); }
public ButtonBuilder Type(Button.ButtonType type) { Button.Type = type; return(this); }
/// <summary> /// 各类型参数个数及说明: /// Plus:1个,加数; /// Minus:1个,减数; /// Multiply:1个,乘数; /// Division:1个,除数; /// Cut:无; /// Reverse:无; /// Sum:无; /// Change:2个,原字符串和新字符串; /// LeftShift:无; /// RightShift:无; /// Mirror:无; /// Append:1个,添加在末尾的数; /// Store:无; /// Inc:2个,增量和待增按钮的List; /// Inv10:无; /// </summary> /// <param name="type">按钮类型</param> /// <param name="args">按钮参数</param> public Button(Button.ButtonType type, params object[] args) { this.type = type; switch (type) { case ButtonType.Plus: { object[] arg = { args[0] }; methods = new Method[] { new Method(true, false, false, arg, Plus, null) }; break; } case ButtonType.Minus: { object[] arg = { args[0] }; methods = new Method[] { new Method(true, false, false, arg, Minus, null) }; break; } case ButtonType.Multiply: { object[] arg = { args[0] }; methods = new Method[] { new Method(true, false, false, arg, Multiply, null) }; break; } case ButtonType.Division: { object[] arg = { args[0] }; methods = new Method[] { new Method(true, false, false, arg, Division, null) }; break; } case ButtonType.Cut: { methods = new Method[] { new Method(true, false, false, null, Cut, null) }; break; } case ButtonType.Reverse: { methods = new Method[] { new Method(true, false, false, null, Reverse, null) }; break; } case ButtonType.Sum: { methods = new Method[] { new Method(true, false, false, null, Sum, null) }; break; } case ButtonType.Change: { object[] arg = { args[0], args[1] }; methods = new Method[] { new Method(true, false, false, arg, Change, null) }; break; } case ButtonType.LeftShift: { methods = new Method[] { new Method(true, false, false, null, LeftShift, null) }; break; } case ButtonType.RightShift: { methods = new Method[] { new Method(true, false, false, null, RightShift, null) }; break; } case ButtonType.Mirror: { methods = new Method[] { new Method(true, false, false, null, Mirror, null) }; break; } case ButtonType.Append: { object[] arg = { args[0] }; methods = new Method[] { new Method(true, false, false, arg, Append, null) }; break; } case ButtonType.Store: { methods = new Method[] { new Method(false, true, true, new object[] { new List <int>() }, StoreFunction, StoreWithdraw), new Method(true, false, false, new object[] { null }, StoreAppend, null) }; break; } case ButtonType.Inc: { object[] arg = { args[0], args[1] }; methods = new Method[] { new Method(true, true, true, arg, IncFunction, IncWithdraw) }; break; } case ButtonType.Inv10: { methods = new Method[] { new Method(true, false, false, null, Inv10, null) }; break; } default: break; } }