From 92c52918e13dbbaf2a658945c349a6d04c29aa81 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 16 Jan 2019 15:13:55 +0200 Subject: Added custom image support for bug reporting. Fixed issue with dispensers filter search. --- .../DefaultStudioApplicationManager.cs | 1 - .../TFS/TeamFoundationServiceExtendedClient.cs | 31 +++++++++++-------- .../Tango.MachineStudio.UI.csproj | 2 +- .../ViewModels/ReportIssueViewVM.cs | 36 +++++++++++++++++++++- .../Views/ReportIssueView.xaml | 14 +++++++-- 5 files changed, 66 insertions(+), 18 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs index 6146d8f45..2e23d9d61 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -379,6 +379,5 @@ namespace Tango.MachineStudio.UI.StudioApplication ConnectedMachine = null; } } - } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs index addd2f4fb..df831afb9 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs @@ -159,22 +159,27 @@ namespace Tango.MachineStudio.UI.TFS item.State = State.New; item.Type = WorkItemType.Bug; - var bitmap = UIHelper.TakeSnapshot(MainWindow.Instance); - - if (!_tempFolder.Exists()) + foreach (var window in Application.Current.Windows.OfType().Where(x => !String.IsNullOrWhiteSpace(x.Title))) { - _tempFolder = TemporaryManager.CreateFolder(); - } + var bitmap = UIHelper.TakeSnapshot(window); - var tempFile = _tempFolder.CreateFile(); - bitmap.SaveJpeg(tempFile.Path, 30); + if (!_tempFolder.Exists()) + { + _tempFolder = TemporaryManager.CreateFolder(); + } - item.Attachments.Add(new Attachment() - { - Description = "Screen Capture", - FilePath = tempFile.Path, - Name = "Screen Capture.jpg", - }); + var tempFile = _tempFolder.CreateFile(); + bitmap.SaveJpeg(tempFile.Path, 30); + + String title = window.Title; + + item.Attachments.Add(new Attachment() + { + Description = title + " Screen Capture", + FilePath = tempFile.Path, + Name = $"{title}.jpg", + }); + } return item; } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index 706b1c8f7..9f2cddd68 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -609,7 +609,7 @@ copy /Y "$(SolutionDir)Referenced Assemblies\Microsoft.WITDataStore32.dll" "$(Ta - + \ No newline at end of file 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 96800d9cf..21330a4fc 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ReportIssueViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ReportIssueViewVM.cs @@ -1,8 +1,11 @@ -using System; +using Microsoft.Win32; +using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core.Commands; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.UI.TFS; @@ -24,9 +27,19 @@ namespace Tango.MachineStudio.UI.ViewModels [WorkItemValidation] public WorkItem WorkItem { get; set; } + private String _imageFile; + public String ImageFile + { + get { return _imageFile; } + set { _imageFile = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand BrowseImageCommand { get; set; } + public ReportIssueViewVM() : base() { _settings = SettingsManager.Default.GetOrCreate(); + BrowseImageCommand = new RelayCommand(BrowseImage); } public ReportIssueViewVM(Project project, WorkItem workItem) : this() @@ -55,12 +68,33 @@ namespace Tango.MachineStudio.UI.ViewModels SelectedTags = new SelectedObjectCollection(Project.Tags.ToObservableCollection(), workItem.Tags.ToObservableCollection()); } + private void BrowseImage() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Select image file"; + dlg.Filter = "Image Files|*.jpg;*.bmp;*.png"; + if (dlg.ShowDialog().Value) + { + ImageFile = dlg.FileName; + } + } + protected override void Accept() { if (Validate()) { WorkItem.Tags = SelectedTags.SynchedSource.ToList(); + if (ImageFile != null && File.Exists(ImageFile)) + { + WorkItem.Attachments.Add(new Attachment() + { + Description = "User Image", + FilePath = ImageFile, + Name = Path.GetFileName(ImageFile), + }); + } + try { _settings.DefaultIssueReportArea = WorkItem.Area.Name; 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 aa2a70a5f..7387c4ae5 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml @@ -12,7 +12,7 @@ xmlns:tfs="clr-namespace:Tango.TFS;assembly=Tango.TFS" xmlns:tfss="clr-namespace:Tango.MachineStudio.UI.TFS" xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views" - mc:Ignorable="d" Width="530" Height="680" Background="White" d:DataContext="{d:DesignInstance Type=vm:ReportIssueViewVM, IsDesignTimeCreatable=False}"> + mc:Ignorable="d" Width="530" Height="720" Background="White" d:DataContext="{d:DesignInstance Type=vm:ReportIssueViewVM, IsDesignTimeCreatable=False}"> @@ -91,11 +91,21 @@ + + + + Attach Image + + + + + + - + Steps To Reproduce -- cgit v1.3.1