コード例 #1
0
 private void SetAlarmTimer()
 {
     _AlarmTimer.Stop();
     _AlarmTimer.ClearJobs();
     _AlarmTimer.AddJob(AlarmTime, new TickHandler(_AlarmTimer_Elapsed));
     _AlarmTimer.Start();
 }
コード例 #2
0
 void ItmAlarm_Click(object sender, EventArgs e)
 {
     try
     {
         _AlarmDialog.SetSchedule(GetSetting("alarm", "Daily|4:30 PM"));
         if (_AlarmDialog.ShowDialog(this) == DialogResult.OK)
         {
             IScheduledItem Item = _AlarmDialog.GetSchedule();
             SetSetting("alarm", _AlarmDialog.GetScheduleString());
             _AlarmTimer.Stop();
             _AlarmTimer.ClearJobs();
             _AlarmTimer.AddJob(Item, new TickHandler(AlarmTimer_Elapsed));
             _AlarmTimer.Start();
         }
     }
     catch (Exception ex)
     {
         Startup.HandleException(ex);
     }
 }
コード例 #3
0
ファイル: Form1.cs プロジェクト: ehsanrashid/ScheduleTimer
 private void button2_Click(object sender, System.EventArgs e)
 {
     timer.Stop();
 }
コード例 #4
0
        private static void MonitorThemeChanges()
        {
#if UNITY_EDITOR_WIN
            registryMonitor?.Stop();
#elif UNITY_EDITOR_OSX
            appearanceMonitor?.Stop();
#endif

            timer?.Stop();

            if (UserPreferences.IsEnabled)
            {
                if (UserPreferences.Mode == UserPreferences.AutoThemeMode.System)
                {
#if UNITY_EDITOR_WIN
                    // Windows: Watch system theme changes in registry
                    registryMonitor             = new RegistryMonitor(RegistryHive.CurrentUser, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize");
                    registryMonitor.RegChanged += (sender, args) => SetEditorThemeFromSystemTheme();
                    registryMonitor.Start();
#elif UNITY_EDITOR_OSX
                    // macOS
                    appearanceMonitor = new AppearanceMonitor();
                    appearanceMonitor.AppearanceChanged += (sender, args) =>
                    {
                        SetEditorThemeFromSystemTheme();
                    };
                    appearanceMonitor.Start();
#endif
                    // Set current system theme on start/when enabled
                    SetEditorThemeFromSystemTheme();
                }
                else if (UserPreferences.Mode == UserPreferences.AutoThemeMode.Time)
                {
                    var now = DateTime.Now.TimeOfDay;

                    // Check current time and set theme
                    if (UserPreferences.LightThemeTime < UserPreferences.DarkThemeTime)
                    {
                        if (now >= UserPreferences.LightThemeTime && now < UserPreferences.DarkThemeTime)
                        {
                            EditorThemeChanger.SetLightTheme();
                        }
                        else
                        {
                            EditorThemeChanger.SetDarkTheme();
                        }
                    }
                    else
                    {
                        if (now < UserPreferences.LightThemeTime && now >= UserPreferences.DarkThemeTime)
                        {
                            EditorThemeChanger.SetDarkTheme();
                        }
                        else
                        {
                            EditorThemeChanger.SetLightTheme();
                        }
                    }

                    // Schedule theme changes
                    var lightThemeSchedule = new ScheduledTime(EventTimeBase.Daily, UserPreferences.LightThemeTime);
                    var darkThemeSchedule  = new ScheduledTime(EventTimeBase.Daily, UserPreferences.DarkThemeTime);
                    timer = new ScheduleTimer();
                    timer.AddJob(lightThemeSchedule, new Action(EditorThemeChanger.SetLightTheme));
                    timer.AddJob(darkThemeSchedule, new Action(EditorThemeChanger.SetDarkTheme));
                    timer.Start();
                }
            }
        }
コード例 #5
0
ファイル: Alarm.cs プロジェクト: Cacowned/mayhem
 protected override void OnDisabled(DisabledEventArgs e)
 {
     tickTimer.Stop();
     tickTimer.Dispose();
 }