Пример #1
0
 /// <summary>Perform the command</summary>
 /// <param name="commandHistory">The command history.</param>
 public void Do(CommandHistory commandHistory)
 {
     if (!supplementsReset) // First call; store a copy of the original values
     {
         prevList = new List <TSupplementItem>(this.suppList.Count);
         for (int i = 0; i < this.suppList.Count; i++)
         {
             TSupplementItem newItem = new TSupplementItem();
             newItem.Assign(suppList[i]);
             prevList.Add(newItem);
         }
     }
     foreach (TSupplementItem supp in suppList)
     {
         int suppNo = TSupplementLibrary.DefaultSuppConsts.IndexOf(supp.Name);
         if (suppNo >= 0)
         {
             string name   = supp.Name;
             double amount = supp.Amount;
             supp.Assign(TSupplementLibrary.DefaultSuppConsts[suppNo]);
             supp.Name   = name;
             supp.Amount = amount;
         }
     }
     supplementsReset = true;
     if (this.parent.curIndex > 0)
     {
         commandHistory.InvokeModelChanged(this.parent[this.parent.curIndex]);
     }
 }
Пример #2
0
        /// <summary>Perform the command</summary>
        /// <param name="commandHistory">The command history.</param>
        public void Do(CommandHistory commandHistory)
        {
            int iSuppNo = TSupplementLibrary.DefaultSuppConsts.IndexOf(this.supplementName);

            if (iSuppNo >= 0)
            {
                this.supplementToAdd = TSupplementLibrary.DefaultSuppConsts[iSuppNo];
                this.prevSuppIdx     = this.parent.curIndex;
                this.parent.curIndex = this.parent.Add(this.supplementName);
                this.supplementAdded = true;
                commandHistory.InvokeModelChanged(this.parent);
            }
        }
Пример #3
0
 /// <summary>
 /// Returns the index of TSupplement in the array of supplements
 /// </summary>
 /// <param name="item"></param>
 /// <returns>The array index, or -1 if not found</returns>
 public int IndexOf(TSupplementItem item)
 {
     return(theModel.IndexOf(item));
 }
Пример #4
0
 public DeleteSupplementCommand(Supplement parent, TSupplementItem supplementItem)
 {
     this.parent             = parent;
     this.supplementToDelete = supplementItem;
 }