Beispiel #1
0
        public void Action(TelnetAction action, int?value)
        {
            //http://ascii-table.com/ansi-escape-sequences-vt-100.php
            //http://web.cs.mun.ca/~michael/c/ascii-table.html

            switch (action)
            {
            case TelnetAction.ClearScreen:
                Write(new byte[] { 0x1b, 0x5b, 0x32, 0x4a });     //Esc[2J
                break;

            case TelnetAction.MoveLeft:
                if (value == null)
                {
                    value = 1;                    //Default is 1
                }
                if (value.Value < 1)
                {
                    throw new InvalidOperationException("Value must be 1 or larger.");
                }
                if (value.Value > 9)
                {
                    throw new InvalidOperationException("Values larger than 1 is yet not supported. Needs to be developed.");
                }
                Write(new byte[] { 0x1b, 0x5b, (byte)(0x30 + value.Value), 0x44 });     //Esc[1D
                break;

            default:
                throw new ArgumentOutOfRangeException(string.Format("Action {0} has not been implemented.", action));
            }
        }
        public void Action(TelnetAction action, int? value)
        {
            //http://ascii-table.com/ansi-escape-sequences-vt-100.php
            //http://web.cs.mun.ca/~michael/c/ascii-table.html

            switch(action)
            {
                case TelnetAction.ClearScreen:
                    Write(new byte[] { 0x1b, 0x5b, 0x32, 0x4a }); //Esc[2J
                    break;
                case TelnetAction.MoveLeft:
                    if (value == null) value = 1; //Default is 1
                    if (value.Value < 1 ) throw new InvalidOperationException("Value must be 1 or larger.");
                    if (value.Value > 9) throw new InvalidOperationException("Values larger than 1 is yet not supported. Needs to be developed.");
                    Write(new byte[] { 0x1b, 0x5b, (byte)(0x30 + value.Value), 0x44 }); //Esc[1D
                    break;
                default:
                    throw new ArgumentOutOfRangeException(string.Format("Action {0} has not been implemented.", action));
            }
        }