示例#1
0
        private void AddItemClickHandler(object sender, EventArgs e)
        {
            Beverage obj = null;

            switch (((Button)sender).Name.ToLower())
            {
            case "buttondripcoffeesmall": obj = new DripCoffeeSmall(); break;

            case "buttondripcoffeemedium": obj = new DripCoffeeMedium(); break;

            case "buttondripcoffeelarge": obj = new DripCoffeeLarge(); break;

            case "buttonlattesmall": obj = new LatteSmall(); break;

            case "buttonlattemedium": obj = new LatteSmall(); break;

            case "buttonlattelarge": obj = new LatteSmall(); break;

            case "buttonespressosmall": obj = new EspressoSmall(); break;

            case "buttonespressomedium": obj = new EspressoMedium(); break;

            case "buttonespressolarge": obj = new EspressoLarge(); break;

            default:
                // TODO - Need to catch this somewhere and display
                throw new ArgumentNullException("Unknown Item Selected");
            }

            _lastItemNodeAdded = AddRootItem(obj);
        }
示例#2
0
        private void buttonRemoveSelectedItem_Click(object sender, EventArgs e)
        {
            ItemTreeNode node = treeOrderList.SelectedNode as ItemTreeNode;

            node.Remove();

            buttonRemoveSelectedItem.Visible = false;
            UpdateTotals();
            // Todo : Need to remove item from the _orderItems object
        }
示例#3
0
 private void InitOrderTree()
 {
     // Create the TreeView Root Node
     _rootNode                    = new ItemTreeNode();
     _rootNode.Text               = "Your Order";
     _rootNode.ForeColor          = AnchorNodeTextColor;
     _rootNode.BackColor          = AnchorNodeTextBackground;
     _rootNode.ImageIndex         = 0;
     _rootNode.SelectedImageIndex = 0;
     treeOrderList.Nodes.Add(_rootNode);
 }
示例#4
0
        private void AddSubItem(ItemTreeNode parentItemNode, Beverage b)
        {
            // TODO - Need to implement the following correctly.
            // parentItemNode is not yet used.
            _orderItems.AddItem(parentItemNode, new OrderItem <Beverage>(b));

            var node = CreateNode(ItemNodeType.SubItem, b);

            parentItemNode.Nodes.Add(node);

            buttonRemoveSelectedItem.Visible = false;
            UpdateTotals();
            treeOrderList.ExpandAll();
        }
示例#5
0
        private void RefreshOrderTree()
        {
            foreach (var i in _orderItems.GetItems())
            {
                Beverage     rootItem = i.RootItem();
                ItemTreeNode rootNode = AddRootItem(rootItem);
                foreach (var s in i.SubItems())
                {
                    AddSubItem(rootNode, s);
                }
            }

                        treeOrderList.ExpandAll();
        }
示例#6
0
        private ItemTreeNode CreateNode(ItemNodeType nodeType, Beverage b)
        {
            ItemTreeNode node = null;

            if (nodeType == ItemNodeType.RootItem)
            {
                node = CreateItemNode(b);
            }
            else if (nodeType == ItemNodeType.SubItem)
            {
                node = CreateSubItemNode(b);
            }
            return(node);
        }
示例#7
0
        private ItemTreeNode CreateSubItemNode(Beverage b)
        {
            var node = new ItemTreeNode(b);
            // TODO - Need to figure out a way to get this to work.
            //string description = (b as BeverageDecorator).GetDecoratorDescriptionOnly();

            string cost = string.Format("{0,15:c}", $"[{b.Cost}]");

            node.Text               = string.Format("{0,30} {1}", b.Description, cost);
            node.ForeColor          = SubItemTextColor;
            node.BackColor          = SubItemTextBackground;
            node.ImageIndex         = 1;
            node.SelectedImageIndex = 1;
            return(node);
        }
示例#8
0
 public void AddItem(ItemTreeNode parentNode, OrderItem <T> item)
 {
     //parentNode.
     AddItem(item);
 }