コード例 #1
0
 public VisualItem(ZeroRowCol ItemRowCol, byte?AttrByte = null)
 {
     this.ItemRowCol = ItemRowCol;
     this.AttrByte   = AttrByte;
     this.Usage      = ShowUsage.Output;
     this.IsOnCanvas = false;
 }
コード例 #2
0
        public void PositionCaret(OneRowCol CaretRowCol)
        {
            // position the caret cursor.
            VisualItemCursor ic = null;

            if (CaretRowCol != null)
            {
                var rowCol = CaretRowCol.ToZeroRowCol();
                this.CaretCursor = VisualItems.FindVisualItemCanvas(rowCol);
            }
            else
            {
                // find the first field on the screen.
                ic = VisualItems.InputItemList().FirstOrDefault();

                this.CaretCursor = new CanvasPositionCursor(ic);
            }

            // by default. place the caret at first input field on screen.
            if (this.CaretCursor.RowCol == null)
            {
                var rowCol = new ZeroRowCol(0, 0);
                this.CaretCursor = VisualItems.FindVisualItemCanvas(rowCol);
            }

            // position the caret cursor at the visual item.
            this.CanvasCaret.StartBlink(this.CaretCursor, true);
        }
コード例 #3
0
        public static ZeroRowCol ShowRowCol(this IVisualItem Item)
        {
            ZeroRowCol showRowCol = null;

            if (Item.AttrByte == null)
            {
                showRowCol = Item.ItemRowCol;
            }
            else if ((Item.AttrByteOccupySpace != null) &&
                     (Item.AttrByteOccupySpace.Value == false))
            {
                showRowCol = Item.ItemRowCol;
            }
            else
            {
                showRowCol = Item.ItemRowCol.Advance(1) as ZeroRowCol;
            }

            if (Item.AdjustShowRowCol != null)
            {
                showRowCol = showRowCol.Add(Item.AdjustShowRowCol) as ZeroRowCol;
            }

            return(showRowCol);
        }
コード例 #4
0
        public IEnumerable <string> ToContentLines( )
        {
            var lineList = new List <string>();

            for (var rx = 0; rx < this.ScreenDim.Height; ++rx)
            {
                var sb = new StringBuilder();
                for (var colNum = 0; colNum < this.ScreenDim.Width; ++colNum)
                {
                    var rowCol = new ZeroRowCol(rx, colNum, this.ScreenDim);
                    var ix     = ToContentIndex(rowCol);
                    var b1     = this.ContentArray[ix];
                    if (b1 == 0x24)
                    {
                        sb.Append('#');
                    }
                    else if (b1.IsAttrByte( ))
                    {
                        sb.Append('@');
                    }
                    else
                    {
                        sb.Append(b1.ToShowChar());
                    }
                }

                lineList.Add(sb.ToString());
            }

            return(lineList);
        }
コード例 #5
0
 protected ShowItemBase(ZeroRowCol RowCol, ShowItemType ItemType, string Value = null)
     : this()
 {
     this.ItemRowCol = RowCol;
     this.ItemType   = ItemType;
     this.Value      = Value;
 }
コード例 #6
0
 public VisualTextBlock(string Text, ZeroRowCol RowCol, byte?AttrByte,
                        Size CharBoxDim, Size KernDim, FontDefn FontDefn)
     : base(RowCol, AttrByte)
 {
     this.TextBlock = new ClientTextBlock(CharBoxDim, KernDim);
     SetPaintDefn(CharBoxDim, KernDim, FontDefn);
     this.ShowText = Text;
 }
コード例 #7
0
 public ContentField(ZeroRowCol RowCol, StartFieldOrder FieldOrder)
 {
     this.RowCol     = RowCol;
     this.FieldOrder = FieldOrder;
     this.LL_Length  = FieldOrder.LL_Length;
     this.FFW_Bytes  = FieldOrder.FFW_Bytes;
     this.FCW_Bytes  = FieldOrder.FCW_Bytes;
 }
コード例 #8
0
        public static ZeroRowCol ToZeroRowCol(this int ix, ScreenDim Dim)
        {
            int colNum = 0;
            int rowNum = Math.DivRem(ix, Dim.Width, out colNum);
            var rowCol = new ZeroRowCol(rowNum, colNum, Dim);

            return(rowCol);
        }
