Пример #1
0
        private void UpdateWeekInfo(bool initial = false)
        {
            if (!_initComplete && !initial)
            {
                return;
            }
            string weekDayPrefix = string.Empty;

            if (int.TryParse(ccbYear.SelectedItem?.ToString(), out int year) == true &&
                int.TryParse(ccbMonth.SelectedItem?.ToString(), out int month) == true &&
                int.TryParse(ccbDay.SelectedItem?.ToString(), out int day) == true)
            {
                DateTime selectedDate = new DateTime(year, month, day);
                if (System.Threading.Thread.CurrentThread.CurrentUICulture.Name == Resources.Swedish)
                {
                    weekDayPrefix = Message.SWEDISH_DAY_OF_WEEK_PREFIX[(int)selectedDate.DayOfWeek];
                }
                int selectedWeek = Week.GetWeekNumber(selectedDate);
                lblInformation.Text = $"{Resources.Week} {selectedWeek}\r\n{weekDayPrefix}{selectedDate.ToLongDateString()}";
                _img = pictureBoxWeek.Image;
                pictureBoxWeek.Image = WeekIcon.GetImage(selectedWeek);
                _img?.Dispose();
            }
            else if (initial)
            {
                if (System.Threading.Thread.CurrentThread.CurrentUICulture.Name == Resources.Swedish)
                {
                    weekDayPrefix = Message.SWEDISH_DAY_OF_WEEK_PREFIX[(int)DateTime.Now.DayOfWeek];
                }
                lblInformation.Text  = $"{Resources.Week} {Week.Current()}\r\n{weekDayPrefix}{DateTime.Now.ToLongDateString()}";
                pictureBoxWeek.Image = WeekIcon.GetImage(Week.Current());
            }
            else
            {
                lblInformation.Text  = Resources.SelectDate;
                pictureBoxWeek.Image = null;
            }
        }