/// <summary> /// 保存配置 /// </summary> /// <param name="config"></param> public static bool SaveConfig(Config config) { ConfigSaver cs = new ConfigSaver(); bool isUpdate = false; #region 判断配置路径是否发生变化,如果发生变化,则告诉状态管理器 try { string[] prePaths = GetCurrentConfig().LogPath.Trim().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); string[] currPaths = config.LogPath.Trim().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); string preFolder = GetCurrentConfig().Folder.Trim(); string currFolder = config.Folder.Trim(); if (prePaths.Count() == currPaths.Count() && preFolder == currFolder) { foreach (string path in currPaths) { if (!prePaths.Contains(path)) { isUpdate = true; break; } } } else { isUpdate = true; } } catch (System.Exception) { isUpdate = false; } #endregion if (isUpdate) { bool status = cs.SaveConfig(config); if (status) { StatusManager.SetPathUpdate(); } return(status); } else { return(true); } }
private void btn_saveConfig_Click(object sender, RoutedEventArgs e) { var config = new OverlayConfig() { ProcessFilePath = attachedProcessFilePath, CrosshairColorIndex = cmb_color.SelectedIndex, CrosshairFileLocation = crosshairOverlayWindow.CrosshairImagePath, CrosshairOpacity = sldr_Opacity.Value, CrosshairScale = crosshairOverlayWindow.CrosshairScale, OffsetX = OffsetX, OffsetY = OffsetY }; configSaver.SaveConfig(config); MessageBox.Show("Config saved successfully"); }
/// <summary> /// 保存配置 /// </summary> /// <param name="config"></param> public static bool SaveConfig(Config config) { ConfigSaver cs = new ConfigSaver(); return(cs.SaveConfig(config)); }