Example #1
0
        /// <summary>
        /// 读取命令配置
        /// </summary>
        /// <returns></returns>
        public static Dictionary <string, string> ReadCommandSettings()
        {
            var filePath = GetConfigFilePath();

            commandConfigHandler = new CommandConfigHandler(filePath);
            Dictionary <string, string> commandSettings = commandConfigHandler.ReadAllCommandConfigs();

            return(commandSettings);
        }
Example #2
0
        /// <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);
            }
        }