コード例 #1
0
        private void AddToShoppingCart(object sender, RoutedEventArgs e)
        {
            if (PrintTypeComboBox.SelectedItem != null)
            {
                PrintBase item;
                switch (PrintTypeComboBox.SelectedIndex)
                {
                case 0:
                    item = new Print(CurrentPhoto.Source as BitmapSource);
                    break;

                case 1:
                    item = new GreetingCard(CurrentPhoto.Source as BitmapSource);
                    break;

                case 2:
                    item = new Shirt(CurrentPhoto.Source as BitmapSource);
                    break;

                default:
                    return;
                }
                ShoppingCart.Add(item);
                ShoppingCartListBox.ScrollIntoView(item);
                ShoppingCartListBox.SelectedItem = item;
                if (false == UploadButton.IsEnabled)
                {
                    UploadButton.IsEnabled = true;
                }
                if (false == RemoveButton.IsEnabled)
                {
                    RemoveButton.IsEnabled = true;
                }
            }
        }
コード例 #2
0
ファイル: window1.xaml.cs プロジェクト: ruo2012/samples-1
        private void AddToPhotoTray(object sender, RoutedEventArgs e)
        {
            if (PrintTypeComboBox.SelectedItem != null)
            {
                foreach (Photo p in PhotosListBox.SelectedItems)
                {
                    Print print = GetPrintFromPhotoTray(p, PrintTypeComboBox.SelectedItem as PrintType);

                    if (print != null)
                    {
                        print.Quantity++;
                    }
                    else
                    {
                        print = new Print(p, PrintTypeComboBox.SelectedItem as PrintType, 1);
                        PhotoTray.Add(print);
                    }
                }
            }
        }