Exemplo n.º 1
0
        private void ShowAllEntities(string displayName)
        {
            UserControl view = this.Views.FirstOrDefault(v => (v.DataContext as WorkspaceViewModel).DisplayName == displayName);

            WorkspaceViewModel viewModel = null;

            if (view == null)
            {
                switch (displayName)
                {
                case "View all products":
                    view      = new MultiProductView();
                    viewModel = new MultiEntityViewModel <Laptop, LaptopViewModel, EntityView>();
                    break;

                case "View all customers":
                    view      = new MultiCustomerView();
                    viewModel = new MultiEntityViewModel <Customer, CustomerViewModel, CustomerView>();
                    break;

                case "View all locations":
                    view      = new MultiLocationView();
                    viewModel = new MultiEntityViewModel <Location, LocationViewModel, LocationView>();
                    break;

                case "View all categories":
                    view      = new MultiCategoryView();
                    viewModel = new MultiEntityViewModel <Category, CategoryViewModel, CategoryView>();
                    break;

                case "View all orders":
                    view      = new MultiOrderView();
                    viewModel = new MultiEntityViewModel <Order, OrderViewModel, OrderView>();
                    break;
                }

                viewModel.RequestClose += this.OnWorkspaceRequestClose;

                view.DataContext = viewModel;

                this.Views.Add(view);
            }

            this.ActivateViewModel(view);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the CustomerViewModel class.
 /// </summary>
 /// <param name="customer">The customer to be shown.</param>
 public CustomerViewModel(Customer customer)
     : base("New customer", customer)
 {
     this.filteredOrderViewModel             = new MultiEntityViewModel <Order, OrderViewModel, OrderView>();
     this.filteredOrderViewModel.AllEntities = this.FilteredOrders;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the OrderViewModel class.
 /// </summary>
 /// <param name="order">The order to be shown.</param>
 public OrderViewModel(Order order)
     : base("New order", order)
 {
     this.filteredLineViewModel             = new MultiEntityViewModel <OrderLine, OrderLineViewModel, OrderLineView>();
     this.filteredLineViewModel.AllEntities = this.FilteredLines;
 }
Exemplo n.º 4
0
 public LaptopViewModel(Laptop laptop)
     : base("New laptop", laptop)
 {
     this.filteredCategoryViewModel             = new MultiEntityViewModel <Category, CategoryViewModel, CategoryView>();
     this.filteredCategoryViewModel.AllEntities = this.FilteredCategories;
 }