private HotBabeSettings checkValues(out ValidationResult result) { HotBabeSettings settings = new HotBabeSettings { AlwaysOnTop = Settings.AlwaysOnTop, AutoRun = Settings.AutoRun, ClickThrough = Settings.ClickThrough, DefaultImageName = tbImage.Text, Left = Settings.Left, Opacity = Settings.Opacity, Top = Settings.Top, UpdateInterval = Settings.UpdateInterval, BlendImages = Settings.BlendImages, HideOnFullscreen = Settings.HideOnFullscreen }; foreach (ImageInfoEditor editor in pnlImages.Controls) { settings.ImageInfos.Add(editor.GetEditorItem()); } foreach (MonitorInfoEditor editor in pnlMonitors.Controls) { settings.MonitorInfos.Add(editor.GetEditorItem()); } result = SettingsValidationHelper.Validate(settings); if (result.ContainsKey("DefaultImageName")) { errorProvider1.SetError(tbImage, result["DefaultImageName"].ToString()); } return(settings); }
///<summary> /// Reload the settings and refresh the view ///</summary> public void Refresh(HotBabeSettings babeSettings) { settings.PropertyChanged -= settingsPropertyChanged; settings = babeSettings ?? settingsManager.LoadSettings(); settings.PropertyChanged += settingsPropertyChanged; _imageName = getImageName(); applySettings(); }
///<summary> /// Load the settings in the editor ///</summary> ///<param name="settings"></param> public void LoadSettings(HotBabeSettings settings) { _settings = settings; Icon = ImageHelper.MakeIcon( ImageHelper.FromFile(PathHelper.GetRootedPath(settings.DefaultImageName)), 16, false); tbImage.Text = PathHelper.GetRelativePath(settings.DefaultImageName); loadImages(); loadMonitors(); }
private void btnSave_Click(object sender, EventArgs e) { if (_dirty) { ValidationResult result; HotBabeSettings settings = checkValues(out result); if (!result.IsValid) { return; } _settings = settings; } DialogResult = DialogResult.OK; Close(); }
///<summary> /// Start the controller ///</summary> public void Start() { Form frm = _view as Form; if (frm != null) { HotBabeSettings settings = _settingsManager.LoadSettings(); _view.LoadSettings(settings); DialogResult dia = frm.ShowDialog(); if (dia == DialogResult.OK) { _settingsManager.SaveSettings(_view.Settings); SettingsChanged.Fire(this, new EventArgs <HotBabeSettings>(_view.Settings)); } } }
private void loadPack(string packFileName) { string zipUriPrefix = "zip:///" + PathHelper.GetRelativePath(packFileName) + "?"; BaseSettingsManager <HotBabeSettings> tempManager = settingsManager.GetNewInstance(zipUriPrefix + "HotBabe.xml"); HotBabeSettings tempSettings = tempManager.LoadSettings(); settings.PropertyChanged -= settingsPropertyChanged; settings.AlwaysOnTop = tempSettings.AlwaysOnTop; settings.AutoRun = tempSettings.AutoRun; settings.ClickThrough = tempSettings.ClickThrough; settings.Left = tempSettings.Left; settings.Opacity = tempSettings.Opacity; settings.Top = tempSettings.Top; settings.UpdateInterval = tempSettings.UpdateInterval; settings.BlendImages = tempSettings.BlendImages; settings.HideOnFullscreen = tempSettings.HideOnFullscreen; settings.MonitorInfos.Clear(); settings.MonitorInfos.AddRange(tempSettings.MonitorInfos); foreach (ImageInfo info in tempSettings.ImageInfos) { if (!PathHelper.IsRooted(info.ImageFileName)) { info.ImageFileName = zipUriPrefix + info.ImageFileName; } } settings.ImageInfos.Clear(); settings.ImageInfos.AddRange(tempSettings.ImageInfos); if (!PathHelper.IsRooted(tempSettings.DefaultImageName)) { tempSettings.DefaultImageName = zipUriPrefix + tempSettings.DefaultImageName; } settings.DefaultImageName = tempSettings.DefaultImageName; settings.PropertyChanged += settingsPropertyChanged; saveSettings(); Refresh(settings); }