public MainWindowViewModel(MainWindow window)
        {
            m_previewResetTimer = new System.Timers.Timer();
            m_systemClockTimer  = new System.Timers.Timer();

            m_vmLock = new object();

            m_latitude         = "";
            m_longitude        = "";
            m_timeToNextPeriod = "--:--:--";
            m_windowTitle      = "Unblind";
            m_currentBrightnessTransitionStatus = DimmerStatus.Idle;
            m_clockElapsedTime          = 0;
            m_currentBrightness         = 100;
            m_maxDisplayBrightness      = 0;
            m_minDisplayBrightness      = 1;
            m_firstRun                  = false;
            m_locationEnabled           = false;
            m_noSupportDetected         = false;
            m_multipleDisplaysConnected = false;
            m_startWithWindows          = false;
            m_startMinimized            = false;

            m_brightnessDimmer = new BrightnessDimmer();
            m_brightnessDimmer.OnBrightnessChange += _OnBrightnessChangeEvent;

            m_brightnessScheduler = new BrightnessScheduler(TimeSpan.FromHours(7), TimeSpan.FromHours(18), 50, 90, 60000, 60000);
            m_brightnessScheduler.OnBrightnessChange += _OnScheduledBrightnessEvent;
            m_brightnessScheduler.PropertyChanged    += _OnSchedulerPropertyChanged;


            //add listener for display changes (display plugged in/unplugged)
            window.OnDisplayChangeDetected += () =>
            {
                _OnDisplayChangeDetected();
            };

            m_previewResetTimer.AutoReset = false;
            m_previewResetTimer.Interval  = m_previewDuration;
            m_previewResetTimer.Elapsed  += new System.Timers.ElapsedEventHandler((object source, System.Timers.ElapsedEventArgs e) =>
            {
                m_brightnessDimmer.AdjustBrightness(m_currentBrightness, m_currentBrightness, 0.0);
            });

            m_systemClockTimer.AutoReset = true;
            m_systemClockTimer.Interval  = 1000;
            m_systemClockTimer.Elapsed  += _ClockTick;

            _InitializeApp(window);
        }
        private void _OnSchedulerPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            BrightnessScheduler scheduler = sender as BrightnessScheduler;

            if (scheduler == null)
            {
                return;
            }

            switch (e.PropertyName)
            {
            case "NightBrightness":
                DataAccess.AppSettingConfigurator.AddUpdateSetting("NightBrightness", scheduler.NightBrightness.ToString());
                break;

            case "DayBrightness":
                DataAccess.AppSettingConfigurator.AddUpdateSetting("DayBrightness", scheduler.DayBrightness.ToString());
                break;

            case "Daytime":
                DataAccess.AppSettingConfigurator.AddUpdateSetting("DaytimeStart", scheduler.Daytime.ToString());
                break;

            case "Nighttime":
                DataAccess.AppSettingConfigurator.AddUpdateSetting("NighttimeStart", scheduler.Nighttime.ToString());
                break;

            case "NightToDayTransitionDuration":
                DataAccess.AppSettingConfigurator.AddUpdateSetting("NightToDayTransitionTime", (scheduler.NightToDayTransitionDuration / 60000.0).ToString());
                break;

            case "DayToNightTransitionDuration":
                DataAccess.AppSettingConfigurator.AddUpdateSetting("DayToNightTransitionTime", (scheduler.DayToNightTransitionDuration / 60000.0).ToString());
                break;

            default: break;
            }
        }