/// <summary>
        /// Used for creating the actual CustomizationScreen window. This is done seperately to allow for the recreation of the screen
        /// to reflect recent updates to items, specifically when changed through a combo item.
        /// </summary>
        private void Refresh()
        {
            setControls = new List <Control>();
            List <CheckBox> addLast = new List <CheckBox>(); //Just to put the drop downs above them.

            MainPanel.Children.RemoveRange(2, MainPanel.Children.Count);
            MenuItemLabel.Text = item.GetType().Name;
            if (!(item is ComboItem))
            {
                foreach (PropertyInfo p in item.GetType().GetProperties())
                {
                    if (p.CanWrite)
                    {
                        if (p.PropertyType.Name == "Boolean")
                        {
                            CreateFromBoolean(item as IOrderItem, p, addLast);
                        }
                        else if (p.PropertyType.IsEnum)
                        {
                            CreateFromEnum(item as IOrderItem, p);
                        }
                    }
                }
                //Add those checkboxes.
                foreach (CheckBox cb in addLast)
                {
                    MainPanel.Children.Add(cb);
                    setControls.Add(cb);
                }
            }
            else
            {
                CreateComboItem(item as ComboItem);
            }
        }
Beispiel #2
0
        }//end OnGet()

        /// <summary>
        /// Builds the string that is displayed
        /// </summary>
        /// <param name="item">the item that you want displayed</param>
        /// <returns>returns string to display</returns>
        public static string BuildString(IOrderItem item)
        {
            StringBuilder sb = new StringBuilder();
            //name of item, price, and calories
            string name = item.GetType().Name;

            foreach (PropertyInfo pi in item.GetType().GetProperties())
            {
                if (pi.Name.ToLower() == "size")
                {
                    dynamic dynamicItem = item;
                    sb.Append($"{dynamicItem.Size}");
                }//end if this property is the size property
            }//end looping foreach property in the item's type

            foreach (PropertyInfo pi in item.GetType().GetProperties())
            {
                if (pi.Name.ToLower() == "flavor")
                {
                    dynamic dynamicItem = item;
                    sb.Append($" {dynamicItem.Flavor}");
                }//end if this property is the flavor property
            }//end looping foreach property in the item's type

            foreach (PropertyInfo pi in item.GetType().GetProperties())
            {
                if (pi.Name.ToLower() == "decaf")
                {
                    dynamic dynamicItem = item;
                    if(dynamicItem.Decaf = true)
                    {
                        sb.Append($" Decaf");
                    }//end if the item is decafinated
                }//end if this property is the flavor property
            }//end looping foreach property in the item's type

            for (int i = 0; i < name.Length; i++)
            {
                if (Char.IsUpper(name[i]) && sb.Length != 0) sb.Append(" ");
                sb.Append(name[i]);
            }//end looping for each character in name

            sb.Append(": ");
            sb.Append(item.Description);
            sb.Append("\t");
            sb.Append(item.Calories);
            sb.Append(" Cals\t");
            sb.Append(item.Price.ToString("C2"));
            return sb.ToString();
        }//end BuildString(item, hasSizeProperty)
 /// <summary>
 /// Creates a new OrderedItem button and stores the orderItem to it.
 /// </summary>
 /// <param name="orderItem"></param>
 public OrderedItem(IOrderItem orderItem, ItemSelectionScreen iss)
 {
     InitializeComponent();
     this.DataContext = orderItem;
     this.iss         = iss;
     this.Content     = orderItem.GetType().Name;
 }
        /// <summary>
        /// Gets all of the items that would be used in a combo box for combo items.
        /// </summary>
        /// <param name="items">A list of all items that would be contained in the combo box</param>
        /// <param name="obj">An instance of an item that was already created to add to the combo box instead of the default value of that object.</param>
        /// <returns></returns>
        private IEnumerable <IOrderItem> GetItemsForComboBox(IEnumerable <IOrderItem> items, IOrderItem obj)
        {
            List <IOrderItem> _list      = new List <IOrderItem>();
            List <Type>       _usedTypes = new List <Type>();

            _list.Add(obj);
            _usedTypes.Add(obj.GetType());
            if (obj is Drink)
            {
                foreach (Drink e in items)
                {
                    if (!e.GetType().Equals(obj.GetType()) && !_usedTypes.Contains(e.GetType()) && e.Size == (obj as Drink).Size)
                    {
                        _list.Add(e);
                        _usedTypes.Add(e.GetType());
                    }
                }
            }
            else if (obj is Side)
            {
                foreach (Side e in items)
                {
                    if (!e.GetType().Equals(obj.GetType()) && !_usedTypes.Contains(e.GetType()) && e.Size == (obj as Side).Size)
                    {
                        _list.Add(e);
                        _usedTypes.Add(e.GetType());
                    }
                }
            }
            else if (obj is Entree)
            {
                foreach (Entree e in items)
                {
                    if (!e.GetType().Equals(obj.GetType()) && !_usedTypes.Contains(e.GetType()))
                    {
                        _list.Add(e);
                        _usedTypes.Add(e.GetType());
                    }
                }
            }
            return(_list);
        }
