private static WindowsTimeZoneCollection LoadTimeZonesFromRegistry() { WindowsTimeZoneCollection tzs = new WindowsTimeZoneCollection(); RegistryKey timeZoneListKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", false); string[] timeZoneKeyNames = timeZoneListKey.GetSubKeyNames(); foreach (string timeZoneKeyName in timeZoneKeyNames) { RegistryKey timeZoneKey = timeZoneListKey.OpenSubKey(timeZoneKeyName); WindowsTimeZone windowsTimeZone = new WindowsTimeZone( timeZoneKey.GetValue("Display") as string, timeZoneKey.GetValue("Dlt") as string, timeZoneKey.GetValue("Std") as string, (int)timeZoneKey.GetValue("Index"), timeZoneKey.GetValue("TZI") as byte[]); tzs.Add(windowsTimeZone); } tzs.SortByTimeZoneBias(); return(tzs); }
public WindowsTimeZone GetConfiguredTimeZone() { if (windowsTimeZone == null) { windowsTimeZone = WindowsTimeZone.TimeZones.GetByZoneIndex(displayTimeZoneIndex) as WindowsTimeZone; } return windowsTimeZone; }
/// <summary> /// Return the zero-based index of the first occurrence of a specific value /// in this WindowsTimeZoneCollection /// </summary> /// <param name="value"> /// The WindowsTimeZone value to locate in the WindowsTimeZoneCollection. /// </param> /// <returns> /// The zero-based index of the first occurrence of the _ELEMENT value if found; /// -1 otherwise. /// </returns> public virtual int IndexOf(WindowsTimeZone value) { return this.List.IndexOf(value); }
/// <summary> /// Determines whether a specfic WindowsTimeZone value is in this WindowsTimeZoneCollection. /// </summary> /// <param name="value"> /// The WindowsTimeZone value to locate in this WindowsTimeZoneCollection. /// </param> /// <returns> /// true if value is found in this WindowsTimeZoneCollection; /// false otherwise. /// </returns> public virtual bool Contains(WindowsTimeZone value) { return this.List.Contains(value); }
/// <summary> /// Adds an instance of type WindowsTimeZone to the end of this WindowsTimeZoneCollection. /// </summary> /// <param name="value"> /// The WindowsTimeZone to be added to the end of this WindowsTimeZoneCollection. /// </param> public virtual void Add(WindowsTimeZone value) { this.List.Add(value); }
private static WindowsTimeZoneCollection LoadTimeZonesFromRegistry() { WindowsTimeZoneCollection tzs = new WindowsTimeZoneCollection(); RegistryKey timeZoneListKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", false); string[] timeZoneKeyNames = timeZoneListKey.GetSubKeyNames(); foreach (string timeZoneKeyName in timeZoneKeyNames) { RegistryKey timeZoneKey = timeZoneListKey.OpenSubKey(timeZoneKeyName); WindowsTimeZone windowsTimeZone = new WindowsTimeZone( timeZoneKey.GetValue("Display") as string, timeZoneKey.GetValue("Dlt") as string, timeZoneKey.GetValue("Std") as string, (int)timeZoneKey.GetValue("Index" ), timeZoneKey.GetValue("TZI") as byte[] ); tzs.Add( windowsTimeZone ); } tzs.SortByTimeZoneBias(); return tzs; }