public void LoadConfigWindow() { try { intervalUpDown.Value = _serverManger.IntervalTimer; _windowSettings = WindowSettings.GetSettings(); transparentTrackBar.Value = _windowSettings.Transparent; Left = _windowSettings.Left; Top = _windowSettings.Top; Width = _windowSettings.Width; Height = _windowSettings.Height; voiceTextBox.Text = _windowSettings.VoiceText; warningVoiceUpDown.Value = _windowSettings.CountVoiceWarning; compactCheckBox.Checked = _windowSettings.IsCompact; } catch { MessageBox.Show("Ошибка загрузки настроек программы"); } }
public static WindowSettings GetSettings() { WindowSettings windowSettings = new WindowSettings(); if (!File.Exists(FileName)) return windowSettings; { using (FileStream fs = new FileStream(FileName, FileMode.Open)) { XmlSerializer xmlSettings = new XmlSerializer(typeof(WindowSettings)); windowSettings = (WindowSettings)xmlSettings.Deserialize(fs); fs.Close(); } } return windowSettings; }