private void UserControl_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (MovingEnabled)
            {
                //this.Dragged.Invoke(this, new EventArgs());

                BillItemControl item = sender as BillItemControl;
                DragDrop.DoDragDrop(item, item, DragDropEffects.Move);

                //this.Released.Invoke(this, new EventArgs());

                /*
                 * Issue -- Allows items to be moved around from their own bill
                 * The Issue with above code is that when item is moved from one bill to another the starting bill will unsubscribe to this items events
                 * and the second bill will subscribe to item's events thereby causing both bills to have their droppability disabled.
                 */
            }
            else if (SplitEnabled)
            {
                this.Clicked.Invoke(this, new BICEventArgs()
                {
                    bic = this
                });
            }
            else
            {
                //Do nothing
            }
        }
Example #2
0
        public void CreateView()
        {
            viewList = new List <BillItemControl>();
            BillItemControl billItemView = new BillItemControl(this);

            viewList.Add(billItemView);
            billItemView.Deleted += new EventHandler <BICEventArgs>(HandleViewDeletion);
        }
Example #3
0
 public void AddItem(BillItemControl item)
 {
     this.ItemListGrid.Children.Add(item);
     item.billControl = this;
     //Subscribing to BillItemControl events -- Used for move drag and drop
     item.Removed += new EventHandler <BICEventArgs>(RemoveItem);
     item.Clicked += new EventHandler <BICEventArgs>(SplitSelection);
     item.Deleted += new EventHandler <BICEventArgs>(DeleteItem);
 }
Example #4
0
        //Logic to split orders
        public void SplitOrderEvenly(List <Bill> billsAffected, BillItemControl bic)
        {
            int numberOfBills = 1 + billsAffected.Count;

            //Calculate the prices of an even split between affected parties
            List <double> prices = calculatePrices(bic.itemPrice, numberOfBills);

            //This loop looks for items inside existing bills or creates new bills
            bic.ChangePrice(prices[0]);
            int index = 1;

            foreach (Bill bill in billsAffected)
            {
                BillItemControl associatedBIC = bill.GetRespectiveItem(this);
                if (associatedBIC == null)
                {
                    //New Bill must create it
                    //Must retain properties of old bill item
                    associatedBIC = new BillItemControl(this, prices[index]);
                    if (bic.itemSent)
                    {
                        associatedBIC.itemSent = true;
                        associatedBIC.CancelButton.Visibility = System.Windows.Visibility.Hidden;
                        SolidColorBrush mySolidColorBrush = new SolidColorBrush();
                        mySolidColorBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#7F7F7F"));
                        associatedBIC.BackgroundColor.Fill = mySolidColorBrush;
                    }

                    viewList.Add(associatedBIC);
                    associatedBIC.Deleted += new EventHandler <BICEventArgs>(HandleViewDeletion);
                    bill.AddExistingItem(associatedBIC);
                }
                else
                {
                    //If it is not a new bill then the price is the old price + new price split into it
                    associatedBIC.ChangePrice(prices[index] + associatedBIC.itemPrice);
                }
                index++;
            }
        }
Example #5
0
        private void ItemListGrid_Drop(object sender, DragEventArgs e)
        {
            BillItemControl itemC = (BillItemControl)e.Data.GetData("AppProject.BillItemControl");
            //Original Item is not in this current bill so add without issue

            BillItemControl bic = billLogic.GetRespectiveItem(itemC.originalItem);

            if (bic == null)
            {
                itemC.Moved();
                billLogic.AddExistingItem(itemC);
            }
            //Checking if your dragging into the same bill.
            else if (itemC.billControl.Equals(bic.billControl))
            {
                //Nothing needs to be done in this instance
            }
            //Item was found to be in the same bill need to combine them and delete one.
            else
            {
                itemC.originalItem.Combine(bic, itemC);
                itemC.Delete();
            }
        }
Example #6
0
 //Combines two seperate BillItemControls
 // *** TO BE USED ONLY ON BILLITEMCONTROLS WITHIN THE SAME BILLLOGIC ***
 public void Combine(BillItemControl combined, BillItemControl destroyed)
 {
     combined.ChangePrice(combined.itemPrice + destroyed.itemPrice);
     //Destroy the second item
     destroyed.ChangePrice(0);
 }
Example #7
0
 public void AddExistingItem(BillItemControl bic)
 {
     billView.AddItem(bic);
     UpdateTotalsInViews();
 }