diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-04-24 19:05:53 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-04-24 19:05:53 +0300 |
| commit | 97e45f70267d961168b77b149022b94022e0e199 (patch) | |
| tree | 89bf6c1c893ab099ef99690d155a0855ba8a9d92 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI | |
| parent | 8046598cb1439b66a8d6e556a61b715fc859a6b0 (diff) | |
| download | Tango-97e45f70267d961168b77b149022b94022e0e199.tar.gz Tango-97e45f70267d961168b77b149022b94022e0e199.zip | |
Working on reporting...
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI')
14 files changed, 545 insertions, 2 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/bug.png b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/bug.png Binary files differnew file mode 100644 index 000000000..ed4b8e6e6 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/bug.png diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationModel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationModel.cs new file mode 100644 index 000000000..eb9ef8012 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.MachineStudio.UI.TFS +{ + public class SystemInformationModel + { + public String ApplicationVersion { get; set; } + public String EmbeddedVersion { get; set; } + public String UserName { get; set; } + public String HostName { get; set; } + public Machine Machine { get; set; } + public String ConfigurationString { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationTemplate.cshtml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationTemplate.cshtml new file mode 100644 index 000000000..7b0c4a896 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationTemplate.cshtml @@ -0,0 +1,70 @@ +@{ + Tango.MachineStudio.UI.TFS.SystemInformationModel vm = Model as Tango.MachineStudio.UI.TFS.SystemInformationModel; +} + +<div> + <div style="font-size:20pt;text-decoration:underline">System Information</div> + <table style="margin-top:10px"> + <tbody> + + <tr> + <td><b>Application Version:</b></td> + <td>@vm.ApplicationVersion</td> + </tr> + + <tr> + <td><b>Embedded Version:</b></td> + <td>@vm.EmbeddedVersion</td> + </tr> + + <tr> + <td><b>Host Name:</b></td> + <td>@vm.HostName</td> + </tr> + + <tr> + <td><b>User:</b></td> + <td>@vm.UserName</td> + </tr> + + </tbody> + </table> + + <div style="font-size:20pt;text-decoration:underline;margin-top:10px">Machine</div> + + @if (vm.Machine != null) + { + <table style="margin-top:10px"> + <tbody> + + <tr> + <td><b>Organization:</b></td> + <td>@vm.Machine.Organization.Name</td> + </tr> + + <tr> + <td><b>Name:</b></td> + <td>@vm.Machine.Name</td> + </tr> + + <tr> + <td><b>S/N:</b></td> + <td>@vm.Machine.SerialNumber</td> + </tr> + + <tr> + <td><b>Version:</b></td> + <td>@vm.Machine.MachineVersion.Version</td> + </tr> + + </tbody> + </table> + + <div style="font-size:20pt;text-decoration:underline;margin-top:10px">Configuration</div> + <div style="white-space:pre;margin-top:10px;font-size:8pt">@vm.ConfigurationString</div> + } + else + { + <div style="color:Red;margin-top:10px">Not Connected</div> + } +</div>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs new file mode 100644 index 000000000..27b257e61 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs @@ -0,0 +1,160 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Tango.BL.Entities; +using Tango.Core.DI; +using Tango.Core.Helpers; +using Tango.Integration.Operation; +using Tango.Logging; +using Tango.MachineStudio.Common.Authentication; +using Tango.MachineStudio.Common.StudioApplication; +using Tango.SharedUI.Helpers; +using Tango.TFS; + +namespace Tango.MachineStudio.UI.TFS +{ + public class TeamFoundationServiceExtendedClient : TeamFoundationServiceClient + { + public Project Project { get; private set; } + + private bool _isInitialized; + public bool IsInitialized + { + get { return _isInitialized; } + private set { _isInitialized = value; RaisePropertyChangedAuto(); } + } + + public TeamFoundationServiceExtendedClient(string collectionURL, string userName, string personalToken) : base(collectionURL, userName, personalToken) + { + + } + + public Task<WorkItem> UploadWorkItem(WorkItem workItem) + { + return UploadWorkItem(Project, workItem); + } + + public void Initialize() + { + Task.Factory.StartNew(() => + { + if (!IsInitialized) + { + Project = GetProject("Tango").Result; + IsInitialized = true; + } + }); + } + + public WorkItem CreateBug() + { + WorkItem item = new WorkItem(); + + IAuthenticationProvider auth = TangoIOC.Default.GetInstance<IAuthenticationProvider>(); + IStudioApplicationManager app = TangoIOC.Default.GetInstance<IStudioApplicationManager>(); + + item.Area = Project.Areas.FirstOrDefault(); + item.Iteration = Project.Iterations.FirstOrDefault(); + + TeamMember currentUser = Project.Members.SingleOrDefault(x => x.UniqueName.ToLower().Contains(auth.CurrentUser.Email.ToLower())); + item.CreatedBy = currentUser; + item.ChangedBy = currentUser; + item.AuthorizedAs = currentUser; + + item.FoundInBuild = app.Version; + item.Priority = Priority.Priority3; + item.Severity = Severity.Medium; + item.State = State.New; + item.Type = WorkItemType.Bug; + + var bitmap = UIHelper.TakeSnapshot(MainWindow.Instance); + String filePath = PathHelper.GetTempFilePath(); + bitmap.SaveJpeg(filePath, 30); + + item.Attachments.Add(new Attachment() + { + Description = "Screen Capture", + FilePath = filePath, + Name = "Screen Capture.jpg", + }); + + FileLogger appFileLogger = LogManager.Default.RegisteredLoggers.FirstOrDefault(x => x.GetType() == typeof(FileLogger)) as FileLogger; + FileLogger embeddedFileLogger = MachineOperator.EmbeddedLogManager.RegisteredLoggers.FirstOrDefault(x => x.GetType() == typeof(FileLogger)) as FileLogger; + + if (appFileLogger != null) + { + String appLogFile = PathHelper.GetTempFilePath(); + File.Copy(appFileLogger.LogFile, appLogFile); + + item.Attachments.Add(new Attachment() + { + Description = "Application Log File", + FilePath = appLogFile, + Name = Path.GetFileName(appFileLogger.LogFile), + }); + } + + if (embeddedFileLogger != null && File.Exists(embeddedFileLogger.LogFile)) + { + String embeddedLogFile = PathHelper.GetTempFilePath(); + File.Copy(appFileLogger.LogFile, embeddedLogFile); + + item.Attachments.Add(new Attachment() + { + Description = "Embedded Log File", + FilePath = embeddedLogFile, + Name = Path.GetFileName(embeddedFileLogger.LogFile), + }); + } + + SystemInformationModel sysModel = new SystemInformationModel(); + sysModel.ApplicationVersion = app.Version; + sysModel.EmbeddedVersion = "Fake Version"; + sysModel.HostName = Environment.MachineName; + sysModel.UserName = auth.CurrentUser.Contact.FullName; + + if (app.ConnectedMachine != null) + { + Machine machine = app.ConnectedMachine.Machine; + + sysModel.Machine = machine; + + MachineDesigner.Views.MainView machineView = new MachineDesigner.Views.MainView(); + machineView.Width = 1280; + machineView.Height = 1100; + machineView.PanelColumnDefinition.Width = new System.Windows.GridLength(0); + machineView.stackHeader.Visibility = Visibility.Collapsed; + machineView.Background = System.Windows.Media.Brushes.White; + machineView.DataContext = new MachineDesigner.ViewModels.MainViewVM() { SelectedMachine = machine, Configuration = machine.Configuration }; + + String configImageFile = PathHelper.GetTempFilePath(); + machineView.RenderToFile(configImageFile, System.Drawing.Imaging.ImageFormat.Jpeg, new System.Windows.Size(machineView.Width, machineView.Height), 100); + + item.Attachments.Add(new Attachment() + { + Description = "Machine Configuration", + FilePath = configImageFile, + Name = "Machine Configuration.jpg" + }); + + sysModel.ConfigurationString = machine.Configuration.CloneConfiguration().ToJsonString(); + } + + String html = String.Empty; + + using (var stream = EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.MachineStudio.UI.TFS.SystemInformationTemplate.cshtml")) + { + StreamReader reader = new StreamReader(stream); + html = reader.ReadToEnd(); + } + + item.SystemInformation = CodeGeneration.Helper.Parse(html, sysModel); + + return item; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamMembersProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamMembersProvider.cs new file mode 100644 index 000000000..0691ca6bd --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamMembersProvider.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.AutoComplete.Editors; +using Tango.Core.DI; + +namespace Tango.MachineStudio.UI.TFS +{ + public class TeamMembersProvider : ISuggestionProvider + { + public IEnumerable GetSuggestions(string filter) + { + return TangoIOC.Default.GetInstance<TeamFoundationServiceExtendedClient>().Project.Members.Where(x => x.AssignName.ToLower().Contains(filter.ToLower())); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/WorkItemValidationAttribute.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/WorkItemValidationAttribute.cs new file mode 100644 index 000000000..1418d0576 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/WorkItemValidationAttribute.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.TFS; + +namespace Tango.MachineStudio.UI.TFS +{ + public class WorkItemValidationAttribute : ValidationAttribute + { + public override bool IsValid(object value) + { + WorkItem item = value as WorkItem; + + if (String.IsNullOrWhiteSpace(item.Title)) + { + ErrorMessage = "Title is empty"; + return false; + } + + if (item.AssignedTo == null) + { + ErrorMessage = "Assigned To is empty"; + return false; + } + + return true; + } + } +} 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 722d37d77..8ab6bb188 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 @@ -147,6 +147,10 @@ <DependentUpon>MessageBoxWindow.xaml</DependentUpon> </Compile> <Compile Include="SupervisingController\IMainView.cs" /> + <Compile Include="TFS\SystemInformationModel.cs" /> + <Compile Include="TFS\TeamFoundationServiceExtendedClient.cs" /> + <Compile Include="TFS\TeamMembersProvider.cs" /> + <Compile Include="TFS\WorkItemValidationAttribute.cs" /> <Compile Include="ViewModels\ConnectedMachineViewVM.cs" /> <Compile Include="ViewModels\LoadingViewVM.cs" /> <Compile Include="ViewModels\LoginViewVM.cs" /> @@ -156,6 +160,7 @@ <Compile Include="ViewModels\MainViewVM.cs" /> <Compile Include="ViewModelLocator.cs" /> <Compile Include="ViewModels\ModuleWindowVM.cs" /> + <Compile Include="ViewModels\ReportIssueViewVM.cs" /> <Compile Include="ViewModels\ShutdownViewVM.cs" /> <Compile Include="ViewModels\UpdateViewVM.cs" /> <Compile Include="Views\ConnectedMachineView.xaml.cs"> @@ -182,6 +187,9 @@ <Compile Include="Notifications\DialogWindow.xaml.cs"> <DependentUpon>DialogWindow.xaml</DependentUpon> </Compile> + <Compile Include="Views\ReportIssueView.xaml.cs"> + <DependentUpon>ReportIssueView.xaml</DependentUpon> + </Compile> <Compile Include="Views\ShutdownView.xaml.cs"> <DependentUpon>ShutdownView.xaml</DependentUpon> </Compile> @@ -258,6 +266,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\ReportIssueView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Views\ShutdownView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -319,6 +331,10 @@ <Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project> <Name>Tango.BL</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.CodeGeneration\Tango.CodeGeneration.csproj"> + <Project>{caedae94-11ed-473c-888a-268a6d38cd20}</Project> + <Name>Tango.CodeGeneration</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.Core\Tango.Core.csproj"> <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> @@ -347,6 +363,10 @@ <Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project> <Name>Tango.SharedUI</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.TFS\Tango.TFS.csproj"> + <Project>{998f8471-dc1b-41b6-9d96-354e1b4e7a32}</Project> + <Name>Tango.TFS</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.Transport\Tango.Transport.csproj"> <Project>{74e700b0-1156-4126-be40-ee450d3c3026}</Project> <Name>Tango.Transport</Name> @@ -440,6 +460,8 @@ </ItemGroup> <ItemGroup> <Content Include="Html\HTML Templates\Thread Break.html" /> + <EmbeddedResource Include="TFS\SystemInformationTemplate.cshtml" /> + <Resource Include="Images\bug.png" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <PropertyGroup> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs index c4b8a1a59..8e6f11452 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs @@ -19,9 +19,11 @@ using Tango.MachineStudio.UI.Navigation; using Tango.MachineStudio.UI.Notifications; using Tango.MachineStudio.UI.StudioApplication; using Tango.MachineStudio.UI.SupervisingController; +using Tango.MachineStudio.UI.TFS; using Tango.MachineStudio.UI.ViewModels; using Tango.MachineStudio.UI.Views; using Tango.Settings; +using Tango.TFS; namespace Tango.MachineStudio.UI { @@ -60,7 +62,9 @@ namespace Tango.MachineStudio.UI TangoIOC.Default.Unregister<IEventLogger>(); TangoIOC.Default.Unregister<ISpeechProvider>(); TangoIOC.Default.Unregister<IHtmlPresenter>(); + TangoIOC.Default.Unregister<ITeamFoundationServiceClient>(); + TangoIOC.Default.Register<TeamFoundationServiceExtendedClient>(new TeamFoundationServiceExtendedClient("https://twinetfs.visualstudio.com/DefaultCollection", "Roy", "szzfokrceo4rhd4eqi5qpmxn3pa5iwl3q7tlqd36l2m7smz2ynoa")); TangoIOC.Default.Register<INotificationProvider, DefaultNotificationProvider>(); TangoIOC.Default.Register<IAuthenticationProvider, DefaultAuthenticationProvider>(); TangoIOC.Default.Register<INavigationManager, DefaultNavigationManager>(); 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 2144983de..0882267e8 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -29,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; @@ -142,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. @@ -183,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; } @@ -247,8 +258,9 @@ namespace Tango.MachineStudio.UI.ViewModels IEventLogger eventLogger, IDiagnosticsFrameProvider frameProvider, ISpeechProvider speechProvider, - IHtmlPresenter htmlPresenter) : base() + IHtmlPresenter htmlPresenter, TeamFoundationServiceExtendedClient tfs) : base() { + TFSClient = tfs; _eventLogger = eventLogger; _navigation = navigationManager; AuthenticationProvider = authenticationProvider; @@ -288,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) @@ -628,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/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml index dd3d122b6..86723479b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -316,6 +316,22 @@ </Image.Style> </Image> </Button> + + <Button Cursor="Hand" Command="{Binding ReportIssueCommand}" IsEnabled="{Binding TFSClient.IsInitialized}"> + <Button.Style> + <Style TargetType="Button" BasedOn="{StaticResource emptyButton}"> + <Setter Property="ToolTip" Value="Report and issue"></Setter> + <Setter Property="Opacity" Value="1"></Setter> + <Style.Triggers> + <Trigger Property="IsEnabled" Value="False"> + <Setter Property="ToolTip" Value="The team foundation service is not available."></Setter> + <Setter Property="Opacity" Value="0.5"></Setter> + </Trigger> + </Style.Triggers> + </Style> + </Button.Style> + <Image Margin="10 0 0 0" Source="/Images/bug.png" Width="24" RenderOptions.BitmapScalingMode="Fant" /> + </Button> </StackPanel> </Grid> </Grid> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml new file mode 100644 index 000000000..f2e3038b9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml @@ -0,0 +1,92 @@ +<UserControl x:Class="Tango.MachineStudio.UI.Views.ReportIssueView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" + xmlns:integration="clr-namespace:Tango.Integration.Services;assembly=Tango.Integration" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:vm="clr-namespace:Tango.MachineStudio.UI.ViewModels" + 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="650" Background="White" d:DataContext="{d:DesignInstance Type=vm:ReportIssueViewVM, IsDesignTimeCreatable=False}"> + + <UserControl.Resources> + <converters:EnumToItemsSourceConverter x:Key="EnumToItemsSourceConverter" /> + <tfss:TeamMembersProvider x:Key="TeamMembersProvider" /> + <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> + </UserControl.Resources> + + <Grid> + <Grid> + <Grid.RowDefinitions> + <RowDefinition Height="90"/> + <RowDefinition Height="377*"/> + <RowDefinition Height="70"/> + </Grid.RowDefinitions> + + <Grid> + <StackPanel Orientation="Horizontal"> + <Image Source="/Images/bug.png" Width="48" RenderOptions.BitmapScalingMode="Fant"></Image> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" FontSize="20">Report Issue</TextBlock> + </StackPanel> + </Grid> + + <Grid Grid.Row="1"> + <StackPanel> + <TextBox materialDesign:HintAssist.Hint="Title" materialDesign:HintAssist.IsFloating="True" FontSize="16" Text="{Binding WorkItem.Title}"></TextBox> + + <autoComplete:AutoCompleteTextBox Provider="{StaticResource TeamMembersProvider}" SelectedItem="{Binding WorkItem.AssignedTo,Mode=TwoWay}" DisplayMember="DisplayName" Margin="0 10 0 0" materialDesign:HintAssist.Hint="Assigned To" materialDesign:HintAssist.IsFloating="True"></autoComplete:AutoCompleteTextBox> + <ComboBox Margin="0 10 0 0" materialDesign:HintAssist.Hint="Area" materialDesign:HintAssist.IsFloating="True" ItemsSource="{Binding Project.Areas}" SelectedItem="{Binding WorkItem.Area}" DisplayMemberPath="Name"></ComboBox> + <ComboBox Margin="0 10 0 0" materialDesign:HintAssist.Hint="Severity" materialDesign:HintAssist.IsFloating="True" ItemsSource="{Binding Source={x:Type tfs:Severity},Converter={StaticResource EnumToItemsSourceConverter}}" SelectedValue="{Binding WorkItem.Severity}" SelectedValuePath="Value" DisplayMemberPath="DisplayName"></ComboBox> + + <TextBlock Margin="0 10 0 0">Tags</TextBlock> + <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Height="120"> + <ItemsControl ItemsSource="{Binding SelectedTags}"> + <ItemsControl.ItemsPanel> + <ItemsPanelTemplate> + <WrapPanel IsItemsHost="True" Orientation="Horizontal" /> + </ItemsPanelTemplate> + </ItemsControl.ItemsPanel> + <ItemsControl.ItemTemplate> + <DataTemplate> + <ToggleButton Style="{StaticResource emptyToggleButton}" IsChecked="{Binding IsSelected}" Cursor="Hand"> + <Border CornerRadius="5" Margin="0 5 5 5" Padding="5" BorderThickness="1" BorderBrush="DimGray"> + <Border.Style> + <Style TargetType="Border"> + <Setter Property="Background" Value="Silver"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding IsSelected}" Value="True"> + <Setter Property="Background" Value="{StaticResource AccentColorBrush}"></Setter> + <Setter Property="TextElement.Foreground" Value="White"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Border.Style> + <TextBlock Text="{Binding Data.Name}" FontSize="11"></TextBlock> + </Border> + </ToggleButton> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> + </ScrollViewer> + </StackPanel> + </Grid> + + <Grid Grid.Row="2"> + <Button HorizontalAlignment="Right" Width="140" Command="{Binding OKCommand}">SUBMIT</Button> + + <ItemsControl ItemsSource="{Binding ValidationErrors}" HorizontalAlignment="Left" Margin="5" VerticalAlignment="Center" Visibility="Visible"> + <ItemsControl.ItemTemplate> + <DataTemplate> + <TextBlock Foreground="#FF4C4C" Margin="0 2 0 0"><Run>*</Run> <Run Text="{Binding}"></Run></TextBlock> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> + </Grid> + </Grid> + </Grid> +</UserControl> 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 new file mode 100644 index 000000000..91a288d3e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.UI.Views +{ + /// <summary> + /// Interaction logic for ReportIssueView.xaml + /// </summary> + public partial class ReportIssueView : UserControl + { + public ReportIssueView() + { + InitializeComponent(); + } + } +} |
