/// <summary> /// the row/col location of the last positon of the item. /// </summary> /// <param name="Item"></param> /// <returns></returns> public static IRowCol ShowEndRowCol(this IVisualItem Item) { var showRowCol = Item.ShowRowCol(); var endRowCol = showRowCol.Advance(Item.ShowLength - 1); return(endRowCol); }
public static LocatedString LocatedText(this IVisualItem Item) { var showRowCol = Item.ShowRowCol(); var s1 = new LocatedString(showRowCol.ColNum, Item.ShowText); return(s1); }
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); }
public LinkedListNode <IVisualItem> FindFieldItem(IVisualItem Find) { var row = this.GetVisualRow(Find.ItemRowCol.RowNum); var node = row.FindFieldItem(Find); return(node); }
public TreeNodeLook(IVisualItem vi) : base(vi) { _scheme = TreeNodeVisualTableScheme.Get(vi.Table); _dataNode = _scheme.GetDataGraph().GetNode(vi.Row); _dataScheme = TreeNodeScheme.Get(_dataNode.Table); }
public Tuple <LinkedListNode <IVisualItem>, RelativePosition> FindInsertLoc( IVisualItem AddItem) { LinkedListNode <IVisualItem> baseNode = null; RelativePosition rltv = RelativePosition.End; // find the item to insert before. var node = ItemList.First; while (node != null) { if (AddItem.ShowEndRowCol( ).ColNum < node.Value.ShowRowCol( ).ColNum) { baseNode = node; rltv = RelativePosition.Before; break; } else if (AddItem.ShowRowCol( ).ColNum <= node.Value.ShowEndRowCol( ).ColNum) { baseNode = node; rltv = RelativePosition.At; break; } node = node.Next; } return(new Tuple <LinkedListNode <IVisualItem>, RelativePosition>(baseNode, rltv)); }
public static RowColRange ItemRange(this IVisualItem Item) { var from = Item.ItemRowCol; var to = Item.ItemEndRowCol(); var range = new RowColRange(from, to); return(range); }
public void StartBlink(IVisualItem Item, IRowCol Loc, string SymbolText) { this.Location = Loc; this.SymbolText = SymbolText; if (BlinkTimer == null) { StartTimer(); } }
public static IRowCol ItemEndRowCol(this IVisualItem Item) { var itemEndRowCol = Item.ShowEndRowCol(); if (Item.TailAttrByte != null) { itemEndRowCol = itemEndRowCol.Advance(1); } return(itemEndRowCol); }
public static ZeroRowCol AttrByteRowCol(this IVisualItem Item) { if (Item.AttrByte == null) { return(null); } else { return(Item.ItemRowCol); } }
public static bool IsEmpty(this IVisualItem Item) { if (Item.ShowText.Length == 0) { return(true); } else { return(false); } }
internal void Update(bool isActive) { if (_visualItemOver != null) { var point = Mouse.PrimaryDevice.GetPosition(this); _visualItemOver.SetIsMouseOver(false, point); _visualItemOver = null; } if (isActive) OnMouseMove(new MouseEventArgs(Mouse.PrimaryDevice, 0)); }
/// <summary> /// column location is within the column bounds of the item. /// </summary> /// <param name="ColNum"></param> /// <returns></returns> public static bool WithinColumnBounds(this IVisualItem Item, int ColNum) { if ((ColNum >= Item.ShowRowCol().ColNum) && (ColNum <= Item.ShowEndRowCol().ColNum)) { return(true); } else { return(false); } }
public override ILook CreateLook(IVisualItem vi) { ILook look = new SimpleEdgeLook(vi) { Visible = vi.Visible, ListenMouse = vi.ListenMouse, X = vi.X, Y = vi.Y, }; return(look); }
public IVisualItem FindItem(int ColNum) { IVisualItem foundItem = null; foreach (var item in ItemList) { if ((item.ShowRowCol( ).ColNum <= ColNum) && (item.ShowEndRowCol( ).ColNum >= ColNum)) { foundItem = item; break; } } return(foundItem); }
public static int ItemLength(this IVisualItem Item) { int lx = 0; if (Item.AttrByte != null) { lx += 1; } if (Item.TailAttrByte != null) { lx += 1; } lx += Item.ShowLength; return(lx); }
/// <summary> /// the location is within the column/row bounds of the visual item. /// </summary> /// <param name="Loc"></param> /// <returns></returns> public static bool ContainsLocation(this IVisualItem Item, IRowCol Loc) { var showRowCol = Item.ShowRowCol(); if ((Loc.RowNum == showRowCol.RowNum) && (Loc.ColNum >= showRowCol.ColNum) && (Loc.ColNum <= Item.ShowEndRowCol( ).ColNum)) { return(true); } else { return(false); } }
public LinkedListNode <IVisualItem> InsertIntoVisualItemsList(IVisualItem visualItem) { var showRowCol = visualItem.ShowRowCol(); var row = this.GetVisualRow(showRowCol.RowNum); // find the visual item on the row which the colnum of this new item is // closest to. var rv = row.FindInsertLoc(showRowCol.ColNum); var baseNode = rv.Item1; var rltv = rv.Item2; var node = row.InsertItem(visualItem, baseNode, rltv); return(node); }
// ItemText method does not make sense. Returns the attr byte concat with ShowText. // But attrByte does not translate from its byte code to unicode. public static string ItemText(this IVisualItem Item) { var sb = new StringBuilder(); if (Item.AttrByte != null) { sb.Append((char)Item.AttrByte.Value); } sb.Append(Item.ShowText); if (Item.TailAttrByte != null) { sb.Append((char)Item.TailAttrByte.Value); } return(sb.ToString()); }
private IVisualItem GetEdgeVisItem(IVisualItem nodeVisItem, out IVisualItem visParentNode) { var treeIndex = GetNodeTreeIndex(nodeVisItem); var dataNode = GetNodeByVisNodeItem(nodeVisItem); var parentNode = _trees[treeIndex].GetParent(dataNode); if (parentNode == null) { visParentNode = null; return(null); } var dataEdge = LavaUtils.GetGraphEdge(_trees[treeIndex].Graph, dataNode, parentNode); visParentNode = _visNodeTables[treeIndex].GetItem(parentNode.Row); return(_visEdgeTables[treeIndex].GetItem(dataEdge.Row)); }
public IVisualItem FindFieldItem(IRowCol ShowRowCol, IRowCol ShowEndRowCol) { IVisualItem foundItem = null; foreach (var item in ItemList.FieldItems) { if (item.ShowRowCol( ).CompareTo(ShowRowCol) >= 0) { if (item.ShowEndRowCol( ).CompareTo(ShowEndRowCol) <= 0) { foundItem = item; } } } return(foundItem); }
/// <summary> /// determine if the show portion of the item ( not the leading attr byte ) spans /// multiple rows of the canvas. /// </summary> /// <param name="Item"></param> /// <returns></returns> public static bool DoesShowSpanMultipleRows(this IVisualItem Item) { bool doesSpan = false; var showRowCol = Item.ShowRowCol(); var endRowCol = Item.ShowEndRowCol(); if (showRowCol.RowNum == endRowCol.RowNum) { doesSpan = false; } else { doesSpan = true; } return(doesSpan); }
private VisualItem VisualItemFactory(IVisualItem ShowItem) { VisualItem visualItem = null; if (ShowItem.DoesShowSpanMultipleRows() == true) { visualItem = new VisualSpanner( ShowItem.ShowText, ShowItem.ItemRowCol, ShowItem.AttrByte, this.CanvasDefn); visualItem.CreateFromItem = (ShowItemBase)ShowItem; } else { visualItem = new VisualTextBlock( ShowItem.ShowText, ShowItem.ItemRowCol, ShowItem.AttrByte, this.CanvasDefn.CharBoxDim, this.CanvasDefn.KernDim, this.CanvasDefn.FontDefn); visualItem.CreateFromItem = (ShowItemBase)ShowItem; } return(visualItem); }
public LinkedListNode <IVisualItem> FindFieldItem(IVisualItem Find) { var node = ItemList.FirstShowItem(); while (node != null) { var item = node.Value; var visualItem = item as VisualItem; if (visualItem.ShowItem != null) { var showItem = visualItem.ShowItem; if (Find.ShowRowCol( ).ColNum >= item.ShowRowCol( ).ColNum) { if (Find.ShowEndRowCol().CompareTo(item.ShowEndRowCol()) <= 0) { break; } } } node = node.NextShowItem(); } return(node); }
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); } }
protected override void OnMouseMove(MouseEventArgs e) { Point point = e.GetPosition(this); if (_visualItemOver != null && _visualItemOver.IsEnabled && _isDragging) { if (e.MouseDevice.LeftButton == MouseButtonState.Pressed) { if (_previousPosition != point) { _visualItemOver.DragDelta(point, new Vector(point.X - _previousPosition.X, point.Y - _previousPosition.Y)); _previousPosition = point; } } else { _isDragging = false; _visualItemOver.DragCompleted(point); } } else if (_visualItemOver == null || !_visualItemOver.IsBusy) { var visualItem = GetVisualItem(point); if (_visualItemOver != null && visualItem != _visualItemOver) _visualItemOver.SetIsMouseOver(false, point); if (_visualItemOver != visualItem) { _visualItemOver = visualItem; if (_visualItemOver != null) _visualItemOver.SetIsMouseOver(true, point); } } if (_visualItemOver != null) _visualItemOver.OnMouseMove(point, e); }
private int GetNodeTreeIndex(IVisualItem nodeVisItem) { return(_visNodeTables.IndexOf(nodeVisItem.VisualTable)); }
/// <summary> /// build a byte stream containing the WTD workstation command orders from all /// of the visual items on the canvas. The visual item list is the equivalent of /// the 5250 format table. /// </summary> /// <param name="VisualItems"></param> /// <returns></returns> public byte[] BuildOrderStream(CanvasPositionCursor Caret) { ByteArrayBuilder ba = new ByteArrayBuilder(); // start header order. { byte[] cmdKeySwitches = new byte[] { 0x00, 0x00, 0x00 }; var buf = StartHeaderOrder.Build(0x00, 0x00, 24, cmdKeySwitches); ba.Append(buf); } // insert cursor order. { var zeroRowCol = Caret.RowCol as ZeroRowCol; var rowCol = zeroRowCol.ToOneRowCol() as OneRowCol; var buf = InsertCursorOrder.Build(rowCol); ba.Append(buf); } // build sets of SBA, StartField and TextData orders for each visual item. The // visual item represents something on the screen. Whether output literal or // and input field. // VisualItem visualItem = null; IVisualItem iVisual = null; var cursor = this.FirstVisualItem(); while (cursor != null) { var pvVisualItem = iVisual; iVisual = cursor.GetVisualItem(); if (iVisual is VisualSpanner) { } else { { var buf = SetBufferAddressOrder.Build( iVisual.ItemRowCol.ToOneRowCol() as OneRowCol); ba.Append(buf); } var visualItem = iVisual as VisualItem; if (iVisual.IsField == true) { var vtb = iVisual as VisualTextBlock; var ffw = vtb.FFW_Bytes; byte attrByte = iVisual.AttrByte.Value; int lgth = iVisual.ShowText.Length; var buf = StartFieldOrder.Build(ffw[0], ffw[1], attrByte, lgth); ba.Append(buf); } // create a text data order from either the text of the literal item. Or the // text value of the entry field. { byte[] buf = null; var s1 = iVisual.ShowText; if (iVisual.IsField == true) { buf = TextDataOrder.Build(s1, null, iVisual.TailAttrByte); } else if (visualItem.CreateFromItem != null) { var litItem = visualItem.CreateFromItem as ShowLiteralItem; if (litItem.rao_RepeatTextByte != null) { var toRowCol = (iVisual.ItemEndRowCol() as ZeroRowCol).ToOneRowCol(); buf = RepeatToAddressOrder.Build( litItem.rao_RepeatTextByte.Value, toRowCol as OneRowCol); } else { var attrByte = litItem.AttrByte; if (s1.Length < litItem.tdo_Length) { s1 = s1.PadRight(litItem.tdo_Length); } buf = TextDataOrder.Build(s1, attrByte, iVisual.TailAttrByte); } } else { buf = TextDataOrder.Build(s1, iVisual.AttrByte, iVisual.TailAttrByte); } ba.Append(buf); } } cursor = cursor.NextItem(true); } return(ba.ToByteArray());; }
public SimpleEdgeLook(IVisualItem vi) : base(vi) { }
public void AddItem(IVisualItem AddItem) { var rv = FindInsertLoc(AddItem); InsertItem(AddItem, rv.Item1, rv.Item2); }
/// <summary> /// advance RowCol to location immed after the end of this item. /// </summary> /// <param name="Item"></param> /// <returns></returns> public static IRowCol NextRowCol(this IVisualItem Item) { var nextRowCol = Item.ItemRowCol.Advance(Item.ItemLength()); return(nextRowCol); }
private INode GetNodeByVisNodeItem(IVisualItem nodeVisItem) { var treeIndex = GetNodeTreeIndex(nodeVisItem); return(_visNodeSchemes[treeIndex].GetDataGraph().GetNode(nodeVisItem.Row)); }