Changed ATI GPU device enumeration.
3 Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 The contents of this file are subject to the Mozilla Public License Version
6 1.1 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
9 http://www.mozilla.org/MPL/
11 Software distributed under the License is distributed on an "AS IS" basis,
12 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 for the specific language governing rights and limitations under the License.
15 The Original Code is the Open Hardware Monitor code.
17 The Initial Developer of the Original Code is
18 Michael Möller <m.moeller@gmx.ch>.
19 Portions created by the Initial Developer are Copyright (C) 2009-2010
20 the Initial Developer. All Rights Reserved.
24 Alternatively, the contents of this file may be used under the terms of
25 either the GNU General Public License Version 2 or later (the "GPL"), or
26 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 in which case the provisions of the GPL or the LGPL are applicable instead
28 of those above. If you wish to allow use of your version of this file only
29 under the terms of either the GPL or the LGPL, and not to allow others to
30 use your version of this file under the terms of the MPL, indicate your
31 decision by deleting the provisions above and replace them with the notice
32 and other provisions required by the GPL or the LGPL. If you do not delete
33 the provisions above, a recipient may use your version of this file under
34 the terms of any one of the MPL, the GPL or the LGPL.
39 using System.Collections.Generic;
42 namespace OpenHardwareMonitor.Utilities {
44 public sealed class Config {
45 private static readonly Config instance = new Config();
47 private string fileName;
49 private System.Configuration.Configuration config;
52 this.fileName = Path.ChangeExtension(
53 System.Windows.Forms.Application.ExecutablePath, ".config");
54 System.Configuration.ExeConfigurationFileMap fileMap =
55 new System.Configuration.ExeConfigurationFileMap();
56 fileMap.ExeConfigFilename = fileName;
57 config = System.Configuration.ConfigurationManager.
58 OpenMappedExeConfiguration(fileMap,
59 System.Configuration.ConfigurationUserLevel.None);
63 string tempName = Path.ChangeExtension(fileName, ".tmp");
65 if (File.Exists(tempName))
66 File.Delete(tempName);
68 config.SaveAs(tempName);
69 if (File.Exists(fileName) && File.Exists(tempName))
70 File.Delete(fileName);
71 File.Move(tempName, fileName);
72 } catch (System.Configuration.ConfigurationErrorsException) { }
75 public static Config Settings {
81 public string this[string name] {
83 System.Configuration.KeyValueConfigurationElement element =
84 config.AppSettings.Settings[name];
91 config.AppSettings.Settings.Remove(name);
92 config.AppSettings.Settings.Add(name, value);
96 public static bool Contains(string name) {
97 System.Configuration.KeyValueConfigurationElement element =
98 instance.config.AppSettings.Settings[name];
99 return element != null;
102 public static void Remove(string name) {
103 instance.config.AppSettings.Settings.Remove(name);
106 public static void Set(string name, bool value) {
107 instance[name] = value ? "true" : "false";
110 public static bool Get(string name, bool value) {
111 System.Configuration.KeyValueConfigurationElement element =
112 instance.config.AppSettings.Settings[name];
116 return element.Value == "true";
119 public static void Set(string name, int value) {
120 instance[name] = value.ToString();
123 public static int Get(string name, int value) {
124 System.Configuration.KeyValueConfigurationElement element =
125 instance.config.AppSettings.Settings[name];
130 if (int.TryParse(element.Value, out parsedValue))