diff --git a/MultiTerm.Core.Tests/MultiTerm.Protocols.Tests.csproj b/MultiTerm.Core.Tests/MultiTerm.Protocols.Tests.csproj
index 413d002..e80d71e 100644
--- a/MultiTerm.Core.Tests/MultiTerm.Protocols.Tests.csproj
+++ b/MultiTerm.Core.Tests/MultiTerm.Protocols.Tests.csproj
@@ -14,7 +14,6 @@
-
diff --git a/MultiTerm.Wpf.CustomControl/MultiFormatTextBox/MultiFormatTextBox.cs b/MultiTerm.Wpf.CustomControl/MultiFormatTextBox/MultiFormatTextBox.cs
index a799c9a..7f658de 100644
--- a/MultiTerm.Wpf.CustomControl/MultiFormatTextBox/MultiFormatTextBox.cs
+++ b/MultiTerm.Wpf.CustomControl/MultiFormatTextBox/MultiFormatTextBox.cs
@@ -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();
+ }
}
///
@@ -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);
}
+ ///
+ /// Clear richtextbox adds new paragraph.
+ ///
+ 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
diff --git a/MultiTerm.Wpf.CustomControl/MultiFormatTextBox/MultiFormatTextBox.xaml b/MultiTerm.Wpf.CustomControl/MultiFormatTextBox/MultiFormatTextBox.xaml
index 9477f95..7d81f39 100644
--- a/MultiTerm.Wpf.CustomControl/MultiFormatTextBox/MultiFormatTextBox.xaml
+++ b/MultiTerm.Wpf.CustomControl/MultiFormatTextBox/MultiFormatTextBox.xaml
@@ -21,7 +21,7 @@
+ Style="{StaticResource TextFontStyle}" Padding="0 5">
diff --git a/MultiTerm.Wpf/ValueConverters/ProtocolTypeToIconConverter.cs b/MultiTerm.Wpf/ValueConverters/ProtocolTypeToIconConverter.cs
index a9447a6..5c1d249 100644
--- a/MultiTerm.Wpf/ValueConverters/ProtocolTypeToIconConverter.cs
+++ b/MultiTerm.Wpf/ValueConverters/ProtocolTypeToIconConverter.cs
@@ -17,9 +17,7 @@ internal class ProtocolTypeToIconConverter : IValueConverter
{ throw new ArgumentException($"Wrong object provided, can only convert from type {nameof(ProtocolType)}"); }
string resourceFolderPath = "pack://application:,,,/Assets/";
- //string path = $"{typeof(MainWindow).FullName};component/Assets/";
- //string packUri = "pack://application:,,,/Assets/";
-
+
string fileName = protocolType switch
{
ProtocolType.Serial => "mdi-serial-port.png",