示例#1
0
        protected virtual CommandViewItem GetChangedCommand(ICommand source, ICommand target)
        {
            var result = new CommandViewItem
            {
                CommandKey   = this.GetCommandKey(source),
                CommandName  = source.CommandPrefix,
                LeftCommand  = source,
                RightCommand = target,
                Database     = this.GetCommandDatabase(source)
            };

            string sourceStr = CommandSerializer.Serialize(source);
            string targetStr = CommandSerializer.Serialize(target);

            result.Group = String.CompareOrdinal(sourceStr, targetStr) == 0 ? Groups.Unmodified : Groups.Changed;

            return(result);
        }
示例#2
0
        private void commandsView_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            CommandViewItem command = null;
            string          path    = this.commandsView.SelectedItems[0].SubItems[1].Text;

            foreach (var cmd in this.data)
            {
                if (string.CompareOrdinal(cmd.CommandKey, path) == 0)
                {
                    command = cmd;
                    break;
                }
            }

            if (command == null)
            {
                MessageBox.Show("Command not found... Something is going wrong.");
            }
            else
            {
                string assemblyPath = Assembly.GetExecutingAssembly().Location;
                string dumpPath     = new FileInfo(assemblyPath).DirectoryName + "\\merge";
                if (!Directory.Exists(dumpPath))
                {
                    Directory.CreateDirectory(dumpPath);
                }

                string sourcePath = dumpPath + "\\source_" + command.CommandKey.GetHashCode() + ".txt";
                string targetPath = dumpPath + "\\target_" + command.CommandKey.GetHashCode() + ".txt";

                CommandSerializer.Serialize(sourcePath, command.LeftCommand);
                CommandSerializer.Serialize(targetPath, command.RightCommand);

                Process.Start("winmergeU.exe", "\"" + sourcePath + "\"" + " " + "\"" + targetPath + "\"");
            }
        }
示例#3
0
        protected virtual IList <CommandViewItem> FilterCommands(IList <CommandViewItem> commands)
        {
            var result = new List <CommandViewItem>();

            var groupTypes = new List <string>();

            for (int i = 0; i < this.clbGroupFilters.CheckedItems.Count; i++)
            {
                groupTypes.Add(this.clbGroupFilters.CheckedItems[i].ToString());
            }

            var commandTypes = new List <string>();

            for (int i = 0; i < this.clbCommandTypeFilter.CheckedItems.Count; i++)
            {
                commandTypes.Add(this.clbCommandTypeFilter.CheckedItems[i].ToString());
            }

            string searchText = this.SearchText.Text;

            foreach (var command in commands)
            {
                if (!groupTypes.Contains(command.Group.ToString()))
                {
                    continue;
                }

                if (!commandTypes.Contains((command.LeftCommand ?? command.RightCommand).CommandPrefix))
                {
                    continue;
                }

                var leftCommand = command.LeftCommand;
                if (leftCommand != null && FilterByCustomFilter(leftCommand) == null)
                {
                    continue;
                }

                var rightCommand = command.RightCommand;
                if (rightCommand != null && FilterByCustomFilter(rightCommand) == null)
                {
                    continue;
                }

                if (!string.IsNullOrEmpty(searchText))
                {
                    if (command.LeftCommand != null)
                    {
                        if (CommandSerializer.Serialize(command.LeftCommand).ToLower().Contains(searchText))
                        {
                            result.Add(command);
                            continue;
                        }
                    }

                    if (command.RightCommand != null)
                    {
                        if (CommandSerializer.Serialize(command.RightCommand).ToLower().Contains(searchText))
                        {
                            result.Add(command);
                            continue;
                        }
                    }

                    continue;
                }

                result.Add(command);
            }

            return(result);
        }
示例#4
0
 protected string GetCommandText(ICommand command)
 {
     return(CommandSerializer.Serialize(command));
 }