Esempio n. 1
0
        private void OnElementSelected(PieceOfClothing obj)//Not very straightforward...
        {
            //if selected object is equal to null (for example when updating the list) we might try to put the previously selected item.
            if (obj == null && temporaryItem != null)
            {
                //if the previous item is on the current list then select it.
                if (ClothesList.Exists(x => x.Id == temporaryItem.Id))
                {
                    CurrentItem = ClothesList.Find(x => x.Id == temporaryItem.Id);
                }
                //if the previously selected item is not on the list then just display nothing.
                else
                {
                    CurrentItem = obj;
                }
            }
            //if currently selected object is existing the go for it.
            else
            {
                CurrentItem = obj;
            }
            //notify other objects via event aggragation.
            PieceOfClothingChangedEvent evt = eventAggregator.GetEvent <PieceOfClothingChangedEvent>();

            evt.Publish(CurrentItem);
        }
Esempio n. 2
0
        public ClothesDetailedViewModel(IEventAggregator eventAggregator)
        {
            //Use the event aggregation to catch the newly selected item on the list
            this.eventAggregator = eventAggregator;
            PieceOfClothingChangedEvent evt =
                eventAggregator.GetEvent <PieceOfClothingChangedEvent>();

            evt.Subscribe(OnCurrentItemChanged, true);
        }
        public ClothesDetailsLowerButtonsBarViewModel(IEventAggregator eventAggregator, IClothesServices clothesService)
        {
            this.clothesService  = clothesService;
            this.eventAggregator = eventAggregator;

            DisplayDeleteConfirmation = false;
            InvokePropertyChanged("DisplayPreDeleteButton");

            timer          = new Timer(2000);
            timer.Elapsed += Timer_Elapsed;

            PieceOfClothingChangedEvent evt =
                eventAggregator.GetEvent <PieceOfClothingChangedEvent>();

            evt.Subscribe(OnCurrentItemChanged, true);
        }
Esempio n. 4
0
        public ClothesDetailsActionButtonsViewModel(IEventAggregator eventAggregator,
                                                    IUnityContainer container,
                                                    IRegionManager regionManager,
                                                    IClothesServices clothesService,
                                                    ClothesEditViewModelFactory viewModelFactory)
        {
            //Use the event aggregation to catch the newly selected item on the list
            this.eventAggregator = eventAggregator;
            PieceOfClothingChangedEvent evt =
                eventAggregator.GetEvent <PieceOfClothingChangedEvent>();

            evt.Subscribe(OnCurrentItemChanged, true);

            //Register the injected fields
            this.container            = container;
            this.regionManager        = regionManager;
            this.clothesService       = clothesService;
            this.editViewModelFactory = viewModelFactory;
        }