Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created October 26, 2023 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/82fb4eb1e6554dd56939163ca4f8cef0 to your computer and use it in GitHub Desktop.
Save bjoerntx/82fb4eb1e6554dd56939163ca4f8cef0 to your computer and use it in GitHub Desktop.
private bool IsCharacterFormatEqual(Paragraph paragraph, ParagraphStyle paragraphStyle)
{
paragraph.Select();
var selection = _textControl.Selection;
foreach (var property in typeof(Selection).GetProperties())
{
if (!_positiveListCharacterFormat.Contains(property.Name))
{
continue;
}
object value1 = property.GetValue(selection);
var paragraphStyleProperty = typeof(ParagraphStyle).GetProperty(property.Name)?.GetValue(paragraphStyle);
// compare the values
if (!object.Equals(value1, paragraphStyleProperty))
{
return false;
}
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment