aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Scripting/Tango.Scripting.Test/MainWindowVM.cs
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2020-04-26 08:34:14 +0200
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2020-04-26 08:34:14 +0200
commit9038c50a3a350312c9895240be28b4fb90fbe3b1 (patch)
treecbc8824844340d8eff76f57455fcea8e7a9d6cd6 /Software/Visual_Studio/Scripting/Tango.Scripting.Test/MainWindowVM.cs
parentccaf9afcde7a630a7d765fa9874322b5f44e2df7 (diff)
parent8438e5447b6bed6ed97f2e3fda6977ce4bf74d0c (diff)
downloadTango-9038c50a3a350312c9895240be28b4fb90fbe3b1.tar.gz
Tango-9038c50a3a350312c9895240be28b4fb90fbe3b1.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/Scripting/Tango.Scripting.Test/MainWindowVM.cs')
-rw-r--r--Software/Visual_Studio/Scripting/Tango.Scripting.Test/MainWindowVM.cs69
1 files changed, 69 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Test/MainWindowVM.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Test/MainWindowVM.cs
new file mode 100644
index 000000000..f57de886f
--- /dev/null
+++ b/Software/Visual_Studio/Scripting/Tango.Scripting.Test/MainWindowVM.cs
@@ -0,0 +1,69 @@
+using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using Tango.Core.Commands;
+using Tango.Scripting.Basic;
+using Tango.SharedUI;
+
+namespace Tango.Scripting.Test
+{
+ public class TestContext : IContext
+ {
+
+ }
+
+ public class MainWindowVM : ViewModel
+ {
+
+ public RelayCommand AddScriptCommand { get; set; }
+ public RelayCommand RunCommand { get; set; }
+
+ private Project<TestContext> _project;
+ public Project<TestContext> Project
+ {
+ get { return _project; }
+ set { _project = value; RaisePropertyChangedAuto(); }
+ }
+
+ public MainWindowVM()
+ {
+ Project = Project<TestContext>.New("untitled");
+ Project.Scripts.Add(Script.New("main.csx", Encoding.Default.GetString(Properties.Resources.template), true));
+ AddScriptCommand = new RelayCommand(AddScriptFile);
+ RunCommand = new RelayCommand(RunProject);
+ }
+
+ private void AddScriptFile()
+ {
+ OpenFileDialog dlg = new OpenFileDialog();
+ dlg.Filter = "CSharp Script|*.csx";
+ if (dlg.ShowDialog().Value)
+ {
+ AddScript(dlg.FileName);
+ }
+ }
+
+ private void AddScript(String file)
+ {
+ Project.Scripts.Add(Script.New(file));
+ }
+
+ private async void RunProject()
+ {
+ var session = await Project.Run(null);
+
+ session.StateChanged += (x, e) =>
+ {
+ if (e.State == ProjectSessionState.Completed)
+ {
+ MessageBox.Show(e.ReturnValue.ToString());
+ }
+ };
+ }
+ }
+}