public static void SaveOrUpdateConfiguration(this IDocumentStore documentStore, Configuration configuration)
 {
     using (var session = documentStore.OpenSession())
     {
         session.Store(configuration, Constants.ConfigurationDocumentKey);
         session.SaveChanges();
     }
 }
示例#2
0
        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();
        }
示例#3
0
        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);
        }
示例#4
0
        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();
        }