diff --git a/Data.cs b/Data.cs new file mode 100644 index 0000000..aa3c7d1 --- /dev/null +++ b/Data.cs @@ -0,0 +1,21 @@ +using System.Collections.ObjectModel; +using System.Text.Json; +using WorldClockStatusWindow.Properties; + +namespace WorldClockStatusWindow; + +internal static class Data +{ + internal static ObservableCollection TimeZoneEntries { get; set; } + + internal static void Load() + { + TimeZoneEntries = JsonSerializer.Deserialize>(Settings.Default.TimeZones); + } + + internal static void Save() + { + Settings.Default.TimeZones = JsonSerializer.Serialize(TimeZoneEntries); + Settings.Default.Save(); + } +} \ No newline at end of file diff --git a/DataErrorDictionary.cs b/DataErrorDictionary.cs new file mode 100644 index 0000000..c136805 --- /dev/null +++ b/DataErrorDictionary.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; + +namespace WorldClockStatusWindow; + +internal class DataErrorDictionary : Dictionary> +{ + public event EventHandler ErrorsChanged; + + private void OnErrorsChanged(string propertyName) + { + ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(propertyName)); + } + + public IEnumerable GetErrors(string propertyName) + { + return TryGetValue(propertyName, out var value) ? value : null; + } + + public void AddError(string propertyName, string error) + { + if (!ContainsKey(propertyName)) + this[propertyName] = []; + + if (this[propertyName].Contains(error)) + return; + + this[propertyName].Add(error); + OnErrorsChanged(propertyName); + } + + public void ClearErrors(string propertyName) + { + if (!ContainsKey(propertyName)) + return; + + Remove(propertyName); + OnErrorsChanged(propertyName); + } +} \ No newline at end of file diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index 7b0b639..3a85414 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -60,6 +60,24 @@ namespace WorldClockStatusWindow.Properties { } } + /// + /// Looks up a localized string similar to Add. + /// + public static string AddTimeZoneLink { + get { + return ResourceManager.GetString("AddTimeZoneLink", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Add Time Zone. + /// + public static string AddTimeZoneToolTip { + get { + return ResourceManager.GetString("AddTimeZoneToolTip", resourceCulture); + } + } + /// /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). /// @@ -79,6 +97,15 @@ namespace WorldClockStatusWindow.Properties { } } + /// + /// Looks up a localized string similar to Cancel. + /// + public static string CancelButton { + get { + return ResourceManager.GetString("CancelButton", resourceCulture); + } + } + /// /// Looks up a localized string similar to Checking for update.... /// @@ -124,6 +151,42 @@ namespace WorldClockStatusWindow.Properties { } } + /// + /// Looks up a localized string similar to Are you sure you want to delete the selected time zones?. + /// + public static string ConfirmDeleteTimeZones { + get { + return ResourceManager.GetString("ConfirmDeleteTimeZones", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Confirm Delete. + /// + public static string ConfirmDeleteTitle { + get { + return ResourceManager.GetString("ConfirmDeleteTitle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Delete. + /// + public static string DeleteTimeZoneLink { + get { + return ResourceManager.GetString("DeleteTimeZoneLink", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Delete Time Zone. + /// + public static string DeleteTimeZoneToolTip { + get { + return ResourceManager.GetString("DeleteTimeZoneToolTip", resourceCulture); + } + } + /// /// Looks up a localized string similar to Downloading update.... /// @@ -133,6 +196,24 @@ namespace WorldClockStatusWindow.Properties { } } + /// + /// Looks up a localized string similar to Edit. + /// + public static string EditTimeZoneLink { + get { + return ResourceManager.GetString("EditTimeZoneLink", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Edit Time Zone. + /// + public static string EditTimeZoneToolTip { + get { + return ResourceManager.GetString("EditTimeZoneToolTip", resourceCulture); + } + } + /// /// Looks up a localized string similar to Installing update.... /// @@ -142,6 +223,15 @@ namespace WorldClockStatusWindow.Properties { } } + /// + /// Looks up a localized string similar to Label. + /// + public static string LabelColumnHeader { + get { + return ResourceManager.GetString("LabelColumnHeader", resourceCulture); + } + } + /// /// Looks up a localized string similar to Loading.... /// @@ -151,6 +241,15 @@ namespace WorldClockStatusWindow.Properties { } } + /// + /// Looks up a localized string similar to OK. + /// + public static string OkayButton { + get { + return ResourceManager.GetString("OkayButton", resourceCulture); + } + } + /// /// Looks up a localized string similar to About. /// @@ -169,6 +268,15 @@ namespace WorldClockStatusWindow.Properties { } } + /// + /// Looks up a localized string similar to Time Zones. + /// + public static string optionCategoryTimeZones { + get { + return ResourceManager.GetString("optionCategoryTimeZones", resourceCulture); + } + } + /// /// Looks up a localized string similar to Update. /// @@ -196,6 +304,33 @@ namespace WorldClockStatusWindow.Properties { } } + /// + /// Looks up a localized string similar to Time Zone. + /// + public static string TimeZoneColumnHeader { + get { + return ResourceManager.GetString("TimeZoneColumnHeader", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Add Time Zone. + /// + public static string TimeZoneWindowAdd { + get { + return ResourceManager.GetString("TimeZoneWindowAdd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Edit Time Zone. + /// + public static string TimeZoneWindowEdit { + get { + return ResourceManager.GetString("TimeZoneWindowEdit", resourceCulture); + } + } + /// /// Looks up a localized string similar to You are already running the most recent version. /// @@ -208,7 +343,7 @@ namespace WorldClockStatusWindow.Properties { } /// - /// Looks up a localized string similar to Version {1} of {0} is now available. + /// Looks up a localized string similar to Version {0} is now available. /// ///Would you like to download and install it now?. /// diff --git a/Properties/Resources.resx b/Properties/Resources.resx index de940b8..527fcf4 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -163,20 +163,65 @@ No updates are available at this time. - Version {0} is now available. + Version {0} is now available. Would you like to download and install it now? - Loading... + Loading... - Checking for update... + Checking for update... - Downloading update... + Downloading update... - Installing update... + Installing update... + + + Time Zones + + + Label + + + Time Zone + + + Add + + + Edit + + + Delete + + + Add Time Zone + + + Edit Time Zone + + + Delete Time Zone + + + Confirm Delete + + + Are you sure you want to delete the selected time zones? + + + Add Time Zone + + + Edit Time Zone + + + OK + + + Cancel \ No newline at end of file diff --git a/SettingsWindow/TimeZoneWindow.xaml b/SettingsWindow/TimeZoneWindow.xaml new file mode 100644 index 0000000..1dc0d56 --- /dev/null +++ b/SettingsWindow/TimeZoneWindow.xaml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +