/// <summary> /// Loads this instance. /// </summary> public void Load() { lock (SyncRoot) { var assembly = Assembly.GetEntryAssembly(); object[] attributes = assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false); AssemblyProductAttribute attribute = null; if (attributes.Length > 0) { attribute = attributes[0] as AssemblyProductAttribute; } string productName = "unknown"; if (attribute != null) { productName = attribute.Product; } this.configFileInfo = ConfigurationFileSupport.GetConfigurationFileInfo(this.Manufacturer, productName, string.Empty, false, false, new string[] { }, "ImsOpcBridge.config", false); var xmlSettings = new ConfigStorage(); xmlSettings.Load(this.configFileInfo.FullName); this.Manufacturer = xmlSettings.GetValue(PathLabelingManufacturer, this.Manufacturer); this.WindowsPosLeft = xmlSettings.GetValue(PathWindowsPosLeft, this.WindowsPosLeft); this.WindowsPosTop = xmlSettings.GetValue(PathWindowsPosTop, this.WindowsPosTop); this.WindowsPosWidth = xmlSettings.GetValue(PathWindowsSizeWidth, this.WindowsPosWidth); this.WindowsPosHeight = xmlSettings.GetValue(PathWindowsSizeHeight, this.WindowsPosHeight); this.CultureName = xmlSettings.GetValue(PathCultureName, this.CultureName); this.AllowCultureChange = xmlSettings.GetValue(PathAllowCultureChange, (bool?)true); this.AllowExecutionOnMachine = xmlSettings.GetValue(ExecutionPolicyException, string.Empty); this.ShowDeviceCommands = xmlSettings.GetValue(PathLayoutShowDeviceCommands, this.ShowDeviceCommands); this.LoggingCommands = xmlSettings.GetValue(PathDoLoggingCommands, this.LoggingCommands); try { CommandAlignment temp; if (!Enum.TryParse(xmlSettings.GetValue(PathLayoutCommandAlignment, "Left"), out temp)) { temp = CommandAlignment.Left; } this.CommandAlignment = temp; } catch (ArgumentException) { this.CommandAlignment = CommandAlignment.Left; } xmlSettings.Save(); xmlSettings.Close(); } }
/// <summary> /// Saves this instance. /// </summary> public void Save() { var xmlSettings = new ConfigStorage(); xmlSettings.Load(this.configFileInfo.FullName); xmlSettings.SetValue(PathLabelingManufacturer, this.Manufacturer); xmlSettings.SetValue(PathWindowsPosLeft, this.WindowsPosLeft.ToString(CultureInfo.InvariantCulture)); xmlSettings.SetValue(PathWindowsPosTop, this.WindowsPosTop.ToString(CultureInfo.InvariantCulture)); xmlSettings.SetValue(PathWindowsSizeWidth, this.WindowsPosWidth.ToString(CultureInfo.InvariantCulture)); xmlSettings.SetValue(PathWindowsSizeHeight, this.WindowsPosHeight.ToString(CultureInfo.InvariantCulture)); xmlSettings.SetValue(PathCultureName, this.CultureName); xmlSettings.SetValue(PathAllowCultureChange, this.AllowCultureChange.ToString()); xmlSettings.SetValue(PathLayoutShowDeviceCommands, this.ShowDeviceCommands.ToString(CultureInfo.InvariantCulture)); xmlSettings.SetValue(PathLayoutCommandAlignment, this.CommandAlignment.ToString()); xmlSettings.SetValue(PathDoLoggingCommands, this.LoggingCommands.ToString(CultureInfo.InvariantCulture)); xmlSettings.Save(); xmlSettings.Close(); }