示例#1
0
    public static Tuple<DataItem, DataItemReport> CaptureReport(
      this IScreenItem item, IScreenLoc Start, ScreenContent Content)
    {
      string captureText = null;
      DataItem dataItem = null;
      DataItemReport itemReport = null;
      ContentItemBase contentItem = null;

      // get the content item at the rowcol location.
      bool rc = true;
      IScreenAtomic atomicItem = null;

      // 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();

      if (item.ItemType != ShowItemType.Section)
      {
        rc = Content.FieldDict.TryGetValue(zeroLoc, out contentItem);
        atomicItem = item as IScreenAtomic;
      }

      if (rc == false)
      {
      }

      else if (item.ItemType == ShowItemType.Section)
      {
        var sectionItem = item as IScreenSection;
        itemReport = sectionItem.CaptureReport(Content);
      }

      else if (item.ItemType == ShowItemType.Field)
      {
        if ((contentItem is ContentField) == true)
        {
          var contentField = contentItem as ContentField;
          dataItem = new DataItem(item.ItemName, contentField.GetShowText(Content));
          captureText = item.ItemName + "=" + contentField.GetShowText(Content);
        }
      }

      // match fixed literal
      else if (item.ItemType == ShowItemType.Literal)
      {
        if ((contentItem is ContentText) == true)
        {
          var contentText = contentItem as ContentText;
          var itemLit = item as IScreenLiteral;
          var ctValue = contentText.GetShowText(Content).TrimEndWhitespace();
        }
      }

      return new Tuple<DataItem, DataItemReport>(dataItem, itemReport);
    }
示例#2
0
        private void DropLayoutItems(object parameters)
        {
            DragDropHelper.DragDropData data = (DragDropHelper.DragDropData)parameters;

            IEnumerable <ContentItemBaseViewModel> items = (data.Data as IList).Cast <ContentItemBaseViewModel>().ToList();

            using (new UndoManager.EventGroupScope())
            {
                if (data.IsReorder)
                {
                    // Find the destination
                    bool            IsAtEnd = false;
                    ContentItemBase target  = null;
                    if (data.IndexInserted == _package.LayoutItems.Count)
                    {
                        IsAtEnd = true;
                    }
                    else
                    {
                        while (target == null && data.IndexInserted < _package.LayoutItems.Count)
                        {
                            ContentItemBase testTarget = _package.LayoutItems[data.IndexInserted];
                            if (items.Select(i => i.Item).Contains(testTarget))
                            {
                                data.IndexInserted++;
                            }
                            else
                            {
                                target = testTarget;
                            }
                        }
                    }

                    // Remove the moved items
                    items.ForEach(i => _package.LayoutItems.Remove(i.Item));

                    // Add them to the new location
                    data.IndexInserted = IsAtEnd ? _package.LayoutItems.Count : 0;
                    if (target != null)
                    {
                        data.IndexInserted = _package.LayoutItems.IndexOf(target);
                    }
                }

                _package.LayoutItems.InsertRange(data.IndexInserted, items.Select(i => i.Item).ToList());
            }
        }
示例#3
0
        private async Task RemoveFromQueueAsync(ContentItemBase item)
        {
            try
            {
                await DataSource.Current.RemoveFromQueueAsync(Platform.Current.AuthManager.User?.ID, item, CancellationToken.None);

                this.Queue.RemoveItem(item);
            }
            catch (Exception ex)
            {
                Platform.Current.Logger.LogError(ex, "Error during AddToQueueAsync");
            }
            finally
            {
                this.AddToQueueCommand.RaiseCanExecuteChanged();
                this.RemoveFromQueueCommand.RaiseCanExecuteChanged();
            }
        }
        protected override async Task OnRefreshAsync(CancellationToken ct)
        {
            try
            {
                this.ShowBusyStatus(Strings.Resources.TextLoading, true);
                this.Item = await DataSource.Current.GetItemAsync(this.ViewParameter.ToString(), ct);
                if (this.Item == null)
                    this.Item = (await DataSource.Current.SearchAsync(this.ViewParameter.ToString(), ct)).FirstOrDefault();
                this.Title = this.Item?.Title;
                this.ClearStatus();
            }
            catch(Exception ex)
            {
                Platform.Current.Logger.LogError(ex, "Error while trying to load data for ID '{0}'", this.ViewParameter);
                this.ShowTimedStatus(Strings.Resources.TextErrorGeneric);
            }

            await base.OnRefreshAsync(ct);
        }
