示例#1
0
        /// <summary>
        /// Сохранение параметров в реестре
        /// </summary>
        /// <param name="paramInfo">Структура, содержащая все сохраняемые параметры</param>
        public void SaveParameter(FindParametersInfo paramInfo)
        {
            if (!_useRegister)
            {
                return;
            }

            RegistryKey regKey = Registry.CurrentUser;

            regKey = regKey.CreateSubKey(RegPath);

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

                // Сохранение опций
                regKey.SetValue("FindText", paramInfo.FindText);
                regKey.SetValue("ReplaceText", paramInfo.ReplaceText);
                regKey.SetValue("register", paramInfo.CheckRegistr.ToString());
                regKey.SetValue("searchUp", paramInfo.CheckSearchUp.ToString());
                regKey.SetValue("wordAll", paramInfo.CheckWordAll.ToString());
                regKey.SetValue("TopMost", paramInfo.TopMost.ToString());
            }
        }
示例#2
0
        /// <summary>
        /// Загрузка параметров из реестра
        /// </summary>
        /// <returns>Структура, содержащая все загруженные параметры</returns>
        public void LoadParameter(out FindParametersInfo paramInfo)
        {
            paramInfo = new FindParametersInfo
            {
                FfLocation    = new Point(250, 150),
                FindText      = "",
                ReplaceText   = "",
                CheckRegistr  = false,
                CheckSearchUp = false,
                CheckWordAll  = false,
                TopMost       = true
            };

            if (!_useRegister)
            {
                return;
            }

            RegistryKey regKey = Registry.CurrentUser;

            regKey = regKey.CreateSubKey(RegPath);

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

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

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

                    s = "";
                    s = (string)regKey.GetValue("register", s);
                    paramInfo.CheckRegistr = Convert.ToBoolean(s);

                    s = "";
                    s = (string)regKey.GetValue("searchUp", s);
                    paramInfo.CheckSearchUp = Convert.ToBoolean(s);

                    s = "";
                    s = (string)regKey.GetValue("wordAll", s);
                    paramInfo.CheckWordAll = Convert.ToBoolean(s);

                    s = "";
                    s = (string)regKey.GetValue("TopMost", s);
                    paramInfo.TopMost = Convert.ToBoolean(s);
                }
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch { }
            // ReSharper restore EmptyGeneralCatchClause
        }