示例#1
0
        /// <summary>
        /// Загрузка параметров из реестра
        /// </summary>
        /// <returns>Структура, содержащая все загруженные параметры</returns>
        public void LoadParameter(out QuickReplaceParametersInfo paramInfo)
        {
            paramInfo = new QuickReplaceParametersInfo
            {
                QrLocation  = new Point(250, 150),
                FindText    = "",
                ReplaceText = "",
                TopMost     = true
            };

            if (!_useRegister)
            {
                return;
            }

            RegistryKey regKey = Registry.CurrentUser;

            regKey = regKey.CreateSubKey(RegPath);

            // Чтение значений из реестра
            try
            {
                if (regKey != null)
                {
                    string s = "";
                    s = (string)regKey.GetValue("QrLocation", s);
                    string[] arr = s.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                    if (arr.Length == 2 && Convert.ToInt32(arr[0]) > 0 && Convert.ToInt32(arr[1]) > 0)
                    {
                        paramInfo.QrLocation = new Point(Convert.ToInt32(arr[0]), Convert.ToInt32(arr[1]));
                    }

                    s = "";
                    s = (string)regKey.GetValue("qrFindText", s);
                    paramInfo.FindText = s;

                    s = "";
                    s = (string)regKey.GetValue("qrReplaceText", s);
                    paramInfo.ReplaceText = s;

                    s = "";
                    s = (string)regKey.GetValue("qrUseRegExp", s);
                    paramInfo.UseRegExp = Convert.ToBoolean(s);

                    s = "";
                    s = (string)regKey.GetValue("qrTopMost", s);
                    paramInfo.TopMost = Convert.ToBoolean(s);
                }
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch { }
            // ReSharper restore EmptyGeneralCatchClause
        }
示例#2
0
        /// <summary>
        /// Сохранение параметров в реестре
        /// </summary>
        /// <param name="paramInfo">Структура, содержащая все сохраняемые параметры</param>
        public void SaveParameter(QuickReplaceParametersInfo paramInfo)
        {
            if (!_useRegister)
            {
                return;
            }

            RegistryKey regKey = Registry.CurrentUser;

            regKey = regKey.CreateSubKey(RegPath);

            if (regKey != null)
            {
                // Сохранение размера и позиции формы
                regKey.SetValue("QrLocation", paramInfo.QrLocation.X + ";" + paramInfo.QrLocation.Y);

                // Сохранение опций
                regKey.SetValue("qrFindText", paramInfo.FindText);
                regKey.SetValue("qrReplaceText", paramInfo.ReplaceText);
                regKey.SetValue("qrUseRegExp", paramInfo.UseRegExp.ToString());
                regKey.SetValue("qrTopMost", paramInfo.TopMost.ToString());
            }
        }