private void createDOWArray() { try { var ci = new CultureInfo(PNLang.Instance.GetLanguageCulture()); var values = Enum.GetValues(typeof(DayOfWeek)).OfType<DayOfWeek>().ToArray<DayOfWeek>(); for (var i = 0; i < values.Length; i++) { _doWeek[i] = new DayOfWeekStruct { DayOfW = values[i], Name = ci.DateTimeFormat.DayNames[i] }; } } catch (Exception ex) { PNStatic.LogException(ex); } }
internal string GetNoteScheduleDescription(PNNoteSchedule sc, DayOfWeekStruct[] days) { try { if (sc.Type == ScheduleType.None) return ""; CultureInfo ci = new CultureInfo(Instance.GetLanguageCulture()); string result = PNStatic.ScheduleDescriptions[sc.Type]; switch (sc.Type) { case ScheduleType.Once: result = result.Replace(PNStrings.PLACEHOLDER1, sc.AlarmDate.ToString(PNStatic.Settings.GeneralSettings.DateFormat, ci)); break; case ScheduleType.EveryDay: result = result.Replace(PNStrings.PLACEHOLDER1, sc.AlarmDate.ToString(PNStatic.Settings.GeneralSettings.TimeFormat, ci)); break; case ScheduleType.RepeatEvery: case ScheduleType.After: result = sc.AlarmAfter.Years > 0 ? result.Replace(PNStrings.YEARS, sc.AlarmAfter.Years.ToString(CultureInfo.InvariantCulture) + " " + Instance.GetControlText("lblAfterYears", "Years")) : result.Replace(PNStrings.YEARS, ""); result = sc.AlarmAfter.Months > 0 ? result.Replace(PNStrings.MONTHS, sc.AlarmAfter.Months.ToString(CultureInfo.InvariantCulture) + " " + Instance.GetControlText("lblAfterMonths", "Months")) : result.Replace(PNStrings.MONTHS, ""); result = sc.AlarmAfter.Weeks > 0 ? result.Replace(PNStrings.WEEKS, sc.AlarmAfter.Weeks.ToString(CultureInfo.InvariantCulture) + " " + Instance.GetControlText("lblAfterWeeks", "Weeks")) : result.Replace(PNStrings.WEEKS, ""); result = sc.AlarmAfter.Days > 0 ? result.Replace(PNStrings.DAYS, sc.AlarmAfter.Days.ToString(CultureInfo.InvariantCulture) + " " + Instance.GetControlText("lblAfterDays", "Days")) : result.Replace(PNStrings.DAYS, ""); result = sc.AlarmAfter.Hours > 0 ? result.Replace(PNStrings.HOURS, sc.AlarmAfter.Hours.ToString(CultureInfo.InvariantCulture) + " " + Instance.GetControlText("lblAfterHours", "Hours")) : result.Replace(PNStrings.HOURS, ""); result = sc.AlarmAfter.Minutes > 0 ? result.Replace(PNStrings.MINUTES, sc.AlarmAfter.Minutes.ToString(CultureInfo.InvariantCulture) + " " + Instance.GetControlText("lblAfterMinutes", "Minutes")) : result.Replace(PNStrings.MINUTES, ""); result = sc.AlarmAfter.Seconds > 0 ? result.Replace(PNStrings.SECONDS, sc.AlarmAfter.Seconds.ToString(CultureInfo.InvariantCulture) + " " + Instance.GetControlText("lblAfterSeconds", "Seconds")) : result.Replace(PNStrings.SECONDS, ""); result += " "; result += Instance.GetControlText("lblAfterStart", "Starting from:"); result += " "; if (sc.StartFrom == ScheduleStart.ExactTime) { result += Instance.GetControlText("optAfterExact", "Exact time"); result += " "; result += sc.StartDate.ToString(PNStatic.Settings.GeneralSettings.DateFormat, ci); } else { result += Instance.GetControlText("optAfterProgram", "Program start"); } break; case ScheduleType.Weekly: result += " "; foreach (DayOfWeek wd in sc.Weekdays) { result += days.FirstOrDefault(dw => dw.DayOfW == wd).Name; result += ", "; } if (result.EndsWith(", ")) { result = result.Substring(0, result.Length - 2); } result += " "; result += Instance.GetControlText("lblWeeklyAt", "At:"); result += " "; result += sc.AlarmDate.ToString(PNStatic.Settings.GeneralSettings.TimeFormat, ci); break; case ScheduleType.MonthlyExact: result = result.Replace(PNStrings.PLACEHOLDER1, sc.AlarmDate.Day.ToString(CultureInfo.InvariantCulture)); result = result.Replace(PNStrings.PLACEHOLDER2, sc.AlarmDate.ToString(PNStatic.Settings.GeneralSettings.TimeFormat, ci)); break; case ScheduleType.MonthlyDayOfWeek: result = result.Replace(PNStrings.PLACEHOLDER1, days.FirstOrDefault(wd => wd.DayOfW == sc.MonthDay.WeekDay).Name); result = result.Replace(PNStrings.PLACEHOLDER2, Instance.GetOrdinalName(sc.MonthDay.OrdinalNumber)); result = result.Replace(PNStrings.PLACEHOLDER3, sc.AlarmDate.ToString(PNStatic.Settings.GeneralSettings.TimeFormat, ci)); break; } return result; } catch (Exception ex) { PNStatic.LogException(ex); return ""; } }