コード例 #1
0
        public void Send(AidKey key = AidKey.Enter)
        {
            List <byte> byteData = new();

            byteData.Add((byte)key);
            var cursorAddress = EncodeAddress(CursorIndex);

            byteData.AddRange(cursorAddress);

            var mdtFields = StartFields.Where(m => m.ModifiedDataTag);

            foreach (var field in mdtFields)
            {
                byteData.Add((byte)Order.SetBufferAddress);
                var fieldAddress = EncodeAddress(field.Index + 1);
                byteData.AddRange(fieldAddress);
                int index = field.Index + 1;
                while (!StartFields.Any(m => m.Index == index))
                {
                    if (index > (24 * 80))
                    {
                        break;
                    }
                    if (ScreenBuffer[index] == 0x0)
                    {
                        index++;
                        continue;
                    }
                    byteData.Add(ScreenBuffer[index++]);
                }
            }
            byteData.AddRange(new byte[] { (byte)Telnet.IAC, (byte)Telnet.EOR });
            WriteBytes(byteData.ToArray());
        }
コード例 #2
0
        public bool TrySetTextByFieldIndex(int index, string text)
        {
            var editableFields = StartFields.Where(w => w.CanEdit);

            if (editableFields.Count() < index)
            {
                return(false);
            }
            var screenIndex = editableFields.Skip(index).First().Index;

            return(TrySetText(screenIndex, text));
        }
コード例 #3
0
        public bool TrySetText(int index, string text)
        {
            var concernedField = StartFields.Where(w => w.Index <= index).OrderBy(w => w.Index).LastOrDefault();

            if (concernedField == null)
            {
                return(false);
            }
            if (concernedField.Index + text.Length > (24 * 80))
            {
                return(false);
            }
            concernedField.ModifiedDataTag = true;
            Encoding.GetBytes(text).CopyTo(ScreenBuffer, index + 1);
            return(true);
        }