示例#5
0
        protected override async Task OnRefreshAsync(CancellationToken ct)
        {
            try
            {
                this.ShowBusyStatus(Strings.Resources.TextLoading, true);
                this.Item = await DataSource.Current.GetItemAsync(this.ViewParameter.ToString(), ct);

                if (this.Item == null)
                {
                    this.Item = (await DataSource.Current.SearchAsync(this.ViewParameter.ToString(), ct)).FirstOrDefault();
                }
                this.Title = this.Item?.Title;
                this.ClearStatus();
            }
            catch (Exception ex)
            {
                Platform.Current.Logger.LogError(ex, "Error while trying to load data for ID '{0}'", this.ViewParameter);
                this.ShowTimedStatus(Strings.Resources.TextErrorGeneric);
            }

            await base.OnRefreshAsync(ct);
        }
示例#6
0
 private async Task RemoveFromQueueAsync(ContentItemBase item)
 {
     try
     {
         await DataSource.Current.RemoveFromQueueAsync(Platform.Current.AuthManager.User?.ID, item, CancellationToken.None);
         this.Queue.RemoveItem(item);
     }
     catch (Exception ex)
     {
         Platform.Current.Logger.LogError(ex, "Error during AddToQueueAsync");
     }
     finally
     {
         this.AddToQueueCommand.RaiseCanExecuteChanged();
         this.RemoveFromQueueCommand.RaiseCanExecuteChanged();
     }
 }
示例#7
0
 private bool CanRemoveFromQueue(ContentItemBase item)
 {
     return this.Queue.ContainsItem(item);
 }
示例#8
0
 private bool CanAddToQueue(ContentItemBase item)
 {
     return !this.Queue.ContainsItem(item);
 }
示例#9
0
        /// <summary>
        /// paint the text and fields of the screen content block onto the item canvas.
        /// </summary>
        /// <param name="ScreenContent"></param>
        /// <param name="ItemCanvas"></param>
        /// <param name="Window"></param>
        public static void PaintScreenContent(this ScreenContent ScreenContent,
                                              ItemCanvas ItemCanvas)
        {
            // use ContentNum to match ScreenContent with the ItemCanvas.
            ItemCanvas.ContentNum = ScreenContent.ContentNum;

            // apply the clear unit command to the itemcanvas.
            if (ScreenContent.DoClearUnit == true)
            {
                ItemCanvas.EraseScreen();
                ScreenContent.DoClearUnit = false;
            }

            else
            {
                // add ContentText items to the ContentDict of the SCB.
                ScreenContent.AddAllContentText();
            }

            // Remove all items on the ItemCanvas that are not in the SCB.
            // todo: need to clear the caret position if field removed from the screen
            //       contains the caret.
            var visualItems = ItemCanvas.VisualItems;

            foreach (var itemCursor in visualItems.ItemList())
            {
                var             vi          = itemCursor.GetVisualItem();
                var             rowCol      = vi.ItemRowCol;
                ContentItemBase contentItem = null;
                var             rc          = ScreenContent.FieldDict.TryGetValue(rowCol, out contentItem);
                if (rc == false)
                {
                    visualItems.RemoveItem(itemCursor, ItemCanvas);
                }
            }

            // loop for each item within the content array.
            foreach (var contentItem in ScreenContent.ContentItems())
            {
                if (contentItem is ContentText)
                {
                    var contentText = contentItem as ContentText;
                    var visualItem  = ItemCanvas.VisualItemFactory(
                        contentText.GetShowText(ScreenContent),
                        contentText.RowCol, contentText.GetAttrByte(ScreenContent),
                        contentText.GetTailAttrByte(ScreenContent));

                    var iMore = visualItem as IVisualItemMore;
                    var node  = iMore.InsertIntoVisualItemsList(ItemCanvas.VisualItems);
                    iMore.AddToCanvas(ItemCanvas);
                    iMore.SetupUnderline();
                }

                else if (contentItem is ContentField)
                {
                    var contentField = contentItem as ContentField;
                    var visualItem   =
                        ItemCanvas.VisualItemFactory(ScreenContent, contentField);

                    if (visualItem != null)
                    {
                        var iMore = visualItem as IVisualItemMore;
                        var node  = iMore.InsertIntoVisualItemsList(ItemCanvas.VisualItems);
                        iMore.AddToCanvas(ItemCanvas);
                        iMore.SetupUnderline();
                        iMore.SetupFieldItem(
                            ScreenContent, contentField,
                            ItemCanvas.CanvasDefn.CharBoxDim, ItemCanvas.CanvasDefn.KernDim);
                    }
                }
            }

            // position the caret.
            ItemCanvas.PositionCaret(ScreenContent.CaretRowCol);
            ItemCanvas.SetFocus();
        }
