/// <summary> /// Find the difference of the two loaded file and add to lists the results /// </summary> private void FindDifference() { ClearUI(); if (FirstFile.FileName == string.Empty || SecondFile.FileName == string.Empty) { return; } var cbb = new CustomBackgroundBlock(); int j = 0; //load the difference _differences = FirstFile.Compare(SecondFile).ToList(); //Load list of difference foreach (ByteDifference byteDifference in _differences) { //create or update custom background block if (j == 0) { cbb = new CustomBackgroundBlock(byteDifference.BytePositionInStream, ++j, RandomBrushes.PickBrush()); } else { cbb.Length = ++j; } if (!_differences.Any(c => c.BytePositionInStream == byteDifference.BytePositionInStream + 1)) { j = 0; new BlockListItem(cbb).With(c => { c.PatchButtonClick += BlockItem_PatchButtonClick; FileDiffBlockList.Items.Add(c); }); //add to hexeditor FirstFile.CustomBackgroundBlockItems.Add(cbb); SecondFile.CustomBackgroundBlockItems.Add(cbb); } } //refresh editor FirstFile.RefreshView(); SecondFile.RefreshView(); //Enable patch button PatchButton.IsEnabled = true; }
private void FindDifference() { ClearUI(); if (FirstFile.FileName == string.Empty || SecondFile.FileName == string.Empty) { return; } var cbb = new CustomBackgroundBlock(); int j = 0; _differences = FirstFile.Compare(SecondFile) .ToList() .OrderBy(c => c.BytePositionInStream); long previousPosition = _differences.First().BytePositionInStream; //Load list of difference ///////////// NOT COMPLETED... IS IN DEBUG.... foreach (ByteDifference byteDifference in _differences) { if (j == 0) { cbb = new CustomBackgroundBlock(byteDifference.BytePositionInStream, ++j, RandomBrushes.PickBrush()); } else { cbb.Length = ++j; } if (byteDifference.BytePositionInStream != previousPosition + 1) { j = 0; new BlockListItem(cbb).With(c => { c.PatchButtonClick += BlockItem_PatchButtonClick; FileDiffBlockList.Items.Add(c); }); //add to hexeditor FirstFile.CustomBackgroundBlockItems.Add(cbb); SecondFile.CustomBackgroundBlockItems.Add(cbb); } previousPosition = byteDifference.BytePositionInStream; } //refresh editor FirstFile.RefreshView(); SecondFile.RefreshView(); }