internal WeekApplicationContext()
 {
     try
     {
         Application.ApplicationExit += OnApplicationExit;
         _week  = new Week();
         Gui    = new TaskbarGui(Week.Current);
         _timer = GetTimer;
     }
     catch (Exception ex)
     {
         _timer?.Stop();
         Message.Show(Text.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);
        }
Beispiel #5
0
 private void SayWeek()
 {
     _speak?.Sentence(Resources.ClearThroat + Resources.Week + Week.Current());
 }