Exemple #1
0
 private static void UpdateIcon(int weekNumber, ref NotifyIcon notifyIcon)
 {
     notifyIcon.Text = Resources.Week + weekNumber;
     System.Drawing.Icon prevIcon = notifyIcon.Icon;
     notifyIcon.Icon = WeekIcon.GetIcon(weekNumber);
     WeekIcon.CleanupIcon(ref prevIcon);
 }
 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();
     }
 }
Exemple #3
0
 private void UpdateIcon(int weekNumber, ref NotifyIcon notifyIcon, int iconResolution)
 {
     Log.LogCaller();
     try
     {
         string       weekDayPrefix  = string.Empty;
         string       longDateString = DateTime.Now.ToLongDateString();
         const string SWEDISH_LONG_DATE_PREFIX_STRING = "den ";
         if (Thread.CurrentThread.CurrentUICulture.Name == Resources.Swedish || longDateString.StartsWith(SWEDISH_LONG_DATE_PREFIX_STRING))
         {
             weekDayPrefix = Message.SWEDISH_DAY_OF_WEEK_PREFIX[(int)DateTime.Now.DayOfWeek];
         }
         notifyIcon.Text = $"{Resources.Week} {weekNumber}\r\n{weekDayPrefix}{longDateString}";
         System.Drawing.Icon prevIcon = notifyIcon.Icon;
         notifyIcon.Icon = WeekIcon.GetIcon(weekNumber, iconResolution);
         WeekIcon.CleanupIcon(ref prevIcon);
     }
     finally
     {
         if (_latestWeek != weekNumber)
         {
             if (Settings.SettingIsValue(Resources.DisplayWeekChangedNotification, "True"))
             {
                 DisplayUserInfoBalloonTip(notifyIcon.Text);
             }
             _latestWeek = weekNumber;
         }
     }
 }
        private void OnUserPreferenceChanged(object sender, EventArgs e)
        {
            Log.LogCaller();
            AutoUpdateCheck();
            int iconRes = WeekIcon.GetIconResolution(true);

            if (iconRes != _lastIconRes)
            {
                UpdateIcon(true, true);
                _lastIconRes = iconRes;
            }
        }
        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);
        }