/// <summary> /// <para>Imports the config file.</para> /// </summary> /// <param name="commandTableHandler">The command table handler.</param> public static void ImportConfig(ShortCommandTableHandler commandTableHandler) { string filePath = FileAndDirectoryHelper.OpenXmlFileDialog(); Dictionary <string, string> importCommandConfig = CommandConfigHandler.ReadCommandConfigFile(filePath); if (importCommandConfig == null || importCommandConfig.Count <= 0) { return; } List <CurrentAndImportCommand> sharedCommands = new List <CurrentAndImportCommand>(); Dictionary <string, string> nameAndCommandCopy = new Dictionary <string, string>(commandTableHandler.UpdateNameAndCommandFromTable()); foreach (var importPair in importCommandConfig) { string importCommand = importPair.Value; if (FileAndDirectoryHelper.IsInvalidPath(importCommand)) { continue; } string name = importPair.Key; if (nameAndCommandCopy.TryGetValue(name, out var currentCommand)) { if (currentCommand.Equals(importCommand)) { continue; } sharedCommands.Add(new CurrentAndImportCommand(name, currentCommand, importCommand)); } else { nameAndCommandCopy[name] = importCommand; } } //有相同的快捷命令冲突 if (sharedCommands.Count > 0) { ShowCommandCompareForm(sharedCommands, nameAndCommandCopy, commandTableHandler); } else if (!nameAndCommandCopy.SequenceEqual(commandTableHandler.ShortNameAndCommands)) { commandTableHandler.UpdateShortNameAndCommands(nameAndCommandCopy); } }
/// <summary> /// 清除无效路径 /// </summary> public void ClearInvalidPath() { int invalidCount = 0; for (int i = ShortNameAndCommandsTable.Rows.Count - 1; i >= 0; i--) { string command = ShortNameAndCommandsTable.Rows[i][RealCommandName].ToString(); //删除无效路径 if (FileAndDirectoryHelper.IsInvalidPath(command)) { ShortNameAndCommandsTable.Rows.RemoveAt(i); invalidCount++; } } MessageBoxHelper.ShowInfoMessageBox(string.Format("共清除{0}个无效路径。", invalidCount)); }