Last active
February 14, 2019 09:40
-
-
Save bjoerntx/930fe3bc3f66a1970fe7f8292fdb8537 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace TrackedChangeCollectionExtensions | |
{ | |
public static class TrackedChangeCollectionExtensions | |
{ | |
// removes all changes in the TrackedChangeCollection with a given username | |
public static int RemoveAll( | |
this TXTextControl.TrackedChangeCollection trackdChangeCollection, | |
string username, bool accept) | |
{ | |
List<TrackedChange> myTrackedChanges = new List<TrackedChange>(); | |
// loop through all changes | |
foreach (TXTextControl.TrackedChange trackedChange in trackdChangeCollection) | |
{ | |
if (trackedChange.UserName == username) | |
myTrackedChanges.Add(trackedChange); | |
} | |
// delete all changes | |
foreach (TrackedChange listedTrackedChange in myTrackedChanges) | |
trackdChangeCollection.Remove(listedTrackedChange, true); | |
return myTrackedChanges.Count; | |
} | |
// removes all changes in all TextParts with a given username | |
public static int RemoveAllTrackedChanges( | |
this TXTextControl.TextPartCollection textPartCollection, | |
string username, bool accept) | |
{ | |
// counter | |
var deletedTrackedChanges = 0; | |
// loop through all text parts | |
foreach (IFormattedText textPart in textPartCollection) | |
{ | |
List<TrackedChange> myTrackedChanges = new List<TrackedChange>(); | |
// loop through all changes | |
foreach (TXTextControl.TrackedChange trackedChange in textPart.TrackedChanges) | |
{ | |
if (trackedChange.UserName == username) | |
myTrackedChanges.Add(trackedChange); | |
} | |
// delete all changes | |
foreach (TrackedChange listedTrackedChange in myTrackedChanges) | |
{ | |
textPart.TrackedChanges.Remove(listedTrackedChange, true); | |
deletedTrackedChanges++; | |
} | |
} | |
return deletedTrackedChanges; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment