private void BackToMainViewButton_OnClick(object sender, RoutedEventArgs e) { MainViewGrid.Visibility = Visibility.Visible; var iniFilePath = CustomPath.GetUserSettingIniPath(); IniUtility.WriteValue(IniSection, IniSection, nameof(MainViewGrid), iniFilePath); }
public static List <string> GetFolders() { var iniFilePath = GetIniFilePath(); var toCleanUpFolders = IniUtility.GetKeyValuesBySection(IniSection, iniFilePath); return(toCleanUpFolders); }
private void MoreOperationsButton_OnClick(object sender, RoutedEventArgs e) { MainViewGrid.Visibility = Visibility.Collapsed; var iniFilePath = CustomPath.GetUserSettingIniPath(); IniUtility.ClearSection(IniSection, iniFilePath); }
public static List <string> GetFolders() { var iniFilePath = CustomPath.GetUserSettingIniPath(); //获取配置清理路径 var toCleanUpFolders = IniUtility.GetKeyValuesBySection(IniSection, iniFilePath); //重置待清理路径列表 var allFolders = ResetToCleanFolers(toCleanUpFolders, iniFilePath); return(allFolders); }
private static void SaveCleanedIniSettings(string iniFilePath) { var toBeCleanedFolders = GetPresetFolders(); int index = 0; var enumerable = toBeCleanedFolders.Select(i => Tuple.Create($"路径{index++}", i)); IniUtility.SaveKeyValuesBySection(enumerable, "程序预置清理路径列表(只读)", iniFilePath); index = 0; var presetFolders = toBeCleanedFolders.Where(path => Directory.Exists(path)).ToList(); IniUtility.SaveKeyValuesBySection( presetFolders.Select(i => Tuple.Create($"路径{index++}", i)), IniSection, iniFilePath); }
private static List <string> ResetToCleanFolers(List <string> toCleanUpFolders, string iniFilePath) { var allFolders = new List <string>(); allFolders.AddRange(toCleanUpFolders.Where(i => Directory.Exists(i))); var currentPresetFolders = GetPresetFolders().Where(path => Directory.Exists(path)).ToList(); if (!currentPresetFolders.All(foler => toCleanUpFolders.Any(i => i == foler))) { allFolders.AddRange(currentPresetFolders.Where(i => allFolders.All(j => j != i))); } //重置缓存目录 IniUtility.ClearSection(IniSection, iniFilePath); int index = 0; IniUtility.SaveKeyValuesBySection(allFolders.Select(i => Tuple.Create($"路径{index++}", i)), IniSection, iniFilePath); return(allFolders); }
/// <summary> /// 通过软件安装路径中的launcherConfig.ini获取当前最新版本路径 /// </summary> /// <param name="softwareFolder"></param> /// <returns></returns> public static string GetLastetVersionPathByIni(string softwareFolder) { string versionPath = string.Empty; var iniPath = Path.Combine(softwareFolder, "swenlauncher\\launcherConfig.ini"); if (File.Exists(versionPath)) { try { var actualExePath = IniUtility.ReadValue("Version", "ActualExePath", iniPath); var leftPathStr = actualExePath.Replace(softwareFolder + "\\", string.Empty); var versionFileName = leftPathStr.Substring(0, leftPathStr.IndexOf("\\")); versionPath = Path.Combine(softwareFolder, versionFileName); } catch (Exception e) { } } return(versionPath); }
public MainWindow() { InitializeComponent(); //Loaded += MainWindow_Loaded; ViewTabControl.SelectedItem = ViewTabControl.Items.Cast <TabItem>().FirstOrDefault(); Loaded += (s, e) => { var iniFilePath = CustomPath.GetUserSettingIniPath(); Task.Run(() => { CleanCacheVeiwModel.Instance.RefreshCommand.Execute(null); }); //获取配置清理路径 var viewName = IniUtility.ReadValue(IniSection, IniSection, iniFilePath); if (string.IsNullOrWhiteSpace(viewName)) { MainViewGrid.Visibility = Visibility.Visible; } else { MainViewGrid.Visibility = viewName == nameof(MainViewGrid) ? Visibility.Visible : Visibility.Collapsed; } }; }