diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-09-27 15:03:41 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-09-27 15:03:41 +0300 |
| commit | 8ae143fbebc5357db447eb6f72076adaaa94fa26 (patch) | |
| tree | c44f75408da68c61de034c7d3b64d60656d1321d /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs | |
| parent | 7c5f7066d5b1e88673731690db71a7e90e37c152 (diff) | |
| download | Tango-8ae143fbebc5357db447eb6f72076adaaa94fa26.tar.gz Tango-8ae143fbebc5357db447eb6f72076adaaa94fa26.zip | |
Working on RML module.
Fixed database diagrams.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs new file mode 100644 index 000000000..ff42d870c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Builders; +using Tango.BL.Entities; +using Tango.MachineStudio.Common; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.RML.ViewModels +{ + public class MainViewVM : StudioViewModel + { + private INotificationProvider _notification; + + private ObservablesContext _rmls_context; + private ObservablesContext _active_context; + + private ObservableCollection<Rml> _rmls; + public ObservableCollection<Rml> Rmls + { + get { return _rmls; } + set { _rmls = value; RaisePropertyChangedAuto(); } + } + + private Rml _selectedRML; + public Rml SelectedRML + { + get { return _selectedRML; } + set { _selectedRML = value; RaisePropertyChangedAuto(); OnSelectedRmlChanged(); } + } + + private Rml _activeRML; + public Rml ActiveRML + { + get { return _activeRML; } + set { _activeRML = value; RaisePropertyChangedAuto(); } + } + + public MainViewVM(INotificationProvider notificationProvider) + { + _notification = notificationProvider; + } + + public override void OnApplicationReady() + { + LoadRmls(); + } + + private void LoadRmls() + { + using (_rmls_context = ObservablesContext.CreateDefault()) + { + Rmls = _rmls.ToList().ToObservableCollection(); + } + } + + private void OnSelectedRmlChanged() + { + if (SelectedRML != null) + { + LoadActiveRML(SelectedRML.Guid); + } + else + { + UnloadActiveRML(); + } + } + + private void UnloadActiveRML() + { + ActiveRML = null; + } + + private async void LoadActiveRML(String guid) + { + using (_notification.PushTaskItem("Loading RML...")) + { + if (_active_context != null) + { + _active_context.Dispose(); + } + + _active_context = ObservablesContext.CreateDefault(); + + ActiveRML = await new RmlBuilder(_active_context) + .Set(guid) + .WithAllParametersGroup() + .WithCCT() + .WithLiquidFactors() + .BuildAsync(); + } + } + } +} |