示例#10
0
 public ContentItemBaseViewModel(ContentItemBase contentItemBase)
 {
     _contentItemBase = contentItemBase;
     RegisterModel(_contentItemBase);
 }
 public Task RemoveFromQueueAsync(string userID, ContentItemBase item, CancellationToken ct)
 {
     return(Task.FromResult <object>(null));
 }
示例#12
0
    public static bool Match(
      this IScreenItem item, IScreenLoc Start, ScreenContent Content, 
      string DebugInfo)
    {
      bool isMatch = true;
      ContentItemBase contentItem = null;

      // get the content item at the rowcol location.
      bool rc = true;
      IScreenAtomic atomicItem = null;

      // 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();

      // item is not a section. Get the field or literal located at the item loc.
      if (item.ItemType != ShowItemType.Section)
      {
        atomicItem = item as IScreenAtomic;
      }

      if ((rc == false) && ( 1 == 2))
      {
        if ( item.IsOptional == false )
          isMatch = false;
      }

      else if ((isMatch == true) && (item.ItemType == ShowItemType.Section))
      {
        var sectionItem = item as IScreenSection;
        isMatch = sectionItem.Match(Content, DebugInfo);
      }

      else if ((isMatch == true) && (item.ItemType == ShowItemType.Field))
      {
        var fieldItem = item as IScreenField;
        rc = Content.FieldDict.TryGetValue(zeroLoc, out contentItem);
        if (rc == false)
          isMatch = false;
        
        // can match a screen field to a literal, but only if the field is output
        // only.
        else if ((contentItem is ContentText) 
          && (fieldItem.Usage != ShowUsage.Output))
          isMatch = false;

        else if ((contentItem is ContentField) == false)
          isMatch = false;
        else
        {
          var contentField = contentItem as ContentField;
          if (contentField.LL_Length != atomicItem.Length)
            isMatch = false;
        }
      }

      // match screen literal to actual content on the screen. The content can be
      // either a field or a literal. But the content has to match one of the 
      // values of the screen literal.
      else if ((isMatch == true) && (item.ItemType == ShowItemType.Literal))
      {
        // screen literal has a dsply attr. advance ....
        if ( atomicItem.DsplyAttr.IsNullOrEmpty( ) == false )
        {
          zeroLoc = zeroLoc.Advance(1) as ZeroRowCol;
        }

        var buf = Content.GetContentBytes_NonNull(zeroLoc, atomicItem.Length);
        var itemLit = item as IScreenLiteral;
        var contentText = buf.EbcdicBytesToString().TrimEndWhitespace();

        // match the screen defn item to the screen content.
        isMatch = itemLit.MatchValue(contentText);

        // failed the match. But if the item content is blank. And this screen
        // item is optional then that is ok.
        if ((isMatch == false) && (item.IsOptional == true) && (contentText.Length == 0))
          isMatch = true;
      }

      else if (isMatch == true)
      {
        throw new Exception("unrecognized screen item type");
      }

      return isMatch;
    }
示例#13
0
 public LayoutContentItemViewModel(ContentItemBase contentItemBase, PackageViewModel package)
     : base(contentItemBase)
 {
     _package = package;
 }
示例#14
0
 private LayoutContentItemViewModel CreateContentItemBaseViewModel(ContentItemBase packageContentItem)
 {
     return(new LayoutContentItemViewModel(packageContentItem, this));
 }
示例#15
0
 private bool CanRemoveFromQueue(ContentItemBase item)
 {
     return(this.Queue.ContainsItem(item));
 }
示例#16
0
 private bool CanAddToQueue(ContentItemBase item)
 {
     return(!this.Queue.ContainsItem(item));
 }