aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2018-04-25 09:44:13 +0300
committerAvi Levkovich <avi@twine-s.com>2018-04-25 09:44:13 +0300
commitd352d3b3bd785d9eb8a93347333de0b357f7ce0e (patch)
tree2488173ea7e4f9d5ddb6ef53de57998815732847 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels
parentc82908b6d5314bc2602ea10c373267b79fbdd810 (diff)
parenta89077bae848d010ae70da6be572dee3b824a895 (diff)
downloadTango-d352d3b3bd785d9eb8a93347333de0b357f7ce0e.tar.gz
Tango-d352d3b3bd785d9eb8a93347333de0b357f7ce0e.zip
Start SPI ADS1220
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs14
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs69
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ReportIssueViewVM.cs43
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs4
4 files changed, 111 insertions, 19 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs
index 512341f7e..2b2b442f7 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs
@@ -15,6 +15,7 @@ using Tango.SharedUI;
using Tango.BL;
using Tango.MachineStudio.Common.EventLogging;
using Tango.BL.Enumerations;
+using Tango.MachineStudio.UI.TFS;
namespace Tango.MachineStudio.UI.ViewModels
{
@@ -25,6 +26,7 @@ namespace Tango.MachineStudio.UI.ViewModels
public class LoadingViewVM : ViewModel
{
private INotificationProvider _notificationProvider;
+ private TeamFoundationServiceExtendedClient _tfs;
private INavigationManager _navigationManager;
private IStudioModuleLoader _studioModuleLoader;
private IEventLogger _eventLogger;
@@ -45,8 +47,9 @@ namespace Tango.MachineStudio.UI.ViewModels
/// <param name="navigationManager">The navigation manager.</param>
/// <param name="studioModuleLoader">The studio module loader.</param>
/// <param name="notificationProvider">The notification provider.</param>
- public LoadingViewVM(IStudioApplicationManager applicationManager, INavigationManager navigationManager, IStudioModuleLoader studioModuleLoader, INotificationProvider notificationProvider, IEventLogger eventLogger)
+ public LoadingViewVM(IStudioApplicationManager applicationManager, INavigationManager navigationManager, IStudioModuleLoader studioModuleLoader, INotificationProvider notificationProvider, IEventLogger eventLogger, TeamFoundationServiceExtendedClient teamFoundationClient)
{
+ _tfs = teamFoundationClient;
_eventLogger = eventLogger;
ApplicationManager = applicationManager;
_navigationManager = navigationManager;
@@ -66,6 +69,15 @@ namespace Tango.MachineStudio.UI.ViewModels
{
try
{
+ try
+ {
+ _tfs.Initialize();
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Could not initialize Team Foundation Service client.");
+ }
+
ObservablesEntitiesAdapter.Instance.Initialize();
_eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!");
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
index b97825d34..0882267e8 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
@@ -1,6 +1,4 @@
-using GalaSoft.MvvmLight.Ioc;
-using GalaSoft.MvvmLight.Messaging;
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
@@ -14,6 +12,7 @@ using System.Windows.Controls;
using System.Windows.Media;
using Tango.BL.Entities;
using Tango.Core.Commands;
+using Tango.Core.DI;
using Tango.Integration.Services;
using Tango.Logging;
using Tango.MachineStudio.Common;
@@ -30,6 +29,7 @@ using Tango.MachineStudio.Common.StudioApplication;
using Tango.MachineStudio.Common.Update;
using Tango.MachineStudio.UI.StudioApplication;
using Tango.MachineStudio.UI.SupervisingController;
+using Tango.MachineStudio.UI.TFS;
using Tango.MachineStudio.UI.Views;
using Tango.MachineStudio.UI.Windows;
using Tango.PMR.Stubs;
@@ -45,7 +45,7 @@ namespace Tango.MachineStudio.UI.ViewModels
/// Represents the Machine Studio main view, view model.
/// </summary>
/// <seealso cref="Tango.SharedUI.ViewModel{Tango.MachineStudio.UI.SupervisingController.IMainView}" />
- public class MainViewVM : ViewModel<IMainView>
+ public class MainViewVM : ViewModel
{
private IStudioModule _currentModule;
private INavigationManager _navigation;
@@ -143,6 +143,11 @@ namespace Tango.MachineStudio.UI.ViewModels
/// </summary>
public RelayCommand<MachinesEvent> ResolveMachineEventCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the report issue command.
+ /// </summary>
+ public RelayCommand ReportIssueCommand { get; set; }
+
private IAuthenticationProvider _authenticationProvider;
/// <summary>
/// Gets or sets the authentication provider.
@@ -184,6 +189,11 @@ namespace Tango.MachineStudio.UI.ViewModels
}
/// <summary>
+ /// Gets or sets the TFS client.
+ /// </summary>
+ public TeamFoundationServiceExtendedClient TFSClient { get; set; }
+
+ /// <summary>
/// Gets or sets the speech provider.
/// </summary>
public ISpeechProvider SpeechProvider { get; set; }
@@ -240,7 +250,6 @@ namespace Tango.MachineStudio.UI.ViewModels
/// <param name="applicationManager">The application manager.</param>
/// <param name="navigationManager">The navigation manager.</param>
public MainViewVM(
- IMainView view,
IAuthenticationProvider authenticationProvider,
IStudioModuleLoader studioModuleLoader,
INotificationProvider notificationProvider,
@@ -249,8 +258,9 @@ namespace Tango.MachineStudio.UI.ViewModels
IEventLogger eventLogger,
IDiagnosticsFrameProvider frameProvider,
ISpeechProvider speechProvider,
- IHtmlPresenter htmlPresenter) : base(view)
+ IHtmlPresenter htmlPresenter, TeamFoundationServiceExtendedClient tfs) : base()
{
+ TFSClient = tfs;
_eventLogger = eventLogger;
_navigation = navigationManager;
AuthenticationProvider = authenticationProvider;
@@ -290,6 +300,8 @@ namespace Tango.MachineStudio.UI.ViewModels
ToggleSpeechCommand = new RelayCommand(() => { SpeechProvider.Mute = !SpeechProvider.Mute; });
ResolveMachineEventCommand = new RelayCommand<MachinesEvent>(ResolveMachineEvent);
+
+ ReportIssueCommand = new RelayCommand(ReportIssue);
}
private void MachineEventsStateProvider_EventsResolved(object sender, IEnumerable<MachinesEvent> e)
@@ -500,17 +512,22 @@ namespace Tango.MachineStudio.UI.ViewModels
if (module != null)
{
+ LogManager.Log(String.Format("Starting module '{0}'...", module.Name));
+
if (!(MainView.Self as MainView).TransitionControl.Elements.ToList().Exists(x => x.GetType() == module.MainViewType))
{
+ LogManager.Log("Module was not initialized. Initializing...");
+
FrameworkElement view = Activator.CreateInstance(module.MainViewType) as FrameworkElement;
NavigationControl.SetNavigationName(view, module.Name);
(MainView.Self as MainView).TransitionControl.Elements.Add(view);
}
}
- foreach (var m in StudioModuleLoader.AllModules.Where(x => x != module))
+ foreach (var m in StudioModuleLoader.AllModules.Where(x => x != module && !x.InNewWindow))
{
m.IsLoaded = false;
+ TangoIOC.Default.GetModuleViewModels(m).ToList().ForEach(x => x.OnNavigatedFrom());
}
if (module != null)
@@ -518,24 +535,21 @@ namespace Tango.MachineStudio.UI.ViewModels
CurrentModule = module;
CurrentModule.IsLoaded = true;
IsModuleLoaded = true;
+
+ LogManager.Log(String.Format("Navigating to module '{0}'...", module.Name));
(MainView.Self as MainView).TransitionControl.NavigateTo(module.Name);
+
+ TangoIOC.Default.GetModuleViewModels(module).ToList().ForEach(x => x.OnNavigatedTo());
}
else
{
IsModuleLoaded = false;
+ LogManager.Log(String.Format("Navigating to Home..."));
(MainView.Self as MainView).TransitionControl.NavigateTo("Home");
}
}
/// <summary>
- /// Called when the <see cref="T:Tango.SharedUI.IView" /> is loaded and attached.
- /// </summary>
- protected override void OnViewAttached()
- {
- base.OnViewAttached();
- }
-
- /// <summary>
/// Opens the module in a new window.
/// </summary>
/// <param name="module">The module.</param>
@@ -545,17 +559,21 @@ namespace Tango.MachineStudio.UI.ViewModels
try
{
+ module.InNewWindow = true;
+
StartModule(null);
- module.InNewWindow = true;
+ LogManager.Log(String.Format("Starting module '{0}' in new window...", module.Name));
if (!(MainView.Self as MainView).TransitionControl.Elements.ToList().Exists(x => x.GetType() == module.MainViewType))
{
+ LogManager.Log("Module was not initialized. Initializing...");
FrameworkElement v = Activator.CreateInstance(module.MainViewType) as FrameworkElement;
NavigationControl.SetNavigationName(v, module.Name);
(MainView.Self as MainView).TransitionControl.Elements.Add(v);
}
+ LogManager.Log("Detaching module view...");
var view = (MainView.Self as MainView).TransitionControl.GetAndDetach(module.Name);
ModuleWindowVM vm = new ModuleWindowVM(module);
@@ -563,13 +581,20 @@ namespace Tango.MachineStudio.UI.ViewModels
window.Closing += (x, y) =>
{
+ LogManager.Log(String.Format("Closing module '{0}' on new window...", module.Name));
+
window.grid.Children.Remove(view);
module.InNewWindow = false;
+ TangoIOC.Default.GetModuleViewModels(module).ToList().ForEach(v => v.OnNavigatedFrom());
};
window.Owner = MainWindow.Instance;
+
+ LogManager.Log("Opening new window...");
window.Show();
+ TangoIOC.Default.GetModuleViewModels(module).ToList().ForEach(x => x.OnNavigatedTo());
+
(_applicationManager as DefaultStudioApplicationManager).RegisterOpenedWindow(window);
}
catch (Exception ex)
@@ -617,5 +642,17 @@ namespace Tango.MachineStudio.UI.ViewModels
_notificationProvider.ShowWarning("Could not locate guidance content for the specified event.");
}
}
+
+ private void ReportIssue()
+ {
+ _notificationProvider.ShowModalDialog<ReportIssueViewVM, ReportIssueView>(new ReportIssueViewVM(TFSClient.Project, TFSClient.CreateBug()), async (vm) =>
+ {
+ using (_notificationProvider.PushTaskItem("Uploading bug report..."))
+ {
+ await TFSClient.UploadWorkItem(vm.WorkItem);
+ }
+
+ }, null);
+ }
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ReportIssueViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ReportIssueViewVM.cs
new file mode 100644
index 000000000..9660db8a5
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ReportIssueViewVM.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.MachineStudio.Common.Notifications;
+using Tango.MachineStudio.UI.TFS;
+using Tango.SharedUI.Components;
+using Tango.TFS;
+
+namespace Tango.MachineStudio.UI.ViewModels
+{
+ public class ReportIssueViewVM : DialogViewVM
+ {
+ public SelectedObjectCollection<Tag> SelectedTags { get; set; }
+
+ public Project Project { get; set; }
+
+ [WorkItemValidation]
+ public WorkItem WorkItem { get; set; }
+
+ public ReportIssueViewVM() : base()
+ {
+
+ }
+
+ public ReportIssueViewVM(Project project, WorkItem workItem) : this()
+ {
+ Project = project;
+ WorkItem = workItem;
+ SelectedTags = new SelectedObjectCollection<Tag>(Project.Tags.ToObservableCollection(), new System.Collections.ObjectModel.ObservableCollection<Tag>());
+ }
+
+ protected override void Accept()
+ {
+ if (Validate())
+ {
+ WorkItem.Tags = SelectedTags.SynchedSource.ToList();
+ base.Accept();
+ }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs
index ab4fd8e0b..0f6ec8b98 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs
@@ -1,6 +1,5 @@
using FluentFTP;
using Ionic.Zip;
-using Microsoft.Practices.ServiceLocation;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -12,6 +11,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Tango.Core.Commands;
+using Tango.Core.DI;
using Tango.Core.Helpers;
using Tango.Logging;
using Tango.MachineStudio.Common.Authentication;
@@ -256,7 +256,7 @@ namespace Tango.MachineStudio.UI.ViewModels
}
}
- ServiceLocator.Current.GetInstance<MainViewVM>().DisableCheckForUpdates = true;
+ TangoIOC.Default.GetInstance<MainViewVM>().DisableCheckForUpdates = true;
Status = UpdateStatus.UpdateCompleted;
}
catch (Exception ex)