internal WeekApplicationContext() { try { Log.LogCaller(); //MonitorProcess.Run(); // Removed because of false positive virus varning _updateHandler = UpdateHandler.Instance; Settings.StartWithWindows = Settings.SettingIsValue(Resources.StartWithWindows, true.ToString()); Application.ApplicationExit += OnApplicationExit; SystemEvents.UserPreferenceChanged += OnUserPreferenceChanged; _currentWeek = Week.Current(); _lastIconRes = WeekIcon.GetIconResolution(); Gui = new TaskbarGui(_currentWeek, _lastIconRes); Gui.UpdateRequest += GuiUpdateRequestHandler; _timer = GetTimer; AutoUpdateCheck(); } catch (Exception ex) { _timer?.Stop(); Log.LogCaller(); Message.Show(Resources.UnhandledException, ex); Application.Exit(); } }
private void UpdateIcon(bool force = false, bool redrawContextMenu = false) { if (_currentWeek == Week.Current() && force == false) { return; } _timer?.Stop(); Application.DoEvents(); try { Log.LogCaller(); _currentWeek = Week.Current(); int iconResolution = Settings.GetIntSetting(Resources.IconResolution, (int)IconSize.Icon256); Log.Info = $"Update icon with week number {_currentWeek} using resolution {iconResolution}x{iconResolution}, redraw context menu={redrawContextMenu}, forced update={force}"; Gui?.UpdateIcon(_currentWeek, iconResolution, redrawContextMenu); } catch (Exception ex) { Message.Show(Resources.FailedToSetIcon, ex); Cleanup(); throw; } if (_timer != null) { int calculatedInterval = 86400000 - ((DateTime.Now.Hour * 3600000) + (DateTime.Now.Minute * 60000) + (DateTime.Now.Second * 1000)); _timer.Interval = calculatedInterval; Log.Info = $"Timer interval={calculatedInterval / 1000}s"; _timer.Start(); } }
internal WeekApplicationContext() { try { Application.ApplicationExit += OnApplicationExit; _week = new Week(); Gui = new TaskbarGui(Week.Current()); _timer = GetTimer; } catch (Exception ex) { _timer?.Stop(); Message.Show(Properties.Resources.UnhandledException, ex); Application.Exit(); } }
private void OnTimerTick(object sender, EventArgs e) { Timer timer = (Timer)sender; timer?.Stop(); Application.DoEvents(); try { Gui?.UpdateIcon(Week.Current()); } catch (Exception ex) { Message.Show(Resources.FailedToSetIcon, ex); Cleanup(); throw; } timer?.Start(); }
private void OnTimerTick(object sender, EventArgs e) { if (!_week.WasChanged()) { return; } var timer = (Timer)sender; timer?.Stop(); Application.DoEvents(); try { Gui?.UpdateIcon(Week.Current()); } catch (Exception ex) { Message.Show(Properties.Resources.FailedToSetIcon, ex); Cleanup(); return; } timer?.Start(); }
private static void SaveIconClick(object o, EventArgs e) { MenuItem mi = (MenuItem)o; mi.Enabled = false; using (SaveFileDialog saveFileDialog = new SaveFileDialog { Title = Resources.SaveIconMenu, AddExtension = true, DefaultExt = ".ico", FileName = Application.ProductName + ".ico", SupportMultiDottedExtensions = false, OverwritePrompt = true, CheckPathExists = true }) { if (DialogResult.OK == saveFileDialog.ShowDialog()) { WeekIcon.SaveIcon(Week.Current(), saveFileDialog.FileName); } } EnableMenuItem(mi); }
private void SayWeek() { _speak?.Sentence(Resources.ClearThroat + Resources.Week + Week.Current()); }