Exemplo n.º 1
0
        /// <summary>
        ///     Sends an operator key to the mainframe.
        /// </summary>
        /// <param name="op"></param>
        /// <returns></returns>
        public bool SendKeyOp(KeyboardOp op)
        {
            var success = false;

            lock (tn)
            {
                // These can go to a locked screen
                if (op == KeyboardOp.Reset)
                {
                    success = true;
                }
                else
                {
                    if ((tn.Keyboard.keyboardLock & KeyboardConstants.OiaMinus) != 0 ||
                        tn.Keyboard.keyboardLock != 0)
                    {
                        success = false;
                    }
                    else
                    {
                        // These need unlocked screen
                        switch (op)
                        {
                        case KeyboardOp.AID:
                        {
                            var v = (byte)typeof(AID).GetField(op.ToString()).GetValue(null);
                            tn.Keyboard.HandleAttentionIdentifierKey(v);
                            success = true;
                            break;
                        }

                        case KeyboardOp.Home:
                        {
                            if (tn.IsAnsi)
                            {
                                Console.WriteLine("IN_ANSI Home key not supported");
                                //ansi_send_home();
                                return(false);
                            }

                            if (!tn.Controller.Formatted)
                            {
                                tn.Controller.SetCursorAddress(0);
                                return(true);
                            }
                            tn.Controller.SetCursorAddress(
                                tn.Controller.GetNextUnprotectedField(tn.Controller.RowCount *
                                                                      tn.Controller.ColumnCount - 1));
                            success = true;
                            break;
                        }

                        case KeyboardOp.ATTN:
                        {
                            tn.Interrupt();
                            success = true;
                            break;
                        }

                        default:
                        {
                            throw new ApplicationException("Sorry, key '" + op + "'not known");
                        }
                        }
                    }
                }
            }
            return(success);
        }