aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-10-14 10:17:23 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-10-14 10:17:23 +0300
commit709f074dcd5cde75434fdb5c46b71e1cfcb22612 (patch)
treef2db75c40f1ab7127bee5df70818aa0160aaf244 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs
parent5a1081358fb466d4368715c22b70b439251d8b30 (diff)
parent87437f979da7baf9a65d98140b361ee85d6966d5 (diff)
downloadTango-709f074dcd5cde75434fdb5c46b71e1cfcb22612.tar.gz
Tango-709f074dcd5cde75434fdb5c46b71e1cfcb22612.zip
MERGE
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.cs64
1 files changed, 55 insertions, 9 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 59cd6fe19..46d745139 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
@@ -38,6 +38,7 @@ using Microsoft.WindowsAPICodePack.Dialogs;
using RealTimeGraphX;
using RealTimeGraphX.WPF.DataSeries;
using RealTimeGraphX.DataPoints;
+using Tango.MachineStudio.Technician.Views;
namespace Tango.MachineStudio.Technician.ViewModels
{
@@ -267,6 +268,15 @@ namespace Tango.MachineStudio.Technician.ViewModels
/// Gets or sets the rename tab command.
/// </summary>
public RelayCommand RenameTabCommand { get; set; }
+
+ /// <summary>
+ /// Gets or sets the import project tabs command.
+ /// </summary>
+ /// <value>
+ /// The import project tabs command.
+ /// </value>
+ public RelayCommand ImportProjectTabsCommand { get; set; }
+
#endregion
#region Constructors
@@ -340,6 +350,7 @@ namespace Tango.MachineStudio.Technician.ViewModels
RemoveTabCommand = new RelayCommand<MachineTechTabVM>(RemoveTab);
NewProjectCommand = new RelayCommand(CreateNewProject);
RenameTabCommand = new RelayCommand(RenameTab);
+ ImportProjectTabsCommand = new RelayCommand(ImportProjectTabs);
}
#endregion
@@ -1788,12 +1799,12 @@ namespace Tango.MachineStudio.Technician.ViewModels
/// Opens the specified project file path.
/// </summary>
/// <param name="fileName">File path.</param>
- public void OpenProjectFile(String fileName)
+ public MachineTechViewProject OpenProjectFile(String fileName, bool load = true)
{
+ MachineTechViewProject project = null;
+
try
{
- MachineTechViewProject project = null;
-
project = MachineTechViewProject.Load(fileName);
if (project.Tabs.Count == 0)
@@ -1807,27 +1818,35 @@ namespace Tango.MachineStudio.Technician.ViewModels
project.Tabs.Add(tab);
}
- LoadProject(project);
- _lastTechProjectFile = fileName;
+ if (load)
+ {
+ LoadProject(project);
+ _lastTechProjectFile = fileName;
+ }
}
catch (Exception ex)
{
LogManager.Log(ex, $"Error loading project file {fileName}.");
_notification.ShowError("An error occurred while trying to load the tech board project file.");
}
+
+ return project;
}
/// <summary>
/// Loads the specified project.
/// </summary>
/// <param name="project">The project.</param>
- public void LoadProject(MachineTechViewProject project)
+ public void LoadProject(MachineTechViewProject project, bool appendToCurrentProject = false)
{
using (_notification.PushTaskItem("Loading technician project file..."))
{
- Tabs.Clear();
- _singleControllers.Clear();
- _multiControllers.Clear();
+ if (!appendToCurrentProject)
+ {
+ Tabs.Clear();
+ _singleControllers.Clear();
+ _multiControllers.Clear();
+ }
foreach (var tab in project.Tabs)
{
@@ -2012,6 +2031,33 @@ namespace Tango.MachineStudio.Technician.ViewModels
}
}
+ /// <summary>
+ /// Imports a project file tabs to the current project.
+ /// </summary>
+ private void ImportProjectTabs()
+ {
+ OpenFileDialog dlg = new OpenFileDialog();
+ dlg.Title = "Select Technician Project File";
+ dlg.Filter = "Technician Project File|*.tpf";
+
+ if (dlg.ShowDialog().Value)
+ {
+ var project = OpenProjectFile(dlg.FileName, false);
+
+ if (project != null)
+ {
+ var vm = new ImportProjectTabViewVM(project.Tabs, Path.GetFileNameWithoutExtension(dlg.FileName));
+ _notification.ShowModalDialog<ImportProjectTabViewVM, ImportProjectTabView>(vm, (x) =>
+ {
+ project.Tabs.Clear();
+ project.Tabs.AddRange(vm.Tabs.SynchedSource.ToList());
+ LoadProject(project, true);
+
+ }, () => { });
+ }
+ }
+ }
+
#endregion
#region IStudioModuleVM