diff options
| author | Roy <roy.mail.net@gmail.com> | 2018-02-11 14:55:39 +0200 |
|---|---|---|
| committer | Roy <roy.mail.net@gmail.com> | 2018-02-11 14:55:39 +0200 |
| commit | 1dd0d4988fb99109765b956adc6a371f5cb036e0 (patch) | |
| tree | 52ccf7950af6039821b1be30005c23bc75083a78 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs | |
| parent | f736578b2c843d0cb23948e088379c3a3c3b12e7 (diff) | |
| download | Tango-1dd0d4988fb99109765b956adc6a371f5cb036e0.tar.gz Tango-1dd0d4988fb99109765b956adc6a371f5cb036e0.zip | |
More work on technician view...
Added auto loading of last project.
Added IShutdownListener interface.
Added TechName to Tech Items.
Fixed issue with tech name of IO port.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs | 97 |
1 files changed, 85 insertions, 12 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs index ca318f029..a4a9f0965 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs @@ -4,6 +4,7 @@ using RealTimeGraphEx.Controllers; using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.IO; using System.Linq; using System.Reflection; using System.Text; @@ -15,21 +16,25 @@ using Tango.Core.Helpers; using Tango.Editors; using Tango.Integration.Observables; using Tango.Integration.Operators; +using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.Common.StudioApplication; using Tango.MachineStudio.Technician.Editors; using Tango.MachineStudio.Technician.Project; using Tango.MachineStudio.Technician.TechItems; using Tango.PMR.Diagnostics; +using Tango.Settings; using Tango.SharedUI; namespace Tango.MachineStudio.Technician.ViewModels { - public class MachineTechViewVM : ViewModel + public class MachineTechViewVM : ViewModel, IShutdownListener { private List<PropertyInfo> _diagnoticsDataProperties; private Dictionary<SingleGraphItem, GraphController> _singleControllers; private Dictionary<MultiGraphItem, GraphMultiController> _multiControllers; private static object _elementsLock = new object(); + private String _lastTechProjectFile; + private INotificationProvider _notification; #region Properties @@ -83,6 +88,16 @@ namespace Tango.MachineStudio.Technician.ViewModels set { _machineOperator = value; RaisePropertyChangedAuto(); } } + private bool _disableRendering; + /// <summary> + /// Gets or sets a value indicating whether [disable rendering]. + /// </summary> + public bool DisableRendering + { + get { return _disableRendering; } + set { _disableRendering = value; RaisePropertyChangedAuto(); OnDisableRenderingChanged(); } + } + #endregion #region Commands @@ -97,8 +112,9 @@ namespace Tango.MachineStudio.Technician.ViewModels #region Constructors - public MachineTechViewVM(IStudioApplicationManager applicationManager) + public MachineTechViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider) { + _notification = notificationProvider; _singleControllers = new Dictionary<SingleGraphItem, GraphController>(); _multiControllers = new Dictionary<MultiGraphItem, GraphMultiController>(); AvailableTechItems = TechItem.GetAvailableTechItems().ToObservableCollection(); @@ -112,6 +128,14 @@ namespace Tango.MachineStudio.Technician.ViewModels OpenProjectCommand = new RelayCommand(OpenProject); SaveAsProjectCommand = new RelayCommand(SaveAsProject); + SaveProjectCommand = new RelayCommand(SaveProject); + + _lastTechProjectFile = SettingsManager.Default.MachineStudio.TechnicianModule.LasTechProjectFile; + + if (File.Exists(_lastTechProjectFile)) + { + OpenProjectFile(_lastTechProjectFile); + } } #endregion @@ -260,6 +284,23 @@ namespace Tango.MachineStudio.Technician.ViewModels #endregion + #region Virtual Methods + + protected virtual void OnDisableRenderingChanged() + { + foreach (var controller in _singleControllers) + { + controller.Value.ChangeRenderMode(!DisableRendering); + } + + foreach (var controller in _multiControllers) + { + controller.Value.ChangeRenderMode(!DisableRendering); + } + } + + #endregion + #region Add/Remove Element public void CreateElement(Rect bounds) @@ -648,17 +689,21 @@ namespace Tango.MachineStudio.Technician.ViewModels public void OpenProjectFile(String fileName) { LoadProject(MachineTechViewProject.Load(fileName)); + _lastTechProjectFile = fileName; } public void LoadProject(MachineTechViewProject project) { - Elements.Clear(); - _singleControllers.Clear(); - _multiControllers.Clear(); - - foreach (var item in project.Items) + using (_notification.PushTaskItem("Loading technician project file...")) { - AddTechItem(item); + Elements.Clear(); + _singleControllers.Clear(); + _multiControllers.Clear(); + + foreach (var item in project.Items) + { + AddTechItem(item); + } } } @@ -670,14 +715,30 @@ namespace Tango.MachineStudio.Technician.ViewModels if (dlg.ShowDialog().Value) { - SaveProject(dlg.FileName); + SaveProjectFile(dlg.FileName); + } + } + + private void SaveProjectFile(String fileName) + { + using (_notification.PushTaskItem("Saving technician project file...")) + { + MachineTechViewProject project = CreateProjectFile(); + project.Save(fileName); + _lastTechProjectFile = fileName; } } - private void SaveProject(String fileName) + private void SaveProject() { - MachineTechViewProject project = CreateProjectFile(); - project.Save(fileName); + if (File.Exists(_lastTechProjectFile)) + { + SaveProjectFile(_lastTechProjectFile); + } + else + { + SaveAsProject(); + } } private MachineTechViewProject CreateProjectFile() @@ -694,5 +755,17 @@ namespace Tango.MachineStudio.Technician.ViewModels } #endregion + + #region IShutdownListener + + public void OnShuttingDown() + { + InvokeUINow(() => + { + SettingsManager.Default.MachineStudio.TechnicianModule.LasTechProjectFile = _lastTechProjectFile; + }); + } + + #endregion } } |
