public override void Engage(int keyValue) { /* * MessageBox.Show(((int)Key.Up).ToString()); * MessageBox.Show(((int)Key.Down).ToString()); * MessageBox.Show(((int)Key.Right).ToString()); * MessageBox.Show(((int)Key.Left).ToString()); * MessageBox.Show(((int)Key.E).ToString()); * MessageBox.Show(((int)Key.F).ToString()); * MessageBox.Show(((int)Key.G).ToString()); * MessageBox.Show(((int)Key.H).ToString()); * MessageBox.Show(((int)Key.I).ToString()); * MessageBox.Show(((int)Key.J).ToString()); * MessageBox.Show(((int)Key.K).ToString()); * MessageBox.Show(((int)Key.L).ToString()); * MessageBox.Show(((int)Key.M).ToString()); * MessageBox.Show(((int)Key.N).ToString()); * MessageBox.Show(((int)Key.O).ToString()); * MessageBox.Show(((int)Key.P).ToString()); * MessageBox.Show(((int)Key.Q).ToString()); * MessageBox.Show(((int)Key.R).ToString()); * MessageBox.Show(((int)Key.S).ToString()); * MessageBox.Show(((int)Key.T).ToString()); * MessageBox.Show(((int)Key.U).ToString()); * MessageBox.Show(((int)Key.V).ToString()); * MessageBox.Show(((int)Key.X).ToString()); * MessageBox.Show(((int)Key.Y).ToString()); * MessageBox.Show(((int)Key.Z).ToString()); * MessageBox.Show(((int)Key.Space).ToString()); * */ PosEvent posEvent = PosEventStack.Instance.CurrentEvent; Char ch = (char)keyValue; // MessageBox.Show(ch.ToString()); Key inputKey = (Key)keyValue; if (inputKey == Key.Space) { PosContext.Instance.AddToInput(" "); } else { PosContext.Instance.AddToInput(inputKey.ToString()); //ch.ToString()); //inputKey.ToString()); } // PosContext.Instance.InputLine = PosContext.Instance.InputLine + inputKey.ToString(); inputText = PosContext.Instance.InputLine; PosContext.Instance.Operprompt.Update(this); }
public KeyEvent(PosKey key) { if (key.Key_Class != null) { try { function = assembly.CreateInstance(key.Key_Class) as PosEvent; } catch (Exception e) { MessageBox.Show(e.ToString()); } } }
// public NumKey(PosContext pContext) // { //this.Context = pContext; // } /* * If the input is >= 0, assume valid number is entered. * Else look at the current PosEvent and figure out what to do * Logon, get the prompt text from that event * EjCheckTender, get the prompt text from that event * etc. */ public override void Engage(int keyValue) { //MessageBox.Show( keyValue.ToString() ); if (keyValue >= 0) { PosContext.Instance.AddToInput(keyValue); } PosEvent posEvent = PosEventStack.Instance.CurrentEvent; if (posEvent is PosError) { PosError posError = posEvent as PosError; PosContext.Instance.Operprompt.Update(posError); return; } if (posEvent is PosNumberDialog) { PosNumberDialog numberDialog = posEvent as PosNumberDialog; this.PromptText = numberDialog.PromptText; numText = PosContext.Instance.InputLine; switch (numberDialog.Type) { case (PosNumberDialogTypes.Clear): break; case (PosNumberDialogTypes.Currency): double currVal = PosContext.Instance.InputDouble() / 100.0; string argToConvert = currVal.ToString(System.Globalization.CultureInfo.CurrentCulture.NumberFormat); // Convert the specified argument using the specified format. try { numText = string.Format(new PosTextFormatter( ), "{0:Money}", argToConvert); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } break; // case (PosNumberDialogTypes.Decimal): double val1 = PosContext.Instance.InputDouble() / 100.0; numText = val1.ToString("#########.##"); break; case (PosNumberDialogTypes.Mask): StringBuilder tmp = new StringBuilder(); tmp.Append('*', numText.Length); numText = tmp.ToString(); break; } } else if (posEvent is EjLine) { numText = PosContext.Instance.InputLine; } else { numText = PosContext.Instance.InputLine; } PosContext.Instance.Operprompt.Update(this); }
/*public string PromptText * { * get * { * return promptText; * } * set * { * promptText= value; * } * }*/ #endregion /** * Customized for event type on top of stack * - PosError, pop the next event and update dialogs. * - If there is input line data, (i.e. user is in the * middle inputing a number, remove the last number. * - else, clear input, pops the stack and update dialogs. */ public override void Engage(int keyValue) { Logger.Info( this.GetType().FullName, this.GetType().FullName + "Key value:" + PosContext.Instance.InputLine.ToString(), PosSettings.Default.Debug ); // MessageBox.Show("*** ClearKey ***"); //PosContext.Instance.InputLine = ""; //PosContext.Instance.Operprompt.Update(this); PosContext.Instance.PosPrompt.EnableInput(); PosEvent posEventCurrent = PosEventStack.Instance.Peek() as PosEvent; // Clear the error event, update dialogs and return if (posEventCurrent is PosError) { PosEventStack.Instance.PopEvent(); PosEvent posEventNext = PosEventStack.Instance.Peek() as PosEvent; if (posEventNext is FinishTransaction) { PosEventStack.Instance.NextEvent(); } if (posEventNext is LogOn) { LogOn logOn = posEventNext as LogOn; PosContext.Instance.Operprompt.Update(this); logOn.States().PushState((int)LogonStates.EnterUser); PosEventStack.Instance.NextEvent(); return; } if (posEventNext is SelectTable) { PosContext.Instance.CurrentPosDisplay.UnloadTableSelect(); PosContext.Instance.HomeGUI(); } PosContext.Instance.ClearInput(); PosContext.Instance.HomeGUI(); PosEventStack.Instance.ClearPending(); PosEventStack.Instance.ClearProcessed(); PosEventStack.Instance.NextEvent(); return; } if (posEventCurrent is UnLock) { return; } if (posEventCurrent is FinishTransaction) { PosEventStack.Instance.NextEvent(); return; } if (posEventCurrent is CloseCashDrawer) { PosEventStack.Instance.NextEvent(); return; } if (posEventCurrent is PromptPrintReceipt) { // get rid of this event and continue PosContext.Instance.ClearInput(); PosContext.Instance.HomeGUI(); PosEventStack.Instance.PopEvent(); PosEventStack.Instance.NextEvent(); return; } // If this is a finish trans then the user wants to // cancel the current tender, clean up the operator // reciept, remove the tender ej and continue. if (posEventCurrent is FinishTransaction) { PosContext.Instance.Receipt.ClearLine(); PosContext.Instance.ClearInput(); //PosContext.Instance.CurrentEj.RemoveCurrLine(); PosContext.Instance.HomeGUI(); PosEventStack.Instance.ClearPending(); PosEventStack.Instance.NextEvent(); return; } if (posEventCurrent is EjItem) { EjItem ejItem = posEventCurrent as EjItem; if (ejItem.DialogStep != EjItem.ITEM_FINAL) { ejItem.States().PopState(); ejItem.States().PushState(EjItem.ITEM_CLEAR); PosEventStack.Instance.NextEvent(); } return; } if (posEventCurrent is EjLine) { PosContext.Instance.ClearInput(); //PosContext.Instance.CurrentEj.RemoveCurrLine (); PosContext.Instance.HomeGUI(); PosEventStack.Instance.ClearPending(); PosContext.Instance.EnableKeys(); PosEventStack.Instance.NextEvent(); return; } if (posEventCurrent is LogOn) { PosContext.Instance.ClearInput(); LogOn logOn = posEventCurrent as LogOn; logOn.ResetState(); PosEventStack.Instance.NextEvent(); return; } if (posEventCurrent is RegisterOpen) { // if ( (PosContext.Instance.CurrentEj.TransHeader.State == (int) Transaction.Status.COMPLETE) || // (PosContext.Instance.CurrentEj.TransHeader.State == (int) Transaction.Status.VOIDED) ) // { // PosContext.Instance.Receipt.ClearLine(); // } PosContext.Instance.HomeGUI(); PosContext.Instance.EnableKeys(); PosContext.Instance.Operprompt.Update(this); PosContext.Instance.Receipt.Update(this); } if (posEventCurrent is TerminalReport) { PosContext.Instance.HomeGUI(); PosContext.Instance.EnableKeys(); PosContext.Instance.Operprompt.Update(this); PosContext.Instance.Receipt.Update(this); } if (posEventCurrent is SelectTable) { PosContext.Instance.HomeGUI(); PosContext.Instance.CurrentPosDisplay.UnloadTableSelect(); PosContext.Instance.Operprompt.Update(this); PosContext.Instance.Receipt.Update(this); } if (posEventCurrent is PosNumberDialog) { PosNumberDialog dialog = posEventCurrent as PosNumberDialog; PosContext.Instance.EnableKeys(); dialog.Clear(); if (PosContext.Instance.Input() > 0) { PosContext.Instance.ClearInput(); PosContext.Instance.Operprompt.Update(dialog); } else { PosContext.Instance.ClearInput(); PosEventStack.Instance.ClearPending(); PosEventStack.Instance.ClearProcessed(); PosEventStack.Instance.NextEvent(); } } else { PosContext.Instance.HomeGUI(); PosContext.Instance.ClearInput(); PosEventStack.Instance.ClearPending(); // PosEventStack.Instance.ClearPending(); PosEventStack.Instance.NextEvent(); } return; }
public void Update(char keyValue) { PosEvent posEvent = PosEventStack.Instance.CurrentEvent; if (keyValue == '\r') { new EnterKey().Engage(0); return; } if (keyValue == ' ') { PosContext.Instance.AddToInput(" "); return; } if (keyValue == '\b') { new ClearPreviousKeyStroke().Engage(0); return; } PosContext.Instance.AddToInput(keyValue.ToString()); //inputKey.ToString()); // PosContext.Instance.InputLine = PosContext.Instance.InputLine + inputKey.ToString(); //inputText = PosContext.Instance.InputLine; if (posEvent is PosNumberDialog) { PosNumberDialog numberDialog = posEvent as PosNumberDialog; //this.inputText = numberDialog.PromptText; inputText = PosContext.Instance.InputLine; switch (numberDialog.Type) { case (PosNumberDialogTypes.Clear): break; case (PosNumberDialogTypes.Currency): double currVal = PosContext.Instance.InputDouble() / 100.0; string argToConvert = currVal.ToString(System.Globalization.CultureInfo.CurrentCulture.NumberFormat); // Convert the specified argument using the specified format. try { inputText = string.Format(new PosTextFormatter(), "{0:Money}", argToConvert); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } break; // case (PosNumberDialogTypes.Decimal): double val1 = PosContext.Instance.InputDouble() / 100.0; inputText = val1.ToString("#########.##"); break; case (PosNumberDialogTypes.Mask): StringBuilder tmp = new StringBuilder(); tmp.Append('*', inputText.Length); inputText = tmp.ToString(); break; } } else if (posEvent is EjLine) { inputText = PosContext.Instance.InputLine; } else { inputText = PosContext.Instance.InputLine; } PosContext.Instance.Operprompt.Update(this); }
public override void Engage(int val) { //MessageBox.Show("*** Discount ***" + keyValue.ToString()); //Check if employee role is authorized to this event //if (!PosContext.Instance.Employee.RolesEventNames.Contains("ExecScript")) //{ // PosError posError = new PosError(PosErrorCode.INSUFFICIENT_USER_AUTHORITY); // posError.Engage(0); // return; //} if (scriptAllreadyRunning) { PosEvent posEvent = PosEventStack.Instance.Peek() as PosEvent; if (ExecScript.ReferenceEquals(posEvent, this)) { return; } } this.scriptAllreadyRunning = true; int keyValue = (int)PosContext.Instance.PosKeyValue; // Use ProcessStartInfo class ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.CreateNoWindow = false; startInfo.UseShellExecute = false; startInfo.WindowStyle = ProcessWindowStyle.Normal; // startInfo.Arguments = "-f j -o \"" + ex1 + "\" -z 1.0 -s y " + ex2; switch (keyValue) { case 1: startInfo.FileName = "Calc.exe"; break; case 2: startInfo.FileName = "Notepad.exe"; break; } try { // Start the process with the info we specified. // Call WaitForExit and then the using statement will close. using (Process exeProcess = Process.Start(startInfo)) { exeProcess.WaitForExit(); } } catch (Exception e) { Logger.Error("ExecScript.cs", e.ToString()); } this.scriptAllreadyRunning = false; PosContext.Instance.ClearInput(); PosEventStack.Instance.ClearPending(); PosEventStack.Instance.NextEvent(); }