aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs')
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs116
1 files changed, 79 insertions, 37 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs
index 1f9eeb1aa..d3adf4d78 100644
--- a/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs
@@ -3,6 +3,7 @@ using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing;
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Text;
@@ -19,6 +20,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
+using Tango.Core.Commands;
using Tango.SharedUI;
namespace Tango.SharedUI.Controls
@@ -76,8 +78,11 @@ namespace Tango.SharedUI.Controls
public partial class ScriptEditorControl : UserControl
{
private CompletionWindow completionWindow;
+ private bool textChanged;
public ScriptEditorControl()
{
+ HighlightTypes = new ObservableCollection<Type>();
+
InitializeComponent();
textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy();
@@ -109,10 +114,16 @@ namespace Tango.SharedUI.Controls
types.Add(new KeyValuePair<string, Type>("TimeSpan", typeof(TimeSpan)));
types.Add(new KeyValuePair<string, Type>("Dispatcher", typeof(Dispatcher)));
types.Add(new KeyValuePair<string, Type>("Task", typeof(Task)));
- types.Add(new KeyValuePair<string, Type>("list", typeof(IList<Object>)));
+ types.Add(new KeyValuePair<string, Type>("List", typeof(IList<Object>)));
types.Add(new KeyValuePair<string, Type>("int", typeof(Int32)));
types.Add(new KeyValuePair<string, Type>("double", typeof(Double)));
types.Add(new KeyValuePair<string, Type>("String", typeof(String)));
+ types.Add(new KeyValuePair<string, Type>("string", typeof(String)));
+
+ foreach (var t in HighlightTypes)
+ {
+ types.Add(new KeyValuePair<string, Type>(t.Name, t));
+ }
var type = types.SingleOrDefault(x => x.Key == keyword);
if (type.Key != null)
@@ -146,42 +157,6 @@ namespace Tango.SharedUI.Controls
}
}
- private async void btnStart_Click(object sender, RoutedEventArgs e)
- {
- btnStart.IsEnabled = false;
- btnStop.IsEnabled = true;
- gridExecuting.Visibility = Visibility.Visible;
- //engine = new ScriptEngine();
- //try
- //{
- // await engine.Run(CanvasItem, textEditor.Text);
- //}
- //catch (Exception ex)
- //{
- // txtError.Text = ex.Message;
- // gridError.Visibility = Visibility.Visible;
- //}
-
- gridExecuting.Visibility = Visibility.Hidden;
- btnStart.IsEnabled = true;
- btnStop.IsEnabled = false;
- }
-
- private void btnStop_Click(object sender, RoutedEventArgs e)
- {
- //engine.Stop();
- }
-
- private void btnOK_Click(object sender, RoutedEventArgs e)
- {
- gridError.Visibility = Visibility.Hidden;
- }
-
- private void Save(object sender, RoutedEventArgs e)
- {
- //CanvasItem.Script = textEditor.Text;
- }
-
private void FillType(Type type, IList<ICompletionData> data)
{
List<CompletionData> items = new List<CompletionData>();
@@ -224,6 +199,73 @@ namespace Tango.SharedUI.Controls
}
}
+ #region Properties
+
+
+
+ public String Text
+ {
+ get { return (String)GetValue(TextProperty); }
+ set { SetValue(TextProperty, value); }
+ }
+ public static readonly DependencyProperty TextProperty =
+ DependencyProperty.Register("Text", typeof(String), typeof(ScriptEditorControl), new PropertyMetadata(null, (d, e) => (d as ScriptEditorControl).OnTextChanged()));
+
+ private void OnTextChanged()
+ {
+ if (!textChanged)
+ {
+ textEditor.Text = Text;
+ textChanged = true;
+ }
+ }
+
+
+
+ public ObservableCollection<Type> HighlightTypes
+ {
+ get { return (ObservableCollection<Type>)GetValue(HighlightTypesProperty); }
+ set { SetValue(HighlightTypesProperty, value); }
+ }
+ public static readonly DependencyProperty HighlightTypesProperty =
+ DependencyProperty.Register("HighlightTypes", typeof(ObservableCollection<Type>), typeof(ScriptEditorControl), new PropertyMetadata(null));
+
+
+
+ #endregion
+
+ #region Commands
+
+ public RelayCommand RunCommand
+ {
+ get { return (RelayCommand)GetValue(RunCommandProperty); }
+ set { SetValue(RunCommandProperty, value); }
+ }
+ public static readonly DependencyProperty RunCommandProperty =
+ DependencyProperty.Register("RunCommand", typeof(RelayCommand), typeof(ScriptEditorControl), new PropertyMetadata(null));
+
+ public RelayCommand StopCommand
+ {
+ get { return (RelayCommand)GetValue(StopCommandProperty); }
+ set { SetValue(StopCommandProperty, value); }
+ }
+ public static readonly DependencyProperty StopCommandProperty =
+ DependencyProperty.Register("StopCommand", typeof(RelayCommand), typeof(ScriptEditorControl), new PropertyMetadata(null));
+
+ public RelayCommand SaveCommand
+ {
+ get { return (RelayCommand)GetValue(SaveCommandProperty); }
+ set { SetValue(SaveCommandProperty, value); }
+ }
+ public static readonly DependencyProperty SaveCommandProperty =
+ DependencyProperty.Register("SaveCommand", typeof(RelayCommand), typeof(ScriptEditorControl), new PropertyMetadata(null));
+
+ #endregion
+
+ private void textEditor_TextChanged(object sender, EventArgs e)
+ {
+ Text = textEditor.Text;
+ }
}
internal static class DocumentUtils