public static ContentField ApplyStartFieldOrder( this ScreenContent master, IRowCol CurRowCol, StartFieldOrder StartField) { ContentField createField = null; var fieldRange = new RowColRange(CurRowCol, StartField.LL_Length + 1); var buf = master.GetContentBytes(CurRowCol, StartField.LL_Length + 1); // get the fields located within the bounds of the StartField. All of these // fields are removed from the ScreenTable. if (buf.AllMatch(0x00) == false) { foreach (var contentField in master.ContentFields(fieldRange)) { master.FieldDict.Remove(contentField.RowCol); master.SetContentBytes(contentField.RowCol, 0x00); } } // add the field to the content table. { // store the attrByte at ItemRowCol location of the field. master.SetContentBytes(CurRowCol, StartField.AttrByte); // store field defn in FieldDict. createField = master.FieldDict.AddFieldOrder(CurRowCol as ZeroRowCol, StartField); } // assign unique fieldKey to the field. { createField.FieldKey = ContentFieldKey.AssignFieldKey(master, createField); } return(createField); }
/// <summary> /// return the ContentField with a textbyte that covers the specified rowcol /// location. /// </summary> /// <param name="ix"></param> /// <returns></returns> public ContentField GetContentField(IRowCol RowCol) { ContentField getField = null; int ix = ToContentIndex(RowCol); // look prior to the location, looking for that closest field. while (ix > 0) { ix -= 1; var textByte = this.ContentArray[ix]; if (textByte.IsAttrByte( )) { ContentItemBase contentItem = null; var rowCol = ix.ToZeroRowCol(this.ScreenDim); var rc = this.FieldDict.TryGetValue(rowCol, out contentItem); // attr byte is start of a field. if ((rc == true) && (contentItem is ContentField)) { var field = contentItem as ContentField; var fieldRange = new RowColRange(field.RowCol.AdvanceRight( ), field.LL_Length); if (fieldRange.Contains(RowCol)) { getField = field; break; } } } } return(getField); }
public void ApplyEraseToAddressOrder( IRowCol curRowCol, EraseToAddressOrder eao, ItemCanvas Canvas) { var eaoRange = new RowColRange(curRowCol, eao.RowCol); var deleteList = new List <VisualItemCursor>(); // build the list of all the items that are overlapped by the repeat range. foreach (var cursor in ItemList()) { var item = cursor.GetVisualItem(); var itemRange = item.ItemRange(); if (eaoRange.CompletelyContains(itemRange) == true) { deleteList.Add(new VisualItemCursor(cursor)); } } // delete all the visual items which are overlapped by the RA order. foreach (var cursor in deleteList) { var item = cursor.GetVisualItem(); var ivm = item as IVisualItemMore; if ((ivm != null) && (item.IsOnCanvas == true)) { ivm.RemoveFromCanvas(Canvas); cursor.RemoveColumnNode(); } } }
public void ApplyTextDataOrder(IRowCol CurRowCol, TextDataOrder TextData) { int lx = TextData.ItemLength(); var itemRange = new RowColRange(CurRowCol, lx); var buf = this.GetContentBytes(CurRowCol, lx); // get the fields located within the bounds of the StartField. All of these // fields are removed from the ScreenTable. if (buf.AllMatch(0x00) == false) { foreach (var contentField in this.ContentFields(itemRange)) { var ix = contentField.RowCol.DistanceInclusive(CurRowCol) - 1; var textByte = TextData.RawBytes[ix]; if (textByte.IsAttrByte( ) == false) { this.FieldDict.Remove(contentField.RowCol); SetContentBytes(contentField.RowCol, 0x00); } } } // apply the textbytes ( including leading and trailing attrbyte ) directly // to the content array. { // store the attrByte at ItemRowCol location of the field. SetContentBytes(CurRowCol, TextData.RawBytes); } }
public void ApplyTextBytes(IRowCol CurRowCol, byte[] TextBytes) { int lx = TextBytes.Length; var itemRange = new RowColRange(CurRowCol, lx); var buf = this.GetContentBytes(CurRowCol, lx); // get the fields located within the bounds of the StartField. All of these // fields are removed from the ScreenTable. var curIndex = this.ToContentIndex(CurRowCol); foreach (var contentField in this.ContentFields(itemRange)) { var fieldIndex = contentField.GetContentIndex(this); var ix = fieldIndex - curIndex; if (TextBytes[ix].IsAttrByte() == false) { this.FieldDict.Remove(contentField.RowCol); SetContentBytes(contentField.RowCol, 0x00); } } // apply the textbytes ( including leading and trailing attrbyte ) directly // to the content array. { // store the attrByte at ItemRowCol location of the field. SetContentBytes(CurRowCol, TextBytes); } }
public static RowColRange ItemRange(this IVisualItem Item) { var from = Item.ItemRowCol; var to = Item.ItemEndRowCol(); var range = new RowColRange(from, to); return(range); }
/// <summary> /// return a sequence containing each byte of the ContentArray within the /// specified range. /// </summary> /// <param name="Range"></param> /// <returns></returns> public IEnumerable <byte> ContentBytes(RowColRange Range) { var bx = ToContentIndex(Range.From); var lx = Range.Length; for (int ix = 0; ix < lx; ++ix) { byte contentByte = this.ContentArray[bx + ix]; yield return(contentByte); } yield break; }
/// <summary> /// return list of visual items which lie fully or partially within the input /// range. /// </summary> /// <param name="Range"></param> /// <returns></returns> public IEnumerable <VisualItemCursor> GetOverlapItems(RowColRange Range) { List <VisualItemCursor> overlapList = null; // build the list of all the items that are overlapped by the repeat range. foreach (var cursor in ItemList()) { var item = cursor.GetVisualItem(); var itemRange = item.ItemRange(); if (Range.ContainsAny(itemRange) == true) { if (overlapList == null) { overlapList = new List <VisualItemCursor>(); } overlapList.Add(new VisualItemCursor(cursor)); } } return(overlapList); }
/// <summary> /// return the sequence of fields that start within the rowcol range of the /// content table. /// </summary> /// <param name="Range"></param> /// <returns></returns> public IEnumerable <ContentField> ContentFields(RowColRange Range) { int ix = 0; ContentItemBase contentItem = null; foreach (var b1 in ContentBytes(Range)) { if (b1.IsAttrByte( )) { var rowCol = Range.From.Advance(ix) as ZeroRowCol; var rc = this.FieldDict.TryGetValue(rowCol, out contentItem); if ((rc == true) && (contentItem is ContentField)) { yield return(contentItem as ContentField); } } ix += 1; } yield break; }
private void PaintScreen_ApplyTextDataOrder(TextDataOrder tdo, IRowCol curRowCol) { var showText = tdo.ShowText; var showRowCol = tdo.ShowRowCol(curRowCol); var itemEndRowCol = tdo.ItemEndRowCol(showRowCol); var itemRange = new RowColRange(curRowCol, itemEndRowCol); IVisualItem ivi = null; // range if visual items which overlap this tdo. var overlapItems = VisualItems.GetOverlapItems(itemRange); if (overlapItems != null) { foreach (var cursor in overlapItems) { var item = cursor.GetVisualItem(); var itemRowCol = item.ItemRowCol; var tailAttrByte = tdo.TailAttrByte; if ((tdo.TailAttrByte != null) && (item.AttrByte != null) && (tdo.ItemEndRowCol(curRowCol).CompareTo(item.ItemRowCol) == 0)) { int xx = 4; } } } else { } if (itemEndRowCol != null) { ivi = VisualItems.FindFieldItem(curRowCol, showRowCol, itemEndRowCol); } if (ivi != null) { // replace textbock segment with the spanner. if (ivi is VisualTextBlockSegment) { var seg = ivi as VisualTextBlockSegment; ivi = seg.Parent; } var vim = ivi as IVisualItemMore; // pos within the canvas item at which to place literal text. int bx = showRowCol.ColNum - ivi.ShowRowCol().ColNum; // apply the literal text. vim.ApplyText(showText, bx); if (tdo.TailAttrByte != null) { ivi.TailAttrByte = tdo.TailAttrByte; } } else if (itemEndRowCol != null) { var visualItem = VisualItemFactory( tdo.ShowText, (ZeroRowCol)curRowCol, tdo.AttrByte, tdo.TailAttrByte); visualItem.FromOrder = tdo; var iMore = visualItem as IVisualItemMore; var node = iMore.InsertIntoVisualItemsList(this.VisualItems); iMore.AddToCanvas(this); } }