This is a specialization of the abstract TimeZone class that implements time zones based in the time zone information found in Windows.
Inheritance: System.TimeZone
Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public WindowsTimeZone GetConfiguredTimeZone()
 {
     if (windowsTimeZone == null)
     {
         windowsTimeZone = WindowsTimeZone.TimeZones.GetByZoneIndex(displayTimeZoneIndex) as WindowsTimeZone;
     }
     return windowsTimeZone;
 }
Exemplo n.º 3
0
 /// <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);
 }
Exemplo n.º 4
0
 /// <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);
 }
Exemplo n.º 5
0
 /// <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);
 }
Exemplo n.º 6
0
        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;
        }