GetByIndex() public method

public GetByIndex ( int index ) : IComparable
index int
return IComparable
コード例 #1
0
        private void ShowDiff(DiffListText source, DiffListText destination, List <DiffResultSpan> diffLines, double seconds)
        {
            _currentIndex = 0;
            _cmdDifferenceNext.Enabled     = true;
            _cmdDifferencePrevious.Enabled = true;
            _differences = new List <int>();
            _rtbSourceScript.BeginUpdate();
            _rtbDestinationScript.BeginUpdate();
            var sourceLines      = new List <KeyValuePair <string, Color> >();
            var destinationLines = new List <KeyValuePair <string, Color> >();
            int i;

            foreach (var drs in diffLines)
            {
                switch (drs.Status)
                {
                case DiffResultSpanStatus.DeleteSource:
                    _differences.Add(sourceLines.Count);
                    for (i = 0; i < drs.Length; i++)
                    {
                        sourceLines.Add(new KeyValuePair <string, Color>(((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line, Color.Red));
                        destinationLines.Add(new KeyValuePair <string, Color>(new string(' ', ((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line.Length), Color.Blue));
                    }
                    break;

                case DiffResultSpanStatus.NoChange:
                    for (i = 0; i < drs.Length; i++)
                    {
                        sourceLines.Add(new KeyValuePair <string, Color>(((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line, Color.Empty));
                        destinationLines.Add(new KeyValuePair <string, Color>(((TextLine)destination.GetByIndex(drs.DestIndex + i)).Line, Color.Empty));
                    }
                    break;

                case DiffResultSpanStatus.AddDestination:
                    _differences.Add(sourceLines.Count);
                    for (i = 0; i < drs.Length; i++)
                    {
                        sourceLines.Add(new KeyValuePair <string, Color>(new string(' ', ((TextLine)destination.GetByIndex(drs.DestIndex + i)).Line.Length), Color.Blue));
                        destinationLines.Add(new KeyValuePair <string, Color>(((TextLine)destination.GetByIndex(drs.DestIndex + i)).Line, Color.Blue));
                    }
                    break;

                case DiffResultSpanStatus.Replace:
                    _differences.Add(sourceLines.Count);
                    for (i = 0; i < drs.Length; i++)
                    {
                        sourceLines.Add(new KeyValuePair <string, Color>(((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line, Color.Red));
                        destinationLines.Add(new KeyValuePair <string, Color>(((TextLine)destination.GetByIndex(drs.DestIndex + i)).Line, Color.Green));
                    }
                    break;
                }
            }

            FillScript(sourceLines, _rtbSourceScript);
            FillScript(destinationLines, _rtbDestinationScript);

            _rtbSourceScript.EndUpdate();
            _rtbDestinationScript.EndUpdate();

            this.Text = _differences.Count + " differences.";
        }
コード例 #2
0
ファイル: DiffResults.cs プロジェクト: chouzicz/SQLMonitor
        private void ShowDiff(DiffListText source, DiffListText destination, List<DiffResultSpan> diffLines, double seconds)
        {
            _currentIndex = 0;
            _cmdDifferenceNext.Enabled = true;
            _cmdDifferencePrevious.Enabled = true;
            _differences = new List<int>();
            _rtbSourceScript.BeginUpdate();
            _rtbDestinationScript.BeginUpdate();
            var sourceLines = new List<KeyValuePair<string, Color>>();
            var destinationLines = new List<KeyValuePair<string, Color>>();
            int i;

            foreach (var drs in diffLines)
            {
                switch (drs.Status)
                {
                    case DiffResultSpanStatus.DeleteSource:
                        _differences.Add(sourceLines.Count);
                        for (i = 0; i < drs.Length; i++)
                        {
                            sourceLines.Add(new KeyValuePair<string, Color>(((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line, Color.Red));
                            destinationLines.Add(new KeyValuePair<string, Color>(new string(' ', ((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line.Length), Color.Blue));
                        }
                        break;
                    case DiffResultSpanStatus.NoChange:
                        for (i = 0; i < drs.Length; i++)
                        {
                            sourceLines.Add(new KeyValuePair<string, Color>(((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line, Color.Empty));
                            destinationLines.Add(new KeyValuePair<string, Color>(((TextLine)destination.GetByIndex(drs.DestIndex + i)).Line, Color.Empty));
                        }
                        break;
                    case DiffResultSpanStatus.AddDestination:
                        _differences.Add(sourceLines.Count);
                        for (i = 0; i < drs.Length; i++)
                        {
                            sourceLines.Add(new KeyValuePair<string, Color>(new string(' ', ((TextLine)destination.GetByIndex(drs.DestIndex + i)).Line.Length), Color.Blue));
                            destinationLines.Add(new KeyValuePair<string, Color>(((TextLine)destination.GetByIndex(drs.DestIndex + i)).Line, Color.Blue));
                        }
                        break;
                    case DiffResultSpanStatus.Replace:
                        _differences.Add(sourceLines.Count);
                        for (i = 0; i < drs.Length; i++)
                        {
                            sourceLines.Add(new KeyValuePair<string, Color>(((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line, Color.Red));
                            destinationLines.Add(new KeyValuePair<string, Color>(((TextLine)destination.GetByIndex(drs.DestIndex + i)).Line, Color.Green));
                        }
                        break;
                }
            }

            FillScript(sourceLines, _rtbSourceScript);
            FillScript(destinationLines, _rtbDestinationScript);

            _rtbSourceScript.EndUpdate();
            _rtbDestinationScript.EndUpdate();

            this.Text = _differences.Count + " differences.";
        }