|
|
|
|
@ -5,6 +5,7 @@ using System.Collections.Generic; |
|
|
|
|
using System.Collections.Specialized; |
|
|
|
|
using System.ComponentModel; |
|
|
|
|
using System.Linq; |
|
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
|
using System.Windows; |
|
|
|
|
using System.Windows.Controls; |
|
|
|
|
using System.Windows.Documents; |
|
|
|
|
@ -80,15 +81,6 @@ public class MultiFormatTextBox : Control |
|
|
|
|
typeof(MultiFormatTextBox)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
~MultiFormatTextBox() |
|
|
|
|
{ |
|
|
|
|
// unregister events |
|
|
|
|
if (this.CurrentMultiFormatString != null && this.CurrentMultiFormatString is INotifyCollectionChanged incc) |
|
|
|
|
{ |
|
|
|
|
incc.CollectionChanged -= this.MultiFormatString_CollectionChanged; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override void OnApplyTemplate() |
|
|
|
|
{ |
|
|
|
|
base.OnApplyTemplate(); |
|
|
|
|
@ -145,6 +137,10 @@ public class MultiFormatTextBox : Control |
|
|
|
|
incc.CollectionChanged += mftb.MultiFormatString_CollectionChanged; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if(mftb.CurrentMultiFormatString == null) |
|
|
|
|
{ |
|
|
|
|
mftb.ResetTextBox(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
@ -170,8 +166,7 @@ public class MultiFormatTextBox : Control |
|
|
|
|
|
|
|
|
|
case NotifyCollectionChangedAction.Reset: |
|
|
|
|
// clear richtextbox add new paragraph |
|
|
|
|
this.richTextBox!.Document.Blocks.Clear(); |
|
|
|
|
this.richTextBox!.Document.Blocks.Add(new Paragraph()); |
|
|
|
|
this.ResetTextBox(); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case NotifyCollectionChangedAction.Replace: |
|
|
|
|
@ -270,6 +265,15 @@ public class MultiFormatTextBox : Control |
|
|
|
|
this.SetRtbCaretPosition(indexCounter); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Clear richtextbox adds new paragraph. |
|
|
|
|
/// </summary> |
|
|
|
|
private void ResetTextBox() |
|
|
|
|
{ |
|
|
|
|
this.richTextBox!.Document.Blocks.Clear(); |
|
|
|
|
this.richTextBox!.Document.Blocks.Add(new Paragraph()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) |
|
|
|
|
{ |
|
|
|
|
lock (lockObj) // lock so no richtextbox textchanged event can happen |
|
|
|
|
|