示例#1
0
        private void GotoCart_Click(object sender, RoutedEventArgs e)
        {
            Consoletxtblock.Text += "Go to Cart Click..." + Environment.NewLine;
            CartWindow cart = new CartWindow();

            cart.valueTxtBox.Text = "0$";
            cart.moneyTxtBox.Text = MoneyTextBox.Text;
            cart.Show();
        }
示例#2
0
        private void AddToCart_Click(object sender, RoutedEventArgs e)
        {
            Consoletxtblock.Text += "Add to Cart Click..." + Environment.NewLine;
            //get ganes from SearchBox
            if (SearchBox.SelectedItems.Count < 1)
            {
                MessageBox.Show("No game has been selected");
                return;
            }
            List <GameData> items = new List <GameData>();

            double[] prices = new double[SearchBox.SelectedItems.Count];
            for (int i = 0; i < SearchBox.SelectedItems.Count; i++)
            {
                GameData game = this.SearchBox.SelectedItems[i] as GameData;
                items.Add(new GameData()
                {
                    Image = game.Image, Title = game.Title, Price = game.Price
                });
                string gameprice = game.Price;
                gameprice = gameprice.Replace("$", string.Empty);
                prices[i] = Convert.ToDouble(gameprice);
            }
            double sum = 0.0;

            //sum game prices
            for (int i = 0; i < SearchBox.SelectedItems.Count; i++)
            {
                sum += prices[i];
            }
            //start new CartWindow
            CartWindow cart = new CartWindow();

            cart.CartBox.ItemsSource = items;
            cart.valueTxtBox.Text    = sum + "$";
            cart.moneyTxtBox.Text    = MoneyTextBox.Text;

            // Add an event handler to update this form

            // when the profile form is updated (when CartUpdated fires).
            cart.CartUpdated += new CartWindow.CartUpdateHandler(AddtoCart_ButtonClicked);

            //show CartWindow
            cart.Show();
        }