aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Scripting/ExpressionGenerator.cs
blob: 8db917a100fb4e423da6becd55cd8ae0add79717 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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;
            }
        }
    }
}