Ejemplo n.º 1
0
    public static ScreenItemInstance FindItem(
      this IScreenItem item, IScreenLoc Start, IScreenLoc FindZeroLoc, 
      ScreenContent Content)
    {
      ScreenItemInstance findItem = null;

      if (item.ItemType == ShowItemType.Section)
      {
        var sectionItem = item as IScreenSection;
        findItem = sectionItem.FindItem(Start, FindZeroLoc, Content);
      }

      else
      {
        // adjust screen loc of the item by start pos of the section it is contained in.
        var adjRow = Start.RowNum - 1;
        var adjCol = Start.ColNum - 1;
        var loc = new OneScreenLoc(
          item.ScreenLoc.RowNum + adjRow, item.ScreenLoc.ColNum + adjCol);
        var zeroLoc = loc.ToZeroRowCol();

        var itemAtomic = item as IScreenAtomic;
        var range = new ScreenLocRange(zeroLoc, itemAtomic.Length, Content.ScreenDim);
        if (range.Contains(FindZeroLoc) == true)
          findItem = new ScreenItemInstance(item, range.From);
      }

      return findItem;
    }
Ejemplo n.º 2
0
        public static ContentItemBase GetContentItem(this ScreenContent Content, IScreenLoc loc)
        {
            ContentItemBase foundItem = null;

            foreach (var contentItem in Content.ContentItems())
            {
                var itemLoc = contentItem.RowCol as IScreenLoc;
                var range   = new ScreenLocRange(
                    itemLoc, contentItem.GetItemLength(Content), Content.ScreenDim);
                if (range.Contains(loc))
                {
                    foundItem = contentItem;
                    break;
                }
            }
            return(foundItem);
        }