Beispiel #1
0
 public MainViewModel()
 {
     if (base.IsInDesigner)
     {
         this.powerPlanService = new PowerPlanService();
         this.UpdatePowerPlans();
     }
     else
     {
         throw new InvalidOperationException("The parameterless constructor should only be used by the WPF designer.");
     }
 }
        public IconEditorViewModel(NotifyIconService notifyIconService, IPowerPlanService powerPlanService)
        {
            this.notifyIconService = notifyIconService;

            this.ApplyCommand         = new DelegateCommand(this.Apply);
            this.LoadDefaultsCommand  = new DelegateCommand(this.RevertToDefault);
            this.RevertChangesCommand = new DelegateCommand(this.RevertChanges);

            this.CreatePowerPlanViewModels(powerPlanService);
            this.LoadPreviousState();
            this.RevertChanges();
        }
        private void CreatePowerPlanViewModels(IPowerPlanService powerPlanService)
        {
            var powerPlans = powerPlanService.GetPowerPlans();

            this.PowerPlans =
                powerPlans
                .Select(item => new PowerPlanIconViewModel(item.Id, item.Name))
                .ToList();

            var selectedPowerPlanId = powerPlans.SingleOrDefault(item => item.IsActive)?.Id;

            if (selectedPowerPlanId.HasValue)
            {
                this.SelectedPowerPlan = this.PowerPlans.Single(item => item.Id == selectedPowerPlanId);
            }
        }
Beispiel #4
0
 public MainViewModel(IPowerPlanService powerPlanService, NotifyIconService notifyIconService)
 {
     this.powerPlanService  = powerPlanService;
     this.notifyIconService = notifyIconService;
 }