diff options
| author | Avi Levkovich <avi@twine-s.com> | 2018-02-20 16:45:00 +0200 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2018-02-20 16:45:00 +0200 |
| commit | 6c208c90bc45aff4a7fa214356a42fe7757c5e6f (patch) | |
| tree | 0d77bc6a0ecfbb53cf42c5462ee19212197ee1bd /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs | |
| parent | b0823127f152fe97a6e8fce29e427c7f3db9cf5a (diff) | |
| parent | 1a573aaa346ec4b8bd58a0e35ab9df571a09b855 (diff) | |
| download | Tango-6c208c90bc45aff4a7fa214356a42fe7757c5e6f.tar.gz Tango-6c208c90bc45aff4a7fa214356a42fe7757c5e6f.zip | |
MERGE
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs')
6 files changed, 96 insertions, 37 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubManager.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubManager.cs index 8e0eafa3a..1808e2a53 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubManager.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubManager.cs @@ -20,7 +20,7 @@ namespace Tango.MachineStudio.Stubs /// </summary> public class StubManager { - private ITransportAdapter _adapter; //Holds the USB transport adapter. + public ITransportAdapter Adapter { get; private set; } /// <summary> /// Occurs when the stub has failed to execute. @@ -48,7 +48,7 @@ namespace Tango.MachineStudio.Stubs /// <param name="adapter">The adapter.</param> public StubManager(ITransportAdapter adapter) { - _adapter = adapter; + Adapter = adapter; } /// <summary> @@ -121,13 +121,13 @@ namespace Tango.MachineStudio.Stubs Task.Factory.StartNew(() => { - _adapter.Write(requestData); + Adapter.Write(requestData); DateTime startTime = DateTime.Now; MessageContainer responseContainer = null; - _adapter.DataAvailable += (sender, data) => + Adapter.DataAvailable += (sender, data) => { responseContainer = MessageFactory.ParseContainer(data); }; @@ -144,7 +144,7 @@ namespace Tango.MachineStudio.Stubs } } - IMessage message = MessageFactory.ParseMessageFromContainer(responseContainer); + IMessage message = MessageFactory.ExtractMessageFromContainer(responseContainer); OnCompleted(JsonConvert.SerializeObject(message, Formatting.Indented)); done = true; }); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs index 2c4b6c76e..817c68b49 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs @@ -5,35 +5,50 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Media.Imaging; -using Tango.DAL.Observables; +using Tango.Integration.Observables; using Tango.MachineStudio.Common; using Tango.MachineStudio.Stubs.Views; using Tango.SharedUI.Helpers; namespace Tango.MachineStudio.Stubs { - public class StubsModule : IStudioModule + /// <summary> + /// Represents a stubs execution Machine Studio module capable of executing stubs against the current connected machine using a C# script engine. + /// </summary> + /// <seealso cref="Tango.MachineStudio.Common.IStudioModule" /> + public class StubsModule : StudioModuleBase { - public string Name => "Stubs"; + /// <summary> + /// Gets the module name. + /// </summary> + public override string Name => "Stubs"; - public string Description => "Execute machine tests using an interactive C# scripting editor"; + /// <summary> + /// Gets the module description. + /// </summary> + public override string Description => "Execute machine tests using an interactive C# scripting editor"; - public BitmapSource Image => ResourceHelper.GetImageFromResources("Images/stubs.jpg"); + /// <summary> + /// Gets the module cover image. + /// </summary> + public override BitmapSource Image => ResourceHelper.GetImageFromResources("Images/stubs.jpg"); - public FrameworkElement MainView => new MainView(); + /// <summary> + /// Gets the module entry point view. + /// </summary> + public override FrameworkElement MainView => new MainView(); - public Permissions Permission => Permissions.RunSynchronizationModule; + /// <summary> + /// Gets the permission required to see and load this module. + /// </summary> + public override Permissions Permission => Permissions.RunSynchronizationModule; - public bool IsInitialized => true; - - public void Dispose() - { - //throw new NotImplementedException(); - } - - public void Initialize() + /// <summary> + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// </summary> + public override void Dispose() { - //throw new NotImplementedException(); + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Tango.MachineStudio.Stubs.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Tango.MachineStudio.Stubs.csproj index 436a8b3ff..c9670d1be 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Tango.MachineStudio.Stubs.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Tango.MachineStudio.Stubs.csproj @@ -135,10 +135,6 @@ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> </ProjectReference> - <ProjectReference Include="..\..\..\Tango.DAL.Observables\Tango.DAL.Observables.csproj"> - <Project>{0ecd6da8-7aa6-48d9-8b65-279d176ad9af}</Project> - <Name>Tango.DAL.Observables</Name> - </ProjectReference> <ProjectReference Include="..\..\..\Tango.Integration\Tango.Integration.csproj"> <Project>{4206ac58-3b57-4699-8835-90bf6db01a61}</Project> <Name>Tango.Integration</Name> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs index 48297c418..6797b15e6 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs @@ -21,10 +21,10 @@ using Tango.Transport.Adapters; namespace Tango.MachineStudio.Stubs.ViewModels { /// <summary> - /// Represents the script execution utility main view model. + /// Represents the script execution module main view model. /// </summary> /// <seealso cref="Tango.SharedUI.ViewModel" /> - public class MainViewVM : ViewModel + public class MainViewVM : ViewModel , IShutdownListener { private UsbTransportAdapter _adapter; //Holds the USB transport adapter. private StubManager _stubManager; @@ -41,7 +41,19 @@ namespace Tango.MachineStudio.Stubs.ViewModels public bool UseConnectedMachine { get { return _useConnectedMachine; } - set { _useConnectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + set + { + _useConnectedMachine = value; + + if (_useConnectedMachine && !ApplicationManager.IsMachineConnected) + { + _notification.ShowError("No connected machine found."); + _useConnectedMachine = false; + } + + RaisePropertyChangedAuto(); + InvalidateRelayCommands(); + } } /// <summary> @@ -251,13 +263,13 @@ namespace Tango.MachineStudio.Stubs.ViewModels "COM9", }; - SelectedPort = SettingsManager.Default.StubsUI.SelectedPort != null ? SettingsManager.Default.StubsUI.SelectedPort : Ports.First(); + SelectedPort = SettingsManager.Default.MachineStudio.StubsModule.SelectedPort != null ? SettingsManager.Default.MachineStudio.StubsModule.SelectedPort : Ports.First(); Status = "Ready"; - if (SettingsManager.Default.StubsUI.LastTabs.Count > 0) + if (SettingsManager.Default.MachineStudio.StubsModule.LastTabs.Count > 0) { - foreach (var file in SettingsManager.Default.StubsUI.LastTabs) + foreach (var file in SettingsManager.Default.MachineStudio.StubsModule.LastTabs) { if (File.Exists(file)) { @@ -269,8 +281,6 @@ namespace Tango.MachineStudio.Stubs.ViewModels { CreateNewTab(); } - - Application.Current.Exit += Current_Exit; } #endregion @@ -513,11 +523,14 @@ namespace Tango.MachineStudio.Stubs.ViewModels Status = "Completed"; } - private void Current_Exit(object sender, ExitEventArgs e) + /// <summary> + /// Called when [shutdown request]. + /// </summary> + /// <returns></returns> + public void OnShuttingDown() { SettingsManager.Default.MachineStudio.StubsModule.SelectedPort = SelectedPort; SettingsManager.Default.MachineStudio.StubsModule.LastTabs = CodeTabs.Select(x => x.File).ToList(); - SettingsManager.SaveDefaultSettings(); } #endregion diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Views/MainView.xaml index 7f6039110..f1254db47 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Views/MainView.xaml @@ -199,7 +199,42 @@ <Grid> <TabControl x:Name="tabControl" Margin="5" ItemsSource="{Binding CodeTabs}" SelectedItem="{Binding SelectedCodeTab}"> - + <TabControl.Resources> + <Style BasedOn="{StaticResource MetroTabItem}" TargetType="{x:Type TabItem}"> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=IsSelected}" Value="True"> + <Setter Property="Background" Value="#007ACC"></Setter> + </DataTrigger> + </Style.Triggers> + <Setter Property="mahapps:ControlsHelper.HeaderFontSize" Value="12"></Setter> + <Setter Property="HeaderTemplate"> + <Setter.Value> + <DataTemplate> + <Border> + <StackPanel Orientation="Horizontal"> + <mahapps:ProgressRing Width="5" Height="5" Margin="0 0 5 0" Foreground="White" Visibility="{Binding IsRunning,Converter={StaticResource BooleanToVisibilityConverter}}"></mahapps:ProgressRing> + <TextBlock Text="{Binding Title}" ToolTip="{Binding File}" Foreground="Gainsboro" VerticalAlignment="Center"></TextBlock> + <Button Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.CloseTabCommand}" CommandParameter="{Binding}" Margin="5 0 0 0" Cursor="Hand" Width="24" Height="24" VerticalAlignment="Center" Style="{DynamicResource MetroCircleButtonStyle}" mahapps:ButtonHelper.PreserveTextCase="True" BorderThickness="0"> + <StackPanel Orientation="Horizontal"> + <fa:ImageAwesome Width="10" Height="10" Icon="Close" Foreground="Gainsboro"></fa:ImageAwesome> + </StackPanel> + </Button> + </StackPanel> + </Border> + </DataTemplate> + </Setter.Value> + </Setter> + <Setter Property="ContentTemplate"> + <Setter.Value> + <DataTemplate> + <Grid Background="#181818"> + <controls:ScriptEditorControl Text="{Binding Code,Mode=TwoWay}" InsertSnippetCommand="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.InsertSnippetCommand,Mode=TwoWay}" SaveCommand="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.SaveCommand}" HighlightTypes="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.HighlightTypes}" RunCommand="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.RunCommand}" StopCommand="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.StopCommand}" /> + </Grid> + </DataTemplate> + </Setter.Value> + </Setter> + </Style> + </TabControl.Resources> </TabControl> <Grid HorizontalAlignment="Right" Margin="0 45 40 0" VerticalAlignment="Top" Visibility="{Binding IsRunning,Converter={StaticResource BooleanToVisibilityConverter}}"> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Views/MainView.xaml.cs index 5eee980de..16de196e1 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Views/MainView.xaml.cs @@ -32,7 +32,7 @@ namespace Tango.MachineStudio.Stubs.Views private void MainView_Loaded(object sender, RoutedEventArgs e) { - ServiceLocator.Current.GetInstance<MainViewVM>().CodeTabs.RemoveAt(0); + //ServiceLocator.Current.GetInstance<MainViewVM>().CodeTabs.RemoveAt(0); } //Auto scroll to bottom of response log each time it is changed. |
