Beispiel #1
0
        //Handles BillItemControl deletion events
        private void HandleViewDeletion(object sender, BICEventArgs e)
        {
            viewList.Remove(e.bic);
            e.bic.Deleted -= new EventHandler <BICEventArgs>(HandleViewDeletion);
            if (viewList.Count == 0)
            {
                this.Empty.Invoke(this, new ItemEventArgs()
                {
                    item = this
                });
            }

            //If the price is set to 0 then its been handled by something else so fase to deleted completely
            else if (e.bic.itemPrice == 0)
            {
                //e.bic = null;
            }

            //Need to recalculate other bills
            //Mechanism, going to default evenly allocate the price of specific split to other bills.
            //Will not perfectly evenly distribute bills.
            else
            {
                double        priceToBeDistributed = e.bic.itemPrice;
                List <double> prices = calculatePrices(priceToBeDistributed, viewList.Count);
                int           index  = 0;
                foreach (BillItemControl bic in viewList)
                {
                    bic.ChangePrice(bic.itemPrice + prices[index]);
                    index++;
                }
            }
        }
Beispiel #2
0
 private void DeleteItem(object sender, BICEventArgs e)
 {
     this.ItemListGrid.Children.Remove(e.bic);
     e.bic.Removed -= new EventHandler <BICEventArgs>(RemoveItem);
     e.bic.Clicked -= new EventHandler <BICEventArgs>(SplitSelection);
     e.bic.Deleted -= new EventHandler <BICEventArgs>(DeleteItem);
     this.BillItemListChange.Invoke(this, new EventArgs());
 }
Beispiel #3
0
 private void RemoveItem(object sender, BICEventArgs e)
 {
     this.ItemListGrid.Children.Remove(e.bic);
     this.BillItemListChange.Invoke(this, new EventArgs());
     //Unsubscribing from BillItemControl(BIC) Events for the BIC removed
     e.bic.Removed -= new EventHandler <BICEventArgs>(RemoveItem);
     e.bic.Clicked -= new EventHandler <BICEventArgs>(SplitSelection);
     e.bic.Deleted -= new EventHandler <BICEventArgs>(DeleteItem);
 }
Beispiel #4
0
 private void SplitSelection(object sender, BICEventArgs e)
 {
     this.SplitRequest.Invoke(this, e);
 }