private void buttonMerge_Click(object sender, RoutedEventArgs e) { // Handle pivot info EditItem ei_pivot = editItems[this.pivot]; for (int i = 0; i < editItems.Count; i++) { editItems[i].isPivot = (i == this.pivot); } // Copy_GUI_to_textGui i.e. copy the content of the RichTextBox to textGui foreach (EditItem ei in editItems) { ei.Copy_GUI_to_textGui(); } // Calculate dlt0 = delta between textMain and textGui i.e. what the user has modified manually foreach (EditItem ei in editItems) { ei.dlt0 = new StrDelta(ei.textMain.strList, ei.textGui.strList); ei.dlt0.Compare(); ei.dlt0.PrintEdits("\ndlt0", @"C:\temp\report.txt", false); if (ei.isPivot == false) { // todo: user cannot modify non-pivot EditItems => in this case delta must be null } } // Calculate dlt1 = delta between pivot and other editItems[] foreach (EditItem ei in editItems) { if (ei.isPivot) { continue; } ei.dlt1 = new StrDelta(ei_pivot.textMain.strList, ei.textMain.strList); ei.dlt1.Compare(); ei.dlt1.PrintEdits("\ndlt1", @"C:\temp\report.txt", true); } // Merge foreach (EditItem ei in editItems) { if (ei.isPivot) { continue; } ei.dltM = new StrDelta(ei_pivot.dlt0); // Initialize dltM = dlt0 ei.dltM.Merge(ei.dlt1); // Merge dlt1 to dtl0 // todo: handle conflicts ei.dltM.PrintEdits("\ndltM", @"C:\temp\report.txt", true); ei.Copy_dltM_to_GUI(); // Copy merge result to the GUI } // todo: ask user to approve the merge. If approved => update txtMain. If not approved => revert (i.e. copy txtMain to GUI) }
public EditItem(EditItem qqei) { this.file = qqei.file; this.lineStart = qqei.lineStart; this.lineEnd = qqei.lineEnd; this.descr = qqei.descr; this.textFile = new Instance(qqei.textFile); // this.text_File = new List<string>(qqei.text_File); // this.text_File_str = qqei.text_File_str; // this.text_File_HashCode = qqei.text_File_HashCode; // this.changedVF = qqei.changedVF; this.status = qqei.status; // textBox = new RichTextBox(); // textBox.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible; // textBox.VerticalScrollBarVisibility = ScrollBarVisibility.Visible; // textBox.Document.PageWidth = 2000; // // ContextMenu cm = new ContextMenu(); // MenuItem mi = new MenuItem(); // mi.Header = "Open"; // cm.Items.Add(mi); // mi.Click += new System.Windows.RoutedEventHandler(this.MEFile_Open_Click); // textBox.ContextMenu = cm; }
private void buttonLoad_Click(object sender, RoutedEventArgs e) { // Create qqEditItem objects editItems = new List <EditItem>(); string[] split = textFiles.Text.Split(','); foreach (string file in split) { EditItem ei = new EditItem(); ei.file = file; ei.lineStart = 0; ei.lineEnd = int.MaxValue; editItems.Add(ei); } CreateGuiObjects(); // Add EditItem objects to the GUI // Load from file foreach (EditItem ei in editItems) { ei.Copy_file_to_textFile(); // Load file into textFile ei.Copy_textFile_to_textMain(); // Copy textFile to textMain ei.Copy_textFile_to_GUI(); // Copy textFile to GUI } }