Esempio n. 1
0
        public static ItemCanvas CreateItemCanvas(this WindowScreenContent ScreenContent,
                                                  ItemCanvas ParentItemCanvas, MasterThread MasterThread,
                                                  PaintThread PaintThread)
        {
            // create the canvas to drawn upon.
            var rv = ScreenContent.CreateWindowedItemCanvas(
                ParentItemCanvas, ParentItemCanvas.CanvasDefn.FontDefn.PointSize,
                MasterThread, PaintThread, ScreenContent.ContentNum);
            var border     = rv.Item1;
            var itemCanvas = rv.Item2;

            itemCanvas.ContentStart = ScreenContent.StartCharPoint;

            // add the canvas control ( actually the border control that contains the
            // canvas ) to the parent canvas.
            var canvasPos = ParentItemCanvas.AddItemToCanvas(
                ScreenContent.StartRowCol, itemCanvas.BorderControl);

            ScreenContent.WindowPos = canvasPos;

            ParentItemCanvas.RemoveCaret();
            itemCanvas.SetFocus();
            itemCanvas.HookBorderDrag();

            return(itemCanvas);
        }
Esempio n. 2
0
 /// <summary>
 /// create this screenContent from the contents of another ScreenContent block
 /// </summary>
 /// <param name="ToParent"></param>
 /// <param name="FromContent"></param>
 public WindowScreenContent(ScreenContent ToParent, WindowScreenContent FromContent)
     : base(ToParent, FromContent)
 {
     this.StartRowCol = FromContent.StartRowCol;
 }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public override ScreenContent Copy(ScreenContent ToParent = null)
        {
            var sc = new WindowScreenContent(ToParent, this);

            return(sc);
        }