public static BackgroundManager GetInstance() { if (backgroundManager == null) { backgroundManager = new BackgroundManager(); } return(backgroundManager); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); bool createNew; oneInstanceMutex = new Mutex(false, "BgInfo_OneInstanceMutex", out createNew); if (!createNew) { MessageBox.Show("Am running already!", "SimpleMan Blues", MessageBoxButton.OK, MessageBoxImage.Asterisk); Shutdown(); return; } commonService = CommonService.GetInstance(); mainWindow = new Blues.MainWindow(); commonService.CurrentMainWindow = mainWindow; infoWindow = new InfoWindow(); commonService.CurrentInfoWindow = infoWindow; backgroundManager = BackgroundManager.GetInstance(); backgroundManager.InitTray(); backgroundManager.StartUnlockTimer(); mainWindow.Show(); var sysAction = new SystemAction { OrderNo = 1, CurrentAction = ActionType.StartUp, ActionTime = DateTime.Now }; commonService.InfoViewModel.SystemActions.Add(sysAction); backgroundManager.SaveSystemAction(sysAction); Microsoft.Win32.SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; }
public TrayViewModel() { ExitCommand = new DelegateCommand(() => Application.Current.Shutdown()); InfoCommand = new DelegateCommand(() => BackgroundManager.GetInstance().ShowInfo()); }