Esempio n. 1
0
 private void DoWork()
 {
     try
     {
         _bytediffs = DiffRange.BuildDifferences(_left, _right, EqualityComparer <byte> .Default).ToArray();
         _linediffs = DiffRange.BuildDifferences(_leftlines, _rightlines, EqualityComparer <string> .Default).ToArray();
         Invoke(new Action(CompleteDifferences));
     }
     catch (ThreadAbortException)
     {
         throw;
     }
     catch
     {
     }
 }
        private void DiffNodesAndAdd(TreeNodeCollection col, DataNode[] left, DataNode[] right)
        {
            treeViewOutput.SuspendLayout();
            col.Clear();

            if ((left.Length == 0) && (right.Length == 0))
            {
                MessageBox.Show(this, Properties.Resources.DiffPacketsControl_NoDifferencesFound, Properties.Resources.DiffPacketsControl_NoDifferencesFoundCaption,
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (left.Length == 0)
            {
                foreach (DataNode packet in right)
                {
                    AddNodes(col, null, packet);
                }
            }
            else if (right.Length == 0)
            {
                foreach (DataNode packet in left)
                {
                    AddNodes(col, packet, null);
                }
            }
            else
            {
                DiffRange[] ranges = DiffRange.BuildDifferences(left, right, new DataNodeEqualityComparer()).ToArray();

                if (ranges.Length > 0)
                {
                    foreach (DiffRange range in ranges)
                    {
                        if (range.LeftLength == range.RightLength)
                        {
                            for (int i = 0; i < range.LeftLength; ++i)
                            {
                                AddNodes(col, left[i + range.LeftStartPos], right[i + range.RightStartPos]);
                            }
                        }
                        else
                        {
                            for (int i = 0; i < range.LeftLength; ++i)
                            {
                                AddNodes(col, left[i + range.LeftStartPos], null);
                            }

                            for (int i = 0; i < range.RightLength; ++i)
                            {
                                AddNodes(col, null, right[i + range.RightStartPos]);
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show(this, Properties.Resources.DiffPacketsControl_NoDifferencesFound, Properties.Resources.DiffPacketsControl_NoDifferencesFoundCaption,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            treeViewOutput.ResumeLayout();
        }