示例#1
0
        public WatchListViewModel(IWatchListService watchListService, IMarketFeedService marketFeedService, IRegionManager regionManager, IEventAggregator eventAggregator)
        {
            if (watchListService == null)
            {
                throw new ArgumentNullException("watchListService");
            }

            if (eventAggregator == null)
            {
                throw new ArgumentNullException("eventAggregator");
            }

            this.HeaderInfo = Resources.WatchListTitle;
            this.WatchListItems = new ObservableCollection<WatchItem>();

            this.marketFeedService = marketFeedService;
            this.regionManager = regionManager;

            this.watchList = watchListService.RetrieveWatchList();
            this.watchList.CollectionChanged += delegate { this.PopulateWatchItemsList(this.watchList); };
            this.PopulateWatchItemsList(this.watchList);

            this.eventAggregator = eventAggregator;
            this.eventAggregator.GetEvent<MarketPricesUpdatedEvent>().Subscribe(this.MarketPricesUpdated, ThreadOption.UIThread);

            this.removeWatchCommand = new DelegateCommand<string>(this.RemoveWatch);

            this.watchListItems.CollectionChanged += this.WatchListItems_CollectionChanged;
        }       
        public WatchListViewModel(IWatchListService watchListService, IMarketFeedService marketFeedService, IRegionManager regionManager, IEventAggregator eventAggregator)
        {
            if (watchListService == null)
            {
                throw new ArgumentNullException("watchListService");
            }

            if (eventAggregator == null)
            {
                throw new ArgumentNullException("eventAggregator");
            }

            this.HeaderInfo     = Resources.WatchListTitle;
            this.WatchListItems = new ObservableCollection <WatchItem>();

            this.marketFeedService = marketFeedService;
            this.regionManager     = regionManager;

            this.watchList = watchListService.RetrieveWatchList();
            this.watchList.CollectionChanged += delegate { this.PopulateWatchItemsList(this.watchList); };
            this.PopulateWatchItemsList(this.watchList);

            this.eventAggregator = eventAggregator;
            this.eventAggregator.GetEvent <MarketPricesUpdatedEvent>().Subscribe(this.MarketPricesUpdated, ThreadOption.UIThread);

            this.removeWatchCommand = new DelegateCommand <string>(this.RemoveWatch);

            this.watchListItems.CollectionChanged += this.WatchListItems_CollectionChanged;
        }
        public WatchListViewModel(IStockTraderRICommandProxy stockTraderRICommandProxy, IWatchListService watchListService, IMarketFeedService marketFeedService, IRegionManager regionManager, IEventAggregator eventAggregator)
        {
            if (watchListService == null)
            {
                throw new ArgumentNullException("watchListService");
            }
            if (stockTraderRICommandProxy == null)
            {
                throw new ArgumentNullException("stockTraderRICommandProxy");
            }
            if (eventAggregator == null)
            {
                throw new ArgumentNullException("eventAggregator");
            }

            //Init Prperties
            this.stockTraderRICommandProxy = stockTraderRICommandProxy;
            this.eventAggregator           = eventAggregator;
            this.watchListService          = watchListService;
            this.HeaderInfo        = Resources.WatchListTitle;
            this.WatchListItems    = new ObservableCollection <WatchItem>();
            this.marketFeedService = marketFeedService;
            this.regionManager     = regionManager;

            // Setup Commands
            this.removeWatchCommand = new DelegateCommand <string>(this.RemoveWatch);
            // this.AddWatchCommand = new DelegateCommand<string>(AddWatch);
            this.stockTraderRICommandProxy.AddToWatchListCommand.RegisterCommand(this.watchListService.AddWatchCommand);

            //Setup Subscribers
            this.eventAggregator.GetEvent <MarketPricesUpdatedEvent>().Subscribe(this.MarketPricesUpdated, ThreadOption.UIThread);
            this.eventAggregator.GetEvent <AddWatchTickerSymbolEvent>().Subscribe(i =>
            {
                this.PopulateWatchItemsList(watchListService.RetrieveWatchList());
            }, ThreadOption.UIThread, true
                                                                                  );

            // Populate Watch Items to views
            this.PopulateWatchItemsList(watchListService.RetrieveWatchList());
        }
示例#4
0
        public WatchListPresentationModel(IWatchListView view, IWatchListService watchListService, IMarketFeedService marketFeedService, IEventAggregator eventAggregator)
        {
            View                = view;
            this.HeaderInfo     = Resources.WatchListTitle;
            this.WatchListItems = new ObservableCollection <WatchItem>();
            View.Model          = this;

            this.marketFeedService = marketFeedService;

            this.watchList = watchListService.RetrieveWatchList();
            watchList.CollectionChanged += delegate { PopulateWatchItemsList(watchList); };
            PopulateWatchItemsList(watchList);

            eventAggregator.GetEvent <MarketPricesUpdatedEvent>().Subscribe(MarketPricesUpdated, ThreadOption.UIThread);
            RemoveWatchCommand = new DelegateCommand <string>(RemoveWatch);
        }