/// <summary> /// Загрузка параметров из реестра /// </summary> /// <returns>Структура, содержащая все загруженные параметры</returns> public void LoadParameter(out PrintInfo paramInfo) { paramInfo = new PrintInfo { Margins = new Margins(30, 30, 30, 30), PaperNumber = 4 }; if (!_useRegister) { return; } RegistryKey regKey = Registry.CurrentUser; regKey = regKey.CreateSubKey(RegPath); try { // Чтение значений из реестра if (regKey != null) { string s = ""; s = (string)regKey.GetValue("marginsBottom", s); paramInfo.Margins.Bottom = Convert.ToInt32(s); s = ""; s = (string)regKey.GetValue("marginsLeft", s); paramInfo.Margins.Left = Convert.ToInt32(s); s = ""; s = (string)regKey.GetValue("marginsRight", s); paramInfo.Margins.Right = Convert.ToInt32(s); s = ""; s = (string)regKey.GetValue("marginsTop", s); paramInfo.Margins.Top = Convert.ToInt32(s); s = ""; s = (string)regKey.GetValue("psNumber", s); paramInfo.PaperNumber = Convert.ToInt32(s); s = ""; s = (string)regKey.GetValue("psLandscape", s); paramInfo.Landscape = Convert.ToBoolean(s); } } // ReSharper disable EmptyGeneralCatchClause catch { } // ReSharper restore EmptyGeneralCatchClause }
/// <summary> /// Сохранение параметров в реестре /// </summary> /// <param name="paramInfo">Структура, содержащая все сохраняемые параметры</param> public void SaveParameter(PrintInfo paramInfo) { if (!_useRegister) { return; } RegistryKey regKey = Registry.CurrentUser; regKey = regKey.CreateSubKey(RegPath); // Сохранение размеров отступов if (regKey != null) { regKey.SetValue("marginsBottom", paramInfo.Margins.Bottom.ToString()); regKey.SetValue("marginsLeft", paramInfo.Margins.Left.ToString()); regKey.SetValue("marginsRight", paramInfo.Margins.Right.ToString()); regKey.SetValue("marginsTop", paramInfo.Margins.Top.ToString()); // Сохранение настроек листа regKey.SetValue("psNumber", paramInfo.PaperNumber.ToString()); regKey.SetValue("psLandscape", paramInfo.Landscape.ToString()); } }