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

            RegistryKey regKey = Registry.CurrentUser;

            regKey = regKey.CreateSubKey(RegPath);

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

                string res = "";
                for (int i = 0; i < paramInfo.ProcessColumnsWidth.Length; i++)
                {
                    res += paramInfo.ProcessColumnsWidth[i] + ";";
                }
                regKey.SetValue("ProcessColumnsWidth", res);
            }
        }
Exemplo n.º 2
0
        public ProcessForm(MainForm mf)
        {
            InitializeComponent();

            _mainForm  = mf;
            _actClass  = new ActionClass();
            _paramInfo = new ProcessParametersInfo();
            _actClass.LoadParameter(out _paramInfo);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Загрузка параметров из реестра
        /// </summary>
        /// <returns>Структура, содержащая все загруженные параметры</returns>
        public void LoadParameter(out ProcessParametersInfo paramInfo)
        {
            paramInfo = new ProcessParametersInfo
            {
                ProcessLocation     = new Point(198, 152),
                ProcessSize         = new Size(936, 719),
                ProcessColumnsWidth = new[] { "182", "496", "70", "127", "11" }
            };

            if (!_useRegister)
            {
                return;
            }

            RegistryKey regKey = Registry.CurrentUser;

            regKey = regKey.CreateSubKey(RegPath);

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

                    s   = "";
                    s   = (string)regKey.GetValue("ProcessSize", s);
                    arr = s.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                    if (arr.Length == 2)
                    {
                        paramInfo.ProcessSize = new Size(Convert.ToInt32(arr[0]), Convert.ToInt32(arr[1]));
                    }

                    s   = "";
                    s   = (string)regKey.GetValue("ProcessColumnsWidth", s);
                    arr = s.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                    if (arr.Length > 1)
                    {
                        paramInfo.ProcessColumnsWidth = arr;
                    }
                }
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch { }
            // ReSharper restore EmptyGeneralCatchClause
        }