diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-10-15 07:53:18 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-10-15 07:53:18 +0300 |
| commit | 94c14b3edbaec2f975df2f20175ba68c79a823ba (patch) | |
| tree | c3d8ac524f20d0cf0a3247a4505815caf365cf43 /Software/Visual_Studio/MachineStudio | |
| parent | fb2991bde321e59160a3dd821ecc08db87ac9217 (diff) | |
| parent | a6f139678b625cc5cd99f4065956d2b8230f420a (diff) | |
| download | Tango-94c14b3edbaec2f975df2f20175ba68c79a823ba.tar.gz Tango-94c14b3edbaec2f975df2f20175ba68c79a823ba.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
16 files changed, 382 insertions, 20 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml index 3ffeaaa77..d550cbccb 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml @@ -4,6 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems" xmlns:converters="clr-namespace:Tango.Editors.Converters;assembly=Tango.Editors" @@ -76,14 +77,61 @@ <Border Background="#202020" Margin="0 3 0 0" CornerRadius="3" Padding="5" Grid.Column="1"> <Grid> - <mahapps:NumericUpDown Style="{x:Null}" InterceptMouseWheel="True" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HorizontalContentAlignment="Right" HideUpDownButtons="True" ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled" HasDecimals="True" Minimum="0" Maximum="400" Padding="0" Value="{Binding SetPoint,FallbackValue='0.0',Mode=TwoWay}" VerticalAlignment="Center" FontSize="44" FontFamily="digital-7" Foreground="#FFD400" Margin="0 0 12 0"> + <mahapps:NumericUpDown x:Name="txtSetPoint" InterceptMouseWheel="True" IsHitTestVisible="{Binding IsEditing}" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HorizontalContentAlignment="Right" HideUpDownButtons="True" ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled" HasDecimals="True" Minimum="0" Maximum="400" Padding="0" Value="{Binding SetPoint,FallbackValue='0.0',Mode=TwoWay}" VerticalAlignment="Center" FontSize="44" FontFamily="digital-7" Foreground="#FFD400" Margin="0 0 12 0"> <mahapps:NumericUpDown.Resources> <Style TargetType="TextBox"> - + <Setter Property="Opacity" Value="1"></Setter> + <Setter Property="CaretBrush" Value="#FFD400"></Setter> + <Setter Property="SelectionBrush" Value="#50FFD400"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding IsEditing}" Value="True"> + <DataTrigger.EnterActions> + <BeginStoryboard Name="blink"> + <Storyboard> + <DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" Storyboard.TargetProperty="Opacity" FillBehavior="Stop"> + <DiscreteDoubleKeyFrame KeyTime="00:00:00" Value="0" /> + <DiscreteDoubleKeyFrame KeyTime="00:00:0.5" Value="1" /> + <DiscreteDoubleKeyFrame KeyTime="00:00:1" Value="1" /> + </DoubleAnimationUsingKeyFrames> + </Storyboard> + </BeginStoryboard> + </DataTrigger.EnterActions> + <DataTrigger.ExitActions> + <RemoveStoryboard BeginStoryboardName="blink" /> + </DataTrigger.ExitActions> + </DataTrigger> + </Style.Triggers> </Style> </mahapps:NumericUpDown.Resources> + + <mahapps:NumericUpDown.Style> + <Style TargetType="mahapps:NumericUpDown"> + + </Style> + </mahapps:NumericUpDown.Style> </mahapps:NumericUpDown> <TextBlock ToolTip="Setting Value" HorizontalAlignment="Right" VerticalAlignment="Bottom" FontSize="9" Foreground="Gainsboro">SV</TextBlock> + + <ToggleButton Checked="ToggleButton_Checked" Style="{x:Null}" IsChecked="{Binding IsEditing}" HorizontalAlignment="Left" VerticalAlignment="Top" Opacity="0.2" Cursor="Hand"> + <ToggleButton.Template> + <ControlTemplate TargetType="ToggleButton"> + <Grid Background="Transparent"> + <materialDesign:PackIcon Width="24" Height="24" Foreground="#FFD400"> + <materialDesign:PackIcon.Style> + <Style TargetType="materialDesign:PackIcon"> + <Setter Property="Kind" Value="PencilBox"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding IsEditing}" Value="True"> + <Setter Property="Kind" Value="Pencil"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </materialDesign:PackIcon.Style> + </materialDesign:PackIcon> + </Grid> + </ControlTemplate> + </ToggleButton.Template> + </ToggleButton> </Grid> </Border> </Grid> @@ -146,10 +194,10 @@ <ColumnDefinition Width="175"/> </Grid.ColumnDefinitions> - <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Gray" FontSize="16" FontWeight="SemiBold">ITC</TextBlock> + <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Gray" FontSize="16" FontWeight="SemiBold">TWI</TextBlock> <Grid Grid.Column="1"> - <Button Style="{x:Null}" Width="60" Height="60" HorizontalAlignment="Right" Cursor="Hand" Command="{Binding SetCommand}"> + <Button Style="{x:Null}" Width="60" Height="60" HorizontalAlignment="Right" Cursor="Hand" Command="{Binding SetCommand}" IsEnabled="{Binding IsEditing}"> <Button.Template> <ControlTemplate TargetType="Button"> <Grid> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml.cs index 37d0defe5..ae105f768 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/HeaterElementEditor.xaml.cs @@ -106,5 +106,11 @@ namespace Tango.MachineStudio.Technician.Editors { } + + private void ToggleButton_Checked(object sender, RoutedEventArgs e) + { + txtSetPoint.Focus(); + txtSetPoint.SelectAll(); + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj index aca44f07f..4cb8c5cee 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj @@ -289,8 +289,12 @@ <Compile Include="TechnicianModule.cs" /> <Compile Include="TechnicianModuleSettings.cs" /> <Compile Include="ViewModelLocator.cs" /> + <Compile Include="ViewModels\ImportProjectTabViewVM.cs" /> <Compile Include="ViewModels\MachineTechTabVM.cs" /> <Compile Include="ViewModels\MachineTechViewVM.cs" /> + <Compile Include="Views\ImportProjectTabView.xaml.cs"> + <DependentUpon>ImportProjectTabView.xaml</DependentUpon> + </Compile> <Compile Include="Views\MachineTechView.xaml.cs"> <DependentUpon>MachineTechView.xaml</DependentUpon> </Compile> @@ -482,6 +486,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\ImportProjectTabView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Views\MachineTechView.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -717,7 +725,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/HeaterItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/HeaterItem.cs index e91c3f185..d419127c5 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/HeaterItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/HeaterItem.cs @@ -47,7 +47,11 @@ namespace Tango.MachineStudio.Technician.TechItems Color = Colors.White; Description = "Heater Controller"; Image = ResourceHelper.GetImageFromResources("Images/heater-controller.png"); - SetCommand = new RelayCommand(() => { SetCommandClicked?.Invoke(); }, (x) => HeaterState.CurrentValue != SetPoint); + SetCommand = new RelayCommand(() => + { + SetCommandClicked?.Invoke(); + IsEditing = false; + }, (x) => HeaterState.CurrentValue != SetPoint); HeaterState = new HeaterState(); } @@ -72,6 +76,11 @@ namespace Tango.MachineStudio.Technician.TechItems _heaterState = value; RaisePropertyChangedAuto(); + if (!IsEditing) + { + SetPoint = _heaterState.SetPoint; + } + InvokeUI(() => { SetCommand.RaiseCanExecuteChanged(); @@ -89,6 +98,15 @@ namespace Tango.MachineStudio.Technician.TechItems set { _setPoint = value; RaisePropertyChangedAuto(); } } + private bool _isEditing; + [XmlIgnore] + public bool IsEditing + { + get { return _isEditing; } + set { _isEditing = value; RaisePropertyChangedAuto(); } + } + + /// <summary> /// Clones this instance. /// </summary> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/ImportProjectTabViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/ImportProjectTabViewVM.cs new file mode 100644 index 000000000..751a563bf --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/ImportProjectTabViewVM.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.MachineStudio.Technician.Project; +using Tango.SharedUI; +using Tango.SharedUI.Components; + +namespace Tango.MachineStudio.Technician.ViewModels +{ + public class ImportProjectTabViewVM : DialogViewVM + { + public String ProjectName { get; set; } + + public SelectedObjectCollection<MachineTechViewProjectTab> Tabs { get; set; } + + public ImportProjectTabViewVM(List<MachineTechViewProjectTab> tabs, String projectName) + { + ProjectName = projectName; + Tabs = new SelectedObjectCollection<MachineTechViewProjectTab>(new ObservableCollection<MachineTechViewProjectTab>(tabs), new ObservableCollection<MachineTechViewProjectTab>()); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs index 59cd6fe19..46d745139 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs @@ -38,6 +38,7 @@ using Microsoft.WindowsAPICodePack.Dialogs; using RealTimeGraphX; using RealTimeGraphX.WPF.DataSeries; using RealTimeGraphX.DataPoints; +using Tango.MachineStudio.Technician.Views; namespace Tango.MachineStudio.Technician.ViewModels { @@ -267,6 +268,15 @@ namespace Tango.MachineStudio.Technician.ViewModels /// Gets or sets the rename tab command. /// </summary> public RelayCommand RenameTabCommand { get; set; } + + /// <summary> + /// Gets or sets the import project tabs command. + /// </summary> + /// <value> + /// The import project tabs command. + /// </value> + public RelayCommand ImportProjectTabsCommand { get; set; } + #endregion #region Constructors @@ -340,6 +350,7 @@ namespace Tango.MachineStudio.Technician.ViewModels RemoveTabCommand = new RelayCommand<MachineTechTabVM>(RemoveTab); NewProjectCommand = new RelayCommand(CreateNewProject); RenameTabCommand = new RelayCommand(RenameTab); + ImportProjectTabsCommand = new RelayCommand(ImportProjectTabs); } #endregion @@ -1788,12 +1799,12 @@ namespace Tango.MachineStudio.Technician.ViewModels /// Opens the specified project file path. /// </summary> /// <param name="fileName">File path.</param> - public void OpenProjectFile(String fileName) + public MachineTechViewProject OpenProjectFile(String fileName, bool load = true) { + MachineTechViewProject project = null; + try { - MachineTechViewProject project = null; - project = MachineTechViewProject.Load(fileName); if (project.Tabs.Count == 0) @@ -1807,27 +1818,35 @@ namespace Tango.MachineStudio.Technician.ViewModels project.Tabs.Add(tab); } - LoadProject(project); - _lastTechProjectFile = fileName; + if (load) + { + LoadProject(project); + _lastTechProjectFile = fileName; + } } catch (Exception ex) { LogManager.Log(ex, $"Error loading project file {fileName}."); _notification.ShowError("An error occurred while trying to load the tech board project file."); } + + return project; } /// <summary> /// Loads the specified project. /// </summary> /// <param name="project">The project.</param> - public void LoadProject(MachineTechViewProject project) + public void LoadProject(MachineTechViewProject project, bool appendToCurrentProject = false) { using (_notification.PushTaskItem("Loading technician project file...")) { - Tabs.Clear(); - _singleControllers.Clear(); - _multiControllers.Clear(); + if (!appendToCurrentProject) + { + Tabs.Clear(); + _singleControllers.Clear(); + _multiControllers.Clear(); + } foreach (var tab in project.Tabs) { @@ -2012,6 +2031,33 @@ namespace Tango.MachineStudio.Technician.ViewModels } } + /// <summary> + /// Imports a project file tabs to the current project. + /// </summary> + private void ImportProjectTabs() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Select Technician Project File"; + dlg.Filter = "Technician Project File|*.tpf"; + + if (dlg.ShowDialog().Value) + { + var project = OpenProjectFile(dlg.FileName, false); + + if (project != null) + { + var vm = new ImportProjectTabViewVM(project.Tabs, Path.GetFileNameWithoutExtension(dlg.FileName)); + _notification.ShowModalDialog<ImportProjectTabViewVM, ImportProjectTabView>(vm, (x) => + { + project.Tabs.Clear(); + project.Tabs.AddRange(vm.Tabs.SynchedSource.ToList()); + LoadProject(project, true); + + }, () => { }); + } + } + } + #endregion #region IStudioModuleVM diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/ImportProjectTabView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/ImportProjectTabView.xaml new file mode 100644 index 000000000..b0d6b23fb --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/ImportProjectTabView.xaml @@ -0,0 +1,43 @@ +<UserControl x:Class="Tango.MachineStudio.Technician.Views.ImportProjectTabView" + 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:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:vm="clr-namespace:Tango.MachineStudio.Technician.ViewModels" + xmlns:local="clr-namespace:Tango.MachineStudio.Technician.Views" + mc:Ignorable="d" + d:DesignHeight="220" d:DesignWidth="600" Background="Transparent" Height="400" d:DataContext="{d:DesignInstance Type=vm:ImportProjectTabViewVM, IsDesignTimeCreatable=False}"> + <Grid> + <DockPanel LastChildFill="True"> + <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right" DockPanel.Dock="Bottom"> + <Button Style="{StaticResource MaterialDesignFlatButton}" IsDefault="True" Margin="0 8 8 0" Command="{Binding OKCommand}"> + IMPORT + </Button> + <Button Style="{StaticResource MaterialDesignFlatButton}" IsCancel="False" Margin="0 8 8 0" Command="{Binding CloseCommand}"> + CANCEL + </Button> + </StackPanel> + <StackPanel DockPanel.Dock="Top" VerticalAlignment="Top" Margin="0 30 0 0"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="Table" VerticalAlignment="Top" Width="50" Height="50" Foreground="#202020" /> + <TextBlock Padding="0 10 0 0" TextWrapping="Wrap" Margin="10 0 0 0" VerticalAlignment="Top" FontSize="14" Text="IMPORT PROJECT TABS" Width="400"></TextBlock> + </StackPanel> + </StackPanel> + + <Grid Margin="60 20 30 20"> + <Border BorderThickness="1" BorderBrush="Gainsboro" Padding="5" CornerRadius="5"> + <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto"> + <ItemsControl ItemsSource="{Binding Tabs}"> + <ItemsControl.ItemTemplate> + <DataTemplate> + <CheckBox Content="{Binding Data.Name}" IsChecked="{Binding IsSelected}" Margin="0 2" /> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> + </ScrollViewer> + </Border> + </Grid> + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/ImportProjectTabView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/ImportProjectTabView.xaml.cs new file mode 100644 index 000000000..31b403dc7 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/ImportProjectTabView.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.Technician.Views +{ + /// <summary> + /// Interaction logic for ImportProjectTabView.xaml + /// </summary> + public partial class ImportProjectTabView : UserControl + { + public ImportProjectTabView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml index 3d129a252..0b2cad073 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml @@ -147,6 +147,17 @@ <fa:ImageAwesome Icon="FolderOpen" Width="16" /> </MenuItem.Icon> </MenuItem> + <MenuItem MinWidth="180" Header="Import" VerticalContentAlignment="Center"> + <MenuItem.Icon> + <fa:ImageAwesome Icon="ArrowRight" Width="16" /> + </MenuItem.Icon> + + <MenuItem Header="Import Project Tabs" VerticalContentAlignment="Center" Command="{Binding ImportProjectTabsCommand}"> + <MenuItem.Icon> + <fa:ImageAwesome Icon="Table" Width="16" /> + </MenuItem.Icon> + </MenuItem> + </MenuItem> <Separator/> <MenuItem Header="Save" Command="{Binding SaveProjectCommand}"> <MenuItem.Icon> 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 4524e0622..631804544 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("3.5.45.18238")] +[assembly: AssemblyVersion("3.5.47.18238")] [assembly: ComVisible(false)]
\ No newline at end of file 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 8eff9ea4e..e6c687b92 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -22,6 +22,9 @@ using Tango.Core.DI; using Tango.BL.Entities; using Tango.BL; using Tango.MachineStudio.UI.ViewModels; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.UI.Views; +using Tango.Integration.Operation; namespace Tango.MachineStudio.UI.StudioApplication { @@ -34,16 +37,18 @@ namespace Tango.MachineStudio.UI.StudioApplication { private INavigationManager _navigationManager; private IStudioModuleLoader _moduleLoader; + private INotificationProvider _notification; private List<Window> _openedWindows; /// <summary> /// Initializes a new instance of the <see cref="DefaultStudioApplicationManager" /> class. /// </summary> /// <param name="navigationManager">The navigation manager.</param> - public DefaultStudioApplicationManager(INavigationManager navigationManager, IStudioModuleLoader moduleLoader) + public DefaultStudioApplicationManager(INavigationManager navigationManager, IStudioModuleLoader moduleLoader, INotificationProvider notification) { _moduleLoader = moduleLoader; _navigationManager = navigationManager; + _notification = notification; _openedWindows = new List<Window>(); Application.Current.MainWindow.ContentRendered += (_, __) => @@ -109,8 +114,22 @@ namespace Tango.MachineStudio.UI.StudioApplication if (e == Transport.TransportComponentState.Disconnected || e == Transport.TransportComponentState.Failed) { ConnectedMachine = null; - } + if (e == Transport.TransportComponentState.Failed) + { + String failed_reason = (sender as IMachineOperator).FailedStateException.Message; + + ConnectionLostViewVM vm = new ConnectionLostViewVM() + { + Exception = failed_reason + }; + + InvokeUI(() => + { + _notification.ShowModalDialog<ConnectionLostViewVM, ConnectionLostView>(vm, (x) => { }, () => { }); + }); + } + } } /// <summary> 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 003a7f194..39f748ceb 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 @@ -171,6 +171,7 @@ <Compile Include="Threading\DefaultDispatcherProvider.cs" /> <Compile Include="ViewModels\AboutViewVM.cs" /> <Compile Include="ViewModels\ConnectedMachineViewVM.cs" /> + <Compile Include="ViewModels\ConnectionLostViewVM.cs" /> <Compile Include="ViewModels\LoadingViewVM.cs" /> <Compile Include="ViewModels\LoginViewVM.cs" /> <Compile Include="ViewModels\MachineConnectionViewVM.cs" /> @@ -189,6 +190,9 @@ <Compile Include="Views\ConnectedMachineView.xaml.cs"> <DependentUpon>ConnectedMachineView.xaml</DependentUpon> </Compile> + <Compile Include="Views\ConnectionLostView.xaml.cs"> + <DependentUpon>ConnectionLostView.xaml</DependentUpon> + </Compile> <Compile Include="Views\LoadingView.xaml.cs"> <DependentUpon>LoadingView.xaml</DependentUpon> </Compile> @@ -269,6 +273,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\ConnectionLostView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Views\LoadingView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -583,7 +591,7 @@ copy /Y "$(SolutionDir)Referenced Assemblies\Microsoft.WITDataStore32.dll" "$(Ta </Target> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_UseGlobalSettings="False" BuildVersion_DetectChanges="True" BuildVersion_UpdateFileVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.DeltaBaseYearDayOfYear" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_BuildVersioningStyle="None.None.Increment.DeltaBaseYearDayOfYear" BuildVersion_UpdateFileVersion="True" BuildVersion_DetectChanges="True" BuildVersion_UseGlobalSettings="False" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectionLostViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectionLostViewVM.cs new file mode 100644 index 000000000..f1f4f69c0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectionLostViewVM.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; + +namespace Tango.MachineStudio.UI.ViewModels +{ + public class ConnectionLostViewVM : DialogViewVM + { + public String Exception { get; set; } + } +} 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 4e3de9e60..b1502f374 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml @@ -12,7 +12,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views" mc:Ignorable="d" - d:DesignHeight="300" d:DesignWidth="300" Width="600" Height="440" Background="White" DataContext="{Binding ConnectedMachineViewVM, Source={StaticResource Locator}}"> + d:DesignHeight="300" d:DesignWidth="300" Width="600" Height="480" Background="White" DataContext="{Binding ConnectedMachineViewVM, Source={StaticResource Locator}}"> <UserControl.Resources> <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"></converters:BooleanToVisibilityConverter> @@ -138,6 +138,8 @@ <ToggleButton IsChecked="{Binding EnableDiagnostics}" HorizontalAlignment="Left"></ToggleButton> <TextBlock FontWeight="SemiBold" Text="Enable Embedded Debug Logs:" /> <ToggleButton IsChecked="{Binding EnableEmbeddedDebugging}" HorizontalAlignment="Left"></ToggleButton> + <TextBlock FontWeight="SemiBold" Text="Enable KeepAlive:" /> + <ToggleButton IsChecked="{Binding UseKeepAlive}" HorizontalAlignment="Left"></ToggleButton> <TextBlock FontWeight="SemiBold" Text="Enable Events:" /> <ToggleButton IsChecked="{Binding EnableEventsNotification}" HorizontalAlignment="Left"></ToggleButton> </controls:TableGrid> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectionLostView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectionLostView.xaml new file mode 100644 index 000000000..bac704fe0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectionLostView.xaml @@ -0,0 +1,58 @@ +<UserControl x:Class="Tango.MachineStudio.UI.Views.ConnectionLostView" + 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:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:vm="clr-namespace:Tango.MachineStudio.UI.ViewModels" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views" + mc:Ignorable="d" + Width="559" Height="266" Background="White" d:DataContext="{d:DesignInstance Type=vm:ConnectionLostViewVM, IsDesignTimeCreatable=False}"> + <Grid> + <Grid> + <Grid.RowDefinitions> + <RowDefinition Height="80"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + + <Grid> + <StackPanel Orientation="Horizontal" Margin="10"> + <Grid> + <Image Source="/Images/machine-trans.png" RenderOptions.BitmapScalingMode="Fant"></Image> + + <Ellipse Fill="#FF2626" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="30" Height="30" Margin="0 0 -5 -5"> + </Ellipse> + <materialDesign:PackIcon Foreground="White" Kind="LanDisconnect" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="20" Height="20" Margin="0 0 0 0" /> + </Grid> + <TextBlock Text="Connection Lost" VerticalAlignment="Center" Margin="10 0 0 0" FontSize="20"></TextBlock> + </StackPanel> + </Grid> + + <Grid Grid.Row="1" Margin="10 0 10 10"> + <Grid.RowDefinitions> + <RowDefinition Height="1*"/> + <RowDefinition Height="50"/> + </Grid.RowDefinitions> + + <Grid> + <StackPanel Margin="0 10 0 0" > + <TextBlock TextWrapping="Wrap"> + <Run>The machine connection has entered an invalid or inactive state and will be regarded as.</Run> + <LineBreak/> + <Run>disconnected.</Run> + </TextBlock> + + <TextBlock Margin="0 20 0 0" FontWeight="SemiBold">Reason:</TextBlock> + <TextBlock Foreground="Gray" Margin="0 2 0 0" Text="{Binding Exception}" Height="75" TextWrapping="Wrap" TextTrimming="CharacterEllipsis"> + + </TextBlock> + </StackPanel> + </Grid> + + <Grid Grid.Row="1"> + <Button HorizontalAlignment="Right" Width="140" Command="{Binding OKCommand}">CLOSE</Button> + </Grid> + </Grid> + </Grid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectionLostView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectionLostView.xaml.cs new file mode 100644 index 000000000..50f0429a4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectionLostView.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 ConnectionLostView.xaml + /// </summary> + public partial class ConnectionLostView : UserControl + { + public ConnectionLostView() + { + InitializeComponent(); + } + } +} |
