public static void SaveOrUpdateConfiguration(this IDocumentStore documentStore, Configuration configuration) { using (var session = documentStore.OpenSession()) { session.Store(configuration, Constants.ConfigurationDocumentKey); session.SaveChanges(); } }
public static void RegisterKeyboardShortcuts(Configuration configuration) { if (hook != null) { // don't rely on the gc here because the shortcut will stay active until cleanup hook.Dispose(); hook = null; } hook = new KeyboardHook(); hook.RegisterHotKey(configuration.ShortcutModifierKeys, configuration.ShortcutKey); hook.KeyPressed += (sender, args) => StateManager.ToggleDistraction(); }
public App() { DocumentStoreContainer.Initialize(); StateManager = new StateManager(DocumentStoreContainer.DocumentStore, TimerState.NotWorking); var configuration = DocumentStoreContainer.DocumentStore.LoadConfiguration(); if (configuration == null) { configuration = new Configuration { ShortcutKey = Keys.Enter, ShortcutModifierKeys = ModifierKeys.Control }; DocumentStoreContainer.DocumentStore.SaveOrUpdateConfiguration(configuration); } RegisterKeyboardShortcuts(configuration); }
public App() { var useEmbeddedMode = Convert.ToBoolean(ConfigurationManager.AppSettings.Get("UseEmbeddedMode")); DocumentStoreContainer.Initialize(useEmbeddedMode); StateManager = new StateManager(DocumentStoreContainer.DocumentStore, TimerState.NotWorking); var configuration = DocumentStoreContainer.DocumentStore.LoadConfiguration(); if (configuration == null) { configuration = new Configuration { ShortcutKey = Keys.Enter, ShortcutModifierKeys = ModifierKeys.Control }; DocumentStoreContainer.DocumentStore.SaveOrUpdateConfiguration(configuration); } RegisterKeyboardShortcuts(configuration); RegisterScreenLockHandlers(); }