Beispiel #5
0
        /// <summary>
        /// Find similair items object from the filtered menu list to display sizes correctly
        /// </summary>
        /// <param name="orderItems">list of filtered menu items</param>
        /// <param name="x">item to find similiar one of</param>
        /// <returns>List of items which are the similiar</returns>
        public List <IOrderItem> ListExtractor(IEnumerable <IOrderItem> orderItems, IOrderItem x)
        {
            string finder = x.GetType().Name;

            List <IOrderItem> sameItems = new List <IOrderItem>();

            foreach (IOrderItem item in orderItems)
            {
                if (finder == item.GetType().Name)
                {
                    sameItems.Add(item);
                }
            }
            used.Add(finder);
            return(sameItems);
        }
Beispiel #6
0
        /// <summary>
        /// Replaces the item with the same type of the given IOrderItem with the given item
        /// </summary>
        /// <param name="list">The ListBox to replace from</param>
        /// <param name="item">An IOrderItem to replace in the list</param>
        void ReplaceOfType(ListBox list, IOrderItem item)
        {
            var items = new List <IOrderItem>(list.ItemsSource.Cast <IOrderItem>());

            // Get the index of the item in the list with the same type as the item
            int i;

            for (i = 0; i < items.Count; i++)
            {
                if (items[i].GetType() == item.GetType())
                {
                    break;
                }
            }

            // Remove the item
            items[i] = item;

            list.ItemsSource = items;
        }
        /// <summary>
        /// Initializes all of the form's elements that correspond with the orderItem's properties. Calls the GetProperties() method from Reflection to find all properties that need a form element
        /// to be created, and then uses all booleans and enums (first creating the arrays responsible) and then passing the PropertyInfo for each property and the correct index to
        /// InitializesCheckBoxes and InitializeComboBoxes to create all of the form's relevant elements.
        /// </summary>
        public void InitializeFormComponents()
        {
            PropertyInfo[] tests = orderItem.GetType().GetProperties();

            int comboBoxCounter = 0;
            int checkBoxCounter = 0;

            foreach (PropertyInfo item in tests)
            {
                if (item.PropertyType.ToString().Contains("BleakwindBuffet.Data.Enums"))
                {
                    comboBoxCounter++;
                }
                else if (item.PropertyType.ToString().Equals("System.Boolean"))
                {
                    checkBoxCounter++;
                }
            }

            checkBoxes       = new CheckBox[checkBoxCounter];
            comboBoxes       = new ComboBox[comboBoxCounter];
            checkBoxBindings = new Binding[checkBoxCounter];
            comboBoxBindings = new Binding[comboBoxCounter];

            checkBoxCounter = 0;
            comboBoxCounter = 0;

            foreach (PropertyInfo item in tests)
            {
                if (item.PropertyType.ToString().Contains("BleakwindBuffet.Data.Enums"))
                {
                    InitializeComboBoxes(comboBoxCounter, item);
                    comboBoxCounter++;
                }
                else if (item.PropertyType.ToString().Equals("System.Boolean"))
                {
                    InitializeCheckBoxes(checkBoxCounter, item);
                    checkBoxCounter++;
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// Checks if the item has a property in POSSIBLE_OPTIONS and if so adds a checkbox or combo box for that property
        /// Binds that box to the property as well
        /// </summary>
        /// <param name="item"></param>
        public void LoadOptionsForItem(IOrderItem item)
        {
            label.Content = $"Customization Window for {item.DisplayName}";

            this.DataContext = item;
            // if this item is a combo item
            // load choice of entree, side, and drink
            if (item is Combo combo)
            {
                AddComboItemPanel(BleakwindBuffet.Data.Menu.EntreeTypes());
                AddComboItemPanel(BleakwindBuffet.Data.Menu.SideTypes());
                AddComboItemPanel(BleakwindBuffet.Data.Menu.DrinkTypes());
            }
            else
            {
                foreach (var property in item.GetType().GetProperties())
                {
                    if (property == null)
                    {
                        continue;
                    }

                    string option = property.Name;

                    if (property.PropertyType == typeof(Boolean))
                    {
                        AddCheckBox(property, option, (bool)property.GetValue(item));
                    }
                    else if (property.PropertyType == typeof(Size))
                    {
                        AddComboBox(property, Sizes.GetSizes());
                    }
                    else if (property.PropertyType == typeof(SodaFlavor))
                    {
                        AddComboBox(property, SodaFlavors.GetFlavors());
                    }
                }
            }
        }
        public ModifyItemControl(IOrderItem item)
        {
            DataContext           = item;
            item.PropertyChanged += (sender, e) => { itemText.GetBindingExpression(TextBlock.TextProperty).UpdateTarget(); }; // Force the texbox to update
            var type = item.GetType();

            InitializeComponent();

            // Loop through all the properties and add the wanted checkboxes
            PropertyInfo[] myPropertyInfo = type.GetProperties();
            for (int i = 0; i < myPropertyInfo.Length; i++)
            {
                if (myPropertyInfo[i].PropertyType == typeof(bool))
                {
                    Viewbox  holdCheck = new Viewbox();
                    CheckBox checkBox  = new CheckBox();
                    checkBox.Content = Regex.Replace(myPropertyInfo[i].Name, "([a-z])([A-Z])", "$1 $2"); // Make a nice name

                    Binding binding = new Binding();
                    binding.Source = DataContext;
                    binding.Path   = new PropertyPath(myPropertyInfo[i].Name);
                    binding.Mode   = BindingMode.TwoWay;
                    checkBox.SetBinding(CheckBox.IsCheckedProperty, binding);

                    holdCheck.Child = checkBox;

                    OptionPanel.Children.Add(holdCheck);
                }
            }

            if (type.GetProperty("Size") != null)
            {
                sizePanel.Visibility = Visibility.Visible;
            }
            if (type.GetProperty("Flavor") != null)
            {
                sodaPanel.Visibility = Visibility.Visible;
            }
        }
Beispiel #10
0
        /// <summary>
        /// Dynamically adds check boxes to customize the order item.
        /// </summary>
        /// <param name="item"></param>
        void AddCheckBoxesForBooleanProperties(IOrderItem item)
        {
            List <CheckBox> Controls = new List <CheckBox>();

            foreach (PropertyInfo prop in item.GetType().GetProperties())
            {
                if (prop.PropertyType == typeof(bool))
                {
                    Binding newBinding = new Binding(prop.Name);
                    newBinding.Source = item;

                    CheckBox newCheckBox = new CheckBox();
                    newCheckBox.Content = prop.Name;
                    newCheckBox.SetBinding(CheckBox.IsCheckedProperty, newBinding);

                    ScaleTransform scale = new ScaleTransform(2.0, 2.0);
                    newCheckBox.RenderTransform = scale;

                    Controls.Add(newCheckBox);
                }
            }

            CheckBoxList.ItemsSource = Controls;
        }
Beispiel #11
0
        /// <summary>
        /// edits the item in the combo
        /// </summary>
        /// <param name="item"> said item to change </param>
        public void editItem(IOrderItem item)
        {
            entreeBorder.Child = null;
            drinkBorder.Child  = null;
            sideBorder.Child   = null;
            b1.IsEnabled       = false;
            b2.IsEnabled       = false;
            b3.IsEnabled       = false;

            if (item.GetType() == typeof(BriarheartBurger))
            {
                editBorder.Child = new BriarheartBurgerCustomization(this, (BriarheartBurger)item);
            }
            else if (item.GetType() == typeof(DoubleDraugr))
            {
                editBorder.Child = new DoubleDraugrCustomization(this, (DoubleDraugr)item);
            }
            else if (item.GetType() == typeof(ThalmorTriple))
            {
                editBorder.Child = new ThalmorTripleCustomization(this, (ThalmorTriple)item);
            }
            else if (item.GetType() == typeof(SmokehouseSkeleton))
            {
                editBorder.Child = new SmokehouseSkeletonCustomization(this, (SmokehouseSkeleton)item);
            }
            else if (item.GetType() == typeof(GardenOrcOmelette))
            {
                editBorder.Child = new GardenOrcOmeletteCustomization(this, (GardenOrcOmelette)item);
            }
            else if (item.GetType() == typeof(PhillyPoacher))
            {
                editBorder.Child = new PhillyPoacherCustomization(this, (PhillyPoacher)item);
            }
            else if (item.GetType() == typeof(ThugsTBone))
            {
                editBorder.Child = new ThugsTBoneCustomization(this, (ThugsTBone)item);
            }

            else if (item.GetType() == typeof(SailorSoda))
            {
                editBorder.Child = new SailorSodaCustomization(this, (SailorSoda)item);
            }
            else if (item.GetType() == typeof(MarkarthMilk))
            {
                editBorder.Child = new MarkarthMilkCustomization(this, (MarkarthMilk)item);
            }
            else if (item.GetType() == typeof(AretinoAppleJuice))
            {
                editBorder.Child = new AretinoAppleJuiceCustomization(this, (AretinoAppleJuice)item);
            }
            else if (item.GetType() == typeof(CandlehearthCoffee))
            {
                editBorder.Child = new CandlehearthCoffeeCustomization(this, (CandlehearthCoffee)item);
            }
            else if (item.GetType() == typeof(WarriorWater))
            {
                editBorder.Child = new WarriorWaterCustomization(this, (WarriorWater)item);
            }

            else if (item.GetType() == typeof(VokunSalad))
            {
                editBorder.Child = new VokunSaladCustomization(this, (VokunSalad)item);
            }
            else if (item.GetType() == typeof(FriedMiraak))
            {
                editBorder.Child = new FriedMiraakCustomization(this, (FriedMiraak)item);
            }
            else if (item.GetType() == typeof(MadOtarGrits))
            {
                editBorder.Child = new MadOtarGritsCustomization(this, (MadOtarGrits)item);
            }
            else if (item.GetType() == typeof(DragonbornWaffleFries))
            {
                editBorder.Child = new DragonbornWaffleFriesCustomization(this, (DragonbornWaffleFries)item);
            }
        }
Beispiel #12
0
        /// <summary>
        /// Method that sends the Point of Sale to a customization screen for the item being editted after
        /// it had been added to the order already
        /// </summary>
        /// <param name="item">The item being editted</param>
        public void ReturnToItemScreen(IOrderItem item)
        {
            //Set the DataContext to a variable and make sure the value is not null
            var order = DataContext as Order;

            if (order == null)
            {
                throw new Exception("Datacontext expected to be an order instance");
            }

            //Create a variable for the customization control to go to and set its value based on item
            FrameworkElement screen = null;

            switch (item.GetType().Name)
            {
            case "AngryChicken":
                screen = new CustomizeAngryChicken();
                break;

            case "CowpokeChili":
                screen = new CustomizeCowpokeChili();
                break;

            case "RustlersRibs":
                screen = new CustomizeRustlersRibs();
                break;

            case "PecosPulledPork":
                screen = new CustomizePecosPulledPork();
                break;

            case "TrailBurger":
                screen = new CustomizeTrailBurger();
                break;

            case "DakotaDoubleBurger":
                screen = new CustomizeDakotaDoubleBurger();
                break;

            case "TexasTripleBurger":
                screen = new CustomizeTexasTripleBurger();
                break;

            case "ChiliCheeseFries":
                screen = new CustomizeChiliCheeseFries();
                break;

            case "CornDodgers":
                screen = new CustomizeCornDodgers();
                break;

            case "PanDeCampo":
                screen = new CustomizePanDeCampo();
                break;

            case "BakedBeans":
                screen = new CustomizeBakedBeans();
                break;

            case "CowboyCoffee":
                screen = new CustomizeCowboyCoffee();
                break;

            case "JerkedSoda":
                screen = new CustomizeJerkedSoda();
                break;

            case "TexasTea":
                screen = new CustomizeTexasTea();
                break;

            case "Water":
                screen = new CustomizeWater();
                break;

            default:
                screen = null;
                break;
            }

            //If screen was set to a value, go to that control
            if (screen != null)
            {
                screen.DataContext = item;
                SwapScreen(screen);
            }
        }