public MainWindow(MainViewModel viewModel, NotifyIconService notifyIconService) { InitializeComponent(); this.viewModel = viewModel; this.DataContext = this.viewModel; notifyIconService.Clicked += (s, e) => this.ToggleWindow(); notifyIconService.CloseRequested += (s, e) => this.Close(); this.Loaded += (s, e) => { var windowHandle = new WindowInteropHelper(this).Handle; Win32Interop.HideWindowFromAltTab(windowHandle); Win32Interop.PowerSchemeChanged += this.OnPowerPlanChanged; Win32Interop.RegisterForPowerSettingNotification(windowHandle); this.viewModel.UpdatePowerPlans(); }; this.Closing += (s, e) => { var windowHandle = new WindowInteropHelper(this).Handle; Win32Interop.PowerSchemeChanged -= this.OnPowerPlanChanged; Win32Interop.UnregisterForPowerSettingNotification(windowHandle); }; }
private void Application_Startup(object sender, StartupEventArgs startupEventArgs) { var notifyIconService = new NotifyIconService(); //var powerPlanService = new WmiPowerPlanService(); var powerPlanService = new PowerPlanService(); this.MainWindow = new MainWindow(new MainViewModel(powerPlanService, notifyIconService), notifyIconService); this.MainWindow.Show(); IconEditorWindow editor = null; notifyIconService.IconEditorLaunchRequested += (s, e) => { if (editor == null || !editor.IsVisible) { editor = new IconEditorWindow(new IconEditorViewModel(notifyIconService, powerPlanService)); editor.Owner = this.MainWindow; editor.Show(); } else { editor.Activate(); } }; }
public void Stop() { dt.Stop(); IncrementMin = Timer.DurationMin; IncrementSec = 0; Timer.State = TimerState.Stopped; NotifyIconService.SetStatusIcon("Stopped"); }
public PowerPlanViewModel(IPowerPlan model, NotifyIconService notifyIconService) { this.model = model; this.notifyIconService = notifyIconService; if (this.IsActive) { this.UpdateIcon(); } }
public void Pause() { if (Timer.State == TimerState.Paused) { return; } dt.Stop(); Timer.State = TimerState.Paused; NotifyIconService.SetStatusIcon("Paused"); }
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(); }
public void Start() { if (Timer.State == TimerState.Started) { return; } else if (Timer.State == TimerState.Stopped) { IncrementMin = Timer.DurationMin; } dt.Start(); NotifyIconService.SetStatusIcon("Started"); }
public MainViewModel(IPowerPlanService powerPlanService, NotifyIconService notifyIconService) { this.powerPlanService = powerPlanService; this.notifyIconService = notifyIconService; }
public void Reset() { NotifyIconService.ResetStatusIcon(); IsConnected = null; }
public void Disconnect() { NotifyIconService.SetStatusIcon("disconnected"); IsConnected = false; }
public void Connect() { NotifyIconService.SetStatusIcon("connected"); IsConnected = true; }