diff --git a/PettingZoo/UI/Tab/Publisher/PayloadEditorControl.xaml b/PettingZoo/UI/Tab/Publisher/PayloadEditorControl.xaml
index 74e5dee..e548248 100644
--- a/PettingZoo/UI/Tab/Publisher/PayloadEditorControl.xaml
+++ b/PettingZoo/UI/Tab/Publisher/PayloadEditorControl.xaml
@@ -29,11 +29,10 @@
+ xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
+ Name="Editor"
+ SyntaxHighlighting="{Binding SyntaxHighlighting}"
+ Style="{StaticResource Payload}" />
diff --git a/PettingZoo/UI/Tab/Subscriber/SubscriberView.xaml b/PettingZoo/UI/Tab/Subscriber/SubscriberView.xaml
index 5684e93..87691f1 100644
--- a/PettingZoo/UI/Tab/Subscriber/SubscriberView.xaml
+++ b/PettingZoo/UI/Tab/Subscriber/SubscriberView.xaml
@@ -6,6 +6,7 @@
xmlns:ui="clr-namespace:PettingZoo.UI"
xmlns:res="clr-namespace:PettingZoo.UI.Tab.Subscriber"
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
+ xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
mc:Ignorable="d"
d:DesignHeight="450"
d:DesignWidth="800"
@@ -25,7 +26,8 @@
HorizontalContentAlignment="Stretch"
ItemsSource="{Binding Messages}"
SelectedItem="{Binding Path=SelectedMessage, Mode=TwoWay}"
- ui:ListBox.AutoScroll="True">
+ ui:ListBox.AutoScroll="True"
+ x:Name="ReferenceControlForBorder">
@@ -95,14 +97,11 @@
-
-
-
+
+
+
diff --git a/PettingZoo/UI/Tab/Subscriber/SubscriberView.xaml.cs b/PettingZoo/UI/Tab/Subscriber/SubscriberView.xaml.cs
index 6ac80c2..f07a3b3 100644
--- a/PettingZoo/UI/Tab/Subscriber/SubscriberView.xaml.cs
+++ b/PettingZoo/UI/Tab/Subscriber/SubscriberView.xaml.cs
@@ -1,6 +1,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
+using ICSharpCode.AvalonEdit.Highlighting;
namespace PettingZoo.UI.Tab.Subscriber
{
@@ -14,6 +15,22 @@ namespace PettingZoo.UI.Tab.Subscriber
DataContext = viewModel;
InitializeComponent();
+ // TODO wrap all this nonsense (which is a duplicate from PayloadEditorControl) in a UserControl
+ // should contain the border, one- or two-way Document binding and the automatic syntax highlighting based on a bound content-type
+ EditorBorder.BorderBrush = ReferenceControlForBorder.BorderBrush;
+ Editor.Options.IndentationSize = 2;
+
+ viewModel.PropertyChanged += (_, args) =>
+ {
+ if (args.PropertyName != nameof(viewModel.SelectedMessageBody))
+ return;
+
+ Editor.Document.Text = viewModel.SelectedMessageBody;
+ Editor.SyntaxHighlighting = (viewModel.SelectedMessage?.Properties.ContentType ?? "") == "application/json"
+ ? HighlightingManager.Instance.GetDefinition(@"Json")
+ : null;
+ };
+
if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
Background = Brushes.Transparent;