public void SelectTopping(int selectionIndex)
        {
            SaladToppingDisplayItem thisSelection = SaladToppingSelectionsList[selectionIndex];

            if (!ToppingFooterPageModel.ExtraToppingSelected ||
                (ToppingFooterPageModel.ExtraToppingSelected && !thisSelection.SaladToppingIsSelected))
            {
                thisSelection.SaladToppingIsSelected = !thisSelection.SaladToppingIsSelected;  //toggle topping selection.
            }

            thisSelection.SaladTopping.ToppingModifier = ToppingFooterPageModel.GetToppingModifierType();
            if (thisSelection.SaladTopping.ToppingModifier == ToppingModifierType.ExtraTopping)
            {
                if (thisSelection.SaladTopping.Count == 0)
                {
                    thisSelection.SaladTopping.Count = 1;
                }
                thisSelection.SaladTopping.Count++;
            }
            else if (thisSelection.SaladTopping.ToppingModifier == ToppingModifierType.NoTopping)
            {
                CurrentSalad.Toppings.RemoveTopping(thisSelection.SaladTopping.ToppingName);
            }

            if (thisSelection.SaladToppingIsSelected)
            {
                if (ToppingFooterPageModel.ExtraToppingSelected &&
                    thisSelection.SaladTopping.Count > 1 &&
                    CurrentSalad.Toppings.IsToppingAlreadyAdded(thisSelection.SaladTopping.ToppingName))
                {
                    CurrentSalad.Toppings.UpdateToppingsTotal();
                    //CurrentSalad.UpdateItemTotal();
                }
                else
                {
                    thisSelection.SaladTopping.SequenceSelected = CurrentSalad.Toppings.CurrentToppings.Count + 1;
                    CurrentSalad.Toppings.AddTopping(thisSelection.SaladTopping);
                    //CurrentSalad.UpdateItemTotal();
                }
            }
            else
            {
                thisSelection.SaladTopping.SequenceSelected = 0;
                thisSelection.SaladTopping.ToppingModifier  = ToppingModifierType.None;
                thisSelection.SaladTopping.Count            = 0;
                CurrentSalad.Toppings.RemoveTopping(thisSelection.SaladTopping.ToppingName);
                //CurrentSalad.UpdateItemTotal();
            }

            //Modifier buttons only work if selected before the topping is selected.  At this point,
            //all should be reset back to black/unselected.
            ToppingFooterPageModel.ExtraToppingSelected  = false;
            ToppingFooterPageModel.LiteToppingSelected   = false;
            ToppingFooterPageModel.NoToppingSelected     = false;
            ToppingFooterPageModel.OnSideToppingSelected = false;
        }
        public void SelectTopping(int selectionIndex)
        {
            //Can't change ListView directly - must change underlying data.  Get this data by the index.
            ToppingDisplayItem thisSelection = ToppingSelectionsList[selectionIndex];

            if (!ToppingFooterPageModel.ExtraToppingSelected ||
                (ToppingFooterPageModel.ExtraToppingSelected && !thisSelection.ListItemIsSelected))
            {
                thisSelection.ListItemIsSelected = !thisSelection.ListItemIsSelected;  //toggle topping selection.
            }

            thisSelection.ListTopping.ToppingModifier = ToppingFooterPageModel.GetToppingModifierType();

            if (thisSelection.ListTopping.ToppingName == ToppingName.Major)
            {
                ProcessMajorToppingSelection(thisSelection);
            }
            //else if (thisSelection.ListTopping.ToppingName == ToppingName.HalfMajor)
            //{
            //    ProcessHalfMajorToppingSelection(thisSelection);
            //}
            else
            {
                if (ToppingFooterPageModel.ExtraToppingSelected)
                {
                    if (thisSelection.ListTopping.Count == 0)
                    {
                        thisSelection.ListTopping.Count = 1;
                    }
                    thisSelection.ListTopping.Count++;
                }
                else if (ToppingFooterPageModel.NoToppingSelected)
                {
                    thisPizza.Toppings.RemoveTopping(thisSelection.ListTopping.ToppingName);
                }

                if (thisSelection.ListItemIsSelected)
                {
                    if (thisSelection.ListTopping.ToppingName == ToppingName.SatchPanSlice)
                    {
                        ThisPizza.ChangePizzaToDeep();
                        OnChangeHeadingPizzaName();
                    }
                    else if (ToppingFooterPageModel.ExtraToppingSelected &&
                             thisSelection.ListTopping.Count > 1 &&
                             ThisPizza.Toppings.IsToppingAlreadyAdded(thisSelection.ListTopping.ToppingName))
                    {
                        ThisPizza.Toppings.UpdateToppingsTotal();
                        ThisPizza.UpdateItemTotal();
                        thisSelection.SelectionColor  = Xamarin.Forms.Color.CornflowerBlue;
                        thisSelection.ButtonWSelected = true;
                    }
                    else
                    {
                        thisSelection.ListTopping.SequenceSelected = ThisPizza.Toppings.CurrentToppings.Count + 1;
                        ThisPizza.Toppings.AddTopping(thisSelection.ListTopping);
                        ThisPizza.UpdateItemTotal();
                        thisSelection.SelectionColor  = Xamarin.Forms.Color.CornflowerBlue;
                        thisSelection.ButtonWSelected = true;
                    }
                }
                else
                {
                    if (thisSelection.ListTopping.ToppingName == ToppingName.SatchPanSlice &&
                        ThisPizza.PizzaType == PizzaType.PanSlice)
                    {
                        ThisPizza.ChangePizzaSliceFromPanToThin();
                        OnChangeHeadingPizzaName();
                    }
                    thisSelection.ListTopping.SequenceSelected = 0;
                    thisSelection.ListTopping.ToppingModifier  = ToppingModifierType.None;
                    thisSelection.ListTopping.Count            = 0;
                    ThisPizza.Toppings.RemoveTopping(thisSelection.ListTopping.ToppingName);
                    thisSelection.SelectionColor  = Xamarin.Forms.Color.Black;
                    thisSelection.ButtonASelected = false;
                    thisSelection.ButtonBSelected = false;
                    thisSelection.ButtonWSelected = false;
                }

                //Modifier buttons only work if selected before the topping is selected.  At this point,
                //all should be reset back to black/unselected.
                ToppingFooterPageModel.ExtraToppingSelected  = false;
                ToppingFooterPageModel.LiteToppingSelected   = false;
                ToppingFooterPageModel.NoToppingSelected     = false;
                ToppingFooterPageModel.OnSideToppingSelected = false;
            }

            //Can't remember why I might need this....
            //if (thisSelection.ListTopping.ToppingName == ToppingName.Cheese)
            //{
            //    if (App.AllToppings.ContainsKey(ToppingName.NoCheese))
            //    {
            //        thisPizza.Toppings.AddTopping(App.AllToppings[ToppingName.NoCheese]);
            //    }
            //}
            //else if (thisSelection.ListTopping.ToppingName == ToppingName.RicottaCalzone ||
            //    thisSelection.ListTopping.ToppingName == ToppingName.Ricotta)
            //{
            //    if (App.AllToppings.ContainsKey(ToppingName.NoRicotta))
            //    {
            //        thisPizza.Toppings.AddTopping(App.AllToppings[ToppingName.NoRicotta]);
            //    }
            //}
        }
