public static bool DoesSpanMultipleRows(IRowCol ItemRowCol, byte?AttrByte, int ShowLength) { bool doesSpan = false; var showRowCol = ItemRowCol; if (AttrByte != null) { showRowCol = ItemRowCol.Advance(1); } var endRowCol = showRowCol; if (ShowLength > 0) { endRowCol = showRowCol.Advance(ShowLength - 1); } if (showRowCol.RowNum == endRowCol.RowNum) { doesSpan = false; } else { doesSpan = true; } return(doesSpan); }
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 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 static IRowCol Advance(this IRowCol RowCol, int Length) { int col = RowCol.ColNum + Length; int row = RowCol.RowNum; // negative advance and column off the charts to the left. while (col < RowCol.HorzBounds.a) { col += RowCol.Width(); row -= 1; if (row < RowCol.VertBounds.a) { row = RowCol.VertBounds.b; } } // positive advance and column out of bounds to the right. while (col > RowCol.HorzBounds.b) { col -= RowCol.Width(); row += 1; if (row > RowCol.VertBounds.b) { row = RowCol.VertBounds.a; } } return(new ZeroRowCol(row, col)); }
/// <summary> /// the repeat text. The repeat character that is duplicated for the length of /// the repeat length. /// </summary> /// <param name="FromRowCol"></param> /// <returns></returns> public string RepeatShowText(IRowCol FromRowCol) { var lx = RepeatLength(FromRowCol); var s1 = new string(this.RepeatShowChar, lx); return(s1); }
public IRowCol NewRowCol( int RowNum = -1, int ColNum = -1, ScreenContent ScreenContent = null, bool ForceParentRelative = false) { IRowCol rowCol = null; if (RowNum == -1) { RowNum = this.RowNum; } if (ColNum == -1) { ColNum = this.ColNum; } if (ScreenContent == null) { if (ForceParentRelative == true) { rowCol = new ZeroRowCol( RowNum, ColNum, this.Dim, RowColRelative.Parent, null); } else { rowCol = new ZeroRowCol( RowNum, ColNum, this.Dim, this.RowColRelative, this.ContentStart); } } else { rowCol = new ZeroRowCol(RowNum, ColNum, ScreenContent); } return(rowCol); }
public override IRowCol Advance(IRowCol Current) { var toRowCol = this.RowCol.ToZeroRowCol(); var nextRowCol = toRowCol.AdvanceRight(); return(nextRowCol); }
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 CanvasPositionCursor FindVisualItemCanvas(IRowCol RowCol) { CanvasPositionCursor posCursor = null; VisualItemCursor foundCursor = null; int foundPos = 0; foreach (var ic in this.InputItemList()) { var ivi = ic.GetVisualItem(); if (ivi.ContainsLocation(RowCol)) { foundCursor = ic; foundPos = RowCol.ColNum - ivi.ShowRowCol().ColNum + 1; break; } } if (foundCursor == null) { posCursor = new CanvasPositionCursor(RowCol as ZeroRowCol); } else { posCursor = new CanvasPositionCursor(foundCursor, foundPos); } return(posCursor); }
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(); } } }
/// <summary> /// calc and return the show rowCol of this item. /// </summary> /// <param name="ItemRowCol"></param> /// <returns></returns> public IRowCol ShowRowCol(IRowCol ItemRowCol) { IRowCol showRowCol = null; showRowCol = ItemRowCol.AdvanceRight(); return(showRowCol); }
/// <summary> /// find the input item on the canvas that preceeds the row/col position. /// </summary> /// <param name="rowCol"></param> /// <returns></returns> public VisualItemCursor FindPrevInputItem( IRowCol rowCol, VisualFeature?Feature = null) { VisualItemCursor findCursor = null; foreach (var cursor in this.InputItemList(Feature)) { var iItem = cursor.GetVisualItem(); var showRowCol = iItem.ShowRowCol(); if (showRowCol.CompareTo(rowCol) == -1) { findCursor = new VisualItemCursor(cursor); } else { break; } } if (findCursor == null) { findCursor = this.InputItemList(Feature).Last(); } return(findCursor); }
/// <summary> /// add the row/col adjustment factor to the canvas cursor. /// </summary> /// <param name="RowCol"></param> /// <returns></returns> public CanvasPositionCursor Add(IRowCol RowCol) { CanvasPositionCursor canvasCursor = null; if (RowCol == null) { canvasCursor = this; } else { var itemCursor = this.ItemCursor; var pos = this.Position; IRowCol outsideRowCol = null; if (this.OutsideRowCol != null) { outsideRowCol = this.OutsideRowCol.Add(RowCol); } if (itemCursor == null) { canvasCursor = new CanvasPositionCursor(outsideRowCol as ZeroRowCol); } else { canvasCursor = new CanvasPositionCursor(itemCursor, pos); } } return(canvasCursor); }
public static IRowCol Add(this IRowCol Value1, IRowCol Value2) { int rowNum = Value1.RowNum + Value2.RowNum; int colNum = Value1.ColNum + Value2.ColNum; return(Value1.NewRowCol(rowNum, colNum)); }
public static Point ToCanvasPos(this IRowCol RowCol, Size CharBoxDim) { double x = RowCol.ColNum * CharBoxDim.Width; double y = RowCol.RowNum * CharBoxDim.Height; return(new Point(x, y)); }
public static IRowCol Negate(this IRowCol RowCol) { var rowNum = RowCol.RowNum * -1; var colNum = RowCol.ColNum * -1; return(RowCol.NewRowCol(rowNum, colNum)); }
/// <summary> /// calc the column distance from Loc1 to Loc2. Distance includes the location /// itself. /// </summary> /// <param name="Loc1"></param> /// <param name="Loc2"></param> /// <param name="Dim"></param> /// <returns></returns> public static int DistanceInclusive(this IRowCol Loc1, IRowCol Loc2, ScreenDim Dim) { // ensure loc1 is before loc2. var loc1 = Loc1; var loc2 = Loc2; if (loc1.IsAfter(loc2)) { loc1 = Loc2; loc2 = Loc1; } // number of rows difference. int rowDiff = loc2.RowNum - loc1.RowNum; // number of colums. if (loc2.ColNum < loc1.ColNum) { rowDiff -= 1; loc2.ColNum += Dim.Width; } int colDiff = loc2.ColNum - loc1.ColNum; int lgth = (rowDiff * Dim.Width) + colDiff + 1; return(lgth); }
public IVisualItem FindFieldItem( IRowCol ItemRowCol, IRowCol ShowRowCol, IRowCol ShowEndRowCol) { var row = this.GetVisualRow(ItemRowCol.RowNum); var node = row.FindFieldItem(ShowRowCol, ShowEndRowCol); return(node); }
/// <summary> /// set the location on the canvas of the caret symbol. /// </summary> /// <param name="Location"></param> public void SetCaretTextBlockLocation( IRowCol Location, bool TraceBlinkPos = false) { var pos = Location.ToCanvasPos(Screen.CanvasDefn.CharBoxDim); System.Windows.Controls.Canvas.SetLeft(CaretTextBlock, pos.X); System.Windows.Controls.Canvas.SetTop(CaretTextBlock, pos.Y); }
/// <summary> /// calc the length of the erase order. Calc as the difference between input /// from pos and erase to location. /// </summary> /// <param name="FromRowCol"></param> /// <returns></returns> public int EraseLength(IRowCol FromRowCol) { var fromRowCol = FromRowCol.ToOneRowCol(); var toRowCol = this.RowCol.ToOneRowCol(); int eraseLength = fromRowCol.DistanceInclusive(toRowCol); return(eraseLength); }
/// <summary> /// calc the length of the report order. Calc as the difference between input /// from pos and repeat until location. /// </summary> /// <param name="FromRowCol"></param> /// <returns></returns> public int RepeatLength(IRowCol FromRowCol) { var fromRowCol = FromRowCol.ToOneRowCol(); var toRowCol = this.RowCol.ToOneRowCol(); int repeatLength = fromRowCol.DistanceInclusive(toRowCol); return(repeatLength); }
public static IRowCol AdvanceUp(this IRowCol RowCol) { int colNum = RowCol.ColNum; int rowNum = RowCol.RowNum - 1; rowNum = RowCol.WrapVertical(rowNum); return(RowCol.NewRowCol(rowNum, colNum)); }
public void StartBlink(IVisualItem Item, IRowCol Loc, string SymbolText) { this.Location = Loc; this.SymbolText = SymbolText; if (BlinkTimer == null) { StartTimer(); } }
public bool Contains(IRowCol RowCol) { bool contains = false; if ((RowCol.CompareTo(this.From) >= 0) && (RowCol.CompareTo(this.To) <= 0)) { contains = true; } return(contains); }
public Point AddItemToCanvas(IRowCol RowCol, FrameworkElement Elem) { // calc the x,y dot position of the visual item. var pos = RowCol.ToCanvasPos(this.CanvasDefn.CharBoxDim); this.Canvas.Children.Add(Elem); System.Windows.Controls.Canvas.SetLeft(Elem, pos.X); System.Windows.Controls.Canvas.SetTop(Elem, pos.Y); return(pos); }
public int ToContentIndex(IRowCol RowCol, int Offset = 0) { if (RowCol.LocationFrame == LocationFrame.OneBased) { RowCol = RowCol.ToZeroRowCol(); } var ix = RowCol.RowNum * this.ScreenDim.Width + RowCol.ColNum; ix += Offset; return(ix); }
public RowColRange(IRowCol From, int Length) { this.From = From; if (Length == 0) { this.To = From; } else { this.To = From.Advance(Length - 1); } }
/// <summary> /// create a new RowCol from component parts. Either a ZeroRowCol or OneRowCol, /// depending on LocationFrame. /// </summary> /// <param name="frame"></param> /// <param name="RowNum"></param> /// <param name="ColNum"></param> /// <param name="Height"></param> /// <param name="Width"></param> /// <returns></returns> public static IRowCol Factory(LocationFrame frame, int RowNum, int ColNum, int Height, int Width) { IRowCol rc = null; if (frame == LocationFrame.OneBased) { rc = new OneRowCol(RowNum, ColNum, new ScreenDim(Height, Width)); } else { rc = new ZeroRowCol(RowNum, ColNum, new ScreenDim(Height, Width)); } return(rc); }
/// <summary> /// calc and return the show rowCol of this item. /// </summary> /// <param name="ItemRowCol"></param> /// <returns></returns> public IRowCol ShowRowCol(IRowCol ItemRowCol) { IRowCol showRowCol = null; if (this.AttrByte == null) { showRowCol = ItemRowCol; } else { showRowCol = ItemRowCol.AdvanceRight(); } return(showRowCol); }