Example #1
0
        public Results(DiffList_TextFile source, DiffList_TextFile destination, ArrayList DiffLines, double seconds)
        {
            InitializeComponent();
            this.Text = string.Format("Results: {0} secs.",seconds.ToString("#0.00"));

            ListViewItem lviS;
            ListViewItem lviD;
            int cnt = 1;
            int i;

            foreach (DiffResultSpan drs in DiffLines)
            {
                switch (drs.Status)
                {
                    case DiffResultSpanStatus.DeleteSource:
                        for (i = 0; i < drs.Length; i++)
                        {
                            lviS = new ListViewItem(cnt.ToString("00000"));
                            lviD = new ListViewItem(cnt.ToString("00000"));
                            lviS.BackColor = Color.Red;
                            lviS.SubItems.Add(((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line);
                            lviD.BackColor = Color.LightGray;
                            lviD.SubItems.Add("");

                            lvSource.Items.Add(lviS);
                            lvDestination.Items.Add(lviD);
                            cnt++;
                        }

                        break;
                    case DiffResultSpanStatus.NoChange:
                        for (i = 0; i < drs.Length; i++)
                        {
                            lviS = new ListViewItem(cnt.ToString("00000"));
                            lviD = new ListViewItem(cnt.ToString("00000"));
                            lviS.BackColor = Color.White;
                            lviS.SubItems.Add(((TextLine)source.GetByIndex(drs.SourceIndex+i)).Line);
                            lviD.BackColor = Color.White;
                            lviD.SubItems.Add(((TextLine)destination.GetByIndex(drs.DestIndex+i)).Line);

                            lvSource.Items.Add(lviS);
                            lvDestination.Items.Add(lviD);
                            cnt++;
                        }

                        break;
                    case DiffResultSpanStatus.AddDestination:
                        for (i = 0; i < drs.Length; i++)
                        {
                            lviS = new ListViewItem(cnt.ToString("00000"));
                            lviD = new ListViewItem(cnt.ToString("00000"));
                            lviS.BackColor = Color.LightGray;
                            lviS.SubItems.Add("");
                            lviD.BackColor = Color.LightGreen;
                            lviD.SubItems.Add(((TextLine)destination.GetByIndex(drs.DestIndex+i)).Line);

                            lvSource.Items.Add(lviS);
                            lvDestination.Items.Add(lviD);
                            cnt++;
                        }

                        break;
                    case DiffResultSpanStatus.Replace:
                        for (i = 0; i < drs.Length; i++)
                        {
                            lviS = new ListViewItem(cnt.ToString("00000"));
                            lviD = new ListViewItem(cnt.ToString("00000"));
                            lviS.BackColor = Color.Red;
                            lviS.SubItems.Add(((TextLine)source.GetByIndex(drs.SourceIndex+i)).Line);
                            lviD.BackColor = Color.LightGreen;
                            lviD.SubItems.Add(((TextLine)destination.GetByIndex(drs.DestIndex+i)).Line);

                            lvSource.Items.Add(lviS);
                            lvDestination.Items.Add(lviD);
                            cnt++;
                        }

                        break;
                }

            }
        }
Example #2
0
        public void BindData(DiffList_TextFile source, DiffList_TextFile destination, ArrayList DiffLines)
        {
            DataTable dt = XmlHelper.GetBindTable();

            int cnt = 1;
            int i;

            foreach (DiffResultSpan drs in DiffLines)
            {
                switch (drs.Status)
                {
                    case DiffResultSpanStatus.DeleteSource:
                        for (i = 0; i < drs.Length; i++)
                        {
                            DataRow dr = dt.NewRow();
                            dr["OldKey"] = cnt.ToString("00000");
                            dr["NewKey"] = cnt.ToString("00000");
                            dr["OldValue"] = ((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line;
                            dr["NewValue"] = "";
                            dr["CombinKey"] = cnt.ToString("00000");

                            dr["CombinValue"] = this.DeleteCheckBox.Checked ? "":((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line;
                            dr["Status"] = "Delete";

                            dt.Rows.Add(dr);
                            cnt++;
                        }
                        break;
                    case DiffResultSpanStatus.NoChange:
                        for (i = 0; i < drs.Length; i++)
                        {
                            DataRow dr = dt.NewRow();
                            dr["OldKey"] = cnt.ToString("00000");
                            dr["NewKey"] = cnt.ToString("00000");
                            dr["OldValue"] = ((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line;
                            dr["NewValue"] = ((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line;
                            dr["Status"] = "Unchanged";
                            dr["CombinKey"] = cnt.ToString("00000");
                            dr["CombinValue"] = ((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line;
                            dt.Rows.Add(dr);
                            cnt++;
                        }
                        break;
                    case DiffResultSpanStatus.AddDestination:
                        for (i = 0; i < drs.Length; i++)
                        {
                            DataRow dr = dt.NewRow();
                            dr["OldKey"] = cnt.ToString("00000");
                            dr["NewKey"] = cnt.ToString("00000");
                            dr["OldValue"] = "";
                            dr["NewValue"] = ((TextLine)destination.GetByIndex(drs.DestIndex + i)).Line;
                            dr["Status"] = "Add";
                            dr["CombinKey"] = cnt.ToString("00000");
                            dr["CombinValue"] = this.GetNewCheckBox.Checked ? ((TextLine)destination.GetByIndex(drs.DestIndex + i)).Line: "";

                            dt.Rows.Add(dr);
                        }
                        break;
                    case DiffResultSpanStatus.Replace:
                        for (i = 0; i < drs.Length; i++)
                        {

                            DataRow dr = dt.NewRow();
                            dr["OldKey"] = cnt.ToString("00000");
                            dr["NewKey"] = cnt.ToString("00000");
                            dr["OldValue"] = ((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line;
                            dr["NewValue"] = ((TextLine)destination.GetByIndex(drs.DestIndex + i)).Line;
                            dr["Status"] = "Modify";
                            dr["CombinKey"] = cnt.ToString("00000");
                            dr["CombinValue"] = this.ModifyCheckBox.Checked ? ((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line : ((TextLine)destination.GetByIndex(drs.DestIndex + i)).Line;

                            dt.Rows.Add(dr);

                            cnt++;
                        }
                        break;
                }

            }
            GridControl.AddButtonColumn(this.WsdlGrid, this.IsAddButtonWsdlColumn);
            this.WsdlGrid.DataSource = dt;
            this.IsAddButtonWsdlColumn = true;
            GridControl.SetGridDifferBackColor(this.WsdlGrid);
            GridControl.HideRow(this.WsdlGrid, this.UnchangedCheckBox, this.NoContainModifyCheckBox);
            GridControl.SetWsdlGridColumnWidth(this.WsdlGrid);

            if (this.WsdlGrid.CurrentCell != null)
            {
                this.ShowOldTextBox.Text = dt.Rows[this.WsdlGrid.CurrentCell.RowIndex]["OldValue"].ToString();
                this.ShowNewTextBox.Text = dt.Rows[this.WsdlGrid.CurrentCell.RowIndex]["NewValue"].ToString();
            }
        }