From 5ee4696c9a82fa23ec477c28b725af104abe90ef Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 2 May 2018 14:23:40 +0300 Subject: Worked on DeveloperConsole. Added some fields to VSTS work item. (resolved...) Resolved issue with application crash when trying to show notification before main window initialized. Added DeveloperConsole permission to DB. Added SetWorkItemAssignment to TFS client. --- .../Console/ConsoleWindow.xaml | 118 ++++++++++++++++++- .../Console/ConsoleWindow.xaml.cs | 10 +- .../Console/ConsoleWindowVM.cs | 129 +++++++++++++++++++-- .../DefaultStudioApplicationManager.cs | 16 +++ .../TFS/TeamFoundationServiceExtendedClient.cs | 3 +- .../Tango.MachineStudio.UI/ViewModelLocator.cs | 2 +- .../ViewModels/LoadingViewVM.cs | 8 +- .../Tango.MachineStudio.UI/Views/MainView.xaml | 21 ++-- .../Views/ReportIssueView.xaml | 4 +- .../Views/ResolvedIssuesView.xaml | 19 ++- 10 files changed, 297 insertions(+), 33 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindow.xaml index 3a30eda57..22338fea7 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindow.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindow.xaml @@ -8,6 +8,7 @@ xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:views="clr-namespace:Tango.MachineStudio.UI.Views" + xmlns:fa="http://schemas.fontawesome.io/icons/" xmlns:sharedControls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:console="clr-namespace:Tango.MachineStudio.UI.Console" xmlns:local="clr-namespace:Tango.MachineStudio.UI.Console" @@ -29,7 +30,105 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -57,12 +156,23 @@ - + - - + + + + + + + + + LOG + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindow.xaml.cs index e22582a46..de2c728b0 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindow.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindow.xaml.cs @@ -26,10 +26,18 @@ namespace Tango.MachineStudio.UI.Console { InitializeComponent(); - this.Loaded += (_, __) => + this.Loaded += (_, __) => { _vm = this.DataContext as ConsoleWindowVM; + _vm.SetLogTextBox(txtLog); }; } + + //Auto scroll to bottom of response log each time it is changed. + private void TextBox_TextChanged(object sender, TextChangedEventArgs e) + { + txtLog.SelectionStart = txtLog.Text.Length; + txtLog.ScrollToEnd(); + } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindowVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindowVM.cs index 9c1192f06..a3a0a734e 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindowVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindowVM.cs @@ -1,10 +1,13 @@ -using System; +using Microsoft.Win32; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; +using System.Windows.Controls; using System.Windows.Threading; using Tango.Core.Commands; using Tango.Core.Helpers; @@ -19,6 +22,8 @@ namespace Tango.MachineStudio.UI.Console { private IStudioModuleLoader _moduleLoader; private INotificationProvider _notificatrion; + private TextBox _txtLog; + private String _currentFile; /// @@ -26,28 +31,36 @@ namespace Tango.MachineStudio.UI.Console /// public ObservableCollection> HighlightTypes { get; set; } + internal void SetLogTextBox(TextBox txtLog) + { + _txtLog = txtLog; + } + /// /// Gets or sets the intellisense types. /// public ObservableCollection> IntellisenseTypes { get; set; } private String _code; - + /// + /// Gets or sets the code. + /// public String Code { get { return _code; } set { _code = value; RaisePropertyChangedAuto(); } } - private String _log; - - public String Log + private bool _isRunning; + /// + /// Gets or sets a value indicating whether a stub is currently running. + /// + public bool IsRunning { - get { return _log; } - set { _log = value; RaisePropertyChangedAuto(); } + get { return _isRunning; } + set { _isRunning = value; RaisePropertyChanged(nameof(IsRunning)); InvalidateRelayCommands(); } } - /// /// Gets or sets the run command. /// @@ -63,6 +76,26 @@ namespace Tango.MachineStudio.UI.Console /// public RelayCommand ClearCommand { get; set; } + /// + /// Gets or sets the new command. + /// + public RelayCommand NewCommand { get; set; } + + /// + /// Gets or sets the open command. + /// + public RelayCommand OpenCommand { get; set; } + + /// + /// Gets or sets the save command. + /// + public RelayCommand SaveCommand { get; set; } + + /// + /// Gets or sets the save as command. + /// + public RelayCommand SaveAsCommand { get; set; } + public ConsoleWindowVM(IStudioModuleLoader moduleLoader, INotificationProvider notification) { _moduleLoader = moduleLoader; @@ -117,6 +150,12 @@ namespace Tango.MachineStudio.UI.Console } Code = EmbeddedResourceHelper.GetEmbeddedResourceText("Tango.MachineStudio.UI.Console.CodeTemplate.cs"); + + NewCommand = new RelayCommand(CreateNew); + OpenCommand = new RelayCommand(OpenFile); + SaveCommand = new RelayCommand(SaveFile); + SaveAsCommand = new RelayCommand(SaveAsFile); + ClearCommand = new RelayCommand(ClearLog); } private void Stop() @@ -127,6 +166,7 @@ namespace Tango.MachineStudio.UI.Console private async void Run() { ScriptEngine engine = new ScriptEngine(new ConsoleOnExecuteParameters(new ConsoleManager(WriteLine))); + engine.Stop(); engine.ReferencedAssemblies.Add(this.GetType()); engine.ReferencedAssemblies.Add(typeof(INotificationProvider)); @@ -140,7 +180,78 @@ namespace Tango.MachineStudio.UI.Console private void WriteLine(String text) { - Log += text + Environment.NewLine; + InvokeUI(() => + { + _txtLog.AppendText(text); + }); + } + + /// + /// Clears the log. + /// + private void ClearLog() + { + _txtLog.Clear(); + } + + /// + /// Saves the selected script file. + /// + private void SaveFile() + { + if (_currentFile == null) + { + SaveAsFile(); + } + else + { + File.WriteAllText(_currentFile, Code); + } + } + + /// + /// Saves the selected script file. + /// + private void SaveAsFile() + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "C# Script Files|*.cs"; + dlg.DefaultExt = ".cs"; + if (dlg.ShowDialog().Value) + { + File.WriteAllText(dlg.FileName, Code); + _currentFile = dlg.FileName; + } + } + + /// + /// Opens a script from HD. + /// + private void OpenFile() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "C# Script Files|*.cs"; + if (dlg.ShowDialog().Value) + { + OpenFile(dlg.FileName); + } + } + + /// + /// Opens the file. + /// + /// The file. + private void OpenFile(String file) + { + Code = File.ReadAllText(file); + _currentFile = file; + } + + private void CreateNew() + { + _txtLog.Clear(); + _currentFile = null; + Code = String.Empty; } } } 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 a5aa6261d..4c02be2b2 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -42,6 +42,22 @@ namespace Tango.MachineStudio.UI.StudioApplication _moduleLoader = moduleLoader; _navigationManager = navigationManager; _openedWindows = new List(); + + Task.Factory.StartNew(() => + { + while (MainWindow.Instance == null) + { + Thread.Sleep(100); + } + + InvokeUI(() => + { + MainWindow.Instance.ContentRendered += (_, __) => + { + TangoIOC.Default.GetAllInstancesByBase().ToList().ForEach(x => x.OnApplicationStarted()); + }; + }); + }); } /// 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 4ca296523..79572eb71 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs @@ -67,7 +67,7 @@ namespace Tango.MachineStudio.UI.TFS IStudioApplicationManager app = TangoIOC.Default.GetInstance(); var items = await GetWorkItemsCreatedBy(Project, GetUserTeamMember()); items.Where(x => x.StepsToReproduce != null).ToList().ForEach(x => x.StepsToReproduce = x.StepsToReproduce.Replace("
", "").Replace("
", "")); - ResolvedWorkItems = items.Where(x => x.State == State.Resolved && x.IsBuildVersionValid && x.FoundInBuildVersion < Version.Parse(app.Version)).ToObservableCollection(); + ResolvedWorkItems = items.Where(x => x.State == State.Resolved && x.ResolvedReason == ResolvedReason.Fixed && x.IsBuildVersionValid && x.FoundInBuildVersion < Version.Parse(app.Version)).ToObservableCollection(); } catch (Exception ex) { @@ -87,6 +87,7 @@ namespace Tango.MachineStudio.UI.TFS { await SetWorkItemState(Project, workItem, State.New); var updated = await AddWorkItemComment(Project, workItem, GetUserTeamMember(), "Bug has been reactivated by " + GetUserTeamMember().DisplayName + " (via Tango Software)."); + updated = await SetWorkItemAssignment(Project, updated, workItem.ResolvedBy); ResolvedWorkItems.Remove(workItem); return updated; } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs index 6e337c0e9..931130a05 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs @@ -76,7 +76,7 @@ namespace Tango.MachineStudio.UI TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); - TangoIOC.Default.Register(new TeamFoundationServiceExtendedClient("https://twinetfs.visualstudio.com/DefaultCollection", "Roy", "szzfokrceo4rhd4eqi5qpmxn3pa5iwl3q7tlqd36l2m7smz2ynoa")); + TangoIOC.Default.Register(new TeamFoundationServiceExtendedClient("https://twinetfs.visualstudio.com", String.Empty, "szzfokrceo4rhd4eqi5qpmxn3pa5iwl3q7tlqd36l2m7smz2ynoa")); TangoIOC.Default.Register(); TangoIOC.Default.Register(); 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 2b2b442f7..29f9102ac 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -16,6 +16,7 @@ using Tango.BL; using Tango.MachineStudio.Common.EventLogging; using Tango.BL.Enumerations; using Tango.MachineStudio.UI.TFS; +using Tango.MachineStudio.Common; namespace Tango.MachineStudio.UI.ViewModels { @@ -23,7 +24,7 @@ namespace Tango.MachineStudio.UI.ViewModels /// Represents the Machine Studio loading view, view model. ///
/// - public class LoadingViewVM : ViewModel + public class LoadingViewVM : StudioViewModelInternal { private INotificationProvider _notificationProvider; private TeamFoundationServiceExtendedClient _tfs; @@ -55,6 +56,11 @@ namespace Tango.MachineStudio.UI.ViewModels _navigationManager = navigationManager; _studioModuleLoader = studioModuleLoader; _notificationProvider = notificationProvider; + } + + public override void OnApplicationStarted() + { + base.OnApplicationStarted(); Load(); } 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 29bd70451..8417c70c8 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -10,9 +10,11 @@ xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:entities="clr-namespace:Tango.BL.Entities;assembly=Tango.BL" + xmlns:enumerations="clr-namespace:Tango.BL.Enumerations;assembly=Tango.BL" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:db="clr-namespace:Tango.MachineStudio.DB.Views;assembly=Tango.MachineStudio.DB" xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views" + xmlns:commonConverters="clr-namespace:Tango.MachineStudio.Common.Converters;assembly=Tango.MachineStudio.Common" mc:Ignorable="d" d:DesignHeight="720" d:DesignWidth="1270" Background="Transparent" DataContext="{Binding MainViewVM, Source={StaticResource Locator}}"> @@ -22,6 +24,7 @@ + @@ -189,14 +192,16 @@ Speech - - - + + + + + -- cgit v1.3.1