diff options
| author | Avi Levkovich <avi@twine-s.com> | 2020-04-21 14:21:19 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2020-04-21 14:21:19 +0300 |
| commit | cd728bf3a7d1db76747cb18bcfe396c83d690e86 (patch) | |
| tree | 99347262eef3f175a7ff1441b6c5a031be74d26f /Software/Visual_Studio/Scripting/Tango.Scripting.Test/MainWindowVM.cs | |
| parent | 7fe23e68512e2462de107e76ae3a92ddd381ac77 (diff) | |
| parent | 97a784b6ce43960bdb92465b08f26d3562a4f202 (diff) | |
| download | Tango-cd728bf3a7d1db76747cb18bcfe396c83d690e86.tar.gz Tango-cd728bf3a7d1db76747cb18bcfe396c83d690e86.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_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.cs | 62 |
1 files changed, 62 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..203196fda --- /dev/null +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.Test/MainWindowVM.cs @@ -0,0 +1,62 @@ +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 MainWindowVM : ViewModel + { + public RelayCommand AddScriptCommand { get; set; } + public RelayCommand RunCommand { get; set; } + + private Project _project; + public Project Project + { + get { return _project; } + set { _project = value; RaisePropertyChangedAuto(); } + } + + public MainWindowVM() + { + Project = Project.New("untitled", Encoding.Default.GetString(Properties.Resources.template)); + 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()); + } + }; + } + } +} |
