From 44728b1223a0e90785fe67f4e5782bee0683ed09 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 1 Aug 2018 18:46:05 +0300 Subject: Implemented default report issue settings on machine studio. --- .../Tango.MachineStudio.UI/App.xaml.cs | 1 + .../Properties/AssemblyInfo.cs | 2 +- .../ViewModels/ConnectedMachineViewVM.cs | 26 +++++--------- .../ViewModels/MainViewVM.cs | 29 ++++++++++++--- .../ViewModels/ReportIssueViewVM.cs | 37 +++++++++++++++++-- .../Views/ConnectedMachineView.xaml | 41 ++++++++++++++++------ .../Views/ReportIssueView.xaml | 4 +-- .../Views/ReportIssueView.xaml.cs | 7 ++++ 8 files changed, 110 insertions(+), 37 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs index 8d5981322..ed2cbdbd7 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs @@ -174,6 +174,7 @@ namespace Tango.MachineStudio.UI catch (Exception ex) { LogManager.Log(ex, "Error in global exception trapper!"); + MessageBox.Show(ex.ToStringSafe()); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs index 121d4ab07..5c08c868b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs @@ -4,5 +4,5 @@ using System.Runtime.InteropServices; [assembly: System.Windows.ThemeInfo(System.Windows.ResourceDictionaryLocation.None, System.Windows.ResourceDictionaryLocation.SourceAssembly)] [assembly: AssemblyTitle("Tango - Machine Studio")] -[assembly: AssemblyVersion("2.1.12.18210")] +[assembly: AssemblyVersion("2.1.14.18213")] [assembly: ComVisible(false)] \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs index 35a4b0e9d..5467c53a0 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs @@ -20,6 +20,7 @@ namespace Tango.MachineStudio.UI.ViewModels Disconnect, UploadHardwareConfig, Reset, + TurnOffHeaters } private IStudioApplicationManager _applicationManager; @@ -45,31 +46,22 @@ namespace Tango.MachineStudio.UI.ViewModels public RelayCommand ResetCommand { get; set; } + public RelayCommand TurnOffHeatersCommand { get; set; } + public ConnectedMachineViewVM(IStudioApplicationManager application, IDiagnosticsFrameProvider frameProvider) { ApplicationManager = application; - DisconnectCommand = new RelayCommand(Disconnect); - UploadHardwareConfigurationCommand = new RelayCommand(UploadHardwareConfiguration); - ResetCommand = new RelayCommand(Reset); + DisconnectCommand = new RelayCommand(() => AcceptResult(ConnectedMachineVMResult.Disconnect)); + UploadHardwareConfigurationCommand = new RelayCommand(() => AcceptResult(ConnectedMachineVMResult.UploadHardwareConfig)); + ResetCommand = new RelayCommand(() => AcceptResult(ConnectedMachineVMResult.Reset)); + TurnOffHeatersCommand = new RelayCommand(() => AcceptResult(ConnectedMachineVMResult.TurnOffHeaters)); DiagnosticsFrameProvider = frameProvider; } - private void Reset() - { - Result = ConnectedMachineVMResult.Reset; - Accept(); - } - - private void UploadHardwareConfiguration() - { - Result = ConnectedMachineVMResult.UploadHardwareConfig; - Accept(); - } - - private void Disconnect() + private void AcceptResult(ConnectedMachineVMResult result) { - Result = ConnectedMachineVMResult.Disconnect; + Result = result; Accept(); } } 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 d0bddf3f2..df1ea5f7e 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -554,8 +554,8 @@ namespace Tango.MachineStudio.UI.ViewModels } catch (Exception ex) { - LogManager.Log(ex, "Error upload hardware configuration."); - NotificationProvider.ShowError("Error upload hardware configuration." + Environment.NewLine + ex.Message); + LogManager.Log(ex, "Error uploading hardware configuration."); + NotificationProvider.ShowError("Error uploading hardware configuration." + Environment.NewLine + ex.Message); } } } @@ -564,7 +564,7 @@ namespace Tango.MachineStudio.UI.ViewModels { if (NotificationProvider.ShowQuestion("This will reset the embedded device. Are you sure?")) { - using (NotificationProvider.PushTaskItem("Uploading hardware configuration...")) + using (NotificationProvider.PushTaskItem("Resetting the embedded device...")) { try { @@ -579,6 +579,25 @@ namespace Tango.MachineStudio.UI.ViewModels } } } + else if (x.Result == ConnectedMachineViewVM.ConnectedMachineVMResult.TurnOffHeaters) + { + if (NotificationProvider.ShowQuestion("This will reset the process parameters. Are you sure?")) + { + using (NotificationProvider.PushTaskItem("Resetting process parameters...")) + { + try + { + await ApplicationManager.ConnectedMachine.UploadProcessParameters(new ProcessParametersTable()); + NotificationProvider.ShowInfo("Heaters are turned off."); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error resetting process parameters."); + NotificationProvider.ShowError("Error resetting process parameters." + Environment.NewLine + ex.Message); + } + } + } + } }); } @@ -744,7 +763,9 @@ namespace Tango.MachineStudio.UI.ViewModels private void ReportIssue() { - _notificationProvider.ShowModalDialog(new ReportIssueViewVM(TFSClient.Project, TFSClient.CreateBug()), async (vm) => + var bug = TFSClient.CreateBug(); + + _notificationProvider.ShowModalDialog(new ReportIssueViewVM(TFSClient.Project, bug), async (vm) => { using (_notificationProvider.PushTaskItem("Uploading bug report...")) { diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ReportIssueViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ReportIssueViewVM.cs index 2935ff81b..96800d9cf 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ReportIssueViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ReportIssueViewVM.cs @@ -3,8 +3,10 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.UI.TFS; +using Tango.Settings; using Tango.SharedUI; using Tango.SharedUI.Components; using Tango.TFS; @@ -13,6 +15,8 @@ namespace Tango.MachineStudio.UI.ViewModels { public class ReportIssueViewVM : DialogViewVM { + private MachineStudioSettings _settings; + public SelectedObjectCollection SelectedTags { get; set; } public Project Project { get; set; } @@ -22,14 +26,33 @@ namespace Tango.MachineStudio.UI.ViewModels public ReportIssueViewVM() : base() { - + _settings = SettingsManager.Default.GetOrCreate(); } public ReportIssueViewVM(Project project, WorkItem workItem) : this() { Project = project; WorkItem = workItem; - SelectedTags = new SelectedObjectCollection(Project.Tags.ToObservableCollection(), new System.Collections.ObjectModel.ObservableCollection()); + + var area = project.Areas.FirstOrDefault(x => x.Name == _settings.DefaultIssueReportArea); + if (area != null) + { + workItem.Area = area; + } + + var assignedTo = project.Members.FirstOrDefault(x => x.Email == _settings.DefaultIssueReportAssignTo); + if (assignedTo != null) + { + workItem.AssignedTo = assignedTo; + } + + var tags = project.Tags.Where(x => _settings.DefaultIssueReportTags.Contains(x.Name)).ToList(); + if (tags != null) + { + workItem.Tags = tags; + } + + SelectedTags = new SelectedObjectCollection(Project.Tags.ToObservableCollection(), workItem.Tags.ToObservableCollection()); } protected override void Accept() @@ -37,6 +60,16 @@ namespace Tango.MachineStudio.UI.ViewModels if (Validate()) { WorkItem.Tags = SelectedTags.SynchedSource.ToList(); + + try + { + _settings.DefaultIssueReportArea = WorkItem.Area.Name; + _settings.DefaultIssueReportAssignTo = WorkItem.AssignedTo.Email; + _settings.DefaultIssueReportTags = WorkItem.Tags.Select(x => x.Name).ToList(); + _settings.Save(); + } + catch { } + base.Accept(); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml index aa2b014fe..995ac4575 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml @@ -46,11 +46,17 @@ + - - + + + + + + + @@ -125,18 +131,31 @@ - + - - - + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml index 2a6228eda..aa2a70a5f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml @@ -40,7 +40,7 @@ - + @@ -114,7 +114,7 @@ - * + * diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml.cs index 91a288d3e..72bef1205 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml.cs @@ -23,6 +23,13 @@ namespace Tango.MachineStudio.UI.Views public ReportIssueView() { InitializeComponent(); + + this.Loaded += ReportIssueView_Loaded; + } + + private void ReportIssueView_Loaded(object sender, RoutedEventArgs e) + { + txt_title.Focus(); } } } -- cgit v1.3.1