From d33c19b3ac6803de4b5c8d475832efef131c1a45 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Wed, 30 Dec 2020 15:11:34 +0000 Subject: Revert "Hope it is fine" --- .../Tango.Scripting.Editors/XamlEditor.cs | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Software/Visual_Studio/Scripting/Tango.Scripting.Editors/XamlEditor.cs (limited to 'Software/Visual_Studio/Scripting/Tango.Scripting.Editors/XamlEditor.cs') diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/XamlEditor.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/XamlEditor.cs new file mode 100644 index 000000000..22b425ba2 --- /dev/null +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/XamlEditor.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace Tango.Scripting.Editors +{ + public class XamlEditor : TextEditor + { + private bool preventCodeUpdate; + + public String Xaml + { + get { return (String)GetValue(XamlProperty); } + set { SetValue(XamlProperty, value); } + } + public static readonly DependencyProperty XamlProperty = + DependencyProperty.Register("Xaml", typeof(String), typeof(XamlEditor), new PropertyMetadata(null, (d, e) => (d as XamlEditor).OnXamlChanged())); + + public XamlEditor() + { + TextChanged += XamlEditor_TextChanged; + } + + private void XamlEditor_TextChanged(object sender, EventArgs e) + { + if (!preventCodeUpdate) + { + preventCodeUpdate = true; + Xaml = Text; + preventCodeUpdate = false; + } + } + + private void OnXamlChanged() + { + if (!preventCodeUpdate) + { + preventCodeUpdate = true; + Text = Xaml; + preventCodeUpdate = false; + } + } + } +} -- cgit v1.3.1