Example #1
0
        public TimerController(TemtemTableController tableController, DetectorLoop detectorLoop, Config config, UserSettings userSettings, SettingsController settingsController)
        {
            this.tableController                   = tableController;
            this.detectorLoop                      = detectorLoop;
            this.detectionLoopInterval             = config.detectionLoopInterval;
            this.disableDetectionOnTimerPause      = userSettings.disableDetectionWhileTimerPaused;
            this.userSettings                      = userSettings;
            this.settingsController                = settingsController;
            settingsController.TimerPausedToggled += ToggleTimeTrackerTimerPaused;

            settingsController.DetectionDisabledChanged      += SetDisableDetectionOnTimerPause;
            settingsController.InactivityTimerEnabledChanged += SetInactivityTimerEnabled;

            detectionLoopTimer = new System.Timers.Timer(detectionLoopInterval);
            timeTrackerTimer   = new System.Timers.Timer(TIME_TRACKER_INTERVAL);
            autosaveTimer      = new System.Timers.Timer();
            inactivityTimer    = new System.Timers.Timer(INACTIVITY_CHECK_INTERVAL);

            //Set the interval for the autosave timer from the user settings
            //The interval is in minutes, the timer accepts miliseconds, the function converts
            SetAutosaveTimeInterval(null, userSettings.autosaveInterval);
            settingsController.AutosaveIntervalChanged += SetAutosaveTimeInterval;


            detectionLoopTimer.Elapsed += DetectionLoopListener;
            timeTrackerTimer.Elapsed   += TimeTrackerListener;
            autosaveTimer.Elapsed      += AutosaveListener;
            inactivityTimer.Elapsed    += InactivityListener;

            detectionLoopTimer.AutoReset = true;
            timeTrackerTimer.AutoReset   = true;
            autosaveTimer.AutoReset      = true;
            inactivityTimer.AutoReset    = true;
        }
        public HotkeyController(SettingsController settingsController, TemtemTrackerUI trackerUI, TemtemTableController tableController)
        {
            this.settingsController = settingsController;
            this.trackerUI          = trackerUI;
            this.tableController    = tableController;

            //Get the hotkeys from settings
            this.resetTableHotkey          = (Keys)settingsController.GetUserSettings().resetTableHotkey;
            this.resetTableHotkeyModifiers = (Keys)settingsController.GetUserSettings().resetTableHotkeyModifier;
            this.resetTableKeyModifiers    = User32.KeysToKeyModifiers(resetTableHotkeyModifiers);
            this.pauseTimerHotkey          = (Keys)settingsController.GetUserSettings().pauseTimerHotkey;
            this.pauseTimerHotkeyModifiers = (Keys)settingsController.GetUserSettings().pauseTimerHotkeyModifier;
            this.pauseTimerKeyModifiers    = User32.KeysToKeyModifiers(pauseTimerHotkeyModifiers);

            //Subscribe to relevant events from settingsController
            settingsController.ToggleHotkeysEnabled    += ToggleHotkeysEnabled;
            settingsController.ResetTableHotkeyChanged += ReloadResetTableHotkey;
            settingsController.PauseTimerHotkeyChanged += ReloadPauseTimerHotkey;

            //Set tracker UI hotkey strings
            PopulateTrackerUIHotkeyLabels();

            //Bind the hotkeys
            User32.RegisterHotKey(this.Handle, RESET_TABLE_HOTKEY_ID, resetTableKeyModifiers, resetTableHotkey);
            User32.RegisterHotKey(this.Handle, PAUSE_TIMER_HOTKEY_ID, pauseTimerKeyModifiers, pauseTimerHotkey);
        }
Example #3
0
        private bool autoresumeEnabled;                 //This is fetched from settings and set in the constructor

        public DetectorLoop(Config config, TemtemTableController tableController, OCRController ocrController, SettingsController settingsController)
        {
            this.config             = config;
            this.tableController    = tableController;
            this.ocrController      = ocrController;
            this.settingsController = settingsController;

            spot1RGB = ColorTranslator.FromHtml(config.spot1RGB).ToArgb();
            spot2RGB = ColorTranslator.FromHtml(config.spot2RGB).ToArgb();
            spot3RGB = ColorTranslator.FromHtml(config.spot3RGB).ToArgb();
            spot4RGB = ColorTranslator.FromHtml(config.spot4RGB).ToArgb();
            spot5RGB = ColorTranslator.FromHtml(config.spot5RGB).ToArgb();
            spot6RGB = ColorTranslator.FromHtml(config.spot6RGB).ToArgb();
            spot7RGB = ColorTranslator.FromHtml(config.spot7RGB).ToArgb();
            spot8RGB = ColorTranslator.FromHtml(config.spot8RGB).ToArgb();

            this.maxAllowedColorDistance = config.maxAllowedColorDistance;

            this.windowAndProcessNames = config.windowAndProcessNames;

            temtemWindows = new Dictionary <uint, TemtemWindowData>();

            //Get relevant settings from the settings controller
            detectionDisabledWhileTimerPaused = settingsController.GetUserSettings().disableDetectionWhileTimerPaused;
            autoresumeEnabled = settingsController.GetUserSettings().resumeAutopausedTimerOnDetection;

            //Add listeners for relevant setting changes
            settingsController.TimerPausedToggled       += TimerPausedListener;
            settingsController.TimerAutopaused          += TimerAutopauseListener;
            settingsController.DetectionDisabledChanged += DetectionDisabledListener;
            settingsController.AutoresumeEnabledChanged += AutoresumeEnabledListener;
        }
Example #4
0
        public DetectorLoop(Config config, TemtemTableController tableController, OCRController ocrController)
        {
            this.config          = config;
            this.tableController = tableController;
            this.ocrController   = ocrController;

            spot1RGB = ColorTranslator.FromHtml(config.spot1RGB).ToArgb();
            spot2RGB = ColorTranslator.FromHtml(config.spot2RGB).ToArgb();
            spot3RGB = ColorTranslator.FromHtml(config.spot3RGB).ToArgb();
            spot4RGB = ColorTranslator.FromHtml(config.spot4RGB).ToArgb();
            spot5RGB = ColorTranslator.FromHtml(config.spot5RGB).ToArgb();
            spot6RGB = ColorTranslator.FromHtml(config.spot6RGB).ToArgb();

            this.maxAllowedColorDistance = config.maxAllowedColorDistance;

            temtemWindows = new Dictionary <uint, TemtemWindowData>();
        }