Exemplo n.º 1
0
        public UsageViewModel(IEventAggregator eventAggregator, IUsageService usageService, IMenuService menuService, IRegionManager regionManager)
        {
            this.eventAggregator = eventAggregator;
            this.usageService    = usageService;
            this.menuService     = menuService;
            this.regionManager   = regionManager;

            CounterpartyChangeEvent counterpartyChangeEvent = eventAggregator.GetEvent <CounterpartyChangeEvent>();

            counterpartyChangeEvent.Subscribe(OnCounterpartyChanged);

            showUsageCommand = new DelegateCommand(ShowUsage);

            menuService.RegisterMenu(new MenuEntry()
            {
                Text = viewName, Command = showUsageCommand
            });
        }
Exemplo n.º 2
0
        public UsageDailyViewModel(IEventAggregator eventAggregator, IUsageService usageService, IMenuService menuService, IRegionManager regionManager)
        {
            this.eventAggregator = eventAggregator;
            this.usageService    = usageService;
            this.menuService     = menuService;
            this.regionManager   = regionManager;

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

            evt.Subscribe(OnSelectedCounterpartyChanged);

            // We may be launching this view after the counterparty has been selected e.g. popup window so get the usage for the currently selected counterparty
            if (usageService.CurrentCounterparty != null)
            {
                var usages = usageService.FindLatestUsageByCounterparty(usageService.CurrentCounterparty);
                Usages = new ObservableCollection <Model.Usage>(usages);
            }

            showUsageDailyCommand = new DelegateCommand(ShowUsageDaily);

            menuService.RegisterMenu(new MenuEntry()
            {
                Text = "Daily Usage", Command = showUsageDailyCommand
            });

            showGraphCommand = new DelegateCommand(ShowGraph);

            menuService.RegisterMenu(new MenuEntry()
            {
                Text = "Show Graph", Command = showGraphCommand
            });

            showUsageDailyPopupCommand = new DelegateCommand(ShowUsageDailyPopup);
            menuService.RegisterMenu(new MenuEntry()
            {
                Text = "Show PopUp Daily Usage", Command = showUsageDailyPopupCommand
            });
        }