Esempio n. 3
0
        public void SelectTopping(int selectionIndex)
        {
            //Can't change ListView directly - must change underlying data.  Get this data by the index.
            CalzoneToppingDisplayItem thisSelection = ToppingSelectionsList[selectionIndex];

            if (!ToppingFooterPageModel.ExtraToppingSelected ||
                (ToppingFooterPageModel.ExtraToppingSelected && !thisSelection.ListItemIsSelected))
            {
                thisSelection.ListItemIsSelected = !thisSelection.ListItemIsSelected;  //toggle topping selection.
            }

            if (thisSelection.ListTopping.ToppingName == ToppingName.Major)
            {
                ProcessMajorToppingSelection(thisSelection);
            }
            else
            {
                thisSelection.ListTopping.ToppingModifier = ToppingFooterPageModel.GetToppingModifierType();

                if (ToppingFooterPageModel.ExtraToppingSelected)
                {
                    if (thisSelection.ListTopping.Count == 0)
                    {
                        thisSelection.ListTopping.Count = 1;
                    }
                    thisSelection.ListTopping.Count++;
                }
                else if (ToppingFooterPageModel.NoToppingSelected)
                {
                    ThisCalzone.Toppings.RemoveTopping(thisSelection.ListTopping.ToppingName);
                }

                if (thisSelection.ListItemIsSelected)
                {
                    if (thisSelection.ListTopping.ToppingName == ToppingName.SteakNCheeseCalzone)
                    {
                        ThisCalzone.ChangeCalzoneToSteakAndCheese();
                        OnChangeHeadingCalzoneName();
                    }
                    if (ToppingFooterPageModel.ExtraToppingSelected &&
                        thisSelection.ListTopping.Count > 1 &&
                        ThisCalzone.Toppings.IsToppingAlreadyAdded(thisSelection.ListTopping.ToppingName))
                    {
                        ThisCalzone.Toppings.UpdateToppingsTotal();
                    }
                    else
                    {
                        thisSelection.ListTopping.SequenceSelected = ThisCalzone.Toppings.CurrentToppings.Count + 1;
                        ThisCalzone.Toppings.AddTopping(thisSelection.ListTopping);
                    }
                }
                else
                {
                    if (thisSelection.ListTopping.ToppingName == ToppingName.SteakNCheeseCalzone)
                    {
                        ThisCalzone.ChangeCalzoneFromSteakToRegular();
                        OnChangeHeadingCalzoneName();
                    }
                    thisSelection.ListTopping.SequenceSelected = 0;
                    thisSelection.ListTopping.ToppingModifier  = ToppingModifierType.None;
                    thisSelection.ListTopping.Count            = 0;
                    ThisCalzone.Toppings.RemoveTopping(thisSelection.ListTopping.ToppingName);
                }

                //Modifier buttons only work if selected before the topping is selected.  At this point,
                //all should be reset back to black/unselected.
                ToppingFooterPageModel.ExtraToppingSelected  = false;
                ToppingFooterPageModel.LiteToppingSelected   = false;
                ToppingFooterPageModel.NoToppingSelected     = false;
                ToppingFooterPageModel.OnSideToppingSelected = false;
            }
        }