コード例 #9
0
 public ShowFieldItem(
     ZeroRowCol RowCol, byte?AttrByte, ShowUsage Usage, ShowDtyp Dtyp, int Dlen)
     : base(RowCol, ShowItemType.Field, AttrByte)
 {
     this.Usage = Usage;
     this.Dtyp  = Dtyp;
     this.Dlen  = Dlen;
     this.Value = "";
 }
コード例 #10
0
 public ContentText(
     ZeroRowCol RowCol, byte?AttrByte, int TextLength,
     int?TailAttrByteIx)
 {
     this.RowCol         = RowCol;
     this.AttrByte       = AttrByte;
     this.TextLength     = TextLength;
     this.TailAttrByteIx = TailAttrByteIx;
 }
コード例 #11
0
        public VisualSpanner(string Text, ZeroRowCol ItemRowCol, byte?AttrByte,
                             CanvasDefn CanvasDefn)
            : base(ItemRowCol)
        {
            // create VisualTextBlock items for each segment that fits on the row.
            this.SegmentList = new List <VisualTextBlockSegment>();
            CreateTextBlockSegments(this, Text, ItemRowCol, AttrByte, CanvasDefn);

            this.AttrByte = AttrByte;
        }
コード例 #12
0
 public VisualTextBlockSegment(
     VisualSpanner Parent, int SegNum, int SegBx,
     string Text, ZeroRowCol RowCol, byte?AttrByte, CanvasDefn CanvasDefn,
     bool AttrByteOccupySpace)
     : base(Text, RowCol, AttrByte,
            CanvasDefn.CharBoxDim, CanvasDefn.KernDim, CanvasDefn.FontDefn)
 {
     this.Parent = Parent;
     this.SegNum = SegNum;
     this.SegBx  = SegBx;
     this.AttrByteOccupySpace = AttrByteOccupySpace;
 }
