Exemple #1
0
        private void AlbumCombobox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int myIndex          = albumCombobox.SelectedIndex; // hitta index
            DepecheModeAlbum alb = albumArray[myIndex];         // kolla upp vilket album detta index representerar

            recordInfo.Content = "The album: " + Environment.NewLine + alb.Title + Environment.NewLine + "was released in " + alb.Description
                                 + Environment.NewLine + "we are selling it for the " + Environment.NewLine + "price of " + alb.Price + "kr";

            string imagePathForListboxItemSelected = "";
            string x = imagePaths[myIndex];

            imagePathForListboxItemSelected = x;
            ImageSource mySource = new BitmapImage(new Uri(imagePathForListboxItemSelected, UriKind.Relative));
            Image       imageForListboxSelected = new Image
            {
                Source              = mySource,
                Width               = 153,
                Height              = 153,
                Stretch             = Stretch.UniformToFill,
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Center,
                Margin              = new Thickness(5)
            };

            RenderOptions.SetBitmapScalingMode(imageForListboxSelected, BitmapScalingMode.HighQuality);
            grid.Children.Add(imageForListboxSelected);
            Grid.SetRow(imageForListboxSelected, 0);
            Grid.SetColumn(imageForListboxSelected, 0);
        }
Exemple #2
0
 private void RemoveFromCartButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         int index          = cart.SelectedIndex;
         DepecheModeAlbum d = cartList[index];
         cart.Items.RemoveAt(index);
         cartList.RemoveAt(index);
         amount -= d.Price;
         totalAmountInCart.Content = "Total " + amount + " Kr";
     }
     catch (ArgumentOutOfRangeException)
     {
         MessageBox.Show("Please select a product to remove");
     }
 }
Exemple #3
0
        public void AddToCartButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int index          = albumCombobox.SelectedIndex;
                DepecheModeAlbum d = albumList[index];
                cart.Items.Add("Depeche Mode " + "      Album: " + d.Title + "     Pris: " + d.Price + "Kr");
                amount += d.Price;
                totalAmountInCart.Content = "Total " + amount + " Kr";

                cartList.Add(new DepecheModeAlbum
                {
                    Title = d.Title,
                    Price = d.Price
                });
            }
            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("Please select a product to add");
            }
        }