コード例 #13
0
        /// <summary>
        /// check that a row in the content space if all blanks.
        /// </summary>
        /// <param name="RowNum"></param>
        /// <returns></returns>
        public bool RowIsBlank(int RowNum)
        {
            var rowcol = new ZeroRowCol(RowNum, 0);
            var buf    = this.GetContentBytes(rowcol, this.ScreenDim.Width);
            var fx     = buf.IndexOfNotEqual(0, EbcdicWhitespace);

            if (fx == -1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #14
0
        public IEnumerable <string> ToOrderDetailReport( )
        {
            var lines = new List <string>();

            var headerLine = "Write to display orders. " + this.OrderList.Count() + " orders.";

            lines.Add(headerLine);

            IRowCol rowCol     = new ZeroRowCol(0, 0);
            var     nextRowCol = rowCol;

            foreach (var order in this.OrderList)
            {
                rowCol = nextRowCol;
                lines.Add(order.ToString(rowCol.ToOneRowCol( )));
                nextRowCol = order.Advance(rowCol);
            }
            return(lines);
        }
コード例 #15
0
        public CanvasPositionCursor(ScreenVisualItems VisualItems, ZeroRowCol RowCol)
        {
            var itemCursor = VisualItems.FindVisualItem(RowCol);

            if (itemCursor == null)
            {
                this.ItemCursor    = null;
                this.Position      = 0;
                this.OutsideRowCol = RowCol;
            }
            else
            {
                var item  = itemCursor.GetVisualItem();
                var iItem = item as IVisualItem;
                int pos   = RowCol.ColNum - iItem.ShowRowCol().ColNum + 1;
                this.ItemCursor = itemCursor;
                this.Position   = pos;
            }
        }
コード例 #16
0
        /// <summary>
        /// create VisualTextBlock or VisualSpanner from string to display on the
        /// canvase. If string spans multiple rows, create VisualSpanner which in turn
        /// contains multiple VisualTextBlock segments.
        /// </summary>
        /// <param name="ShowText"></param>
        /// <param name="ItemRowCol"></param>
        /// <param name="AttrByte"></param>
        /// <param name="TailAttrByte"></param>
        /// <returns></returns>
        public VisualItem VisualItemFactory(string ShowText, ZeroRowCol ItemRowCol,
                                            byte?AttrByte, byte?TailAttrByte)
        {
            VisualItem visualItem = null;

            if (CanvasCommon.DoesSpanMultipleRows(
                    ItemRowCol, AttrByte, ShowText.Length) == true)
            {
                visualItem =
                    new VisualSpanner(ShowText, ItemRowCol, AttrByte, this.CanvasDefn);
            }
            else
            {
                visualItem = new VisualTextBlock(
                    ShowText, ItemRowCol, AttrByte,
                    this.CanvasDefn.CharBoxDim, this.CanvasDefn.KernDim,
                    this.CanvasDefn.FontDefn);
                visualItem.TailAttrByte = TailAttrByte;
            }
            return(visualItem);
        }
コード例 #17
0
        /// <summary>
        /// create list of ShowLiteralItem and ShowFieldItem from the list of orders of
        /// a WriteToDisplay command.
        /// </summary>
        /// <param name="WtdCommand"></param>
        /// <param name="LogList"></param>
        /// <returns></returns>
        public static Tuple <ShowItemList, OneRowCol> BuildShowItemList(
            this WriteToDisplayCommand WtdCommand, ScreenDim ScreenDim,
            TelnetLogList LogList)
        {
            var       itemList  = new ShowItemList();
            IRowCol   curRowCol = new ZeroRowCol(0, 0);
            OneRowCol caret     = null;

            foreach (var order in WtdCommand.OrderList)
            {
                bool newGroup = false;
                if ((order.OrderCode == WtdOrder.SetBufferAddress) ||
                    (order.OrderCode == WtdOrder.StartHeader))
                {
                    newGroup = true;
                }
                LogList.AddItem(Direction.Read, order.ToString(), newGroup);
                LogList.AddItem(Direction.Read, order.ToHexString());

                if (order is TextDataOrder)
                {
                    var tdo = order as TextDataOrder;
                    var s1  = tdo.ShowText;
                    if ((tdo.AttrByte != null) || (s1.Length > 0) ||
                        (tdo.TailAttrByte != null))
                    {
                        var litItem = new ShowLiteralItem(
                            (ZeroRowCol)curRowCol, tdo.AttrByte, s1, tdo.TailAttrByte);
                        litItem.tdo_Length = s1.Length;

                        itemList.Add(litItem);
                        curRowCol = curRowCol.Advance(litItem.ItemLength());
                    }
                }

                else if (order.OrderCode == WtdOrder.StartField)
                {
                    var sfo      = order as StartFieldOrder;
                    var lx       = sfo.LL_Length;
                    var attrByte = sfo.AttrByte;

                    var fldItem = new ShowFieldItem((ZeroRowCol)curRowCol, sfo.AttrByte,
                                                    ShowUsage.Both, ShowDtyp.Char, lx);
                    fldItem.IsMonocase   = sfo.IsMonocase;
                    fldItem.sfo_FCW      = sfo.FCW_Bytes;
                    fldItem.sfo_FFW      = sfo.FFW_Bytes;
                    fldItem.sfo_Length   = sfo.LL_Length;
                    fldItem.IsNonDisplay = sfo.IsNonDisplay;

                    // field is non display.
                    //        if ((attrByte & 0x07) == 0x07)
                    //        {
                    //          fldItem.IsNonDisplay = true;
                    //        }

                    itemList.Add(fldItem);
                    curRowCol = curRowCol.Advance(1); // advance because of attrbyte.
                }

                else if (order.OrderCode == WtdOrder.SetBufferAddress)
                {
                    var sba = order as SetBufferAddressOrder;
                    curRowCol = sba.GetRowCol(ScreenDim).ToZeroRowCol();
                }

                else if (order.OrderCode == WtdOrder.InsertCursor)
                {
                    var ico = order as InsertCursorOrder;
                    caret = ico.RowCol;
                }

                else if (order.OrderCode == WtdOrder.RepeatToAddress)
                {
                    var rao = order as RepeatToAddressOrder;
                    var s1  = rao.RepeatShowText((ZeroRowCol)curRowCol);

                    var litItem = new ShowLiteralItem((ZeroRowCol)curRowCol, s1);
                    litItem.rao_RepeatTextByte = rao.RepeatTextByte;
                    litItem.rao_ToRowCol       = rao.RowCol;

                    itemList.Add(litItem);
                    curRowCol = curRowCol.Advance(s1.Length);
                }

                else if (order.OrderCode == WtdOrder.EraseToAddress)
                {
                    var eao     = order as EraseToAddressOrder;
                    var lx      = eao.EraseLength((ZeroRowCol)curRowCol);
                    var s1      = (" ").Repeat(lx);
                    var litItem = new ShowLiteralItem((ZeroRowCol)curRowCol, s1);
                    litItem.rao_RepeatTextByte = 0x00;
                    litItem.rao_ToRowCol       = eao.RowCol;

                    itemList.Add(litItem);
                    curRowCol = curRowCol.Advance(s1.Length);
                }
            }
            return(new Tuple <ShowItemList, OneRowCol>(itemList, caret));
        }
コード例 #18
0
 /// <summary>
 /// construct from absolute row and column positions. Cursor is located outside of
 /// a VisualItem on the canvas.
 /// </summary>
 /// <param name="RowNum"></param>
 /// <param name="ColNum"></param>
 public CanvasPositionCursor(ZeroRowCol RowCol)
 {
     this.ItemCursor    = null;
     this.Position      = 0;
     this.OutsideRowCol = RowCol;
 }
コード例 #19
0
 public ContinuedContentField(ZeroRowCol RowCol, StartFieldOrder FieldOrder)
     : base(RowCol, FieldOrder)
 {
 }
コード例 #20
0
        /// <summary>
        /// create visual items from the show items and place those visual items on the
        /// canvase.
        /// </summary>
        /// <param name="ShowItemList"></param>
        private OneRowCol PaintScreen_Actual(
            WriteToDisplayCommand WTD_command, TelnetLogList LogList = null)
        {
            IRowCol   curRowCol = new ZeroRowCol(0, 0);
            OneRowCol caret     = null;

            foreach (var order in WTD_command.OrderList)
            {
                if (LogList != null)
                {
                    LogList.AddItem(Direction.Read, "PaintScreen. " + order.ToString());
                }

                if (order is TextDataOrder)
                {
                    var tdo = order as TextDataOrder;
                    if (tdo.IsEmpty() == false)
                    {
                        PaintScreen_ApplyTextDataOrder(tdo, curRowCol);
                    }
                    curRowCol = tdo.Advance(curRowCol);
                }

                else if (order is SetBufferAddressOrder)
                {
                    var sba = order as SetBufferAddressOrder;
                    curRowCol = sba.GetRowCol(this.ScreenDim).ToZeroRowCol();
                }

                else if (order.OrderCode == WtdOrder.InsertCursor)
                {
                    var ico = order as InsertCursorOrder;
                    caret = ico.RowCol;
                }

                else if (order is StartFieldOrder)
                {
                    var sfo = order as StartFieldOrder;
                    {
                        var showText = new String(' ', sfo.LL_Length);
                        var vtb      = new VisualTextBlock(
                            showText, (ZeroRowCol)curRowCol, sfo.AttrByte,
                            this.CanvasDefn.CharBoxDim, this.CanvasDefn.KernDim,
                            this.CanvasDefn.FontDefn);
                        var iMore = vtb as IVisualItemMore;
                        var node  = iMore.InsertIntoVisualItemsList(this.VisualItems);
                        iMore.AddToCanvas(this);

                        vtb.SetupFieldItem(
                            sfo, this.CanvasDefn.CharBoxDim, this.CanvasDefn.KernDim);
                    }
                    curRowCol = curRowCol.Advance(1);
                }

                else if (order is RepeatToAddressOrder)
                {
                    var rao = order as RepeatToAddressOrder;
                    this.VisualItems.ApplyRepeatToAddressOrder(curRowCol, rao, this);
                    var lx = rao.RepeatLength((ZeroRowCol)curRowCol);
                    curRowCol = curRowCol.Advance(lx);
                }

                else if (order is EraseToAddressOrder)
                {
                    var eao = order as EraseToAddressOrder;
                    this.VisualItems.ApplyEraseToAddressOrder(curRowCol, eao, this);
                    var lx = eao.EraseLength((ZeroRowCol)curRowCol);
                    curRowCol = curRowCol.Advance(lx);
                }
            }
            return(caret);
        }
コード例 #21
0
 public VisualItem(ZeroRowCol ItemRowCol)
 {
     this.ItemRowCol = ItemRowCol;
     this.Usage      = ShowUsage.Output;
     this.IsOnCanvas = false;
 }
コード例 #22
0
 public ShowLiteralItem(ZeroRowCol RowCol, string Value)
     : base(RowCol, ShowItemType.Literal, Value)
 {
 }
コード例 #23
0
        /// <summary>
        /// apply the orders of the WriteToDisplay command to the screen content
        /// block.
        /// </summary>
        /// <param name="ApplyMaster"></param>
        /// <param name="wtdCmd"></param>
        /// <returns></returns>
        public static ScreenContent Apply(
            this ScreenContent ApplyMaster, WriteToDisplayCommand wtdCmd)
        {
            IRowCol curRowCol = new ZeroRowCol(0, 0, ApplyMaster);
            var     master    = ApplyMaster;

            foreach (var order in wtdCmd.OrderList)
            {
                if (order is SetBufferAddressOrder)
                {
                    var sba = order as SetBufferAddressOrder;
                    curRowCol = sba.GetRowCol(master.ScreenDim).ToZeroRowCol().ToContentRelative(master);
                }

                // screen position is out of bounds. Do not place text or field onto the
                // screen at an invalid position.
                else if (curRowCol.ColNum >= master.ScreenDim.Width)
                {
                }

                else if (order is StartFieldOrder)
                {
                    var sfo          = order as StartFieldOrder;
                    var contentField = master.ApplyStartFieldOrder(curRowCol, sfo);
                    curRowCol = curRowCol.Advance(1);
                }

                else if (order is RepeatToAddressOrder)
                {
                    var rao       = order as RepeatToAddressOrder;
                    var lx        = rao.RepeatLength((ZeroRowCol)curRowCol.ToParentRelative(master));
                    var textBytes = rao.GetRepeatTextBytes(lx);
                    master.ApplyTextBytes(curRowCol, textBytes);
                    curRowCol = curRowCol.Advance(lx);
                }

                else if (order is TextDataOrder)
                {
                    var tdo = order as TextDataOrder;
                    master.ApplyTextBytes(curRowCol, tdo.RawBytes);
                    curRowCol = tdo.Advance(curRowCol);
                }

                else if (order is InsertCursorOrder)
                {
                    var ico = order as InsertCursorOrder;
                    master.CaretRowCol = ico.RowCol;
                }

                else if (order is EraseToAddressOrder)
                {
                    var eao       = order as EraseToAddressOrder;
                    var lx        = eao.EraseLength((ZeroRowCol)curRowCol.ToParentRelative(master));
                    var textBytes = ((byte)0x00).Repeat(lx);
                    master.ApplyTextBytes(curRowCol, textBytes);
                    curRowCol = curRowCol.Advance(lx);
                }

                // WriteStructuredField order. used to create a window ScreenContent
                // within the main screenContent.
                else if (order is CreateWindowStructuredField)
                {
                    var sfo = order as CreateWindowStructuredField;

                    // create the window as a ScreenContent block onto itself. All future
                    // WTD orders are applied to the window screen content.
                    var windowMaster = new WindowScreenContent(
                        master,
                        sfo.WindowDim, (ZeroRowCol)curRowCol);

                    // store the index of this new child window as the index of the
                    // "current window" SCB within the parent SCB.
                    master.CurrentChildIndex = master.Children.Length - 1;

                    // the window is now the current SCB.
                    master = windowMaster;

                    // reset the current rowCol to position 0,0 within the window.
                    curRowCol = new ZeroRowCol(0, 0, master);
                }
            }

            return(master);
        }
コード例 #24
0
 public WindowScreenContent(
     ScreenContent Parent, ScreenDim WindowDim, ZeroRowCol RowCol)
     : base(Parent, WindowDim, Parent.ContentOdom)
 {
     this.StartRowCol = RowCol;
 }
コード例 #25
0
 public ShowLiteralItem(
     ZeroRowCol RowCol, byte?AttrByte, string Value, byte?TailAttrByte = null)
     : base(RowCol, ShowItemType.Literal, AttrByte, Value)
 {
     this.TailAttrByte = TailAttrByte;
 }