diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-11-13 22:04:35 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-11-13 22:04:35 +0200 |
| commit | 9171be1942bf2368dd9e408e6a51a3c667056ec9 (patch) | |
| tree | c2d686e384ef59e4dd2c625f23d4f0e882bd635c /Software/Visual_Studio | |
| parent | e76eb4aa4d7e4c4762995144765b5ee6e9532961 (diff) | |
| parent | 8651169fac81e34685f52f8bb9147115f7ac8765 (diff) | |
| download | Tango-9171be1942bf2368dd9e408e6a51a3c667056ec9.tar.gz Tango-9171be1942bf2368dd9e408e6a51a3c667056ec9.zip | |
MERGED FSE configuration to master.
Diffstat (limited to 'Software/Visual_Studio')
117 files changed, 5785 insertions, 122 deletions
diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Firmware/Tango.FSE.Firmware_0qifchtm_wpftmp.csproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Firmware/Tango.FSE.Firmware_0qifchtm_wpftmp.csproj new file mode 100644 index 000000000..8708fb9b0 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Firmware/Tango.FSE.Firmware_0qifchtm_wpftmp.csproj @@ -0,0 +1,203 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{7CB96D74-8B71-4A81-B4E1-6DE7BFCA6174}</ProjectGuid> + <OutputType>library</OutputType> + <RootNamespace>Tango.FSE.Firmware</RootNamespace> + <AssemblyName>Tango.FSE.Firmware</AssemblyName> + <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <WarningLevel>4</WarningLevel> + <Deterministic>true</Deterministic> + <NuGetPackageImportStamp> + </NuGetPackageImportStamp> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\..\..\Build\FSE\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>..\..\..\Build\FSE\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + </ItemGroup> + <ItemGroup> + <Compile Include="Contracts\ILogsView.cs" /> + <Compile Include="Dialogs\FirmwareUpdateView.xaml.cs"> + <DependentUpon>FirmwareUpdateView.xaml</DependentUpon> + </Compile> + <Compile Include="Dialogs\FirmwareUpdateViewVM.cs" /> + <Compile Include="Navigation\PeekLogsNavigationObject.cs" /> + <Compile Include="ViewModelLocator.cs" /> + <Compile Include="FirmwareModule.cs" /> + <Compile Include="ViewModels\FileSystemViewVM.cs" /> + <Compile Include="ViewModels\LogsViewVM.cs" /> + <Compile Include="ViewModels\MainViewVM.cs" /> + <Compile Include="ViewModels\UpdatesViewVM.cs" /> + <Compile Include="Views\FileSystemView.xaml.cs"> + <DependentUpon>FileSystemView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\LogsView.xaml.cs"> + <DependentUpon>LogsView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\MainView.xaml.cs"> + <DependentUpon>MainView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\UpdatesView.xaml.cs"> + <DependentUpon>UpdatesView.xaml</DependentUpon> + </Compile> + </ItemGroup> + <ItemGroup> + <Compile Include="Properties\AssemblyInfo.cs"> + <SubType>Code</SubType> + </Compile> + <Compile Include="Properties\Resources.Designer.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>Resources.resx</DependentUpon> + </Compile> + <Compile Include="Properties\Settings.Designer.cs"> + <AutoGen>True</AutoGen> + <DependentUpon>Settings.settings</DependentUpon> + <DesignTimeSharedInput>True</DesignTimeSharedInput> + </Compile> + <EmbeddedResource Include="Properties\Resources.resx"> + <Generator>ResXFileCodeGenerator</Generator> + <LastGenOutput>Resources.Designer.cs</LastGenOutput> + </EmbeddedResource> + <None Include="app.config" /> + <None Include="packages.config" /> + <None Include="Properties\Settings.settings"> + <Generator>SettingsSingleFileGenerator</Generator> + <LastGenOutput>Settings.Designer.cs</LastGenOutput> + </None> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\..\PPC\Tango.PPC.Shared\Tango.PPC.Shared.csproj"> + <Project>{208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}</Project> + <Name>Tango.PPC.Shared</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\SideChains\Tango.AutoComplete\Tango.AutoComplete.csproj"> + <Project>{bb2abb74-ba58-4812-83aa-ec8171f42df4}</Project> + <Name>Tango.AutoComplete</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.BL\Tango.BL.csproj"> + <Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project> + <Name>Tango.BL</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Core\Tango.Core.csproj"> + <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> + <Name>Tango.Core</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.FileSystem\Tango.FileSystem.csproj"> + <Project>{c6ebbbbe-2123-44dc-aef7-a0d47d736ac0}</Project> + <Name>Tango.FileSystem</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Integration\Tango.Integration.csproj"> + <Project>{4206ac58-3b57-4699-8835-90bf6db01a61}</Project> + <Name>Tango.Integration</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Logging\Tango.Logging.csproj"> + <Project>{bc932dbd-7cdb-488c-99e4-f02cf441f55e}</Project> + <Name>Tango.Logging</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.PMR\Tango.PMR.csproj"> + <Project>{e4927038-348d-4295-aaf4-861c58cb3943}</Project> + <Name>Tango.PMR</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Settings\Tango.Settings.csproj"> + <Project>{d8f1ad85-526a-4f50-b6dc-d437af63d8d8}</Project> + <Name>Tango.Settings</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.SharedUI\Tango.SharedUI.csproj"> + <Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project> + <Name>Tango.SharedUI</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Transport\Tango.Transport.csproj"> + <Project>{74e700b0-1156-4126-be40-ee450d3c3026}</Project> + <Name>Tango.Transport</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.FSE.BL\Tango.FSE.BL.csproj"> + <Project>{834c81c3-09b5-45d7-be12-e7d1e6655a7c}</Project> + <Name>Tango.FSE.BL</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.FSE.Common\Tango.FSE.Common.csproj"> + <Project>{bc37cccb-7392-4f78-8d1c-e9629e6e046e}</Project> + <Name>Tango.FSE.Common</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + </ItemGroup> + <ItemGroup> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <Import Project="..\..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets" Condition="Exists('..\..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets')" /> + <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> + <PropertyGroup> + <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> + </PropertyGroup> + <Error Condition="!Exists('..\..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets'))" /> + </Target> + <ItemGroup> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\packages\ControlzEx.3.0.2.4\lib\net45\ControlzEx.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\packages\MahApps.Metro.1.6.5\lib\net46\MahApps.Metro.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\packages\MaterialDesignColors.1.2.2\lib\net45\MaterialDesignColors.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\packages\MaterialDesignThemes.3.0.1\lib\net45\MaterialDesignThemes.Wpf.dll" /> + <ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Microsoft.CSharp.dll" /> + <ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\mscorlib.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll" /> + <ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\PresentationCore.dll" /> + <ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\PresentationFramework.dll" /> + <ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.ComponentModel.DataAnnotations.dll" /> + <ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Core.dll" /> + <ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Data.DataSetExtensions.dll" /> + <ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Data.dll" /> + <ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.dll" /> + <ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Net.Http.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\packages\ControlzEx.3.0.2.4\lib\net45\System.Windows.Interactivity.dll" /> + <ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Xaml.dll" /> + <ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Xml.dll" /> + <ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Xml.Linq.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\SideChains\Tango.AutoComplete\bin\Debug\Tango.AutoComplete.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\Build\Core\Debug\Tango.BL.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\Build\Core\Debug\Tango.Core.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\Tango.FileSystem\bin\Debug\Tango.FileSystem.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\Build\FSE\Debug\Tango.FSE.BL.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\Build\FSE\Debug\Tango.FSE.Common.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\Build\Core\Debug\Tango.Integration.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\Build\Core\Debug\Tango.Logging.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\Build\Core\Debug\Tango.PMR.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\Build\PPC\Debug\Tango.PPC.Shared.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\Build\Core\Debug\Tango.Settings.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\Build\Core\Debug\Tango.SharedUI.dll" /> + <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\Build\Core\Debug\Tango.Transport.dll" /> + <ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\WindowsBase.dll" /> + </ItemGroup> + <ItemGroup> + <Compile Include="C:\DATA\Development\Tango\Software\Visual_Studio\FSE\Modules\Tango.FSE.Firmware\obj\Debug\App.g.cs" /> + <Compile Include="C:\DATA\Development\Tango\Software\Visual_Studio\FSE\Modules\Tango.FSE.Firmware\obj\Debug\Dialogs\FirmwareUpdateView.g.cs" /> + <Compile Include="C:\DATA\Development\Tango\Software\Visual_Studio\FSE\Modules\Tango.FSE.Firmware\obj\Debug\Views\FileSystemView.g.cs" /> + <Compile Include="C:\DATA\Development\Tango\Software\Visual_Studio\FSE\Modules\Tango.FSE.Firmware\obj\Debug\Views\LogsView.g.cs" /> + <Compile Include="C:\DATA\Development\Tango\Software\Visual_Studio\FSE\Modules\Tango.FSE.Firmware\obj\Debug\Views\MainView.g.cs" /> + <Compile Include="C:\DATA\Development\Tango\Software\Visual_Studio\FSE\Modules\Tango.FSE.Firmware\obj\Debug\Views\UpdatesView.g.cs" /> + <Compile Include="C:\DATA\Development\Tango\Software\Visual_Studio\FSE\Modules\Tango.FSE.Firmware\obj\Debug\GeneratedInternalTypeHelper.g.cs" /> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/App.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/App.xaml new file mode 100644 index 000000000..28a976e78 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/App.xaml @@ -0,0 +1,16 @@ +<Application x:Class="Tango.FSE.MachineConfiguration.App" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> + <Application.Resources> + <ResourceDictionary> + <ResourceDictionary.MergedDictionaries> + <ResourceDictionary Source="pack://application:,,,/Tango.FSE.Common;component/Resources/Converters.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.FSE.Common;component/Resources/Colors.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.FSE.Common;component/Resources/Fonts.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.FSE.Common;component/Resources/Images.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.FSE.Common;component/Resources/Styles.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.FSE.Common;component/Resources/Controls.xaml" /> + </ResourceDictionary.MergedDictionaries> + </ResourceDictionary> + </Application.Resources> +</Application>
\ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ConfigurationModule.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ConfigurationModule.cs new file mode 100644 index 000000000..2f2c0dbb1 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ConfigurationModule.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media.Imaging; +using Tango.BL.Enumerations; +using Tango.FSE.Common; +using Tango.FSE.MachineConfiguration.Views; + +namespace Tango.FSE.MachineConfiguration +{ + [FSEModule(index: 7)] + public class ConfigurationModule : FSEModuleBase + { + public override string Name { get; } = "Configuration"; + public override string Description { get; } = "Configuration Module"; + public override Type MainViewType { get; } = typeof(MainView); + public override Permissions Permission { get; } = Permissions.FSE_RunFSE; + + public override void Dispose() + { + + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ConfigurationViewModel.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ConfigurationViewModel.cs new file mode 100644 index 000000000..bfcc60bcf --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ConfigurationViewModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.FSE.Common.Navigation; +using Tango.FSE.MachineConfiguration.Navigation; + +namespace Tango.FSE.MachineConfiguration +{ + public class ConfigurationViewModel : ModularNavigationFSEViewModel<ConfigurationView> + { + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Converters/DataStoreValueToStringConverter.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Converters/DataStoreValueToStringConverter.cs new file mode 100644 index 000000000..4acf7fd8e --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Converters/DataStoreValueToStringConverter.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.DataStore; + +namespace Tango.FSE.MachineConfiguration.Converters +{ + public class DataStoreValueToStringConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is IDataStoreItem item) + { + if (item != null) + { + return DataStoreHelper.FormatDataStoreItem(item).ToOneLine().Ellipsis(100); + } + } + + return value; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogView.xaml new file mode 100644 index 000000000..2fd3b9cdf --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogView.xaml @@ -0,0 +1,53 @@ +<UserControl x:Class="Tango.FSE.MachineConfiguration.Dialogs.DataStoreItemEditDialogView" + 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:material="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:local="clr-namespace:Tango.FSE.MachineConfiguration.Dialogs" + xmlns:controls="clr-namespace:Tango.FSE.Common.Controls;assembly=Tango.FSE.Common" + xmlns:sharedControls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:datastore="clr-namespace:Tango.DataStore;assembly=Tango.DataStore" + xmlns:pmr="clr-namespace:Tango.PMR.Common;assembly=Tango.PMR" + mc:Ignorable="d" + Width="400" Height="500" d:DataContext="{d:DesignInstance Type=local:DataStoreItemEditDialogViewVM, IsDesignTimeCreatable=False}" Background="{StaticResource FSE_PrimaryBackgroundLightBrush}" Foreground="{StaticResource FSE_PrimaryForegroundBrush}"> + <Grid Margin="10"> + <DockPanel> + <StackPanel DockPanel.Dock="Top" > + <StackPanel Orientation="Horizontal"> + <material:PackIcon Width="40" Height="40" Kind="Key" /> + <TextBlock Margin="10 0 0 0" FontSize="{StaticResource FSE_LargerFontSize}" VerticalAlignment="Center" Text="{Binding Item.Key}"></TextBlock> + </StackPanel> + </StackPanel> + + <StackPanel Margin="0 10 0 0" DockPanel.Dock="Top"> + <TextBlock FontSize="{StaticResource FSE_SmallerFontSize}" Foreground="{StaticResource FSE_GrayBrush}">Data Type</TextBlock> + + <DockPanel> + <Button Visibility="{Binding Type,Converter={StaticResource EnumToVisibilityConverter},ConverterParameter='Proto'}" DockPanel.Dock="Right" Style="{StaticResource FSE_RaisedButton_Dark_Hover_Accent_Foreground}" Margin="5 5 0 0" Padding="10 0" FontSize="{StaticResource FSE_SmallFontSize}" Height="20" VerticalAlignment="Center" Command="{Binding InitProtoCommand}" ToolTip="Create the basic structure for this proto message">Init</Button> + <Button Visibility="{Binding Type,Converter={StaticResource EnumToVisibilityConverter},ConverterParameter='Bytes'}" DockPanel.Dock="Right" Style="{StaticResource FSE_RaisedButton_Dark_Hover_Accent_Foreground}" Margin="5 5 0 0" Padding="10 0" FontSize="{StaticResource FSE_SmallFontSize}" Height="20" VerticalAlignment="Center" Command="{Binding LoadFileCommand}" ToolTip="Load bytes from file">Load File</Button> + <controls:FSERoundedCornersComboBox IsEnabled="{Binding EnableTypeChange}" FontSize="{StaticResource FSE_SmallFontSize}" Margin="0 5 0 0" ItemsSource="{Binding Source={x:Type datastore:DataType},Converter={StaticResource EnumToItemsSourceConverter}}" SelectedValue="{Binding Type,Mode=TwoWay}" SelectedValuePath="Value" DisplayMemberPath="DisplayName"></controls:FSERoundedCornersComboBox> + </DockPanel> + + <StackPanel Margin="0 10 0 0" Visibility="{Binding Type,Converter={StaticResource EnumToVisibilityConverter},ConverterParameter='Proto'}"> + <TextBlock Foreground="{StaticResource FSE_GrayBrush}" FontSize="{StaticResource FSE_SmallerFontSize}">Message Type</TextBlock> + <sharedControls:SearchComboBox IsEnabled="{Binding EnableTypeChange}" FontSize="{StaticResource FSE_SmallFontSize}" Margin="0 -5 5 0" ItemsSource="{Binding Source={x:Type pmr:MessageType},Converter={StaticResource EnumToItemsSourceConverter},ConverterParameter='false'}" SelectedItem="{Binding ProtoMessageType,Mode=TwoWay}"></sharedControls:SearchComboBox> + </StackPanel> + </StackPanel> + + <DockPanel DockPanel.Dock="Bottom" Margin="0 5 0 0" MinHeight="15"> + <DockPanel Visibility="{Binding HasError,Converter={StaticResource BooleanToVisibilityConverter}}"> + <material:PackIcon Margin="0 0 0 0" VerticalAlignment="Top" Kind="Alert" Foreground="{StaticResource FSE_ErrorBrush}" Width="12" Height="12" /> + <TextBlock Foreground="{StaticResource FSE_ErrorBrush}" Margin="5 0 0 0" Text="{Binding Error}" FontSize="{StaticResource FSE_SmallerFontSize}" TextWrapping="Wrap"></TextBlock> + </DockPanel> + </DockPanel> + + <Grid Margin="0 10 0 0"> + <TextBox Style="{StaticResource FSE_Rounded_Corners_TextBox_Multiline}" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" TextWrapping="NoWrap" Background="{StaticResource FSE_PrimaryBackgroundDarkBrush}" FontSize="{StaticResource FSE_SmallFontSize}" Text="{Binding EditingValue,UpdateSourceTrigger=PropertyChanged}"> + + </TextBox> + </Grid> + + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogView.xaml.cs new file mode 100644 index 000000000..b0f741759 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogView.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.FSE.MachineConfiguration.Dialogs +{ + /// <summary> + /// Interaction logic for DataStoreItemEditDialogView.xaml + /// </summary> + public partial class DataStoreItemEditDialogView : UserControl + { + public DataStoreItemEditDialogView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogViewVM.cs new file mode 100644 index 000000000..29ec03942 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/DataStoreItemEditDialogViewVM.cs @@ -0,0 +1,173 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.Core.DI; +using Tango.Core.ExtensionMethods; +using Tango.Core.Helpers; +using Tango.DataStore; +using Tango.DataStore.Editing; +using Tango.FSE.Common; +using Tango.FSE.Common.Storage; +using Tango.PMR; +using Tango.PMR.Common; + +namespace Tango.FSE.MachineConfiguration.Dialogs +{ + public class DataStoreItemEditDialogViewVM : FSEDialogViewVM + { + private const int MAX_FILE_SIZE_KB = 100; + + [TangoInject] + private IStorageProvider StorageProvider { get; set; } + + [TangoInject] + private Common.Notifications.INotificationProvider NotificationProvider { get; set; } + + private DataStoreItemModel _item; + public DataStoreItemModel Item + { + get { return _item; } + set + { + _item = value; + RaisePropertyChangedAuto(); + + if (_item.IsGlobal) + { + Value = _item.GlobalItem.Value; + } + else + { + Value = _item.Value; + } + + Type = _item.Type; + + if (Type == DataType.Proto) + { + ProtoMessageType = (Value as DataStoreProtoObject).MessageType; + } + + if (_item.IsGlobal) + { + EditingValue = _item.GlobalItem.ToString(); + } + else + { + EditingValue = _item.ToString(); + } + } + } + + public bool EnableTypeChange { get; set; } + + private Object _value; + public Object Value + { + get { return _value; } + set { _value = value; RaisePropertyChangedAuto(); } + } + + private DataType _type; + public DataType Type + { + get { return _type; } + set { _type = value; RaisePropertyChangedAuto(); OnEditingValueChanged(); } + } + + private MessageType _protoMessageType; + public MessageType ProtoMessageType + { + get { return _protoMessageType; } + set { _protoMessageType = value; RaisePropertyChangedAuto(); OnEditingValueChanged(); } + } + + private String _editingValue; + public String EditingValue + { + get { return _editingValue; } + set { _editingValue = value; RaisePropertyChangedAuto(); OnEditingValueChanged(); } + } + + private String _error; + public String Error + { + get { return _error; } + set { _error = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(HasError)); InvalidateRelayCommands(); } + } + + public bool HasError + { + get { return Error != null; } + } + + public RelayCommand LoadFileCommand { get; set; } + + public RelayCommand InitProtoCommand { get; set; } + + public DataStoreItemEditDialogViewVM() + { + EnableTypeChange = true; + LoadFileCommand = new RelayCommand(LoadFile); + InitProtoCommand = new RelayCommand(InitProto); + TangoIOC.Default.Inject(this); + } + + private void InitProto() + { + if (Type == DataType.Proto) + { + var type = MessageFactory.GetPMRTypeFromMessageType(ProtoMessageType); + var instance = Activator.CreateInstance(type); + EditingValue = instance.ToJsonString(); + } + } + + private async void LoadFile() + { + if (Type == DataType.Bytes) + { + var result = await StorageProvider.OpenFile("Load a file"); + if (result) + { + if ((new FileInfo(result.SelectedItem).Length / 1024) > MAX_FILE_SIZE_KB) + { + await NotificationProvider.ShowError($"The selected file size exceeds the maximum {MAX_FILE_SIZE_KB}kb allowed."); + return; + } + + var bytes = File.ReadAllBytes(result.SelectedItem); + Value = bytes; + _editingValue = DataStoreHelper.GetByteArrayHexString(bytes); + RaisePropertyChanged(nameof(EditingValue)); + } + } + } + + private void OnEditingValueChanged() + { + if (EditingValue != null) + { + try + { + Value = DataStoreHelper.ParseDataStoreValue(Type, EditingValue, ProtoMessageType); + Error = null; + } + catch (Exception ex) + { + Error = ex.Message; + } + } + } + + protected override bool CanOK() + { + return base.CanOK() && !HasError; + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ExportDialogView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ExportDialogView.xaml new file mode 100644 index 000000000..55d0efc4f --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ExportDialogView.xaml @@ -0,0 +1,114 @@ +<UserControl x:Class="Tango.FSE.MachineConfiguration.Dialogs.ExportDialogView" + 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:material="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:controls="clr-namespace:Tango.FSE.Common.Controls;assembly=Tango.FSE.Common" + xmlns:local="clr-namespace:Tango.FSE.MachineConfiguration.Dialogs" + mc:Ignorable="d" + Width="800" Height="500" d:DataContext="{d:DesignInstance Type=local:ExportDialogViewVM, IsDesignTimeCreatable=False}" Background="{StaticResource FSE_PrimaryBackgroundLightBrush}" Foreground="{StaticResource FSE_PrimaryForegroundBrush}"> + <Grid Margin="10"> + <DockPanel> + <StackPanel DockPanel.Dock="Top" > + <StackPanel Orientation="Horizontal"> + <material:PackIcon Width="40" Height="40" Kind="Export" /> + <TextBlock Margin="10 0 0 0" FontSize="{StaticResource FSE_LargerFontSize}" VerticalAlignment="Center" Text="Export Data Store"></TextBlock> + </StackPanel> + </StackPanel> + + <DockPanel Margin="0 10 0 0"> + <Border Padding="5" MinWidth="100" BorderBrush="{StaticResource FSE_PrimaryBackgroundLightBrush}" BorderThickness="1" CornerRadius="3" Background="{StaticResource FSE_PrimaryBackgroundDarkBrush}"> + <ListBox x:Name="listCollections" ItemsSource="{Binding DataStore.Collections}" SelectedIndex="0"> + <ListBox.ItemTemplate> + <DataTemplate> + <DockPanel> + <CheckBox IsChecked="{Binding IsSelected}" /> + <TextBlock Margin="10 0 0 0" Text="{Binding Name}"></TextBlock> + </DockPanel> + </DataTemplate> + </ListBox.ItemTemplate> + </ListBox> + </Border> + + <Border Margin="5 0 0 0" Padding="5" MinWidth="100" BorderBrush="{StaticResource FSE_PrimaryBackgroundLightBrush}" BorderThickness="1" CornerRadius="3" Background="{StaticResource FSE_PrimaryBackgroundDarkBrush}"> + <DataGrid IsReadOnly="True" AutoGenerateColumns="False" Style="{StaticResource FSE_DataGrid}" CellStyle="{StaticResource FSE_DataGrid_Cell}" CanUserReorderColumns="False" CanUserSortColumns="False" ItemsSource="{Binding ElementName=listCollections,Path=SelectedItem.Items}"> + <DataGrid.Columns> + <DataGridTemplateColumn> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <UniformGrid Columns="2"> + <CheckBox IsEnabled="{Binding IsGlobal,Converter={StaticResource BooleanInverseConverter}}" IsChecked="{Binding IsSelected,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> + <material:PackIcon Kind="Key" Width="32" /> + </UniformGrid> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="KEY" Width="Auto"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Text="{Binding Key}"></TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="TYPE" Width="Auto"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Text="{Binding Type}"> + <TextBlock.Style> + <Style TargetType="TextBlock"> + <Setter Property="Foreground" Value="{StaticResource FSE_PrimaryForegroundBrush}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding Type}" Value="Boolean"> + <Setter Property="Foreground" Value="#FF9BFF"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="Bytes"> + <Setter Property="Foreground" Value="#FFFBA3"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="Double"> + <Setter Property="Foreground" Value="#85B1FF"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="Float"> + <Setter Property="Foreground" Value="#FFDCB8"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="Int32"> + <Setter Property="Foreground" Value="#FF858D "></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="String"> + <Setter Property="Foreground" Value="#B9FFA5"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="Proto"> + <Setter Property="Foreground" Value="#A5FFF9"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="LOCAL" Width="1*"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Text="{Binding FormattedValue,Converter={StaticResource StringToOneLineConverter},ConverterParameter='100',Mode=OneWay}" Visibility="{Binding IsDeleted,Converter={StaticResource BooleanToVisibilityInverseConverter}}"> + <TextBlock.Style> + <Style TargetType="TextBlock"> + <Setter Property="FontWeight" Value="Normal"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding HasDifference}" Value="True"> + <Setter Property="FontWeight" Value="Bold"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + </DataGrid.Columns> + </DataGrid> + </Border> + </DockPanel> + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ExportDialogView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ExportDialogView.xaml.cs new file mode 100644 index 000000000..4ee37908c --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ExportDialogView.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.FSE.MachineConfiguration.Dialogs +{ + /// <summary> + /// Interaction logic for ImportDialogView.xaml + /// </summary> + public partial class ExportDialogView : UserControl + { + public ExportDialogView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ExportDialogViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ExportDialogViewVM.cs new file mode 100644 index 000000000..9f605c79e --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ExportDialogViewVM.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DataStore.Editing; +using Tango.FSE.Common; + +namespace Tango.FSE.MachineConfiguration.Dialogs +{ + public class ExportDialogViewVM : FSEDialogViewVM + { + public DataStoreModel DataStore { get; set; } + + public ExportDialogViewVM() + { + OKText = "EXPORT"; + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ImportDialogView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ImportDialogView.xaml new file mode 100644 index 000000000..5d9653eb4 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ImportDialogView.xaml @@ -0,0 +1,113 @@ +<UserControl x:Class="Tango.FSE.MachineConfiguration.Dialogs.ImportDialogView" + 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:material="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:local="clr-namespace:Tango.FSE.MachineConfiguration.Dialogs" + mc:Ignorable="d" + Width="800" Height="500" d:DataContext="{d:DesignInstance Type=local:ImportDialogViewVM, IsDesignTimeCreatable=False}" Background="{StaticResource FSE_PrimaryBackgroundLightBrush}" Foreground="{StaticResource FSE_PrimaryForegroundBrush}"> + <Grid Margin="10"> + <DockPanel> + <StackPanel DockPanel.Dock="Top" > + <StackPanel Orientation="Horizontal"> + <material:PackIcon Width="40" Height="40" Kind="Import" /> + <TextBlock Margin="10 0 0 0" FontSize="{StaticResource FSE_LargerFontSize}" VerticalAlignment="Center" Text="Import Data Store"></TextBlock> + </StackPanel> + </StackPanel> + + <DockPanel Margin="0 10 0 0"> + <Border Padding="5" MinWidth="100" BorderBrush="{StaticResource FSE_PrimaryBackgroundLightBrush}" BorderThickness="1" CornerRadius="3" Background="{StaticResource FSE_PrimaryBackgroundDarkBrush}"> + <ListBox x:Name="listCollections" ItemsSource="{Binding DataStore.Collections}" SelectedIndex="0"> + <ListBox.ItemTemplate> + <DataTemplate> + <DockPanel> + <CheckBox IsChecked="{Binding IsSelected}" /> + <TextBlock Margin="10 0 0 0" Text="{Binding Name}"></TextBlock> + </DockPanel> + </DataTemplate> + </ListBox.ItemTemplate> + </ListBox> + </Border> + + <Border Margin="5 0 0 0" Padding="5" MinWidth="100" BorderBrush="{StaticResource FSE_PrimaryBackgroundLightBrush}" BorderThickness="1" CornerRadius="3" Background="{StaticResource FSE_PrimaryBackgroundDarkBrush}"> + <DataGrid IsReadOnly="True" AutoGenerateColumns="False" Style="{StaticResource FSE_DataGrid}" CellStyle="{StaticResource FSE_DataGrid_Cell}" CanUserReorderColumns="False" CanUserSortColumns="False" ItemsSource="{Binding ElementName=listCollections,Path=SelectedItem.Items}"> + <DataGrid.Columns> + <DataGridTemplateColumn> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <UniformGrid Columns="2"> + <CheckBox IsEnabled="{Binding IsGlobal,Converter={StaticResource BooleanInverseConverter}}" IsChecked="{Binding IsSelected,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> + <material:PackIcon Kind="Key" Width="32" /> + </UniformGrid> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="KEY" Width="Auto"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Text="{Binding Key}"></TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="TYPE" Width="Auto"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Text="{Binding Type}"> + <TextBlock.Style> + <Style TargetType="TextBlock"> + <Setter Property="Foreground" Value="{StaticResource FSE_PrimaryForegroundBrush}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding Type}" Value="Boolean"> + <Setter Property="Foreground" Value="#FF9BFF"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="Bytes"> + <Setter Property="Foreground" Value="#FFFBA3"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="Double"> + <Setter Property="Foreground" Value="#85B1FF"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="Float"> + <Setter Property="Foreground" Value="#FFDCB8"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="Int32"> + <Setter Property="Foreground" Value="#FF858D "></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="String"> + <Setter Property="Foreground" Value="#B9FFA5"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="Proto"> + <Setter Property="Foreground" Value="#A5FFF9"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="LOCAL" Width="1*"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Text="{Binding FormattedValue,Converter={StaticResource StringToOneLineConverter},ConverterParameter='100',Mode=OneWay}" Visibility="{Binding IsDeleted,Converter={StaticResource BooleanToVisibilityInverseConverter}}"> + <TextBlock.Style> + <Style TargetType="TextBlock"> + <Setter Property="FontWeight" Value="Normal"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding HasDifference}" Value="True"> + <Setter Property="FontWeight" Value="Bold"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + </DataGrid.Columns> + </DataGrid> + </Border> + </DockPanel> + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ImportDialogView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ImportDialogView.xaml.cs new file mode 100644 index 000000000..bc729601f --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ImportDialogView.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.FSE.MachineConfiguration.Dialogs +{ + /// <summary> + /// Interaction logic for ImportDialogView.xaml + /// </summary> + public partial class ImportDialogView : UserControl + { + public ImportDialogView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ImportDialogViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ImportDialogViewVM.cs new file mode 100644 index 000000000..a4e53e85b --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Dialogs/ImportDialogViewVM.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DataStore.Editing; +using Tango.FSE.Common; + +namespace Tango.FSE.MachineConfiguration.Dialogs +{ + public class ImportDialogViewVM : FSEDialogViewVM + { + public DataStoreModel DataStore { get; set; } + + public ImportDialogViewVM() + { + OKText = "IMPORT"; + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Images/configuration.png b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Images/configuration.png Binary files differnew file mode 100644 index 000000000..f46a49d23 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Images/configuration.png diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Images/data_collection.png b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Images/data_collection.png Binary files differnew file mode 100644 index 000000000..95163a226 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Images/data_collection.png diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Messages/EditingCompositionLoadedMessage.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Messages/EditingCompositionLoadedMessage.cs new file mode 100644 index 000000000..b858c34e0 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Messages/EditingCompositionLoadedMessage.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.FSE.BL.Services; +using static Tango.FSE.BL.Services.MachineConfigurationService; + +namespace Tango.FSE.MachineConfiguration.Messages +{ + public class EditingCompositionLoadedMessage + { + public MachineEditingComposition EditingComposition { get; set; } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Models/CsvModel.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Models/CsvModel.cs new file mode 100644 index 000000000..1e12fda4b --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Models/CsvModel.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FSE.MachineConfiguration.Models +{ + public class CsvModel + { + public String Date { get; set; } + public String Collection { get; set; } + public String Key { get; set; } + public String Type { get; set; } + public String MessageType { get; set; } + public String Value { get; set; } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Navigation/ConfigurationNavigationManager.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Navigation/ConfigurationNavigationManager.cs new file mode 100644 index 000000000..c1dfdfda7 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Navigation/ConfigurationNavigationManager.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Tango.FSE.Common.Navigation; +using Tango.SharedUI.Controls; + +namespace Tango.FSE.MachineConfiguration.Navigation +{ + public class ConfigurationNavigationManager : ModularNavigationManager<ConfigurationView> + { + public ConfigurationNavigationManager(FrameworkElement navigationControlParent) : base(navigationControlParent) + { + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Navigation/ConfigurationView.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Navigation/ConfigurationView.cs new file mode 100644 index 000000000..187e44ac9 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Navigation/ConfigurationView.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FSE.MachineConfiguration.Navigation +{ + public enum ConfigurationView + { + SelectionView, + MachineView, + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/AssemblyInfo.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..027dd9516 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango.FSE.MachineConfiguration")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.FSE.MachineConfiguration")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file +//inside a <PropertyGroup>. For example, if you are using US english +//in your source files, set the <UICulture> to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Resources.Designer.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Resources.Designer.cs new file mode 100644 index 000000000..830d15d6a --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace Tango.FSE.MachineConfiguration.Properties +{ + + + /// <summary> + /// A strongly-typed resource class, for looking up localized strings, etc. + /// </summary> + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// <summary> + /// Returns the cached ResourceManager instance used by this class. + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.FSE.MachineConfiguration.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// <summary> + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Resources.resx b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Resources.resx @@ -0,0 +1,117 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root>
\ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Settings.Designer.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Settings.Designer.cs new file mode 100644 index 000000000..e41736026 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace Tango.FSE.MachineConfiguration.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Settings.settings b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Properties/Settings.settings @@ -0,0 +1,7 @@ +<?xml version='1.0' encoding='utf-8'?> +<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> + <Profiles> + <Profile Name="(Default)" /> + </Profiles> + <Settings /> +</SettingsFile>
\ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj new file mode 100644 index 000000000..db7b7d12d --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Tango.FSE.MachineConfiguration.csproj @@ -0,0 +1,266 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{15BCB5BB-731E-4E2D-AA28-75485050A8DC}</ProjectGuid> + <OutputType>library</OutputType> + <RootNamespace>Tango.FSE.MachineConfiguration</RootNamespace> + <AssemblyName>Tango.FSE.MachineConfiguration</AssemblyName> + <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <WarningLevel>4</WarningLevel> + <Deterministic>true</Deterministic> + <NuGetPackageImportStamp> + </NuGetPackageImportStamp> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\..\..\Build\FSE\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>..\..\..\Build\FSE\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="ControlzEx, Version=3.0.2.4, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\ControlzEx.3.0.2.4\lib\net45\ControlzEx.dll</HintPath> + </Reference> + <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath> + </Reference> + <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath> + </Reference> + <Reference Include="Google.Protobuf, Version=3.4.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll</HintPath> + </Reference> + <Reference Include="MahApps.Metro, Version=1.6.5.1, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\MahApps.Metro.1.6.5\lib\net46\MahApps.Metro.dll</HintPath> + </Reference> + <Reference Include="MaterialDesignColors, Version=1.2.2.920, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\MaterialDesignColors.1.2.2\lib\net45\MaterialDesignColors.dll</HintPath> + </Reference> + <Reference Include="MaterialDesignThemes.Wpf, Version=3.0.1.920, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\MaterialDesignThemes.3.0.1\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath> + </Reference> + <Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.ComponentModel.DataAnnotations" /> + <Reference Include="System.Data" /> + <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\ControlzEx.3.0.2.4\lib\net45\System.Windows.Interactivity.dll</HintPath> + </Reference> + <Reference Include="System.Xml" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Xaml"> + <RequiredTargetFramework>4.0</RequiredTargetFramework> + </Reference> + <Reference Include="WindowsBase" /> + <Reference Include="PresentationCore" /> + <Reference Include="PresentationFramework" /> + </ItemGroup> + <ItemGroup> + <Compile Include="ConfigurationViewModel.cs" /> + <Compile Include="Converters\DataStoreValueToStringConverter.cs" /> + <Compile Include="Dialogs\DataStoreItemEditDialogView.xaml.cs"> + <DependentUpon>DataStoreItemEditDialogView.xaml</DependentUpon> + </Compile> + <Compile Include="Dialogs\DataStoreItemEditDialogViewVM.cs" /> + <Compile Include="Dialogs\ExportDialogView.xaml.cs"> + <DependentUpon>ExportDialogView.xaml</DependentUpon> + </Compile> + <Compile Include="Dialogs\ImportDialogView.xaml.cs"> + <DependentUpon>ImportDialogView.xaml</DependentUpon> + </Compile> + <Compile Include="Dialogs\ExportDialogViewVM.cs" /> + <Compile Include="Dialogs\ImportDialogViewVM.cs" /> + <Compile Include="Messages\EditingCompositionLoadedMessage.cs" /> + <Compile Include="Models\CsvModel.cs" /> + <Compile Include="Navigation\ConfigurationNavigationManager.cs" /> + <Compile Include="Navigation\ConfigurationView.cs" /> + <Compile Include="ViewModelLocator.cs" /> + <Compile Include="ConfigurationModule.cs" /> + <Compile Include="ViewModels\ConfigurationViewVM.cs" /> + <Compile Include="ViewModels\DataStoreViewVM.cs" /> + <Compile Include="ViewModels\MachineViewVM.cs" /> + <Compile Include="ViewModels\MainViewVM.cs" /> + <Compile Include="ViewModels\SelectionViewVM.cs" /> + <Compile Include="Views\ConfigurationView.xaml.cs"> + <DependentUpon>ConfigurationView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\DataStoreView.xaml.cs"> + <DependentUpon>DataStoreView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\SelectionView.xaml.cs"> + <DependentUpon>SelectionView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\MachineView.xaml.cs"> + <DependentUpon>MachineView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\MainView.xaml.cs"> + <DependentUpon>MainView.xaml</DependentUpon> + </Compile> + </ItemGroup> + <ItemGroup> + <Compile Include="Properties\AssemblyInfo.cs"> + <SubType>Code</SubType> + </Compile> + <Compile Include="Properties\Resources.Designer.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>Resources.resx</DependentUpon> + </Compile> + <Compile Include="Properties\Settings.Designer.cs"> + <AutoGen>True</AutoGen> + <DependentUpon>Settings.settings</DependentUpon> + <DesignTimeSharedInput>True</DesignTimeSharedInput> + </Compile> + <EmbeddedResource Include="Properties\Resources.resx"> + <Generator>ResXFileCodeGenerator</Generator> + <LastGenOutput>Resources.Designer.cs</LastGenOutput> + </EmbeddedResource> + <None Include="app.config" /> + <None Include="packages.config" /> + <None Include="Properties\Settings.settings"> + <Generator>SettingsSingleFileGenerator</Generator> + <LastGenOutput>Settings.Designer.cs</LastGenOutput> + </None> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\..\SideChains\Tango.AutoComplete\Tango.AutoComplete.csproj"> + <Project>{bb2abb74-ba58-4812-83aa-ec8171f42df4}</Project> + <Name>Tango.AutoComplete</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.BL\Tango.BL.csproj"> + <Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project> + <Name>Tango.BL</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Core\Tango.Core.csproj"> + <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> + <Name>Tango.Core</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.CSV\Tango.CSV.csproj"> + <Project>{58e8825f-0c96-449c-b320-1e82b0aa876b}</Project> + <Name>Tango.CSV</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.DataStore.Editing\Tango.DataStore.Editing.csproj"> + <Project>{ee088ff7-04d1-41fb-9d6a-cedeee7a7b9c}</Project> + <Name>Tango.DataStore.Editing</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.DataStore.EF\Tango.DataStore.EF.csproj"> + <Project>{88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4}</Project> + <Name>Tango.DataStore.EF</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.DataStore.Remote\Tango.DataStore.Remote.csproj"> + <Project>{29448f3c-9b3e-4da6-8555-46a8b9a6b3aa}</Project> + <Name>Tango.DataStore.Remote</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.DataStore\Tango.DataStore.csproj"> + <Project>{e0364dfa-0721-4637-9d32-9d22aac109d6}</Project> + <Name>Tango.DataStore</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Integration\Tango.Integration.csproj"> + <Project>{4206ac58-3b57-4699-8835-90bf6db01a61}</Project> + <Name>Tango.Integration</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Logging\Tango.Logging.csproj"> + <Project>{bc932dbd-7cdb-488c-99e4-f02cf441f55e}</Project> + <Name>Tango.Logging</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.PMR\Tango.PMR.csproj"> + <Project>{e4927038-348d-4295-aaf4-861c58cb3943}</Project> + <Name>Tango.PMR</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Settings\Tango.Settings.csproj"> + <Project>{d8f1ad85-526a-4f50-b6dc-d437af63d8d8}</Project> + <Name>Tango.Settings</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.SharedUI\Tango.SharedUI.csproj"> + <Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project> + <Name>Tango.SharedUI</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Transport\Tango.Transport.csproj"> + <Project>{74e700b0-1156-4126-be40-ee450d3c3026}</Project> + <Name>Tango.Transport</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.FSE.BL\Tango.FSE.BL.csproj"> + <Project>{834c81c3-09b5-45d7-be12-e7d1e6655a7c}</Project> + <Name>Tango.FSE.BL</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.FSE.Common\Tango.FSE.Common.csproj"> + <Project>{bc37cccb-7392-4f78-8d1c-e9629e6e046e}</Project> + <Name>Tango.FSE.Common</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <Page Include="App.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Dialogs\DataStoreItemEditDialogView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="Dialogs\ExportDialogView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Dialogs\ImportDialogView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="Views\ConfigurationView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\DataStoreView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="Views\SelectionView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="Views\MachineView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="Views\MainView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\configuration.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\data_collection.png" /> + </ItemGroup> + <ItemGroup /> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <Import Project="..\..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets" Condition="Exists('..\..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets')" /> + <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> + <PropertyGroup> + <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> + </PropertyGroup> + <Error Condition="!Exists('..\..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets'))" /> + </Target> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModelLocator.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModelLocator.cs new file mode 100644 index 000000000..187565ca4 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModelLocator.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.DI; +using Tango.FSE.MachineConfiguration.Navigation; +using Tango.FSE.MachineConfiguration.ViewModels; +using Tango.FSE.MachineConfiguration.Views; + +namespace Tango.FSE.MachineConfiguration +{ + public static class ViewModelLocator + { + static ViewModelLocator() + { + TangoIOC.Default.Register<ConfigurationNavigationManager>(new ConfigurationNavigationManager(MainView.Instance)); + TangoIOC.Default.Register<MainViewVM>(); + TangoIOC.Default.Register<SelectionViewVM>(); + TangoIOC.Default.Register<MachineViewVM>(); + TangoIOC.Default.Register<ConfigurationViewVM>(); + TangoIOC.Default.Register<DataStoreViewVM>(); + } + + public static MainViewVM MainViewVM + { + get + { + return TangoIOC.Default.GetInstance<MainViewVM>(); + } + } + + public static SelectionViewVM SelectionViewVM + { + get + { + return TangoIOC.Default.GetInstance<SelectionViewVM>(); + } + } + + public static MachineViewVM MachineViewVM + { + get + { + return TangoIOC.Default.GetInstance<MachineViewVM>(); + } + } + + public static ConfigurationViewVM ConfigurationViewVM + { + get + { + return TangoIOC.Default.GetInstance<ConfigurationViewVM>(); + } + } + + public static DataStoreViewVM DataStoreViewVM + { + get + { + return TangoIOC.Default.GetInstance<DataStoreViewVM>(); + } + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/ConfigurationViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/ConfigurationViewVM.cs new file mode 100644 index 000000000..61eef2bdc --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/ConfigurationViewVM.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.Core.Commands; +using Tango.Core.DI; +using Tango.FSE.Common; +using Tango.FSE.Common.AutoComplete; +using Tango.FSE.Common.SQL; +using Tango.FSE.MachineConfiguration.Messages; +using static Tango.FSE.BL.Services.MachineConfigurationService; + +namespace Tango.FSE.MachineConfiguration.ViewModels +{ + public class ConfigurationViewVM : FSEViewModel + { + [TangoInject] + private IRemoteSqlProvider RemoteSqlProvider { get; set; } + + private MachineEditingComposition _editingComposition; + public MachineEditingComposition EditingComposition + { + get { return _editingComposition; } + set { _editingComposition = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand SaveCommand { get; set; } + public RelayCommand ResetCountersCommand { get; set; } + public RelayCommand ResetDeviceRegistrationCommand { get; set; } + + + public ConfigurationViewVM() + { + RegisterForMessage<EditingCompositionLoadedMessage>(OnEditingCompositionLoaded); + SaveCommand = new RelayCommand(SaveConfiguration); + ResetCountersCommand = new RelayCommand(ResetCounters); + ResetDeviceRegistrationCommand = new RelayCommand(ResetDeviceRegistration); + } + + private void OnEditingCompositionLoaded(EditingCompositionLoadedMessage msg) + { + using (NotificationProvider.PushTaskItem("Loading machine configuration...")) + { + EditingComposition = msg.EditingComposition; + EditingComposition.Machine.ForceVersionUpdateChanged += (x, value) => { if (value) EditingComposition.Machine.SuspendVersionUpdate = false; }; + EditingComposition.Machine.SuspendVersionUpdateChanged += (x, value) => { if (value) EditingComposition.Machine.ForceVersionUpdate = false; }; + } + } + + private async void SaveConfiguration() + { + using (NotificationProvider.PushTaskItem("Saving machine configuration...")) + { + EditingComposition = await Services.MachineConfigurationService.SaveMachineEditingComposition(EditingComposition); + await NotificationProvider.ShowSuccess("Machine configuration saved successfully."); + } + } + + private async void ResetCounters() + { + if (!MachineProvider.IsPPCAvailable) + { + await NotificationProvider.ShowError("Resetting the machine counters requires an active connection to this machine."); + return; + } + + if (!await NotificationProvider.ShowWarningQuestion("Resetting the machine counters will delete the entire job runs history. Are you sure?", "RESET COUNTERS", "CANCEL")) return; + + using (var task = NotificationProvider.PushTaskItem("Resetting machine counters...")) + { + task.UpdateProgress("Resetting local machine counters..."); + + var result = await RemoteSqlProvider.ExecuteSqlCommandAsync(new RemoteSqlCommand() + { + Mode = RemoteSqlCommandMode.Local, + Timeout = 30, + SQL = "DELETE FROM JOB_RUNS" + }); + + int localJobRuns = result.LocalAffectedRecords; + + task.UpdateProgress("Resetting global machine counters..."); + + int remoteJobRuns = await Services.MachineConfigurationService.ResetCounters(EditingComposition.Machine.Guid); + + await NotificationProvider.ShowSuccess("Machine counters deleted successfully."); + } + } + + private async void ResetDeviceRegistration() + { + if (!await NotificationProvider.ShowWarningQuestion("Resetting the machine's device registration will allow other panel PCs to perform a machine setup for this machine. Are you sure?", "RESET", "CANCEL")) return; + + EditingComposition.Machine.IsDeviceRegistered = false; + EditingComposition.Machine.DeviceId = null; + EditingComposition.Machine.DeviceName = null; + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs new file mode 100644 index 000000000..198f1bd9b --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs @@ -0,0 +1,465 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.Core.Commands; +using Tango.Core.DI; +using Tango.CSV; +using Tango.DataStore; +using Tango.DataStore.Editing; +using Tango.FSE.Common; +using Tango.FSE.Common.Connection; +using Tango.FSE.Common.DataStore; +using Tango.FSE.Common.Notifications; +using Tango.FSE.MachineConfiguration.Dialogs; +using Tango.FSE.MachineConfiguration.Messages; +using Tango.FSE.MachineConfiguration.Models; +using static Tango.FSE.BL.Services.MachineConfigurationService; +using static Tango.SharedUI.Controls.NavigationControl; + +namespace Tango.FSE.MachineConfiguration.ViewModels +{ + public class DataStoreViewVM : FSEViewModel, INavigationViewModel + { + private String _machineGuid; + private MachineEditingComposition _editingComposition; + private ICollectionView _selectedCollectionView; + private ICollectionView _collectionsView; + + [TangoInject] + public IDataStoreProvider DataStoreProvider { get; set; } + + private DataStoreModel _dataStore; + public DataStoreModel DataStore + { + get { return _dataStore; } + set { _dataStore = value; RaisePropertyChangedAuto(); } + } + + private DataStoreCollectionModel _selectedCollection; + public DataStoreCollectionModel SelectedCollection + { + get { return _selectedCollection; } + set { _selectedCollection = value; RaisePropertyChangedAuto(); OnSelectedCollectionChanged(); } + } + + private DataStoreItemModel _selectedItem; + public DataStoreItemModel SelectedItem + { + get { return _selectedItem; } + set { _selectedItem = value; RaisePropertyChangedAuto(); } + } + + private String _filter; + public String Filter + { + get { return _filter; } + set { _filter = value; RaisePropertyChangedAuto(); _selectedCollectionView?.Refresh(); } + } + + public bool CanSync + { + get { return MachineProvider.IsPPCAvailable && MachineProvider.Machine != null && _machineGuid == MachineProvider.Machine.Guid; } + } + + public RelayCommand<DataStoreItemModel> RemoveItemCommand { get; set; } + public RelayCommand<DataStoreCollectionModel> RemoveCollectionCommand { get; set; } + public RelayCommand AddItemCommand { get; set; } + public RelayCommand AddCollectionCommand { get; set; } + public RelayCommand<DataStoreItemModel> EditItemCommand { get; set; } + public RelayCommand SaveCommand { get; set; } + public RelayCommand ReloadCommand { get; set; } + public RelayCommand ImportCommand { get; set; } + public RelayCommand ExportCommand { get; set; } + + public DataStoreViewVM() + { + RegisterForMessage<EditingCompositionLoadedMessage>(OnEditingCompositionLoaded); + RemoveItemCommand = new RelayCommand<DataStoreItemModel>(RemoveItem); + RemoveCollectionCommand = new RelayCommand<DataStoreCollectionModel>(RemoveCollection); + AddItemCommand = new RelayCommand(AddItem); + AddCollectionCommand = new RelayCommand(AddCollection); + EditItemCommand = new RelayCommand<DataStoreItemModel>(EditItem); + SaveCommand = new RelayCommand(SaveModel); + ReloadCommand = new RelayCommand(ReloadDataStore); + ExportCommand = new RelayCommand(ExportDataStore); + ImportCommand = new RelayCommand(ImportDataStore); + } + + [TangoInject] + public DataStoreViewVM(IMachineProvider machineProvider) : this() + { + machineProvider.MachineConnected += (_, __) => RaisePropertyChanged(nameof(CanSync)); + machineProvider.MachineDisconnected += (_, __) => RaisePropertyChanged(nameof(CanSync)); + } + + private async void ReloadDataStore() + { + if (DataStore != null) + { + if (DataStore.Collections.SelectMany(x => x.Items).Any(x => x.HasDifference)) + { + if (!await NotificationProvider.ShowWarningQuestion("Reloading the data store will discard all the current changes. Are you sure?", "RELOAD")) + { + return; + } + } + } + + await LoadDataStore(); + } + + private async void EditItem(DataStoreItemModel item) + { + var vm = await NotificationProvider.ShowDialog<DataStoreItemEditDialogViewVM>(new DataStoreItemEditDialogViewVM() { Item = item, EnableTypeChange = !item.IsGlobal }); + + if (vm.DialogResult) + { + item.IsDeleted = false; + item.IsGlobal = false; + item.Type = vm.Type; + item.Value = vm.Value; + } + } + + private async void AddCollection() + { + var result = await NotificationProvider.ShowInputBox("Add Collection", "Please enter the collection name", MaterialDesignThemes.Wpf.PackIconKind.Collection, null, null, 20, null, null, (input) => + { + if (DataStore.Collections.ToList().Exists(x => x.Name.ToLower() == input.ToLower())) + { + return "The specified collection already exists."; + } + + return null; + }); + + if (result.Confirmed) + { + if (DataStore.Collections.ToList().Exists(x => x.Name.ToLower() == result.Input.ToLower())) + { + await NotificationProvider.ShowError("The specified collection already exists."); + AddCollection(); + return; + } + + DataStore.Collections.Add(new DataStoreCollectionModel() + { + Name = result.Input + }); + + SelectedCollection = DataStore.Collections.Last(); + } + } + + private async void AddItem() + { + var result = await NotificationProvider.ShowInputBox("Add Item", "Please enter the item key", MaterialDesignThemes.Wpf.PackIconKind.KeyAdd, null, null, 20, null, null, (input) => + { + if (SelectedCollection.Items.ToList().Exists(x => x.Key.ToLower() == input.ToLower())) + { + return "The specified key already exists in the collection."; + } + + return null; + }); + + if (result.Confirmed) + { + if (SelectedCollection.Items.ToList().Exists(x => x.Key == result.Input)) + { + await NotificationProvider.ShowError("The specified key already exists in the collection."); + AddItem(); + return; + } + + SelectedCollection.Items.Add(new DataStoreItemModel() + { + Date = DateTime.UtcNow, + Guid = Guid.NewGuid().ToString(), + Key = result.Input, + Type = DataType.Int32, + Value = 10 + }); + } + } + + private void RemoveCollection(DataStoreCollectionModel collection) + { + collection.IsDeleted = true; + _collectionsView?.Refresh(); + } + + private void RemoveItem(DataStoreItemModel item) + { + item.IsDeleted = true; + _selectedCollectionView.Refresh(); + } + + private void OnEditingCompositionLoaded(EditingCompositionLoadedMessage obj) + { + DataStore = null; + _editingComposition = obj.EditingComposition; + _machineGuid = obj.EditingComposition.Machine.Guid; + } + + private void OnSelectedCollectionChanged() + { + if (SelectedCollection != null) + { + _selectedCollectionView = CollectionViewSource.GetDefaultView(SelectedCollection.Items); + _selectedCollectionView.Filter = (x) => FilterItems(x as DataStoreItemModel); + _selectedCollectionView.Refresh(); + } + } + + private bool FilterItems(DataStoreItemModel itemModel) + { + return (!itemModel.IsDeleted || itemModel.GlobalItem != null) && (String.IsNullOrWhiteSpace(Filter) || itemModel.Key.ToLower().Contains(Filter.ToLower())); + } + + private async void SaveModel() + { + try + { + using (NotificationProvider.PushTaskItem("Updating data store...")) + { + await DataStoreProvider.UpdateDataStoreModel(DataStore, _machineGuid); + } + + if (MachineProvider.IsPPCAvailable) + { + await NotificationProvider.ShowSuccess("The connected machine is now synchronized with the data store."); + } + else + { + await NotificationProvider.ShowSuccess("Data store saved successfully.\nThe machine will be updated on the next synchronization pass."); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error saving data store."); + await NotificationProvider.ShowError($"Error occurred while trying to save the data store.\n{ex.FlattenMessage()}"); + return; + } + + await LoadDataStore(); + } + + private async Task LoadDataStore() + { + try + { + using (NotificationProvider.PushTaskItem("Loading data store...")) + { + IsFree = false; + RaisePropertyChanged(nameof(CanSync)); + + var dataStore = await DataStoreProvider.GetDataStoreModel(_machineGuid); + + _collectionsView = CollectionViewSource.GetDefaultView(dataStore.Collections); + _collectionsView.Filter = (x) => { return !(x as DataStoreCollectionModel).IsDeleted; }; + _collectionsView.Refresh(); + + DataStore = dataStore; + SelectedCollection = DataStore.Collections.FirstOrDefault(); + + IsFree = true; + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error loading data store."); + if (await NotificationProvider.ShowWarningQuestion($"Error occurred while trying to load the data store.\n{ex.FlattenMessage()}", "RETRY", "CANCEL")) + { + await LoadDataStore(); + return; + } + } + } + + public async override void OnNavigatedTo() + { + base.OnNavigatedTo(); + + if (DataStore == null) + { + await LoadDataStore(); + } + } + + private async void ImportDataStore() + { + var result = await StorageProvider.OpenFile("Import data store", "CSV Files|*.csv"); + + if (result) + { + try + { + DataStoreModel model = new DataStoreModel(); + + using (NotificationProvider.PushTaskItem("Analyzing file...")) + { + await Task.Delay(1000); + + await Task.Factory.StartNew(() => + { + var items = CsvFile.Read<CsvModel>(new CsvSource(result.SelectedItem)).ToList(); + + foreach (var collection in items.GroupBy(x => x.Collection)) + { + DataStoreCollectionModel collectionModel = new DataStoreCollectionModel(); + + collectionModel = new DataStoreCollectionModel(); + collectionModel.Name = collection.First().Collection; + collectionModel.IsSelected = true; + model.Collections.Add(collectionModel); + + foreach (var item in collection) + { + DataStoreItemModel itemModel = new DataStoreItemModel(); + itemModel.Guid = Guid.NewGuid().ToString(); + itemModel.Key = item.Key; + itemModel.Date = DateTime.Parse(item.Date); + itemModel.IsSelected = true; + + DataType type = (DataType)Enum.Parse(typeof(DataType), item.Type); + itemModel.OriginalType = type; + itemModel.Type = type; + + PMR.Common.MessageType? messageType = null; + if (type == DataType.Proto && item.MessageType.IsNotNullOrEmpty()) + { + messageType = (PMR.Common.MessageType)Enum.Parse(typeof(PMR.Common.MessageType), item.MessageType); + } + + itemModel.OriginalValue = DataStoreHelper.ParseDataStoreValue(type, item.Value, messageType); + itemModel.Value = itemModel.OriginalValue; + + collectionModel.Items.Add(itemModel); + } + } + }); + } + + var vm = await NotificationProvider.ShowDialog<ImportDialogViewVM>(new ImportDialogViewVM() { DataStore = model }); + + if (vm.DialogResult) + { + if (!vm.DataStore.Collections.SelectMany(x => x.Items).Any(x => x.IsSelected)) + { + await NotificationProvider.ShowInfo("No items selected to import."); + return; + } + + foreach (var collection in vm.DataStore.Collections.Where(x => x.Items.Any(y => y.IsSelected))) + { + var collectionModel = DataStore.Collections.FirstOrDefault(x => x.Name == collection.Name); + + if (collectionModel == null) + { + DataStore.Collections.Add(collection); + } + else + { + foreach (var item in collection.Items.Where(x => x.IsSelected)) + { + var itemModel = collectionModel.Items.FirstOrDefault(x => x.Key == item.Key); + + if (itemModel == null) + { + itemModel = new DataStoreItemModel(); + itemModel.Guid = item.Guid; + itemModel.Key = item.Key; + collectionModel.Items.Add(itemModel); + } + + itemModel.Date = DateTime.UtcNow; + itemModel.IsDeleted = false; + itemModel.IsGlobal = false; + itemModel.Type = item.Type; + itemModel.Value = item.Value; + } + } + } + + await NotificationProvider.ShowSuccess("Data store imported successfully."); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error importing data store."); + await NotificationProvider.ShowError($"Error importing the data store.\n{ex.FlattenMessage()}"); + } + } + } + + private async void ExportDataStore() + { + var vm = await NotificationProvider.ShowDialog<ExportDialogViewVM>(new ExportDialogViewVM() { DataStore = DataStore }); + + if (vm.DialogResult) + { + if (!vm.DataStore.Collections.SelectMany(x => x.Items).Any(x => x.IsSelected)) + { + await NotificationProvider.ShowInfo("No items selected to export."); + return; + } + + var result = await StorageProvider.SaveFile("Export data store", "CSV Files|*.csv", $"{_editingComposition.Machine.SerialNumber}_datastore_{DateTime.Now.ToFileName()}.csv", ".csv"); + + if (result) + { + try + { + using (NotificationProvider.PushTaskItem("Exporting data store...")) + { + await Task.Delay(1000); + + await Task.Factory.StartNew(() => + { + using (DynamicCsvFile csvFile = new DynamicCsvFile(result.SelectedItem)) + { + csvFile.Columns.Add(new DynamicCsvFileColumn() { Name = "Date" }); + csvFile.Columns.Add(new DynamicCsvFileColumn() { Name = "Collection" }); + csvFile.Columns.Add(new DynamicCsvFileColumn() { Name = "Key" }); + csvFile.Columns.Add(new DynamicCsvFileColumn() { Name = "Type" }); + csvFile.Columns.Add(new DynamicCsvFileColumn() { Name = "MessageType" }); + csvFile.Columns.Add(new DynamicCsvFileColumn() { Name = "Value" }); + + foreach (var collection in DataStore.Collections) + { + foreach (var item in collection.Items.Where(x => x.IsSelected && !x.IsGlobal && x.Value != null)) + { + PMR.Common.MessageType? messageType = null; + + if (item.Type == DataType.Proto) + { + messageType = (item.Value as DataStoreProtoObject).MessageType; + } + + csvFile.Append(item.Date, $"\"{collection.Name}\"", $"\"{item.Key}\"", item.Type, messageType.ToStringSafe(), $"\"{item.FormattedValue.Replace("\"", "\"\"")}\""); + } + } + } + }); + } + + NotificationProvider.PushSnackbarItem(MessageType.Success, "Export Data Store", true, "Data store exported successfully.", TimeSpan.FromSeconds(8), null, () => + { + StorageProvider.ShowInExplorer(result.SelectedItem); + }); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error exporting data store."); + await NotificationProvider.ShowError($"Error exporting the data store.\n{ex.FlattenMessage()}"); + } + } + } + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MachineViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MachineViewVM.cs new file mode 100644 index 000000000..24a0cbc42 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MachineViewVM.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.FSE.Common; +using Tango.FSE.Common.Navigation; +using Tango.FSE.MachineConfiguration.Messages; +using static Tango.FSE.BL.Services.MachineConfigurationService; +using static Tango.FSE.MachineConfiguration.ViewModels.MachineViewVM; + +namespace Tango.FSE.MachineConfiguration.ViewModels +{ + public class MachineViewVM : ConfigurationViewModel, INavigationObjectReceiver<NavigationObject> + { + public class NavigationObject + { + public String MachineGuid { get; set; } + } + + public enum NavigationView + { + ConfigurationView, + DataStoreView, + } + + private NavigationView _selectedView; + public NavigationView SelectedView + { + get { return _selectedView; } + set + { + _selectedView = value; + RaisePropertyChangedAuto(); + } + } + + private MachineEditingComposition _editingComposition; + public MachineEditingComposition EditingComposition + { + get { return _editingComposition; } + set { _editingComposition = value; RaisePropertyChangedAuto(); } + } + + public void OnNavigatedToWithObject(NavigationObject obj) + { + SelectedView = NavigationView.ConfigurationView; + LoadMachine(obj.MachineGuid); + } + + private async void LoadMachine(String machineGuid) + { + using (NotificationProvider.PushTaskItem("Loading machine configuration...")) + { + EditingComposition = await Services.MachineConfigurationService.GetMachineEditingComposition(machineGuid); + RaiseMessage(new EditingCompositionLoadedMessage() { EditingComposition = EditingComposition }); + } + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MainViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MainViewVM.cs new file mode 100644 index 000000000..5b8ca21ac --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/MainViewVM.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.FSE.Common; +using Tango.FSE.Common.Navigation; +using Tango.FSE.MachineConfiguration.Navigation; +using Tango.SharedUI.Helpers; + +namespace Tango.FSE.MachineConfiguration.ViewModels +{ + [ModularNavigationContainer] + public class MainViewVM : ConfigurationViewModel + { + public override void OnApplicationReady() + { + InvokeUI(() => + { + NavigationManager.MenuItems.Add(new NavigationMenuItem(() => + { + NavigationManager.NavigateTo<ConfigurationModule>(); + }) + { + Name = "Configuration", + Index = 8, + Description = "Access to the organization machines configuration and settings", + Image = ResourceHelper.GetImageFromResources("Images/configuration.png"), + }); + }); + } + + public async override Task<bool> OnApplicationLogout() + { + while (ModularNavigationManager.CurrentView != ConfigurationView.SelectionView) + { + if (!await ModularNavigationManager.NavigateBack()) + { + return false; + } + } + + return await base.OnApplicationLogout(); + } + + public async override Task<bool> OnNavigateBackRequest() + { + if (ModularNavigationManager.CurrentView == ConfigurationView.SelectionView) + { + return await base.OnNavigateBackRequest(); + } + else + { + await ModularNavigationManager.NavigateBack(); + return false; + } + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/SelectionViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/SelectionViewVM.cs new file mode 100644 index 000000000..b65ad7102 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/SelectionViewVM.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.Core.Commands; +using Tango.FSE.Common; +using Tango.FSE.MachineConfiguration.Navigation; + +namespace Tango.FSE.MachineConfiguration.ViewModels +{ + public class SelectionViewVM : ConfigurationViewModel + { + private Machine _selectedMachine; + /// <summary> + /// Gets or sets the selected machine. + /// </summary> + public Machine SelectedMachine + { + get { return _selectedMachine; } + set { _selectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + public RelayCommand ManageMachineCommand { get; set; } + + public SelectionViewVM() + { + ManageMachineCommand = new RelayCommand(ManageSelectedMachine, () => SelectedMachine != null); + } + + private void ManageSelectedMachine() + { + if (SelectedMachine == null) + { + NotificationProvider.ShowError("No machine selected."); + return; + } + + ModularNavigationManager.NavigateTo(ConfigurationView.MachineView, new MachineViewVM.NavigationObject() + { + MachineGuid = SelectedMachine.Guid + }); + } + + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + + if (SelectedMachine == null && MachineProvider.Machine != null) + { + SelectedMachine = MachineProvider.Machine; + } + } + + public override Task<bool> OnApplicationLogout() + { + ModularNavigationManager.NavigateTo(ConfigurationView.SelectionView); + SelectedMachine = null; + return base.OnApplicationLogout(); + } + } +} + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml new file mode 100644 index 000000000..ed24c3a67 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml @@ -0,0 +1,195 @@ +<UserControl x:Class="Tango.FSE.MachineConfiguration.Views.ConfigurationView" + 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:local="clr-namespace:Tango.FSE.MachineConfiguration.Views" + xmlns:global="clr-namespace:Tango.FSE.MachineConfiguration" + xmlns:material="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:vm="clr-namespace:Tango.FSE.MachineConfiguration.ViewModels" + xmlns:enumerations="clr-namespace:Tango.BL.Enumerations;assembly=Tango.BL" + xmlns:commonControls="clr-namespace:Tango.FSE.Common.Controls;assembly=Tango.FSE.Common" + xmlns:resolution="clr-namespace:Tango.FSE.Common.Resolution;assembly=Tango.FSE.Common" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" + mc:Ignorable="d" + d:DesignHeight="2000" d:DesignWidth="1920" d:DataContext="{d:DesignInstance Type=vm:ConfigurationViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.ConfigurationViewVM}" d:DesignStyle="{StaticResource FSE_User_Control_Designer}"> + + <Grid Margin="0 20"> + + <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Padding="0 0 20 0" FocusVisualStyle="{x:Null}"> + + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="4*" /> + <ColumnDefinition Width="5*" /> + </Grid.ColumnDefinitions> + + <!--<Grid Grid.Column="1"> + <commonControls:MachineView Opacity="0.6" DataContext="{Binding EditingComposition.Machine}" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="50 100 50 50" MaxWidth="600" /> + </Grid>--> + + <StackPanel Grid.Column="0" > + + <GroupBox Margin="0 20" Style="{StaticResource FSE_Game_GroupBox}" Header="Provisioning"> + <StackPanel Margin="0 0 0 5"> + <DockPanel VerticalAlignment="Top" Margin="0 10 0 0" ToolTip="Activate the windows operating system license"> + <ToggleButton IsChecked="{Binding EditingComposition.Machine.SetupActivation}" /> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">Activate Windows License</TextBlock> + </DockPanel> + + <StackPanel Margin="43 0 0 0"> + <TextBlock Foreground="{StaticResource FSE_GrayBrush}" FontSize="{StaticResource FSE_SmallerFontSize}">License Key</TextBlock> + <TextBox Foreground="{StaticResource FSE_GrayBrush}" Text="{Binding EditingComposition.Machine.OsKey,UpdateSourceTrigger=PropertyChanged}" FontSize="{StaticResource FSE_SmallFontSize}" VerticalAlignment="Center" Style="{StaticResource FSE_Rounded_Corners_TextBox}" Margin="0 2 0 0" Width="250" HorizontalAlignment="Left"></TextBox> + </StackPanel> + + <DockPanel Margin="0 20 0 0" ToolTip="Install Team Viewer for remote desktop support"> + <ToggleButton IsChecked="{Binding EditingComposition.Machine.SetupRemoteAssistance}" /> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">Setup Team Viewer</TextBlock> + </DockPanel> + + <DockPanel Margin="0 20 0 0" ToolTip="Perform UWF activation for protecting the disk by resetting file system changes after each system restart"> + <ToggleButton IsChecked="{Binding EditingComposition.Machine.SetupUwf}" /> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">Activate Disk Protection</TextBlock> + </DockPanel> + + <DockPanel Margin="0 20 0 0" ToolTip="Connect the panel PC application to an in-memory emulator (for testing purpose only)"> + <ToggleButton IsChecked="{Binding EditingComposition.Machine.IsDemo}" /> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">Use Firmware Emulator (Demo Machine)</TextBlock> + </DockPanel> + <StackPanel Margin="2 40 0 0"> + + <Separator Margin="0 10" /> + + <TextBlock FontWeight="SemiBold" Foreground="{StaticResource FSE_RedBrush}">Device Registration</TextBlock> + + <DockPanel> + <StackPanel> + + <TextBlock Margin="0 5 0 0" FontSize="{StaticResource FSE_SmallFontSize}"> + <Run>Registered:</Run> + <Run Foreground="{StaticResource FSE_GrayBrush}" Text="{Binding EditingComposition.Machine.IsDeviceRegistered,Mode=OneWay,Converter={StaticResource BooleanToYesNoConverter},FallbackValue='No'}"></Run> + </TextBlock> + + <TextBlock Margin="0 5 0 0" FontSize="{StaticResource FSE_SmallFontSize}"> + <Run>Device ID:</Run> + <Run Foreground="{StaticResource FSE_GrayBrush}" Text="{Binding EditingComposition.Machine.DeviceId,Mode=OneWay,FallbackValue='N/A',TargetNullValue='N/A'}"></Run> + </TextBlock> + + <TextBlock Margin="0 5 0 0" FontSize="{StaticResource FSE_SmallFontSize}"> + <Run>Device Name:</Run> + <Run Foreground="{StaticResource FSE_GrayBrush}" Text="{Binding EditingComposition.Machine.DeviceName,Mode=OneWay,FallbackValue='N/A',TargetNullValue='N/A'}"></Run> + </TextBlock> + </StackPanel> + + <Button Width="180" Command="{Binding ResetDeviceRegistrationCommand}" Margin="0 0 10 0" ToolTip="Device registration protects the system from provisioning of the same machine on multiple devices (panel PC's). Use this reset option when replacing an existing panel PC with a new one." IsEnabled="{Binding Machine.IsDeviceRegistered}" Cursor="Hand" HorizontalAlignment="Right" FontSize="{StaticResource FSE_SmallFontSize}" VerticalAlignment="Bottom" Style="{StaticResource FSE_Button_Red}">Reset Device Registration</Button> + </DockPanel> + </StackPanel> + + <StackPanel Margin="2 40 0 0"> + + <Separator Margin="0 10" /> + + <TextBlock FontWeight="SemiBold" Foreground="{StaticResource FSE_RedBrush}">Machine Counters</TextBlock> + + <DockPanel> + <StackPanel> + + <TextBlock Margin="0 5 0 0" FontSize="{StaticResource FSE_SmallFontSize}"> + <Run>Total Dye Time:</Run> + <Run Foreground="{StaticResource FSE_GrayBrush}" Text="{Binding EditingComposition.TotalDyeTime,Mode=OneWay,FallbackValue='N/A',TargetNullValue='N/A'}"></Run> + </TextBlock> + + <TextBlock Margin="0 5 0 0" FontSize="{StaticResource FSE_SmallFontSize}"> + <Run>Total Dye Meters:</Run> + <Run Foreground="{StaticResource FSE_GrayBrush}" Text="{Binding EditingComposition.TotalDyeMeters,Mode=OneWay,FallbackValue='N/A',TargetNullValue='N/A'}"></Run> + </TextBlock> + </StackPanel> + + <Button Width="180" Command="{Binding ResetCountersCommand}" Margin="0 0 10 0" ToolTip="Reset the entire job runs history for this machine" IsEnabled="{Binding Machine.IsDeviceRegistered}" Cursor="Hand" HorizontalAlignment="Right" FontSize="{StaticResource FSE_SmallFontSize}" VerticalAlignment="Bottom" Style="{StaticResource FSE_Button_Red}">Reset Machine Counters</Button> + </DockPanel> + </StackPanel> + </StackPanel> + </GroupBox> + + <GroupBox Margin="0 20" Style="{StaticResource FSE_Game_GroupBox}" Header="Machine Update"> + <StackPanel Margin="0 10 0 5"> + <DockPanel ToolTip="Prevent firmware upgrade when updating"> + <ToggleButton material:ToggleButtonAssist.SwitchTrackOnBackground="{StaticResource FSE_PrimaryBackgroundLighterBrush}" IsChecked="{Binding EditingComposition.Machine.SetupFirmware,Converter={StaticResource BooleanInverseConverter}}" /> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">Disable Firmware Upgrade</TextBlock> + </DockPanel> + + <DockPanel Margin="0 20 0 0" ToolTip="Force the machine to perform an update even if there is no update available"> + <ToggleButton IsChecked="{Binding EditingComposition.Machine.ForceVersionUpdate}" /> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">Force Version Update</TextBlock> + </DockPanel> + + <DockPanel Margin="0 20 0 0" ToolTip="Prevent this machine from updating software"> + <ToggleButton IsChecked="{Binding EditingComposition.Machine.SuspendVersionUpdate}" /> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">Suspend Version Update</TextBlock> + </DockPanel> + </StackPanel> + </GroupBox> + + <GroupBox Margin="0 20" Style="{StaticResource FSE_Game_GroupBox}" Header="Machine Identity"> + <StackPanel Margin="0 0 0 5"> + + <StackPanel Margin="0 10 0 0"> + <TextBlock FontSize="{StaticResource FSE_SmallFontSize}" Foreground="{StaticResource FSE_GrayBrush}">Serial Number</TextBlock> + <TextBox Margin="0 2 0 0" Text="{Binding EditingComposition.Machine.SerialNumber}" Width="250" HorizontalAlignment="Left"></TextBox> + </StackPanel> + + <StackPanel Margin="0 20 0 0"> + <TextBlock FontSize="{StaticResource FSE_SmallFontSize}" Foreground="{StaticResource FSE_GrayBrush}">Name</TextBlock> + <TextBox Margin="0 2 0 0" Text="{Binding EditingComposition.Machine.Name}" Width="250" HorizontalAlignment="Left"></TextBox> + </StackPanel> + + <StackPanel Margin="0 20 0 0"> + <TextBlock FontSize="{StaticResource FSE_SmallFontSize}" Foreground="{StaticResource FSE_GrayBrush}">Organization</TextBlock> + <ComboBox Width="250" HorizontalAlignment="Left" ItemsSource="{Binding EditingComposition.Organizations}" SelectedItem="{Binding EditingComposition.Machine.Organization}" DisplayMemberPath="Name" /> + </StackPanel> + + <StackPanel Margin="0 20 0 0"> + <TextBlock FontSize="{StaticResource FSE_SmallFontSize}" Foreground="{StaticResource FSE_GrayBrush}">Site</TextBlock> + <ComboBox Width="250" HorizontalAlignment="Left" ItemsSource="{Binding EditingComposition.Machine.Organization.Sites}" SelectedValue="{Binding EditingComposition.Machine.SiteGuid}" SelectedValuePath="Guid" DisplayMemberPath="Name" /> + </StackPanel> + </StackPanel> + </GroupBox> + + <GroupBox Margin="0 20" Style="{StaticResource FSE_Game_GroupBox}" Header="Hardware"> + <StackPanel> + <StackPanel Margin="0 10 0 0"> + <TextBlock FontSize="{StaticResource FSE_SmallFontSize}" Foreground="{StaticResource FSE_GrayBrush}">Head Type</TextBlock> + <ComboBox Width="250" HorizontalAlignment="Left" ItemsSource="{Binding Source={x:Type enumerations:HeadTypes},Converter={StaticResource EnumToItemsSourceConverter}}" SelectedValue="{Binding EditingComposition.Machine.MachineHeadType}" SelectedValuePath="Value" DisplayMemberPath="DisplayName" /> + </StackPanel> + + <StackPanel Margin="0 20 0 0"> + <TextBlock FontSize="{StaticResource FSE_SmallFontSize}" Foreground="{StaticResource FSE_GrayBrush}">Hardware Version</TextBlock> + <controls:SearchComboBox MinWidth="250" HorizontalAlignment="Left" ItemsSource="{Binding EditingComposition.HardwareVersions}" SelectedItem="{Binding EditingComposition.Machine.Configuration.HardwareVersion}" SearchProperty="FullName" /> + </StackPanel> + </StackPanel> + </GroupBox> + </StackPanel> + </Grid> + </ScrollViewer> + + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="4*" /> + <ColumnDefinition Width="5*" /> + </Grid.ColumnDefinitions> + + <Grid Grid.Column="1" Margin="0 0 50 0"> + <DockPanel> + <Button Command="{Binding SaveCommand}" DockPanel.Dock="Bottom" VerticalAlignment="Top" HorizontalAlignment="Center" Width="250" Height="50" Margin="0 -40 0 0" material:ButtonAssist.CornerRadius="25"> + <DockPanel> + <material:PackIcon Kind="ContentSave" /> + <TextBlock Margin="5 0 0 0">SAVE</TextBlock> + </DockPanel> + </Button> + <commonControls:MachineView Opacity="0.6" DataContext="{Binding EditingComposition.Machine}" HorizontalAlignment="Center" VerticalAlignment="Top" resolution:ResolutionHelper.HighResolutionMargin="50 50 50 50" resolution:ResolutionHelper.LowResolutionMargin="50 0 50 50" MaxWidth="600" /> + </DockPanel> + </Grid> + </Grid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.xaml.cs new file mode 100644 index 000000000..d25948d2c --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/ConfigurationView.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.FSE.MachineConfiguration.Views +{ + /// <summary> + /// Interaction logic for MachineDataStoreView.xaml + /// </summary> + public partial class ConfigurationView : UserControl + { + public ConfigurationView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml new file mode 100644 index 000000000..52a140c81 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml @@ -0,0 +1,239 @@ +<UserControl x:Class="Tango.FSE.MachineConfiguration.Views.DataStoreView" + 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:local="clr-namespace:Tango.FSE.MachineConfiguration.Views" + xmlns:helpers="clr-namespace:Tango.SharedUI.Helpers;assembly=Tango.SharedUI" + xmlns:global="clr-namespace:Tango.FSE.MachineConfiguration" + xmlns:controls="clr-namespace:Tango.FSE.Common.Controls;assembly=Tango.FSE.Common" + xmlns:vm="clr-namespace:Tango.FSE.MachineConfiguration.ViewModels" + xmlns:material="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:commonControls="clr-namespace:Tango.FSE.Common.Controls;assembly=Tango.FSE.Common" + xmlns:resolution="clr-namespace:Tango.FSE.Common.Resolution;assembly=Tango.FSE.Common" + xmlns:converters="clr-namespace:Tango.FSE.MachineConfiguration.Converters" + mc:Ignorable="d" + d:DesignHeight="720" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:DataStoreViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.DataStoreViewVM}" d:DesignStyle="{StaticResource FSE_User_Control_Designer}"> + + <UserControl.Resources> + <converters:DataStoreValueToStringConverter x:Key="DataStoreValueToStringConverter" /> + </UserControl.Resources> + + <DockPanel Margin="0 10 0 0"> + + <DockPanel DockPanel.Dock="Top"> + <DockPanel DockPanel.Dock="Left" HorizontalAlignment="Left"> + <Image Source="../Images/data_collection.png" Stretch="Uniform" Width="40" RenderOptions.BitmapScalingMode="Fant" Opacity="0.5" /> + <DockPanel Margin="10 0 0 0" > + <TextBlock Margin="0 5 0 0" FontSize="{StaticResource FSE_SmallFontSize}" Foreground="{StaticResource FSE_GrayBrush}"> + <Run>The data store contains global and local (machine) configuration and calibration parameters.</Run> + <LineBreak/> + <Run>Updating the data store parameters will take effect on the next machine cloud synchronization pass.</Run> + <LineBreak/> + <Run>If this is the currently connected machine, updating the data store will take effect immediately.</Run> + </TextBlock> + </DockPanel> + </DockPanel> + + <DockPanel DockPanel.Dock="Right" Margin="0 0 10 0" VerticalAlignment="Center" ToolTip="Allow updates on this grid based on changes that are triggered by the machine's firmware device"> + <ToggleButton IsChecked="{Binding DataStoreProvider.AcceptFirmwareChanges}" /> + <TextBlock Margin="10 0 0 0" FontSize="{StaticResource FSE_SmallFontSize}" VerticalAlignment="Center">Accept Real-Time Firmware Updates</TextBlock> + </DockPanel> + + <Grid> + + </Grid> + </DockPanel> + + <DockPanel Margin="0 20 0 0"> + <DockPanel DockPanel.Dock="Bottom" > + + <Grid DockPanel.Dock="Left"> + <DockPanel VerticalAlignment="Center" Visibility="{Binding CanSync,Converter={StaticResource BooleanToVisibilityConverter}}"> + <material:PackIcon Kind="InfoCircleOutline" Foreground="{StaticResource FSE_GreenBrush}" /> + <TextBlock FontSize="{StaticResource FSE_SmallFontSize}" Foreground="{StaticResource FSE_GreenBrush}" VerticalAlignment="Center" Margin="5 2 0 0">Machine is connected, updating the data store will be take effect immediately.</TextBlock> + </DockPanel> + </Grid> + + <StackPanel DockPanel.Dock="Right" Orientation="Horizontal" Margin="0 10 0 5"> + <Button IsEnabled="{Binding IsFree}" ToolTip="Import a data store csv file" Width="120" VerticalAlignment="Center" Margin="0 0 10 0" Height="35" material:ButtonAssist.CornerRadius="18" Style="{StaticResource FSE_RaisedButton_Dark_Hover}" Command="{Binding ImportCommand}"> + <DockPanel> + <material:PackIcon Kind="Import" /> + <TextBlock Margin="5 0 0 0">IMPORT</TextBlock> + </DockPanel> + </Button> + <Button IsEnabled="{Binding IsFree}" ToolTip="Export this data store to a csv file" Width="120" VerticalAlignment="Center" Margin="0 0 10 0" Height="35" material:ButtonAssist.CornerRadius="18" Style="{StaticResource FSE_RaisedButton_Dark_Hover}" Command="{Binding ExportCommand}"> + <DockPanel> + <material:PackIcon Kind="Export" /> + <TextBlock Margin="5 0 0 0">EXPORT</TextBlock> + </DockPanel> + </Button> + <Button ToolTip="Apply the data store changes" IsEnabled="{Binding IsFree}" Width="200" Height="45" material:ButtonAssist.CornerRadius="25" Command="{Binding SaveCommand}"> + <DockPanel> + <material:PackIcon Kind="ContentSaveAll" /> + <TextBlock Margin="5 0 0 0"> + <TextBlock.Style> + <Style TargetType="TextBlock"> + <Setter Property="Text" Value="UPDATE"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding CanSync}" Value="True"> + <Setter Property="Text" Value="UPDATE & SYNC"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> + </DockPanel> + </Button> + </StackPanel> + + <Grid> + <!--FOOTER CENTER CONTENT--> + </Grid> + </DockPanel> + <Grid> + <DockPanel> + + <Grid DockPanel.Dock="Top" Panel.ZIndex="100"> + <!--TOP BAR--> + + <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 0 5 -45"> + <DockPanel Margin="0 0 20 0" VerticalAlignment="Center"> + <material:PackIcon Kind="Search" resolution:ResolutionHelper.Mode="High" Foreground="{StaticResource FSE_PrimaryAccentBrush}" VerticalAlignment="Center" Width="24" Height="24" Margin="0 0 5 0" /> + <TextBox IsEnabled="{Binding IsFree}" material:HintAssist.Hint="Search" Text="{Binding Filter,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,Delay=500}" Background="{StaticResource FSE_PrimaryBackgroundBrush}" Width="250" Style="{StaticResource FSE_Rounded_Corners_TextBox}" Height="33"></TextBox> + </DockPanel> + <controls:TextIconButton IsEnabled="{Binding IsFree}" material:ButtonAssist.CornerRadius="15" Command="{Binding AddItemCommand}" Icon="Add" Width="150">ADD ITEM</controls:TextIconButton> + <commonControls:IconButton Margin="10 0 0 0" Icon="Refresh" Foreground="{StaticResource FSE_PrimaryAccentBrush}" Cursor="Hand" ToolTip="Reload the data store" Command="{Binding ReloadCommand}" /> + </StackPanel> + </Grid> + + <DockPanel> + <!--<TextBlock Margin="0 -25 0 0" DockPanel.Dock="Top" FontFamily="{StaticResource hand}" Foreground="{StaticResource FSE_PrimaryAccentBrush}" FontSize="{StaticResource FSE_LargerFontSize}">Collections</TextBlock>--> + + <DockPanel> + + <Border DockPanel.Dock="Bottom" Height="50" Background="#404040" CornerRadius="0 0 5 5"> + <controls:TextIconButton IsEnabled="{Binding IsFree}" material:ButtonAssist.CornerRadius="15" Command="{Binding AddCollectionCommand}" Icon="Add" Width="180">ADD COLLECTION</controls:TextIconButton> + </Border> + + <Border Padding="8" Background="{StaticResource FSE_PrimaryBackgroundMidBrush}" CornerRadius="5 5 0 0" BorderThickness="1" BorderBrush="{StaticResource FSE_PrimaryBackgroundLightBrush}"> + <ListBox IsEnabled="{Binding IsFree}" ItemsSource="{Binding DataStore.Collections}" SelectedItem="{Binding SelectedCollection}" MinWidth="200" HorizontalContentAlignment="Stretch"> + <ListBox.ItemTemplate> + <DataTemplate> + <DockPanel> + <material:PackIcon Kind="Collection" /> + <controls:IconButton DockPanel.Dock="Right" HorizontalAlignment="Right" ToolTip="Delete collection" Cursor="Hand" Width="20" Height="20" Padding="0" Icon="Close" Foreground="{StaticResource FSE_RedBrush}" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.RemoveCollectionCommand}" CommandParameter="{Binding}" /> + <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" Text="{Binding Name}"></TextBlock> + </DockPanel> + </DataTemplate> + </ListBox.ItemTemplate> + </ListBox> + </Border> + </DockPanel> + </DockPanel> + + <Grid Margin="10 0 0 0"> + <Border Background="#8B202020" Padding="0 0 0 5" CornerRadius="5" BorderThickness="1" BorderBrush="{StaticResource FSE_PrimaryBackgroundLightBrush}"> + <Grid> + <Border VerticalAlignment="Top" Background="{StaticResource FSE_PrimaryBackgroundLightBrush}" Height="47" CornerRadius="5 5 0 0"> + + </Border> + <DataGrid IsEnabled="{Binding IsFree}" IsReadOnly="True" helpers:DataGridHelper.DoubleClickCommand="{Binding EditItemCommand}" AutoGenerateColumns="False" Style="{StaticResource FSE_DataGrid}" CellStyle="{StaticResource FSE_DataGrid_Cell}" CanUserReorderColumns="False" CanUserSortColumns="False" ItemsSource="{Binding SelectedCollection.Items}" SelectedItem="{Binding SelectedItem}"> + <DataGrid.Columns> + <DataGridTemplateColumn Width="50"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <material:PackIcon Kind="Key" Width="32" /> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="KEY" Width="Auto"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Text="{Binding Key}"></TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="TYPE" Width="Auto"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Text="{Binding Type}"> + <TextBlock.Style> + <Style TargetType="TextBlock"> + <Setter Property="Foreground" Value="{StaticResource FSE_PrimaryForegroundBrush}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding Type}" Value="Boolean"> + <Setter Property="Foreground" Value="#FF9BFF"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="Bytes"> + <Setter Property="Foreground" Value="#FFFBA3"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="Double"> + <Setter Property="Foreground" Value="#85B1FF"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="Float"> + <Setter Property="Foreground" Value="#FFDCB8"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="Int32"> + <Setter Property="Foreground" Value="#FF858D "></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="String"> + <Setter Property="Foreground" Value="#B9FFA5"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="Proto"> + <Setter Property="Foreground" Value="#A5FFF9"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="GLOBAL" Width="Auto"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Text="{Binding GlobalItem,Converter={StaticResource DataStoreValueToStringConverter},TargetNullValue='-'}"></TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Header="LOCAL" Width="1*"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Text="{Binding FormattedValue,Converter={StaticResource StringToOneLineConverter},ConverterParameter='100',Mode=OneWay}" Visibility="{Binding IsDeleted,Converter={StaticResource BooleanToVisibilityInverseConverter}}"> + <TextBlock.Style> + <Style TargetType="TextBlock"> + <Setter Property="FontWeight" Value="Normal"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding HasDifference}" Value="True"> + <Setter Property="FontWeight" Value="Bold"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTemplateColumn Width="100"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <UniformGrid Columns="2"> + <controls:IconButton ToolTip="Edit local value" Cursor="Hand" Width="20" Padding="0" Height="20" Icon="Edit" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.EditItemCommand}" CommandParameter="{Binding}" /> + <Grid IsEnabled="{Binding IsGlobal,Converter={StaticResource BooleanInverseConverter}}"> + <controls:IconButton ToolTip="Delete local" IsEnabled="{Binding IsDeleted,Converter={StaticResource BooleanInverseConverter}}" Cursor="Hand" Width="20" Height="20" Padding="0" Icon="Close" Foreground="{StaticResource FSE_RedBrush}" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.RemoveItemCommand}" CommandParameter="{Binding}" /> + </Grid> + </UniformGrid> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + </DataGrid.Columns> + </DataGrid> + </Grid> + </Border> + </Grid> + </DockPanel> + </Grid> + </DockPanel> + </DockPanel> +</UserControl> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.xaml.cs new file mode 100644 index 000000000..add553b35 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/DataStoreView.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.FSE.MachineConfiguration.Views +{ + /// <summary> + /// Interaction logic for MachineDataStoreView.xaml + /// </summary> + public partial class DataStoreView : UserControl + { + public DataStoreView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml new file mode 100644 index 000000000..ca6470db3 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml @@ -0,0 +1,49 @@ +<UserControl x:Class="Tango.FSE.MachineConfiguration.Views.MachineView" + 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:global="clr-namespace:Tango.FSE.MachineConfiguration" + xmlns:vm="clr-namespace:Tango.FSE.MachineConfiguration.ViewModels" + xmlns:local="clr-namespace:Tango.FSE.MachineConfiguration.Views" + xmlns:commonControls="clr-namespace:Tango.FSE.Common.Controls;assembly=Tango.FSE.Common" + xmlns:resolution="clr-namespace:Tango.FSE.Common.Resolution;assembly=Tango.FSE.Common" + mc:Ignorable="d" + d:DesignHeight="1080" d:DesignWidth="1920" d:DataContext="{d:DesignInstance Type=vm:MachineViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MachineViewVM}" d:DesignStyle="{StaticResource FSE_User_Control_Designer}"> + <Grid> + + <Grid Margin="0 20 0 0"> + <Grid> + <Grid.Style> + <Style TargetType="Grid"> + <Setter Property="Margin" Value="100 0"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding ResolutionService.IsLowResolution}" Value="True"> + <Setter Property="Margin" Value="10"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Grid.Style> + + <DockPanel> + <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" HorizontalAlignment="Left"> + <Image Source="{StaticResource FSE_Machine_Full}" Width="100" Stretch="Uniform" RenderOptions.BitmapScalingMode="Fant" /> + <StackPanel Margin="5 0 0 0"> + <TextBlock Text="{Binding EditingComposition.Machine.SerialNumber,FallbackValue='101010'}" FontSize="{StaticResource FSE_ModuleHeaderFontSize}"></TextBlock> + <TextBlock Text="{Binding EditingComposition.Machine.Organization.Name,FallbackValue='Organization'}" FontSize="{StaticResource FSE_LargerFontSize}" Foreground="{StaticResource FSE_GrayBrush}"></TextBlock> + </StackPanel> + </StackPanel> + <Grid Margin="0 20 0 0"> + <commonControls:FSETabControl TabsWidth="500" x:Name="tabs" SelectedObject="{Binding SelectedView,Mode=TwoWay}"> + <local:ConfigurationView Tag="CONFIGURATION"/> + <local:DataStoreView Tag="DATA STORE"/> + </commonControls:FSETabControl> + + <TextBlock resolution:ResolutionHelper.MinWidth="1500" Margin="10 0 0 0" FontFamily="{StaticResource hand}" FontSize="{StaticResource FSE_ModuleHeaderFontSize}" Foreground="{StaticResource FSE_PrimaryAccentDarkBrush}" VerticalAlignment="Top" HorizontalAlignment="Left" Text="{Binding ElementName=tabs,Path=SelectedElement.Tag,Converter={StaticResource StringToTitleCaseConverter}}"></TextBlock> + </Grid> + </DockPanel> + </Grid> + </Grid> + + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.xaml.cs new file mode 100644 index 000000000..5e4d5ed7d --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MachineView.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.FSE.MachineConfiguration.Views +{ + /// <summary> + /// Interaction logic for MachineView.xaml + /// </summary> + public partial class MachineView : UserControl + { + public MachineView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MainView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MainView.xaml new file mode 100644 index 000000000..a321a1bb8 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MainView.xaml @@ -0,0 +1,18 @@ +<UserControl x:Class="Tango.FSE.MachineConfiguration.Views.MainView" + 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:global="clr-namespace:Tango.FSE.MachineConfiguration" + xmlns:vm="clr-namespace:Tango.FSE.MachineConfiguration.ViewModels" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:local="clr-namespace:Tango.FSE.MachineConfiguration.Views" + mc:Ignorable="d" + d:DesignHeight="1920" d:DesignWidth="1080" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}" d:DesignStyle="{StaticResource FSE_User_Control_Designer}"> + <Grid> + <controls:NavigationControl TransitionType="Slide" TransitionDuration="00:00:0.2"> + <local:SelectionView/> + <local:MachineView/> + </controls:NavigationControl> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MainView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MainView.xaml.cs new file mode 100644 index 000000000..650c297a4 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/MainView.xaml.cs @@ -0,0 +1,31 @@ +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.FSE.MachineConfiguration.Views +{ + /// <summary> + /// Interaction logic for MainView.xaml + /// </summary> + public partial class MainView : UserControl + { + public static MainView Instance { get; set; } + + public MainView() + { + Instance = this; + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/SelectionView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/SelectionView.xaml new file mode 100644 index 000000000..69cebf324 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/SelectionView.xaml @@ -0,0 +1,61 @@ +<UserControl x:Class="Tango.FSE.MachineConfiguration.Views.SelectionView" + 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:local="clr-namespace:Tango.FSE.MachineConfiguration.Views" + xmlns:material="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:global="clr-namespace:Tango.FSE.MachineConfiguration" + xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" + xmlns:vm="clr-namespace:Tango.FSE.MachineConfiguration.ViewModels" + mc:Ignorable="d" + d:DesignHeight="1080" d:DesignWidth="1920" d:DataContext="{d:DesignInstance Type=vm:SelectionViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.SelectionViewVM}" d:DesignStyle="{StaticResource FSE_User_Control_Designer}"> + <Grid> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + + <TextBlock HorizontalAlignment="Center" FontSize="{StaticResource FSE_ModuleHeaderFontSize}">Machine Configuration</TextBlock> + <TextBlock TextWrapping="Wrap" Margin="0 20 0 0" TextAlignment="Center" LineHeight="25"> + <Run>The machine configuration module allows you to manage the currently connected machine configuration and other machine settings.</Run> + <LineBreak/> + <Run>Given the proper permissions, you will also be able to manage other organization machines.</Run> + </TextBlock> + + <StackPanel Margin="0 40 0 0" Width="500" HorizontalAlignment="Center"> + <Image Source="../Images/configuration.png" Stretch="None" /> + + <TextBlock Margin="60" HorizontalAlignment="Center" FontWeight="SemiBold" Foreground="{StaticResource FSE_PrimaryAccentBrush}" FontSize="{StaticResource FSE_LargerFontSize}">Select Machine</TextBlock> + <autoComplete:AutoCompleteTextBox material:HintAssist.Hint="Serial Number" MaxPopupHeight="300" Margin="0 5 0 0" Provider="{Binding MachinesAutoCompleteProvider}" SelectedItem="{Binding SelectedMachine,Mode=TwoWay}" DisplayMember="SerialNumber"> + <autoComplete:AutoCompleteTextBox.SelectedItemTemplate> + <DataTemplate> + <DockPanel VerticalAlignment="Center"> + <Image RenderOptions.BitmapScalingMode="Fant" Source="{StaticResource FSE_Machine_Small}" Width="24" /> + <StackPanel VerticalAlignment="Center" Margin="10 0 0 0" Orientation="Horizontal"> + <TextBlock Text="{Binding SerialNumber}" FontSize="{StaticResource FSE_SmallFontSize}"></TextBlock> + <TextBlock Margin="10 0 0 0" FontSize="{StaticResource FSE_SmallFontSize}" Foreground="{StaticResource FSE_GrayBrush}" Text="{Binding Name}"></TextBlock> + </StackPanel> + </DockPanel> + </DataTemplate> + </autoComplete:AutoCompleteTextBox.SelectedItemTemplate> + <autoComplete:AutoCompleteTextBox.ItemTemplate> + <DataTemplate> + <DockPanel VerticalAlignment="Center"> + <Image RenderOptions.BitmapScalingMode="Fant" Source="{StaticResource FSE_Machine_Small}" Width="32" /> + <StackPanel Margin="5 0 0 0"> + <TextBlock Text="{Binding SerialNumber}"></TextBlock> + <TextBlock Margin="0 5 0 0" FontSize="{StaticResource FSE_SmallerFontSize}" Foreground="{StaticResource FSE_GrayBrush}" Text="{Binding Name}"></TextBlock> + </StackPanel> + </DockPanel> + </DataTemplate> + </autoComplete:AutoCompleteTextBox.ItemTemplate> + </autoComplete:AutoCompleteTextBox> + + <Button material:ButtonAssist.CornerRadius="25" Command="{Binding ManageMachineCommand}" Margin="0 100 0 0" Height="50" Width="250"> + <DockPanel> + <TextBlock>CONTINUE</TextBlock> + <material:PackIcon Margin="10 0 0 0" VerticalAlignment="Center" Kind="ArrowRight" /> + </DockPanel> + </Button> + </StackPanel> + </StackPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/SelectionView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/SelectionView.xaml.cs new file mode 100644 index 000000000..618ae299a --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/Views/SelectionView.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.FSE.MachineConfiguration.Views +{ + /// <summary> + /// Interaction logic for MachineSelectionView.xaml + /// </summary> + public partial class SelectionView : UserControl + { + public SelectionView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/app.config b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/app.config new file mode 100644 index 000000000..36bc04f85 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/app.config @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <configSections> + <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> + <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> + </configSections> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.2.2.0" newVersion="1.2.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.4.2.0" newVersion="1.4.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Console" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reactive.Core" publicKeyToken="94bc3704cddfc263" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> + </dependentAssembly> + </assemblyBinding> + </runtime> + <entityFramework> + <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> + <providers> + <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> + </providers> + </entityFramework> +</configuration>
\ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/packages.config b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/packages.config new file mode 100644 index 000000000..dd8c723e4 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/packages.config @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="ControlzEx" version="3.0.2.4" targetFramework="net461" /> + <package id="EntityFramework" version="6.2.0" targetFramework="net461" /> + <package id="Google.Protobuf" version="3.4.1" targetFramework="net461" /> + <package id="MahApps.Metro" version="1.6.5" targetFramework="net461" /> + <package id="MaterialDesignColors" version="1.2.2" targetFramework="net461" /> + <package id="MaterialDesignThemes" version="3.0.1" targetFramework="net461" /> + <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net461" /> +</packages>
\ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Themes/Generic.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Themes/Generic.xaml index 3917368f2..0e055d730 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Themes/Generic.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/Themes/Generic.xaml @@ -635,7 +635,6 @@ </Style.Triggers> </Style> - <Style x:Key="FSE_Debug_TextBoxStyle" TargetType="TextBox"> <Setter Property="Background" Value="Transparent"></Setter> <Setter Property="BorderBrush" Value="{StaticResource FSE_BorderBrush}"></Setter> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.UsersAndRoles/ViewModels/OrganizationSelectionViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.UsersAndRoles/ViewModels/OrganizationSelectionViewVM.cs index 9a84cca7d..0abc285a9 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.UsersAndRoles/ViewModels/OrganizationSelectionViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.UsersAndRoles/ViewModels/OrganizationSelectionViewVM.cs @@ -63,7 +63,7 @@ namespace Tango.FSE.UsersAndRoles.ViewModels try { - return Services.OrganizationsService.GetCurrentUserOrganizations().Result.Where(x => x.Name.ToLower().StartsWith(key.ToLower())).Take(4).ToList(); + return Services.OrganizationsService.GetCurrentUserOrganizations().Result.Where(x => x.Name.ToLower().StartsWith(key.ToLower())).ToList(); } catch (Exception ex) { diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServicesContainer.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServicesContainer.cs index e5487bc1e..c8773eccd 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServicesContainer.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServicesContainer.cs @@ -63,6 +63,16 @@ namespace Tango.FSE.BL public OrganizationsService OrganizationsService { get; set; } /// <summary> + /// Gets or sets the machine configuration service. + /// </summary> + public MachineConfigurationService MachineConfigurationService { get; set; } + + /// <summary> + /// Gets or sets the data store service. + /// </summary> + public DataStoreService DataStoreService { get; set; } + + /// <summary> /// Initializes a new instance of the <see cref="FSEServicesContainer"/> class. /// </summary> /// <param name="authentication">The authentication.</param> @@ -78,6 +88,8 @@ namespace Tango.FSE.BL PublishedProcedureProjectsService = new PublishedProcedureProjectsService(); MachineEventsService = new MachineEventsService(); OrganizationsService = new OrganizationsService(); + MachineConfigurationService = new MachineConfigurationService(); + DataStoreService = new DataStoreService(); } } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/DataStoreService.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/DataStoreService.cs new file mode 100644 index 000000000..2dd29fdc4 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/DataStoreService.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.DataStore; + +namespace Tango.FSE.BL.Services +{ + public class DataStoreService : FSEServiceBase + { + public Task<List<GlobalDataStoreItem>> GetGlobalDataStoreItems() + { + return Task.Factory.StartNew<List<GlobalDataStoreItem>>(() => + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + return db.GlobalDataStoreItems.ToList().OrderBy(x => x.CollectionName).OrderBy(x => x.Key).ToList(); + } + }); + } + + public Task<List<DataStoreItem>> GetMachinelDataStoreItems(String machineGuid) + { + return Task.Factory.StartNew<List<DataStoreItem>>(() => + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + return db.DataStoreItems.Where(x => x.MachineGuid == machineGuid && !x.IsDeleted).ToList().OrderBy(x => x.CollectionName).OrderBy(x => x.Key).ToList(); + } + }); + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/MachineConfigurationService.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/MachineConfigurationService.cs new file mode 100644 index 000000000..a30198ff2 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/MachineConfigurationService.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using System.Data.Entity; +using Tango.BL.Builders; + +namespace Tango.FSE.BL.Services +{ + public class MachineConfigurationService : FSEServiceBase + { + public class MachineEditingComposition : IDisposable + { + public Machine Machine { get; set; } + public List<Organization> Organizations { get; set; } + public List<HardwareVersion> HardwareVersions { get; set; } + public String TotalDyeTime { get; set; } + public String TotalDyeMeters { get; set; } + internal ObservablesContext Context { get; set; } + + public MachineEditingComposition() + { + Organizations = new List<Organization>(); + HardwareVersions = new List<HardwareVersion>(); + } + + public void Dispose() + { + Context?.Dispose(); + Context = null; + } + } + + public Task<MachineEditingComposition> GetMachineEditingComposition(String machineGuid) + { + return Task.Factory.StartNew<MachineEditingComposition>(() => + { + ObservablesContext db = ObservablesContext.CreateDefault(); + + MachineEditingComposition composition = new MachineEditingComposition(); + + //Organizations + bool allowAll = CurrentUser.HasPermission(Tango.BL.Enumerations.Permissions.FSE_ManageAllOrganizationsUsersAndRoles); + composition.Organizations = db.Organizations.Where(x => allowAll || x.Guid == CurrentUser.OrganizationGuid).Include(x => x.Sites).ToList(); + + //Machine + composition.Machine = new MachineBuilder(db).Set(machineGuid).WithConfiguration().Build(); + + //Hardware Versions + composition.HardwareVersions = db.HardwareVersions.OrderByDescending(x => x.Version).ToList(); + + //Counters + var jobRuns = db.JobRuns.Where(x => x.MachineGuid == machineGuid).Select(x => new { x.StartDate, x.EndDate, x.EndPosition }).ToList(); + composition.TotalDyeTime = TimeSpan.FromHours(jobRuns.Select(x => x.EndDate - x.StartDate).Sum(x => x.TotalHours)).ToStringUnlimitedHours(); + int meters = (int)jobRuns.Select(x => x.EndPosition).Sum(); + composition.TotalDyeMeters = $"{meters.ToString("N0")} meters"; + + composition.Context = db; + + return composition; + }); + } + + public Task<MachineEditingComposition> SaveMachineEditingComposition(MachineEditingComposition composition) + { + return Task.Factory.StartNew<MachineEditingComposition>(() => + { + composition.Machine.SetupFpga = composition.Machine.SetupFirmware; + + composition.Context.SaveChanges(); + composition.Context.Dispose(); + return GetMachineEditingComposition(composition.Machine.Guid).Result; + }); + } + + public Task<int> ResetCounters(String machineGuid) + { + return Task.Factory.StartNew<int>(() => + { + using (ObservablesContext db = new ObservablesContext()) + { + return db.JobRuns.Where(x => x.MachineGuid == machineGuid).DeleteFromQuery(); + } + }); + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/MachinesService.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/MachinesService.cs index 6f598a770..c03077a45 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/MachinesService.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/MachinesService.cs @@ -73,7 +73,6 @@ namespace Tango.FSE.BL.Services LogManager.Log("Machine retrieved successfully. Caching machine..."); var cachedMachine = CachedMachine.FromObservable<CachedMachine>(machine); - var m = cachedMachine.ToObservable(); //Store in memory cache. _machinesCache.Put(serialNumber, cachedMachine); @@ -271,12 +270,24 @@ namespace Tango.FSE.BL.Services List<CachedMachine> cachedMachines = new List<CachedMachine>(); - try + foreach (var machine in machines) { - foreach (var machine in machines) + try { var cachedMachine = CachedMachine.FromObservable<CachedMachine>(machine); - _machinesCache.Put(machine.SerialNumber, cachedMachine); + cachedMachines.Add(cachedMachine); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error creating cached machine (partial) '{machine.SerialNumber}'."); + } + } + + try + { + foreach (var cachedMachine in cachedMachines) + { + _machinesCache.Put(cachedMachine.SerialNumber, cachedMachine); } } catch (Exception ex) @@ -292,7 +303,14 @@ namespace Tango.FSE.BL.Services foreach (var cachedMachine in cachedMachines) { - collection.Upsert(cachedMachine); + try + { + collection.Upsert(cachedMachine); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error caching machine '{cachedMachine.SerialNumber}' (partial) to disk."); + } } } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj b/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj index 39257df86..d15611e91 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj @@ -119,6 +119,8 @@ <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="ReadOnlyEntityRepository.cs" /> <Compile Include="ServicesSettings.cs" /> + <Compile Include="Services\DataStoreService.cs" /> + <Compile Include="Services\MachineConfigurationService.cs" /> <Compile Include="WindowsRegistry\RegistryService.cs" /> <Compile Include="Services\AuthenticationService.cs" /> <Compile Include="Services\BugReportingService.cs" /> @@ -145,6 +147,14 @@ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.DataStore.EF\Tango.DataStore.EF.csproj"> + <Project>{88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4}</Project> + <Name>Tango.DataStore.EF</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.DataStore\Tango.DataStore.csproj"> + <Project>{e0364dfa-0721-4637-9d32-9d22aac109d6}</Project> + <Name>Tango.DataStore</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.Logging\Tango.Logging.csproj"> <Project>{bc932dbd-7cdb-488c-99e4-f02cf441f55e}</Project> <Name>Tango.Logging</Name> diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/IMachineProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/IMachineProvider.cs index 9a98477b8..8c4512c41 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/IMachineProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Connection/IMachineProvider.cs @@ -41,7 +41,7 @@ namespace Tango.FSE.Common.Connection MachineConnectionTypes ConnectionType { get; } /// <summary> - /// Gets a value indicating whether the <see cref="ConnectionType"/> equals <see cref="MachineConnectionTypes.Wifi"/> or <see cref="MachineConnectionTypes.SignalR"/>. + /// Gets a value indicating whether the machine is connected and the <see cref="ConnectionType"/> equals <see cref="MachineConnectionTypes.Wifi"/> or <see cref="MachineConnectionTypes.SignalR"/>. /// </summary> bool IsPPCAvailable { get; } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/MachineView.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/MachineView.xaml index c37613e3e..8d375cc6d 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/MachineView.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/MachineView.xaml @@ -47,11 +47,11 @@ </Border> </Grid> - <TextBlock Canvas.Left="532" FontStyle="Italic" Foreground="Gray" Canvas.Top="-22">Hardware</TextBlock> + <!--<TextBlock Canvas.Left="532" FontStyle="Italic" Foreground="Gray" Canvas.Top="-22">Hardware</TextBlock> <Grid Width="97" Height="90" Canvas.Left="431" Canvas.Top="-13"> <Rectangle Stroke="Gray" VerticalAlignment="Top" StrokeThickness="1" StrokeDashArray="5" RenderTransformOrigin="0.5,0.5"/> <Rectangle Stroke="Gray" HorizontalAlignment="Left" StrokeThickness="1" StrokeDashArray="5" RenderTransformOrigin="0.5,0.5"/> - </Grid> + </Grid>--> <UniformGrid Width="310" Canvas.Top="295" Canvas.Left="420" TextElement.Foreground="#252525" Rows="1" Columns="8" TextElement.FontSize="9"> <TextBlock HorizontalAlignment="Center">1</TextBlock> @@ -217,17 +217,17 @@ <Rectangle Stroke="Gray" HorizontalAlignment="Left" StrokeThickness="2" StrokeDashArray="3" RenderTransformOrigin="0.5,0.5"/> </Grid> - <TextBlock Canvas.Top="395" Canvas.Left="331" FontStyle="Italic" Foreground="Gray">Mid Tanks</TextBlock> + <!--<TextBlock Canvas.Top="395" Canvas.Left="331" FontStyle="Italic" Foreground="Gray">Mid Tanks</TextBlock> <Grid Width="62" Height="29" Canvas.Top="418" Canvas.Left="357"> <Rectangle Stroke="Gray" VerticalAlignment="Bottom" StrokeThickness="2" StrokeDashArray="4" RenderTransformOrigin="0.5,0.5"/> <Rectangle Stroke="Gray" HorizontalAlignment="Left" StrokeThickness="1" StrokeDashArray="5" RenderTransformOrigin="0.5,0.5"/> - </Grid> + </Grid>--> - <TextBlock Canvas.Top="469" Canvas.Left="304" FontStyle="Italic" Foreground="Gray">Cartridges</TextBlock> + <!--<TextBlock Canvas.Top="469" Canvas.Left="304" FontStyle="Italic" Foreground="Gray">Cartridges</TextBlock> <Grid Width="87" Height="10" Canvas.Top="487" Canvas.Left="332"> <Rectangle Stroke="Gray" VerticalAlignment="Bottom" StrokeThickness="2" StrokeDashArray="5" RenderTransformOrigin="0.5,0.5"/> <Rectangle Stroke="Gray" HorizontalAlignment="Left" StrokeThickness="2" StrokeDashArray="5" RenderTransformOrigin="0.5,0.5"/> - </Grid> + </Grid>--> <Grid x:Name="gridTablet" Width="67" IsHitTestVisible="True" SnapsToDevicePixels="True" ClipToBounds="True" Height="90" Canvas.Left="188" Canvas.Top="198"> <Grid.RowDefinitions> diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/DataStore/IDataStoreProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/DataStore/IDataStoreProvider.cs new file mode 100644 index 000000000..a54766893 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/DataStore/IDataStoreProvider.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DataStore.Editing; + +namespace Tango.FSE.Common.DataStore +{ + public interface IDataStoreProvider + { + bool AcceptFirmwareChanges { get; set; } + Task<DataStoreModel> GetDataStoreModel(String machineGuid); + Task<DataStoreModel> UpdateDataStoreModel(DataStoreModel model, String machineGuid); + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/DataStore/IRemoteDataStoreManager.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/DataStore/IRemoteDataStoreManager.cs index 02cc3ac9d..162c109be 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/DataStore/IRemoteDataStoreManager.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/DataStore/IRemoteDataStoreManager.cs @@ -9,6 +9,6 @@ namespace Tango.FSE.Common.DataStore { public interface IRemoteDataStoreManager : IDataStoreManager { - + } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/INotificationProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/INotificationProvider.cs index 3c7350be7..027555022 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/INotificationProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/INotificationProvider.cs @@ -138,7 +138,7 @@ namespace Tango.FSE.Common.Notifications /// <param name="okText">The ok text.</param> /// <param name="cancelText">The cancel text.</param> /// <returns></returns> - Task<InputBoxResult> ShowInputBox(String title, String message, PackIconKind icon = PackIconKind.InfoOutline, String defaultInput = null, String inputHint = null, int? maxChars = null, String okText = null, String cancelText = null); + Task<InputBoxResult> ShowInputBox(String title, String message, PackIconKind icon = PackIconKind.InfoOutline, String defaultInput = null, String inputHint = null, int? maxChars = null, String okText = null, String cancelText = null, Func<String, String> validationFunc = null); /// <summary> /// Shows a question message box. diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/InputBoxVM.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/InputBoxVM.cs index 7744d04d0..415c6cfc5 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/InputBoxVM.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/InputBoxVM.cs @@ -14,11 +14,45 @@ namespace Tango.FSE.Common.Notifications public int MaxCharacters { get; set; } + internal Func<String,String> ValidationFunction { get; set; } + private String _input; public String Input { get { return _input; } - set { _input = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + set + { + _input = value; + RaisePropertyChangedAuto(); + + if (_input.IsNotNullOrEmpty()) + { + if (ValidationFunction != null) + { + Error = ValidationFunction.Invoke(_input); + } + } + else + { + Error = null; + } + + RaisePropertyChanged(nameof(HasValidationError)); + + InvalidateRelayCommands(); + } + } + + public bool HasValidationError + { + get { return !String.IsNullOrWhiteSpace(Error); } + } + + private String _error; + public String Error + { + get { return _error; } + set { _error = value; RaisePropertyChangedAuto(); } } public InputBoxVM() : base() @@ -28,7 +62,7 @@ namespace Tango.FSE.Common.Notifications protected override bool CanOK() { - return base.CanOK() && Input.IsNotNullOrEmpty(); + return base.CanOK() && Input.IsNotNullOrEmpty() && !HasValidationError; } } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml index 24c4e91ec..4b5d8f8d2 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml @@ -3,11 +3,14 @@ xmlns:editors="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" xmlns:actions="clr-namespace:Tango.FSE.Common.EventTriggerActions" xmlns:material="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:wpf="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:local="clr-namespace:Tango.FSE.Common.Resources"> + + <Style x:Key="FSE_FlatButton_OpacityHover" TargetType="Button" BasedOn="{StaticResource MaterialDesignToolForegroundButton}"> <Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter> <Style.Triggers> @@ -821,4 +824,252 @@ </Setter> </Style> + <Style x:Key="FSE_Game_GroupBox" TargetType="GroupBox"> + <Setter Property="Foreground" Value="{StaticResource FSE_PrimaryForegroundBrush}"></Setter> + <Setter Property="Background" Value="{StaticResource FSE_PrimaryBackgroundMidBrush}"></Setter> + <Setter Property="BorderBrush" Value="{StaticResource FSE_PrimaryBackgroundLightBrush}"></Setter> + <Setter Property="FontSize" Value="{StaticResource FSE_SmallFontSize}"></Setter> + <Setter Property="Padding" Value="8"></Setter> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="GroupBox"> + <DockPanel> + <Grid DockPanel.Dock="Top"> + <Polygon HorizontalAlignment="Left" VerticalAlignment="Top" Width="{Binding ElementName=border,Path=ActualWidth}" Height="{Binding ElementName=border,Path=ActualHeight}" Fill="{StaticResource FSE_PrimaryBackgroundLighterBrush}" Stretch="Fill" Points="0,0 100,0 130,30 0,30"></Polygon> + + <Grid VerticalAlignment="Top"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="40*" /> + <ColumnDefinition Width="60*" /> + </Grid.ColumnDefinitions> + <Border VerticalAlignment="Top" Padding="0 0 50 0" x:Name="border"> + <Border Padding="{TemplateBinding Padding}" TextElement.FontSize="{StaticResource FSE_DefaultFontSize}"> + <ContentPresenter Content="{TemplateBinding Header}" /> + </Border> + </Border> + </Grid> + </Grid> + <Border TextElement.Foreground="{TemplateBinding Foreground}" TextElement.FontSize="{TemplateBinding FontSize}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" CornerRadius="0 3 3 3" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1"> + <ContentPresenter Content="{TemplateBinding Content}" /> + </Border> + </DockPanel> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + <Style TargetType="{x:Type controls:SearchComboBox}" BasedOn="{StaticResource MaterialDesignComboBox}"> + <Setter Property="KeyboardNavigation.DirectionalNavigation" Value="Once"></Setter> + <Setter Property="ItemTemplate"> + <Setter.Value> + <DataTemplate> + <TextBlock Text="{Binding}"></TextBlock> + </DataTemplate> + </Setter.Value> + </Setter> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type controls:SearchComboBox}"> + <Border Background="{TemplateBinding Background}" + BorderBrush="{TemplateBinding BorderBrush}" + BorderThickness="{TemplateBinding BorderThickness}"> + + <Grid Background="Transparent"> + <DockPanel> + <Grid VerticalAlignment="Center" Margin="15 10 0 10" DockPanel.Dock="Right" Width="8" Height="8"> + <Path Stretch="Uniform" Data="M7,10L12,15L17,10H7Z" Fill="{StaticResource FSE_GrayBrush}"> + + </Path> + </Grid> + <ContentControl Focusable="False" FocusVisualStyle="{x:Null}" VerticalAlignment="Bottom" Margin="0 0 0 5" Content="{TemplateBinding SelectedItem}" ContentTemplate="{TemplateBinding ItemTemplate}"> + + </ContentControl> + </DockPanel> + <ToggleButton x:Name="btnToggle" Focusable="False" FocusVisualStyle="{x:Null}" KeyboardNavigation.DirectionalNavigation="Once" Opacity="0" Style="{x:Null}" IsChecked="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=IsOpened,Mode=TwoWay}"> + + </ToggleButton> + + <Popup StaysOpen="False" MinWidth="{Binding ElementName=btnToggle,Path=ActualWidth}" PlacementTarget="{Binding ElementName=btnToggle}" Placement="Bottom" IsOpen="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=IsOpened,Mode=TwoWay}" MaxHeight="{TemplateBinding MaxDropDownHeight}" AllowsTransparency="True"> + <Border Margin="5" Background="{StaticResource WhiteBrush}" CornerRadius="3" Padding="5" MinWidth="{Binding ElementName=btnToggle,Path=ActualWidth}"> + <Border.Effect> + <DropShadowEffect ShadowDepth="0" /> + </Border.Effect> + <DockPanel> + <TextBox x:Name="txt" KeyboardNavigation.DirectionalNavigation="Once" DockPanel.Dock="Top" Margin="10" Padding="0 5" Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=SearchFilter,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></TextBox> + <ListBox x:Name="list" FocusVisualStyle="{x:Null}" ItemsSource="{TemplateBinding ListItemsSource}" ItemTemplate="{TemplateBinding ItemTemplate}" DisplayMemberPath="{TemplateBinding DisplayMemberPath}"> + + </ListBox> + </DockPanel> + </Border> + </Popup> + </Grid> + + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + <Style TargetType="{x:Type ToggleButton}"> + <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/> + <Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidForegroundBrush}"/> + <Setter Property="Background" Value="{DynamicResource PrimaryHueMidBrush}"/> + <Setter Property="wpf:ToggleButtonAssist.SwitchTrackOnBackground" Value="Black"/> + <Setter Property="wpf:ToggleButtonAssist.SwitchTrackOffBackground" Value="Black"/> + <Setter Property="BorderThickness" Value="1"/> + <Setter Property="Padding" Value="0 1 0 0"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type ToggleButton}"> + <ControlTemplate.Resources> + <SineEase x:Key="RippleEasingFunction" EasingMode="EaseInOut"/> + <Storyboard x:Key="ShowRipple"> + <DoubleAnimation Storyboard.TargetName="RippleThumb" Storyboard.TargetProperty="Opacity" + EasingFunction="{StaticResource RippleEasingFunction}" + To="0.26" Duration="0"/> + <DoubleAnimation Storyboard.TargetName="RippleThumb" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" + EasingFunction="{StaticResource RippleEasingFunction}" + From="1" To="2.5" Duration="0:0:0.2"/> + <DoubleAnimation Storyboard.TargetName="RippleThumb" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" + EasingFunction="{StaticResource RippleEasingFunction}" + From="1" To="2.5" Duration="0:0:0.2"/> + </Storyboard> + <Storyboard x:Key="HideRipple"> + <DoubleAnimation Storyboard.TargetName="RippleThumb" Storyboard.TargetProperty="Opacity" + EasingFunction="{StaticResource RippleEasingFunction}" + To="0" Duration="0:0:0.3"/> + </Storyboard> + </ControlTemplate.Resources> + <Viewbox Width="34"> + <VisualStateManager.VisualStateGroups> + <VisualStateGroup x:Name="CheckStates"> + <VisualStateGroup.Transitions> + <VisualTransition From="*" To="Checked"> + <Storyboard> + <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="ThumbHolder"> + <EasingDoubleKeyFrame KeyTime="0" Value="0"/> + <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="23.5"> + <EasingDoubleKeyFrame.EasingFunction> + <QuadraticEase EasingMode="EaseOut"/> + </EasingDoubleKeyFrame.EasingFunction> + </EasingDoubleKeyFrame> + </DoubleAnimationUsingKeyFrames> + </Storyboard> + </VisualTransition> + <VisualTransition From="Checked" To="Unchecked"> + <Storyboard> + <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="ThumbHolder"> + <EasingDoubleKeyFrame KeyTime="0" Value="23.5"/> + <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"> + <EasingDoubleKeyFrame.EasingFunction> + <QuadraticEase EasingMode="EaseOut"/> + </EasingDoubleKeyFrame.EasingFunction> + </EasingDoubleKeyFrame> + </DoubleAnimationUsingKeyFrames> + </Storyboard> + </VisualTransition> + </VisualStateGroup.Transitions> + <VisualState x:Name="Checked"> + <Storyboard> + <DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="ThumbHolder" + Duration="0" To="23.5" /> + </Storyboard> + </VisualState> + <VisualState x:Name="Unchecked"> + <Storyboard> + <DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="ThumbHolder" + Duration="0" To="0" /> + </Storyboard> + </VisualState> + </VisualStateGroup> + </VisualStateManager.VisualStateGroups> + <Grid> + <Rectangle x:Name="Track" + Fill= "{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ToggleButtonAssist.SwitchTrackOffBackground)}" + Opacity="0.26" + HorizontalAlignment="Left" + Height="15" + Margin="4.211,5,4.211,0" + Stroke="{x:Null}" + VerticalAlignment="Top" + Width="40" + RadiusY="7.5" + RadiusX="7.5"/> + <Grid x:Name="ThumbHolder" + HorizontalAlignment="Left" VerticalAlignment="Top"> + <Ellipse x:Name="RippleThumb" + Fill="{DynamicResource PrimaryHueLightBrush}" + Height="25" Width="25" + IsHitTestVisible="False" + Opacity="0.26" + Margin="0" + HorizontalAlignment="Center" VerticalAlignment="Center" + RenderTransformOrigin="0.5,0.5"> + <Ellipse.RenderTransform> + <ScaleTransform ScaleX="1" ScaleY="1"/> + </Ellipse.RenderTransform> + </Ellipse> + <AdornerDecorator CacheMode="{Binding RelativeSource={RelativeSource Self}, Path=(wpf:ShadowAssist.CacheMode)}"> + <Ellipse x:Name="Thumb" + Fill="#707070" Stroke="{x:Null}" + HorizontalAlignment="Center" VerticalAlignment="Center" + Width="25" Height="25" + Margin="0,0,0,0" + RenderTransformOrigin="0.5,0.5" + Effect="{DynamicResource MaterialDesignShadowDepth1}"> + </Ellipse> + </AdornerDecorator> + <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" + Margin="{TemplateBinding Padding}" + x:Name="ContentPresenter" + HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" + FlowDirection="LeftToRight"/> + <Grid.RenderTransform> + <TranslateTransform X="0" Y="0"/> + </Grid.RenderTransform> + </Grid> + </Grid> + </Viewbox> + <ControlTemplate.Triggers> + <Trigger Property="IsChecked" Value="True"> + <Setter TargetName="Thumb" Property="Fill" Value="{StaticResource FSE_PrimaryAccentBrush}" /> + <Setter TargetName="Track" Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ToggleButtonAssist.SwitchTrackOnBackground)}" /> + <Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidForegroundBrush}"/> + </Trigger> + <MultiTrigger> + <MultiTrigger.Conditions> + <Condition Property="IsChecked" Value="True" /> + <Condition Property="wpf:ToggleButtonAssist.HasOnContent" Value="True" /> + </MultiTrigger.Conditions> + <Setter TargetName="ContentPresenter" Property="Content" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ToggleButtonAssist.OnContent)}" /> + <Setter TargetName="ContentPresenter" Property="ContentTemplate" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ToggleButtonAssist.OnContentTemplate)}" /> + </MultiTrigger> + <Trigger Property="IsChecked" Value="False"> + <Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidBrush}"/> + <!-- Need to set Foreground to Background here instead of hardcoded PrimaryHueMidBrush --> + </Trigger> + <Trigger Property="Button.IsDefaulted" Value="true"/> + <Trigger Property="IsMouseOver" Value="true"/> + <Trigger Property="IsPressed" Value="true"> + <Trigger.EnterActions> + <BeginStoryboard Storyboard="{StaticResource ShowRipple}"/> + </Trigger.EnterActions> + <Trigger.ExitActions> + <BeginStoryboard Storyboard="{StaticResource HideRipple}"/> + </Trigger.ExitActions> + </Trigger> + <Trigger Property="IsEnabled" Value="false"> + <Setter TargetName="Thumb" Property="Fill" Value="{StaticResource FSE_PrimaryBackgroundLightBrush}" /> + <Setter TargetName="Track" Property="Fill" Value="{StaticResource FSE_PrimaryBackgroundLightBrush}" /> + </Trigger> + </ControlTemplate.Triggers> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + <Style TargetType="Separator"> + <Setter Property="Background" Value="{StaticResource FSE_PrimaryBackgroundLightBrush}"></Setter> + </Style> + </ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj index 4f0cb622b..bb44045b7 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj @@ -188,6 +188,7 @@ <Compile Include="Converters\TimeSpanHumanizeConverter.cs" /> <Compile Include="Core\FSEProgress.cs" /> <Compile Include="DashboardTile.cs" /> + <Compile Include="DataStore\IDataStoreProvider.cs" /> <Compile Include="DataStore\IRemoteDataStoreManager.cs" /> <Compile Include="DemoMode\DemoModeCommand.cs" /> <Compile Include="DemoMode\IDemoModeManager.cs" /> @@ -505,6 +506,10 @@ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.DataStore.Editing\Tango.DataStore.Editing.csproj"> + <Project>{ee088ff7-04d1-41fb-9d6a-cedeee7a7b9c}</Project> + <Name>Tango.DataStore.Editing</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.DataStore\Tango.DataStore.csproj"> <Project>{e0364dfa-0721-4637-9d32-9d22aac109d6}</Project> <Name>Tango.DataStore</Name> diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs index 94b035ab5..aad63fdf9 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs @@ -342,6 +342,7 @@ namespace Tango.FSE.UI.Connection { IsConnected = false; IsBusy = false; + Machine = null; OnMachineDisconnected(MachineOperator, null); } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Controls/NotificationsControl.xaml b/Software/Visual_Studio/FSE/Tango.FSE.UI/Controls/NotificationsControl.xaml index 4e6ada6b5..4a2510552 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Controls/NotificationsControl.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Controls/NotificationsControl.xaml @@ -336,10 +336,14 @@ <commonControls:IconButton Icon="Close" Padding="5" Cursor="Hand" Margin="0 0 5 0" Command="{Binding CloseCommand}" CommandParameter="{Binding}" HorizontalAlignment="Right" Width="{Binding RelativeSource={RelativeSource Self},Path=ActualHeight}"/> </Grid> - <StackPanel Grid.Row="1" Margin="40" VerticalAlignment="Top"> - <TextBlock Foreground="{StaticResource FSE_PrimaryForegroundBrush}" Text="{Binding Message}" TextWrapping="Wrap"></TextBlock> - <TextBox x:Name="txtInput" KeyDown="TxtInput_KeyDown" Margin="0 20 0 0" Text="{Binding Input,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" MaxLength="{Binding MaxCharacters}" material:HintAssist.Hint="{Binding InputHint}" /> - </StackPanel> + <Grid Grid.Row="1" Margin="40" VerticalAlignment="Top"> + <StackPanel> + <TextBlock Foreground="{StaticResource FSE_PrimaryForegroundBrush}" Text="{Binding Message}" TextWrapping="Wrap"></TextBlock> + <TextBox x:Name="txtInput" KeyDown="TxtInput_KeyDown" Margin="0 20 0 0" Text="{Binding Input,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" MaxLength="{Binding MaxCharacters}" material:HintAssist.Hint="{Binding InputHint}" /> + </StackPanel> + + <TextBlock VerticalAlignment="Bottom" Margin="0 0 0 -20" TextWrapping="Wrap" Foreground="{StaticResource FSE_ErrorBrush}" FontSize="{StaticResource FSE_SmallFontSize}" Text="{Binding Error}" Visibility="{Binding HasValidationError,Converter={StaticResource BooleanToVisibilityConverter}}"></TextBlock> + </Grid> <StackPanel HorizontalAlignment="Right" Grid.Row="2" Margin="10" Orientation="Horizontal"> <Button MinWidth="150" x:Name="btnInputCancel" Height="Auto" Style="{StaticResource FSE_RaisedButton_Dark_Hover}" Margin="0 0 10 0" Command="{Binding CloseCommand}" Visibility="{Binding HasCancel,Converter={StaticResource BooleanToVisibilityConverter}}" Content="{Binding CancelText}"></Button> diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/DataStore/DefaultDataStoreProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/DataStore/DefaultDataStoreProvider.cs new file mode 100644 index 000000000..167af2dd5 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/DataStore/DefaultDataStoreProvider.cs @@ -0,0 +1,340 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.DTO; +using Tango.BL.Entities; +using Tango.Core; +using Tango.Core.DI; +using Tango.DataStore; +using Tango.DataStore.Editing; +using Tango.DataStore.EF; +using Tango.DataStore.Remote; +using Tango.FSE.BL; +using Tango.FSE.Common.Connection; +using Tango.FSE.Common.DataStore; + +namespace Tango.FSE.UI.DataStore +{ + public class DefaultDataStoreProvider : ExtendedObject, IDataStoreProvider + { + private DataStoreModel _lastModel; + private IMachineProvider MachineProvider { get; set; } + + [TangoInject] + private FSEServicesContainer Services { get; set; } + + private bool _acceptFirmwareChanges; + public bool AcceptFirmwareChanges + { + get { return _acceptFirmwareChanges; } + set { _acceptFirmwareChanges = value; RaisePropertyChangedAuto(); } + } + + public DefaultDataStoreProvider(IMachineProvider machineProvider) + { + MachineProvider = machineProvider; + MachineProvider.MachineConnected += MachineProvider_MachineConnected; + } + + private void MachineProvider_MachineConnected(object sender, MachineConnectedEventArgs e) + { + _lastModel = null; + + if (MachineProvider.IsPPCAvailable) + { + LogManager.Log("Starting listening for data store changes..."); + + MachineProvider.MachineOperator.SendGenericContinuousRequest<RemoteDataStoreStartListenRequest, RemoteDataStoreStartListenResponse>(new RemoteDataStoreStartListenRequest()).Subscribe((response) => + { + if (response.ChangeType != RemoteDataStoreChangeType.None) + { + LogManager.Log($"Data store change received for '{response.Item.Key}.{response.Item.Key}'..."); + OnDataStoreItemChanged(response); + } + }, (ex) => + { + if (!(ex is Transport.TransporterDisconnectedException)) + { + LogManager.Log(ex, "Error occurred on data store changes listener."); + } + }, () => + { + //Nothing. + }); + } + } + + private void OnDataStoreItemChanged(RemoteDataStoreStartListenResponse response) + { + if (_lastModel != null && AcceptFirmwareChanges) + { + DataStoreCollectionModel collectionModel = _lastModel.Collections.FirstOrDefault(x => x.Name == response.CollectionName); + + if (collectionModel == null) + { + collectionModel = new DataStoreCollectionModel(); + collectionModel.Name = response.CollectionName; + _lastModel.Collections.Add(collectionModel); + } + + var remoteItem = response.Item; + + var itemModel = collectionModel.Items.FirstOrDefault(x => x.Guid == remoteItem.Guid); + + if (itemModel == null) + { + itemModel = DataStoreItemModel.FromLocalDataStoreItem(remoteItem, null); + itemModel.ExistsOnMachine = true; + collectionModel.Items.Add(itemModel); + } + else + { + itemModel.Value = remoteItem.Value; + itemModel.Type = remoteItem.Type; + itemModel.Date = remoteItem.Date; + } + } + } + + public Task<DataStoreModel> GetDataStoreModel(String machineGuid) + { + return Task.Factory.StartNew<DataStoreModel>(() => + { + DataStoreModel model = new DataStoreModel(); + + List<GlobalDataStoreItem> globalItems = Services.DataStoreService.GetGlobalDataStoreItems().Result; + List<DataStoreItem> localItems = Services.DataStoreService.GetMachinelDataStoreItems(machineGuid).Result; + + List<DataStoreItemModel> itemsModels = new List<DataStoreItemModel>(); + + //Get machine items from db. + foreach (var collection in localItems.GroupBy(x => x.CollectionName)) + { + DataStoreCollectionModel collectionModel = new DataStoreCollectionModel(); + collectionModel.Name = collection.First().CollectionName; + + foreach (var item in collection) + { + GlobalDataStoreItem globalItem = globalItems.FirstOrDefault(x => x.CollectionName == item.CollectionName && x.Key == item.Key); + + if (globalItem != null) + { + globalItems.Remove(globalItem); + } + + DataStoreItemModel itemModel = DataStoreItemModel.FromLocalDataStoreItem(item.ToDataStoreItem(), globalItem?.ToDataStoreItem()); + collectionModel.Items.Add(itemModel); + } + + model.Collections.Add(collectionModel); + } + + //Get machine items from connected machine. + if (MachineProvider.IsPPCAvailable && machineGuid == MachineProvider.Machine.Guid) + { + var response = MachineProvider.MachineOperator.SendGenericRequest<RemoteDataStoreGetAllItemsRequest, RemoteDataStoreGetAllItemsResponse>(new RemoteDataStoreGetAllItemsRequest(), new Transport.TransportRequestConfig() { Timeout = TimeSpan.FromSeconds(30) }).Result; + + foreach (var collection in response.Collections) + { + DataStoreCollectionModel collectionModel = model.Collections.FirstOrDefault(x => x.Name == collection.Name); + + if (collectionModel == null) + { + collectionModel = new DataStoreCollectionModel(); + collectionModel.Name = collection.Name; + model.Collections.Add(collectionModel); + } + + foreach (var remoteItem in collection.Items) + { + var localItem = collectionModel.Items.FirstOrDefault(x => x.Key == remoteItem.Key); + + if (localItem != null) + { + localItem.ExistsOnMachine = true; + } + + if (localItem != null && remoteItem.Date > localItem.Date) + { + localItem.Value = remoteItem.Value; + localItem.OriginalValue = remoteItem.Value; + localItem.Type = remoteItem.Type; + localItem.Date = remoteItem.Date; + } + else if (localItem == null) + { + GlobalDataStoreItem globalItem = globalItems.FirstOrDefault(x => x.CollectionName == collection.Name && x.Key == remoteItem.Key); + + if (globalItem != null) + { + globalItems.Remove(globalItem); + } + + DataStoreItemModel itemModel = DataStoreItemModel.FromLocalDataStoreItem(remoteItem, globalItem?.ToDataStoreItem()); + itemModel.ExistsOnMachine = true; + collectionModel.Items.Add(itemModel); + } + + } + } + } + + //Get global items without overrides from db. + foreach (var collection in globalItems.GroupBy(x => x.CollectionName)) + { + DataStoreCollectionModel collectionModel = model.Collections.FirstOrDefault(x => x.Name == collection.First().CollectionName); + + if (collectionModel == null) + { + collectionModel = new DataStoreCollectionModel(); + collectionModel.Name = collection.First().CollectionName; + model.Collections.Add(collectionModel); + } + + foreach (var item in collection) + { + DataStoreItemModel itemModel = DataStoreItemModel.FromGlobalDataStoreItem(item.ToDataStoreItem()); + collectionModel.Items.Add(itemModel); + } + } + + + _lastModel = model; + return model; + }); + } + + private class SaveModel + { + public String CollectionName { get; set; } + public DataStoreItemModel Item { get; set; } + } + + public Task<DataStoreModel> UpdateDataStoreModel(DataStoreModel model, String machineGuid) + { + return Task.Factory.StartNew<DataStoreModel>(() => + { + List<SaveModel> globals = new List<SaveModel>(); + List<SaveModel> locals = new List<SaveModel>(); + List<SaveModel> deleted = new List<SaveModel>(); + UpdateDataStoreRequest updateRequest = new UpdateDataStoreRequest(); + + foreach (var collection in model.Collections.Where(x => !x.IsDeleted)) + { + foreach (var item in collection.Items) + { + if (item.IsGlobal) + { + globals.Add(new SaveModel() { CollectionName = collection.Name, Item = item }); + } + else if (item.IsDeleted) + { + deleted.Add(new SaveModel() { CollectionName = collection.Name, Item = item }); + } + else if (item.HasDifference || (MachineProvider.IsPPCAvailable && !item.ExistsOnMachine)) + { + locals.Add(new SaveModel() { CollectionName = collection.Name, Item = item }); + } + } + } + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var allItems = db.DataStoreItems.Where(x => x.MachineGuid == machineGuid).ToList(); + + //Deleted collections + foreach (var deletedCollection in model.Collections.Where(x => x.IsDeleted)) + { + foreach (var itemDb in allItems.ToList()) + { + if (itemDb.CollectionName == deletedCollection.Name) + { + itemDb.IsDeleted = true; + itemDb.LastUpdated = DateTime.UtcNow; + itemDb.IsSynchronized = false; + updateRequest.ToDelete.Add(itemDb.Guid); + } + } + } + + //Deleted items + foreach (var item in deleted) + { + var itemDb = allItems.FirstOrDefault(x => x.CollectionName == item.CollectionName && x.Key == item.Item.Key); + if (itemDb != null) + { + itemDb.IsDeleted = true; + itemDb.LastUpdated = DateTime.UtcNow; + itemDb.IsSynchronized = false; + updateRequest.ToDelete.Add(itemDb.Guid); + } + } + + //locals + foreach (var item in locals) + { + DataStoreItem itemDb = allItems.FirstOrDefault(x => x.CollectionName == item.CollectionName && x.Key == item.Item.Key); + + if (itemDb == null) //new local item. + { + itemDb = new DataStoreItem(); + itemDb.MachineGuid = machineGuid; + itemDb.CollectionName = item.CollectionName; + itemDb.Key = item.Item.Key; + itemDb.LastUpdated = DateTime.UtcNow; + itemDb.DataType = (int)item.Item.Type; + itemDb.Value = EFDataStoreHelper.CreateBytes(item.Item.Type, item.Item.Value); + db.DataStoreItems.Add(itemDb); + updateRequest.ToUpsert.Add(DataStoreItemDTO.FromObservable(itemDb)); + } + else //update local item only if changed... + { + bool upsert = MachineProvider.IsPPCAvailable && !item.Item.ExistsOnMachine; + + if (itemDb.IsDeleted) //restore if item was deleted.. + { + itemDb.IsDeleted = false; + itemDb.LastUpdated = DateTime.UtcNow; + itemDb.IsSynchronized = false; + upsert = true; + } + + //update item only if it has difference although "locals" already contains only differences. + var bytes = EFDataStoreHelper.CreateBytes(item.Item.Type, item.Item.Value); + + if (itemDb.DataType != (int)item.Item.Type || !Enumerable.SequenceEqual(itemDb.Value, bytes)) + { + itemDb.DataType = (int)item.Item.Type; + itemDb.Value = bytes; + itemDb.LastUpdated = DateTime.UtcNow; + itemDb.IsSynchronized = false; + upsert = true; + } + + if (upsert) + { + updateRequest.ToUpsert.Add(DataStoreItemDTO.FromObservable(itemDb)); + } + } + } + + if (MachineProvider.IsPPCAvailable && machineGuid == MachineProvider.Machine.Guid) + { + //Direct Sync Here. + //Make all items "IsSynchronized = true" if success. + var response = MachineProvider.MachineOperator.SendGenericRequest<UpdateDataStoreRequest, UpdateDataStoreResponse>(updateRequest, new Transport.TransportRequestConfig() { Timeout = TimeSpan.FromSeconds(30) }).Result; + + allItems.ForEach(x => x.IsSynchronized = true); + } + + db.SaveChanges(); + } + + return GetDataStoreModel(machineGuid).Result; + }); + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/FileAssociation/DefaultFileAssociationProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/FileAssociation/DefaultFileAssociationProvider.cs index 0d582cb11..89364cbbd 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/FileAssociation/DefaultFileAssociationProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/FileAssociation/DefaultFileAssociationProvider.cs @@ -19,6 +19,7 @@ namespace Tango.FSE.UI.FileAssociation { private Dictionary<String, Action<FileAssociationPackage>> _handlers; private IpcServer _ipcServer; + private bool _initialized; public const string FILE_ASSOCIATION_PREFIX = "-file"; public const int FILE_ASSOCIATION_ARGS_COUNT = 3; @@ -44,6 +45,10 @@ namespace Tango.FSE.UI.FileAssociation public async void OnApplicationReady(IFSEApplicationManager applicationManager) { + if (!_initialized) return; + + _initialized = true; + try { LogManager.Log("Starting file association IPC service..."); diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Notifications/DefaultNotificationProvider.cs index 4992953c2..7299a836d 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Notifications/DefaultNotificationProvider.cs @@ -340,7 +340,7 @@ namespace Tango.FSE.UI.Notifications return source.Task; } - public Task<InputBoxResult> ShowInputBox(string title, string message, PackIconKind icon = PackIconKind.InformationOutline, string defaultInput = null, string inputHint = null, int? maxChars = null, string okText = null, string cancelText = null) + public Task<InputBoxResult> ShowInputBox(string title, string message, PackIconKind icon = PackIconKind.InformationOutline, string defaultInput = null, string inputHint = null, int? maxChars = null, string okText = null, string cancelText = null, Func<String, String> validationFunc = null) { TaskCompletionSource<InputBoxResult> source = new TaskCompletionSource<InputBoxResult>(); @@ -350,6 +350,8 @@ namespace Tango.FSE.UI.Notifications vm.Icon = icon; vm.Input = defaultInput; vm.InputHint = inputHint; + vm.ValidationFunction = validationFunc; + if (maxChars != null) { vm.MaxCharacters = maxChars.Value; diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj index 6c5b993b5..baff92208 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj @@ -261,6 +261,7 @@ <Compile Include="Converters\MidTankLevelToElementHeightConverter.cs" /> <Compile Include="Converters\StringToFirstLetterConverter.cs" /> <Compile Include="Cryptography\DefaultCryptographyProvider.cs" /> + <Compile Include="DataStore\DefaultDataStoreProvider.cs" /> <Compile Include="DataStore\DefaultRemoteDataStoreManager.cs" /> <Compile Include="DataStore\RemoteDataStoreCollection.cs" /> <Compile Include="DemoMode\DefaultDemoModeManager.cs" /> @@ -640,6 +641,14 @@ <Project>{38197109-8610-4d3f-92b9-16d48df94d7c}</Project> <Name>Tango.DAL.Remote</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.DataStore.Editing\Tango.DataStore.Editing.csproj"> + <Project>{EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}</Project> + <Name>Tango.DataStore.Editing</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.DataStore.EF\Tango.DataStore.EF.csproj"> + <Project>{88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4}</Project> + <Name>Tango.DataStore.EF</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.DataStore.Remote\Tango.DataStore.Remote.csproj"> <Project>{29448f3c-9b3e-4da6-8555-46a8b9a6b3aa}</Project> <Name>Tango.DataStore.Remote</Name> @@ -716,6 +725,10 @@ <Project>{ac5b4be7-d607-4a38-98f8-b87aca468313}</Project> <Name>Tango.FSE.Insights</Name> </ProjectReference> + <ProjectReference Include="..\Modules\Tango.FSE.MachineConfiguration\Tango.FSE.MachineConfiguration.csproj"> + <Project>{15bcb5bb-731e-4e2d-aa28-75485050a8dc}</Project> + <Name>Tango.FSE.MachineConfiguration</Name> + </ProjectReference> <ProjectReference Include="..\Modules\Tango.FSE.PPCConsole\Tango.FSE.PPCConsole.csproj"> <Project>{866b916a-207c-43f0-b403-7c4a820c2e11}</Project> <Name>Tango.FSE.PPCConsole</Name> diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs index fd514b7ac..e9d18d777 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs @@ -117,6 +117,7 @@ namespace Tango.FSE.UI TangoIOC.Default.Unregister<IRemoteActionsProvider>(); TangoIOC.Default.Unregister<IActionLogManager>(); TangoIOC.Default.Unregister<IRemoteDataStoreManager>(); + TangoIOC.Default.Unregister<IDataStoreProvider>(); //TangoIOC.Default.Unregister<ExternalBridgeScanner>(); //TangoIOC.Default.Unregister<IDiagnosticsFrameProvider>(); //TangoIOC.Default.Unregister<IEventLogger>(); @@ -160,6 +161,7 @@ namespace Tango.FSE.UI TangoIOC.Default.Register<IInsightsProvider, DefaultInsightsProvider>(); TangoIOC.Default.Register<IRemoteActionsProvider, DefaultRemoteActionsProvider>(); TangoIOC.Default.Register<IRemoteDataStoreManager, DefaultRemoteDataStoreManager>(); + TangoIOC.Default.Register<IDataStoreProvider, DefaultDataStoreProvider>(); TangoIOC.Default.Register<MainWindowVM>(); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/DataStore/DefaultDataStoreService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/DataStore/DefaultDataStoreService.cs index ddc0f6cdb..ce8e42e35 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/DataStore/DefaultDataStoreService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/DataStore/DefaultDataStoreService.cs @@ -17,18 +17,33 @@ using Tango.PPC.Common.ExternalBridge; using Tango.Transport; using Tango.Core.ExtensionMethods; using Newtonsoft.Json.Linq; +using Tango.BL; +using Tango.DataStore.Editing; +using Newtonsoft.Json; +using Tango.Core; namespace Tango.PPC.Common.DataStore { [TangoCreateWhenRegistered] - public class DefaultDataStoreService : IDataStoreService, IExternalBridgeRequestHandler + public class DefaultDataStoreService : ExtendedObject, IDataStoreService, IExternalBridgeRequestHandler { private IDataStoreManager _manager; + private IMachineProvider _machineProvider; + private List<ListerReceiver> _listenerReceivers; + + private class ListerReceiver + { + public String Token { get; set; } + public ExternalBridgeReceiver Receiver { get; set; } + } public DefaultDataStoreService(IPPCExternalBridgeService externalBridge, IMachineProvider machineProvider) { externalBridge.RegisterRequestHandler(this); + + _listenerReceivers = new List<ListerReceiver>(); + _machineProvider = machineProvider; machineProvider.MachineOperator.RegisterRequestHandler<PutDataStoreItemRequest>(OnPutDataStoreItemRequest); machineProvider.MachineOperator.RegisterRequestHandler<GetDataStoreItemRequest>(OnGetDataStoreItemRequest); } @@ -132,6 +147,112 @@ namespace Tango.PPC.Common.DataStore }, token); } + [ExternalBridgeRequestHandlerMethod(typeof(RemoteDataStoreGetAllItemsRequest), RequestHandlerLoggingMode.LogRequestName)] + public async Task OnRemoteDataStoreGetAllItemsRequest(RemoteDataStoreGetAllItemsRequest request, String token, ExternalBridgeReceiver receiver) + { + List<RemoteDataStoreCollection> collections = new List<RemoteDataStoreCollection>(); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var items = db.DataStoreItems.Where(x => !x.IsDeleted).ToList(); + + foreach (var itemsGroup in items.GroupBy(x => x.CollectionName)) + { + RemoteDataStoreCollection collection = new RemoteDataStoreCollection(); + collection.Name = itemsGroup.First().CollectionName; + collections.Add(collection); + + foreach (var item in itemsGroup) + { + collection.Items.Add(CreateRemoteItem(item.ToDataStoreItem())); + } + } + } + + await receiver.SendGenericResponse(new RemoteDataStoreGetAllItemsResponse() + { + Collections = collections + }, token); + } + + [ExternalBridgeRequestHandlerMethod(typeof(UpdateDataStoreRequest), RequestHandlerLoggingMode.LogRequestName)] + public async Task OnUpdateDataStoreRequest(UpdateDataStoreRequest request, String token, ExternalBridgeReceiver receiver) + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var allItems = db.DataStoreItems.ToList(); + + foreach (var guid in request.ToDelete) + { + var item = allItems.FirstOrDefault(x => x.Guid == guid); + if (item != null) + { + item.IsDeleted = true; + item.IsSynchronized = true; + item.LastUpdated = DateTime.UtcNow; + } + } + + foreach (var item in request.ToUpsert) + { + var itemDb = allItems.FirstOrDefault(x => x.CollectionName == item.CollectionName && x.Key == item.Key); + + if (itemDb == null) + { + itemDb = new BL.Entities.DataStoreItem(); + itemDb.Guid = item.Guid; + db.DataStoreItems.Add(itemDb); + } + + itemDb.CollectionName = item.CollectionName; + itemDb.DataType = item.DataType; + itemDb.IsDeleted = item.IsDeleted; + itemDb.IsSynchronized = true; + itemDb.Key = item.Key; + itemDb.LastUpdated = item.LastUpdated; + itemDb.Value = item.Value; + } + + db.SaveChanges(); + + if (_machineProvider.IsConnected) + { + Core.Threading.ThreadFactory.StartNew(() => + { + foreach (var item in request.ToUpsert) + { + try + { + var response = _machineProvider.MachineOperator.SendRequest<DataStoreItemModifiedRequest, DataStoreItemModifiedResponse>(new DataStoreItemModifiedRequest() + { + Collection = item.CollectionName, + Key = item.Key + }).Result; + } + catch (Exception ex) + { + Logging.LogManager.Default.Log(ex, $"Error notifying firmware about data store item change '{item.CollectionName}.{item.Key}'."); + } + } + }); + } + } + + await receiver.SendGenericResponse(new UpdateDataStoreResponse(), token); + } + + [ExternalBridgeRequestHandlerMethod(typeof(RemoteDataStoreStartListenRequest), RequestHandlerLoggingMode.LogRequestName)] + public async Task OnRemoteDataStoreStartListenRequest(RemoteDataStoreStartListenRequest request, String token, ExternalBridgeReceiver receiver) + { + _listenerReceivers.Add(new ListerReceiver() { Receiver = receiver, Token = token }); + + await receiver.SendGenericResponse(new RemoteDataStoreStartListenResponse() + { + ChangeType = RemoteDataStoreChangeType.None, + Item = null + }, token); + } + private RemoteDataStoreItem CreateRemoteItem(IDataStoreItem item) { RemoteDataStoreItem remote = new RemoteDataStoreItem(); @@ -151,6 +272,36 @@ namespace Tango.PPC.Common.DataStore { GetManager().GetCollection(request.Collection).Put(request.Key, GetPMRValue(request.Item)); await transporter.SendResponse(new PutDataStoreItemResponse(), token); + + try + { + if (_listenerReceivers.Count > 0) + { + var item = GetManager().GetCollection(request.Collection).GetItem(request.Key); + var remoteItem = CreateRemoteItem(item); + + foreach (var listener in _listenerReceivers.ToList()) + { + try + { + await listener.Receiver.SendGenericResponse(new RemoteDataStoreStartListenResponse() + { + ChangeType = RemoteDataStoreChangeType.Modified, + CollectionName = request.Collection, + Item = remoteItem + }, listener.Token); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error sending data store item notification to receiver '{listener.Receiver.Adapter.ToString()}'"); + } + } + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error generating data store item notifications."); + } } catch (Exception ex) { @@ -281,6 +432,7 @@ namespace Tango.PPC.Common.DataStore public void OnReceiverDisconnected(ExternalBridgeReceiver receiver) { //Do nothing. + _listenerReceivers.RemoveAll(x => x.Receiver == receiver); } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 4cb3b42dc..1b073ee6f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -388,6 +388,10 @@ <Project>{58e8825f-0c96-449c-b320-1e82b0aa876b}</Project> <Name>Tango.CSV</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.DataStore.Editing\Tango.DataStore.Editing.csproj"> + <Project>{ee088ff7-04d1-41fb-9d6a-cedeee7a7b9c}</Project> + <Name>Tango.DataStore.Editing</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.DataStore.EF\Tango.DataStore.EF.csproj"> <Project>{88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4}</Project> <Name>Tango.DataStore.EF</Name> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs index fb5b9796f..5218d9f70 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs @@ -182,7 +182,7 @@ namespace Tango.PPC.UI.Connectivity || net.NetworkInterfaceType == NetworkInterfaceType.Ethernet3Megabit || net.NetworkInterfaceType == NetworkInterfaceType.FastEthernetFx || net.NetworkInterfaceType == NetworkInterfaceType.FastEthernetT - || net.NetworkInterfaceType == NetworkInterfaceType.GigabitEthernet) && net.Name == "Ethernet" && net.OperationalStatus == OperationalStatus.Up) + || net.NetworkInterfaceType == NetworkInterfaceType.GigabitEthernet) && net.Name.ToStringOrEmpty().StartsWith("Ethernet") && net.OperationalStatus == OperationalStatus.Up) { IsLanConnected = true; return; diff --git a/Software/Visual_Studio/Tango.BL/DTO/DataStoreItemDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/DataStoreItemDTOBase.cs index 8a6bfd7a4..9951338ec 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/DataStoreItemDTOBase.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/DataStoreItemDTOBase.cs @@ -62,6 +62,14 @@ namespace Tango.BL.DTO } /// <summary> + /// is deleted + /// </summary> + public Boolean IsDeleted + { + get; set; + } + + /// <summary> /// is synchronized /// </summary> public Boolean IsSynchronized diff --git a/Software/Visual_Studio/Tango.BL/Entities/DataStoreItemBase.cs b/Software/Visual_Studio/Tango.BL/Entities/DataStoreItemBase.cs index c9c433e02..6d393f6a2 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/DataStoreItemBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/DataStoreItemBase.cs @@ -35,6 +35,8 @@ namespace Tango.BL.Entities public event EventHandler<Byte[]> ValueChanged; + public event EventHandler<Boolean> IsDeletedChanged; + public event EventHandler<Boolean> IsSynchronizedChanged; public event EventHandler<Machine> MachineChanged; @@ -173,6 +175,33 @@ namespace Tango.BL.Entities } } + protected Boolean _isdeleted; + + /// <summary> + /// Gets or sets the datastoreitembase is deleted. + /// </summary> + + [Column("IS_DELETED")] + + public Boolean IsDeleted + { + get + { + return _isdeleted; + } + + set + { + if (_isdeleted != value) + { + _isdeleted = value; + + OnIsDeletedChanged(value); + + } + } + } + protected Boolean _issynchronized; /// <summary> @@ -269,6 +298,15 @@ namespace Tango.BL.Entities } /// <summary> + /// Called when the IsDeleted has changed. + /// </summary> + protected virtual void OnIsDeletedChanged(Boolean isdeleted) + { + IsDeletedChanged?.Invoke(this, isdeleted); + RaisePropertyChanged(nameof(IsDeleted)); + } + + /// <summary> /// Called when the IsSynchronized has changed. /// </summary> protected virtual void OnIsSynchronizedChanged(Boolean issynchronized) diff --git a/Software/Visual_Studio/Tango.BL/Entities/HardwareVersion.cs b/Software/Visual_Studio/Tango.BL/Entities/HardwareVersion.cs index 590fe9e13..bc65c33ce 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/HardwareVersion.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/HardwareVersion.cs @@ -109,5 +109,16 @@ namespace Tango.BL.Entities { } + + /// <summary> + /// Returns a <see cref="System.String" /> that represents this instance. + /// </summary> + /// <returns> + /// A <see cref="System.String" /> that represents this instance. + /// </returns> + public override string ToString() + { + return FullName; + } } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/Organization.cs b/Software/Visual_Studio/Tango.BL/Entities/Organization.cs index 738c77efb..7580c6fd1 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Organization.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Organization.cs @@ -15,5 +15,10 @@ namespace Tango.BL.Entities { } + + public override string ToString() + { + return Name; + } } } diff --git a/Software/Visual_Studio/Tango.CSV/DynamicCsvFile.cs b/Software/Visual_Studio/Tango.CSV/DynamicCsvFile.cs index 0c4d79949..ec04de3ff 100644 --- a/Software/Visual_Studio/Tango.CSV/DynamicCsvFile.cs +++ b/Software/Visual_Studio/Tango.CSV/DynamicCsvFile.cs @@ -82,6 +82,7 @@ namespace Tango.CSV } _writer.WriteLine(String.Join(",", valuesStr)); + _writer.Flush(); } public void Dispose() @@ -92,6 +93,7 @@ namespace Tango.CSV if (_disposeStream) { + _writer?.Dispose(); _stream?.Dispose(); } } diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/StringExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/StringExtensions.cs index 97c8773d6..5a12e16bb 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/StringExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/StringExtensions.cs @@ -261,6 +261,11 @@ public static class StringExtensions return !String.IsNullOrWhiteSpace(str); } + public static String ToOneLine(this String str) + { + return str.Replace(Environment.NewLine, " "); + } + public static List<T> ToEnumValues<T>(this String str, char splitChar) where T : struct { if (!String.IsNullOrWhiteSpace(str)) diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/DATA_STORE_ITEMS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/DATA_STORE_ITEMS.cs index ad42a6db8..6fcfe6a86 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/DATA_STORE_ITEMS.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/DATA_STORE_ITEMS.cs @@ -22,6 +22,7 @@ namespace Tango.DAL.Remote.DB public string KEY { get; set; } public int DATA_TYPE { get; set; } public byte[] VALUE { get; set; } + public bool IS_DELETED { get; set; } public bool IS_SYNCHRONIZED { get; set; } public virtual MACHINE MACHINE { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index 3b471ca54..13b409e05 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -266,6 +266,7 @@ <Property Name="KEY" Type="nvarchar" MaxLength="50" Nullable="false" /> <Property Name="DATA_TYPE" Type="int" Nullable="false" /> <Property Name="VALUE" Type="image" Nullable="false" /> + <Property Name="IS_DELETED" Type="bit" Nullable="false" /> <Property Name="IS_SYNCHRONIZED" Type="bit" Nullable="false" /> </EntityType> <EntityType Name="DISPENSER_TYPES"> @@ -3671,6 +3672,7 @@ <Property Name="KEY" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" /> <Property Name="DATA_TYPE" Type="Int32" Nullable="false" /> <Property Name="VALUE" Type="Binary" Nullable="false" MaxLength="Max" FixedLength="false" /> + <Property Name="IS_DELETED" Type="Boolean" Nullable="false" /> <Property Name="IS_SYNCHRONIZED" Type="Boolean" Nullable="false" /> <NavigationProperty Name="MACHINE" Relationship="RemoteModel.FK_DATA_STORES_MACHINES" FromRole="DATA_STORE_ITEMS" ToRole="MACHINE" /> </EntityType> @@ -6294,6 +6296,7 @@ <EntityTypeMapping TypeName="RemoteModel.DATA_STORE_ITEMS"> <MappingFragment StoreEntitySet="DATA_STORE_ITEMS"> <ScalarProperty Name="IS_SYNCHRONIZED" ColumnName="IS_SYNCHRONIZED" /> + <ScalarProperty Name="IS_DELETED" ColumnName="IS_DELETED" /> <ScalarProperty Name="VALUE" ColumnName="VALUE" /> <ScalarProperty Name="DATA_TYPE" ColumnName="DATA_TYPE" /> <ScalarProperty Name="KEY" ColumnName="KEY" /> diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index 357b569f8..e1c915039 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,90 +5,90 @@ <!-- Diagram content (shape and connector positions) --> <edmx:Diagrams> <Diagram DiagramId="f9ae01d708754bbd997add25a4bacc79" Name="Diagram1" ZoomLevel="87"> - <EntityTypeShape EntityType="RemoteModel.ACTION_LOGS" Width="1.5" PointX="11.25" PointY="27.25" /> - <EntityTypeShape EntityType="RemoteModel.ADDRESS" Width="1.5" PointX="1.5" PointY="76" /> - <EntityTypeShape EntityType="RemoteModel.APPLICATION_DISPLAY_PANEL_VERSIONS" Width="1.5" PointX="1.5" PointY="62" /> - <EntityTypeShape EntityType="RemoteModel.APPLICATION_FIRMWARE_VERSIONS" Width="1.5" PointX="1.5" PointY="56.125" /> - <EntityTypeShape EntityType="RemoteModel.APPLICATION_OS_VERSIONS" Width="1.5" PointX="1.5" PointY="64.875" /> + <EntityTypeShape EntityType="RemoteModel.ACTION_LOGS" Width="1.5" PointX="11.25" PointY="49.875" /> + <EntityTypeShape EntityType="RemoteModel.ADDRESS" Width="1.5" PointX="1.5" PointY="1.75" /> + <EntityTypeShape EntityType="RemoteModel.APPLICATION_DISPLAY_PANEL_VERSIONS" Width="1.5" PointX="4.5" PointY="59.25" /> + <EntityTypeShape EntityType="RemoteModel.APPLICATION_FIRMWARE_VERSIONS" Width="1.5" PointX="4.5" PointY="68" /> + <EntityTypeShape EntityType="RemoteModel.APPLICATION_OS_VERSIONS" Width="1.5" PointX="4.5" PointY="62.125" /> <EntityTypeShape EntityType="RemoteModel.BRUSH_STOPS" Width="1.5" PointX="15.75" PointY="17" /> - <EntityTypeShape EntityType="RemoteModel.CARTRIDGE_TYPES" Width="1.5" PointX="3.75" PointY="43.5" /> - <EntityTypeShape EntityType="RemoteModel.CAT" Width="1.5" PointX="8.25" PointY="19.875" /> - <EntityTypeShape EntityType="RemoteModel.CCT" Width="1.5" PointX="0.75" PointY="15.75" /> - <EntityTypeShape EntityType="RemoteModel.COLOR_CATALOGS" Width="1.5" PointX="1.5" PointY="7.625" /> - <EntityTypeShape EntityType="RemoteModel.COLOR_CATALOGS_GROUPS" Width="1.5" PointX="3.75" PointY="8.125" /> - <EntityTypeShape EntityType="RemoteModel.COLOR_CATALOGS_ITEMS" Width="1.5" PointX="6" PointY="6.875" /> - <EntityTypeShape EntityType="RemoteModel.COLOR_CATALOGS_ITEMS_RECIPES" Width="1.5" PointX="8.25" PointY="15.75" /> - <EntityTypeShape EntityType="RemoteModel.COLOR_SPACES" Width="1.5" PointX="9" PointY="33.5" /> - <EntityTypeShape EntityType="RemoteModel.CONFIGURATION" Width="1.5" PointX="3.75" PointY="61.75" /> - <EntityTypeShape EntityType="RemoteModel.CONTACT" Width="1.5" PointX="1.5" PointY="72.125" /> - <EntityTypeShape EntityType="RemoteModel.CUSTOMER" Width="1.5" PointX="9" PointY="11.5" /> - <EntityTypeShape EntityType="RemoteModel.DATA_STORE_ITEMS" Width="1.5" PointX="8.25" PointY="76.25" /> - <EntityTypeShape EntityType="RemoteModel.DISPENSER_TYPES" Width="1.5" PointX="1.5" PointY="36.5" /> - <EntityTypeShape EntityType="RemoteModel.DISPENSER" Width="1.5" PointX="3.75" PointY="35.875" /> - <EntityTypeShape EntityType="RemoteModel.EMBEDDED_FIRMWARE_VERSIONS" Width="1.5" PointX="1.5" PointY="59.125" /> - <EntityTypeShape EntityType="RemoteModel.EVENT_TYPES" Width="1.5" PointX="9" PointY="40.75" /> + <EntityTypeShape EntityType="RemoteModel.CARTRIDGE_TYPES" Width="1.5" PointX="6.75" PointY="36.625" /> + <EntityTypeShape EntityType="RemoteModel.CAT" Width="1.5" PointX="5.25" PointY="23.875" /> + <EntityTypeShape EntityType="RemoteModel.CCT" Width="1.5" PointX="0.75" PointY="26.625" /> + <EntityTypeShape EntityType="RemoteModel.COLOR_CATALOGS" Width="1.5" PointX="1.5" PointY="40.625" /> + <EntityTypeShape EntityType="RemoteModel.COLOR_CATALOGS_GROUPS" Width="1.5" PointX="3.75" PointY="41.125" /> + <EntityTypeShape EntityType="RemoteModel.COLOR_CATALOGS_ITEMS" Width="1.5" PointX="6" PointY="39.875" /> + <EntityTypeShape EntityType="RemoteModel.COLOR_CATALOGS_ITEMS_RECIPES" Width="1.5" PointX="8.25" PointY="19.75" /> + <EntityTypeShape EntityType="RemoteModel.COLOR_SPACES" Width="1.5" PointX="9" PointY="10.625" /> + <EntityTypeShape EntityType="RemoteModel.CONFIGURATION" Width="1.5" PointX="6.75" PointY="64.75" /> + <EntityTypeShape EntityType="RemoteModel.CONTACT" Width="1.5" PointX="1.5" PointY="35.875" /> + <EntityTypeShape EntityType="RemoteModel.CUSTOMER" Width="1.5" PointX="9" PointY="7.5" /> + <EntityTypeShape EntityType="RemoteModel.DATA_STORE_ITEMS" Width="1.5" PointX="11.25" PointY="72" /> + <EntityTypeShape EntityType="RemoteModel.DISPENSER_TYPES" Width="1.5" PointX="4.5" PointY="29.125" /> + <EntityTypeShape EntityType="RemoteModel.DISPENSER" Width="1.5" PointX="6.75" PointY="28.5" /> + <EntityTypeShape EntityType="RemoteModel.EMBEDDED_FIRMWARE_VERSIONS" Width="1.5" PointX="4.5" PointY="65" /> + <EntityTypeShape EntityType="RemoteModel.EVENT_TYPES" Width="1.5" PointX="9" PointY="31.75" /> <EntityTypeShape EntityType="RemoteModel.FIBER_SHAPES" Width="1.5" PointX="0.75" PointY="20.25" /> - <EntityTypeShape EntityType="RemoteModel.FIBER_SYNTHS" Width="1.5" PointX="0.75" PointY="32.75" /> - <EntityTypeShape EntityType="RemoteModel.FSE_VERSIONS" Width="1.5" PointX="11.25" PointY="42.625" /> - <EntityTypeShape EntityType="RemoteModel.GLOBAL_DATA_STORE_ITEMS" Width="1.5" PointX="10.75" PointY="0.75" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_BLOWER_TYPES" Width="1.5" PointX="4.5" PointY="58.375" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_BLOWERS" Width="1.5" PointX="6.75" PointY="60" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_BREAK_SENSOR_TYPES" Width="1.5" PointX="6.5" PointY="80.375" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_BREAK_SENSORS" Width="1.5" PointX="8.75" PointY="64.125" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_DANCER_TYPES" Width="1.5" PointX="1.5" PointY="80.375" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_DANCERS" Width="1.5" PointX="3.75" PointY="67.375" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_MOTOR_TYPES" Width="1.5" PointX="9.5" PointY="59.375" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_MOTORS" Width="1.5" PointX="11.75" PointY="56" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_PID_CONTROL_TYPES" Width="1.5" PointX="9.5" PointY="80.375" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_PID_CONTROLS" Width="1.5" PointX="11.75" PointY="66.5" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_SPEED_SENSOR_TYPES" Width="1.5" PointX="6.5" PointY="88.375" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_SPEED_SENSORS" Width="1.5" PointX="8.75" PointY="72.125" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_VERSIONS" Width="1.5" PointX="1.5" PointY="67.875" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_WINDER_TYPES" Width="1.5" PointX="6.5" PointY="84.375" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_WINDERS" Width="1.5" PointX="8.75" PointY="68.25" /> - <EntityTypeShape EntityType="RemoteModel.IDS_PACK_FORMULAS" Width="1.5" PointX="3.75" PointY="40.125" /> - <EntityTypeShape EntityType="RemoteModel.IDS_PACKS" Width="1.5" PointX="6" PointY="32.125" /> - <EntityTypeShape EntityType="RemoteModel.JOB_RUNS" Width="1.5" PointX="14.75" PointY="0.75" /> + <EntityTypeShape EntityType="RemoteModel.FIBER_SYNTHS" Width="1.5" PointX="0.75" PointY="23.625" /> + <EntityTypeShape EntityType="RemoteModel.FSE_VERSIONS" Width="1.5" PointX="11.25" PointY="27.625" /> + <EntityTypeShape EntityType="RemoteModel.GLOBAL_DATA_STORE_ITEMS" Width="1.5" PointX="3.75" PointY="0.75" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_BLOWER_TYPES" Width="1.5" PointX="7.5" PointY="84.5" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_BLOWERS" Width="1.5" PointX="9.75" PointY="76.125" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_BREAK_SENSOR_TYPES" Width="1.5" PointX="9.5" PointY="80.5" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_BREAK_SENSORS" Width="1.5" PointX="11.75" PointY="68.25" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_DANCER_TYPES" Width="1.5" PointX="9.5" PointY="57.5" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_DANCERS" Width="1.5" PointX="11.75" PointY="62.375" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_MOTOR_TYPES" Width="1.5" PointX="11.5" PointY="84.375" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_MOTORS" Width="1.5" PointX="13.75" PointY="72.125" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_PID_CONTROL_TYPES" Width="1.5" PointX="12.5" PointY="58.5" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_PID_CONTROLS" Width="1.5" PointX="14.75" PointY="64.5" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_SPEED_SENSOR_TYPES" Width="1.5" PointX="4.5" PointY="75.5" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_SPEED_SENSORS" Width="1.5" PointX="6.75" PointY="71.25" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_VERSIONS" Width="1.5" PointX="4.5" PointY="70.875" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_WINDER_TYPES" Width="1.5" PointX="4.5" PointY="79.5" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_WINDERS" Width="1.5" PointX="6.75" PointY="75.25" /> + <EntityTypeShape EntityType="RemoteModel.IDS_PACK_FORMULAS" Width="1.5" PointX="6.75" PointY="33.375" /> + <EntityTypeShape EntityType="RemoteModel.IDS_PACKS" Width="1.5" PointX="9" PointY="37.625" /> + <EntityTypeShape EntityType="RemoteModel.JOB_RUNS" Width="1.5" PointX="5.75" PointY="0.75" /> <EntityTypeShape EntityType="RemoteModel.JOB" Width="1.5" PointX="11.25" PointY="16.375" /> - <EntityTypeShape EntityType="RemoteModel.LINEAR_MASS_DENSITY_UNITS" Width="1.5" PointX="0.75" PointY="27" /> - <EntityTypeShape EntityType="RemoteModel.LIQUID_TYPES" Width="1.5" PointX="3" PointY="2.625" /> - <EntityTypeShape EntityType="RemoteModel.LIQUID_TYPES_RMLS" Width="1.5" PointX="5.25" PointY="16" /> - <EntityTypeShape EntityType="RemoteModel.MACHINE_STUDIO_VERSIONS" Width="1.5" PointX="11.25" PointY="31" /> - <EntityTypeShape EntityType="RemoteModel.MACHINE_VERSIONS" Width="1.5" PointX="3.75" PointY="80.125" /> - <EntityTypeShape EntityType="RemoteModel.MACHINE" Width="1.5" PointX="6" PointY="64.875" /> - <EntityTypeShape EntityType="RemoteModel.MACHINES_EVENTS" Width="1.5" PointX="11.25" PointY="49.125" /> - <EntityTypeShape EntityType="RemoteModel.MEDIA_CONDITIONS" Width="1.5" PointX="0.75" PointY="24" /> - <EntityTypeShape EntityType="RemoteModel.MEDIA_MATERIALS" Width="1.5" PointX="0.75" PointY="12.75" /> - <EntityTypeShape EntityType="RemoteModel.MEDIA_PURPOSES" Width="1.5" PointX="0.75" PointY="29.875" /> - <EntityTypeShape EntityType="RemoteModel.MID_TANK_TYPES" Width="1.5" PointX="3.75" PointY="32.75" /> - <EntityTypeShape EntityType="RemoteModel.ORGANIZATION" Width="1.5" PointX="3.75" PointY="74" /> - <EntityTypeShape EntityType="RemoteModel.PERMISSION" Width="1.5" PointX="12" PointY="5.125" /> + <EntityTypeShape EntityType="RemoteModel.LINEAR_MASS_DENSITY_UNITS" Width="1.5" PointX="0.75" PointY="12.75" /> + <EntityTypeShape EntityType="RemoteModel.LIQUID_TYPES" Width="1.5" PointX="3" PointY="10.625" /> + <EntityTypeShape EntityType="RemoteModel.LIQUID_TYPES_RMLS" Width="1.5" PointX="5.25" PointY="20" /> + <EntityTypeShape EntityType="RemoteModel.MACHINE_STUDIO_VERSIONS" Width="1.5" PointX="11.25" PointY="32.375" /> + <EntityTypeShape EntityType="RemoteModel.MACHINE_VERSIONS" Width="1.5" PointX="6.75" PointY="55.875" /> + <EntityTypeShape EntityType="RemoteModel.MACHINE" Width="1.5" PointX="9" PointY="60.625" /> + <EntityTypeShape EntityType="RemoteModel.MACHINES_EVENTS" Width="1.5" PointX="11.25" PointY="45.125" /> + <EntityTypeShape EntityType="RemoteModel.MEDIA_CONDITIONS" Width="1.5" PointX="0.75" PointY="29.875" /> + <EntityTypeShape EntityType="RemoteModel.MEDIA_MATERIALS" Width="1.5" PointX="0.75" PointY="15.75" /> + <EntityTypeShape EntityType="RemoteModel.MEDIA_PURPOSES" Width="1.5" PointX="0.75" PointY="32.75" /> + <EntityTypeShape EntityType="RemoteModel.MID_TANK_TYPES" Width="1.5" PointX="6.75" PointY="59.875" /> + <EntityTypeShape EntityType="RemoteModel.ORGANIZATION" Width="1.5" PointX="0.75" PointY="6.75" /> + <EntityTypeShape EntityType="RemoteModel.PERMISSION" Width="1.5" PointX="12" PointY="8.5" /> <EntityTypeShape EntityType="RemoteModel.PROCESS_PARAMETERS_TABLES" Width="1.5" PointX="7.5" PointY="46.625" /> <EntityTypeShape EntityType="RemoteModel.PROCESS_PARAMETERS_TABLES_GROUPS" Width="1.5" PointX="5.25" PointY="49.25" /> - <EntityTypeShape EntityType="RemoteModel.PUBLISHED_PROCEDURE_PROJECTS" Width="1.5" PointX="5.75" PointY="1" /> - <EntityTypeShape EntityType="RemoteModel.PUBLISHED_PROCEDURE_PROJECTS_VERSIONS" Width="1.5" PointX="8" PointY="1.125" /> + <EntityTypeShape EntityType="RemoteModel.PUBLISHED_PROCEDURE_PROJECTS" Width="1.5" PointX="11.75" PointY="1" /> + <EntityTypeShape EntityType="RemoteModel.PUBLISHED_PROCEDURE_PROJECTS_VERSIONS" Width="1.5" PointX="14" PointY="1.125" /> <EntityTypeShape EntityType="RemoteModel.RML" Width="1.5" PointX="3" PointY="15" /> - <EntityTypeShape EntityType="RemoteModel.RMLS_SPOOLS" Width="1.5" PointX="5.25" PointY="23.875" /> - <EntityTypeShape EntityType="RemoteModel.ROLE" Width="1.5" PointX="12" PointY="9" /> - <EntityTypeShape EntityType="RemoteModel.ROLES_PERMISSIONS" Width="1.5" PointX="14.25" PointY="9.125" /> + <EntityTypeShape EntityType="RemoteModel.RMLS_SPOOLS" Width="1.5" PointX="8.25" PointY="15.875" /> + <EntityTypeShape EntityType="RemoteModel.ROLE" Width="1.5" PointX="12" PointY="12.375" /> + <EntityTypeShape EntityType="RemoteModel.ROLES_PERMISSIONS" Width="1.5" PointX="14.25" PointY="12.5" /> <EntityTypeShape EntityType="RemoteModel.SEGMENT" Width="1.5" PointX="13.5" PointY="20" /> - <EntityTypeShape EntityType="RemoteModel.SITE" Width="1.5" PointX="3" PointY="29" /> - <EntityTypeShape EntityType="RemoteModel.SITES_CATALOGS" Width="1.5" PointX="11.25" PointY="12.5" /> - <EntityTypeShape EntityType="RemoteModel.SITES_RMLS" Width="1.5" PointX="5.25" PointY="20.25" /> - <EntityTypeShape EntityType="RemoteModel.SPOOL_TYPES" Width="1.5" PointX="9" PointY="5.625" /> - <EntityTypeShape EntityType="RemoteModel.SPOOL" Width="1.5" PointX="11.25" PointY="38.125" /> - <EntityTypeShape EntityType="RemoteModel.sysdiagram" Width="1.5" PointX="5.75" PointY="12.75" /> - <EntityTypeShape EntityType="RemoteModel.TANGO_UPDATES" Width="1.5" PointX="13.75" PointY="12.75" /> - <EntityTypeShape EntityType="RemoteModel.TANGO_VERSIONS" Width="1.5" PointX="14.25" PointY="53.5" /> - <EntityTypeShape EntityType="RemoteModel.TECH_CONTROLLERS" Width="1.5" PointX="15.75" PointY="12.75" /> + <EntityTypeShape EntityType="RemoteModel.SITE" Width="1.5" PointX="3" PointY="7" /> + <EntityTypeShape EntityType="RemoteModel.SITES_CATALOGS" Width="1.5" PointX="14.25" PointY="27.375" /> + <EntityTypeShape EntityType="RemoteModel.SITES_RMLS" Width="1.5" PointX="5.25" PointY="16.25" /> + <EntityTypeShape EntityType="RemoteModel.SPOOL_TYPES" Width="1.5" PointX="6" PointY="10.25" /> + <EntityTypeShape EntityType="RemoteModel.SPOOL" Width="1.5" PointX="11.25" PointY="38.375" /> + <EntityTypeShape EntityType="RemoteModel.sysdiagram" Width="1.5" PointX="7.75" PointY="0.75" /> + <EntityTypeShape EntityType="RemoteModel.TANGO_UPDATES" Width="1.5" PointX="14.75" PointY="4.75" /> + <EntityTypeShape EntityType="RemoteModel.TANGO_VERSIONS" Width="1.5" PointX="14.25" PointY="39.625" /> + <EntityTypeShape EntityType="RemoteModel.TECH_CONTROLLERS" Width="1.5" PointX="11.75" PointY="4.75" /> <EntityTypeShape EntityType="RemoteModel.TECH_DISPENSERS" Width="1.5" PointX="16.75" PointY="0.75" /> <EntityTypeShape EntityType="RemoteModel.TECH_HEATERS" Width="1.5" PointX="16.75" PointY="3.75" /> <EntityTypeShape EntityType="RemoteModel.TECH_IOS" Width="1.5" PointX="16.75" PointY="6.75" /> - <EntityTypeShape EntityType="RemoteModel.TECH_MONITORS" Width="1.5" PointX="17.75" PointY="11.75" /> + <EntityTypeShape EntityType="RemoteModel.TECH_MONITORS" Width="1.5" PointX="16.75" PointY="11.75" /> <EntityTypeShape EntityType="RemoteModel.TECH_VALVES" Width="1.5" PointX="17.75" PointY="16.75" /> - <EntityTypeShape EntityType="RemoteModel.USER" Width="1.5" PointX="9" PointY="27.75" /> - <EntityTypeShape EntityType="RemoteModel.USERS_ROLES" Width="1.5" PointX="14.25" PointY="29.125" /> - <EntityTypeShape EntityType="RemoteModel.WINDING_METHODS" Width="1.5" PointX="9" PointY="24.625" /> + <EntityTypeShape EntityType="RemoteModel.USER" Width="1.5" PointX="9" PointY="24.125" /> + <EntityTypeShape EntityType="RemoteModel.USERS_ROLES" Width="1.5" PointX="14.25" PointY="31.5" /> + <EntityTypeShape EntityType="RemoteModel.WINDING_METHODS" Width="1.5" PointX="9" PointY="4.375" /> <AssociationConnector Association="RemoteModel.FK_ACTION_LOGS_USERS" /> <AssociationConnector Association="RemoteModel.FK_ORGANIZATIONS_ADDRESSES" /> <AssociationConnector Association="RemoteModel.FK_USERS_ADDRESSES" /> diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/CustomControl1.cs b/Software/Visual_Studio/Tango.DataStore.Editing/CustomControl1.cs new file mode 100644 index 000000000..fab0127e8 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/CustomControl1.cs @@ -0,0 +1,25 @@ +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.DataStore.Editing +{ + public class CustomControl1 : Control + { + static CustomControl1() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomControl1), new FrameworkPropertyMetadata(typeof(CustomControl1))); + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreCollectionModel.cs b/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreCollectionModel.cs new file mode 100644 index 000000000..3e58aa4b1 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreCollectionModel.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; + +namespace Tango.DataStore.Editing +{ + public class DataStoreCollectionModel : ExtendedObject + { + public String Name { get; set; } + public ObservableCollection<DataStoreItemModel> Items { get; set; } + public bool IsDeleted { get; set; } + + private bool _isSelected; + public bool IsSelected + { + get { return _isSelected; } + set { _isSelected = value; RaisePropertyChangedAuto(); Items.ToList().ForEach(x => x.IsSelected = value); } + } + + public DataStoreCollectionModel() + { + Items = new ObservableCollection<DataStoreItemModel>(); + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreItemModel.cs b/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreItemModel.cs new file mode 100644 index 000000000..3b1741395 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreItemModel.cs @@ -0,0 +1,140 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; + +namespace Tango.DataStore.Editing +{ + public class DataStoreItemModel : ExtendedObject, IDataStoreItem + { + public IDataStoreItem GlobalItem { get; set; } + + public DataType OriginalType { get; set; } + public Object OriginalValue { get; set; } + + private Object _value; + public Object Value + { + get { return _value; } + set { _value = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(HasDifference)); RaisePropertyChanged(nameof(FormattedValue)); } + } + + private bool _isSelected; + public bool IsSelected + { + get { return _isSelected; } + set { _isSelected = value; RaisePropertyChangedAuto(); } + } + + public bool HasDifference + { + get + { + if (OriginalType != Type) + { + return true; + } + + if (OriginalType == DataType.Bytes && Type == DataType.Bytes) + { + if (OriginalValue != null && Value != null) + { + return !Enumerable.SequenceEqual(OriginalValue as byte[], Value as byte[]); + } + } + + if (Value == null && OriginalValue == null) return false; + + return !OriginalValue.ToStringSafe().Equals(Value.ToStringSafe()) || (IsGlobal && GlobalItem.Value != Value); + } + } + + public String FormattedValue + { + get { return this.ToString().ToOneLine(); } + } + + public string Guid { get; set; } + public string Key { get; set; } + + private DataType _type; + public DataType Type + { + get { return _type; } + set { _type = value; RaisePropertyChangedAuto(); } + } + + private DateTime _date; + public DateTime Date + { + get { return _date; } + set { _date = value; RaisePropertyChangedAuto(); } + } + + public bool IsSynchronized { get; set; } + public bool ExistsOnMachine { get; set; } + + private bool _isGlobal; + public bool IsGlobal + { + get { return _isGlobal; } + set { _isGlobal = value; RaisePropertyChangedAuto(); } + } + + private bool _isDeleted; + public bool IsDeleted + { + get { return _isDeleted; } + set { _isDeleted = value; RaisePropertyChangedAuto(); } + } + + public static DataStoreItemModel FromLocalDataStoreItem(IDataStoreItem local, IDataStoreItem globalItem) + { + DataStoreItemModel model = new DataStoreItemModel(); + + model.OriginalValue = local.Value; + model.Value = local.Value; + model.Guid = local.Guid; + model.Key = local.Key; + model.OriginalType = local.Type; + model.Type = local.Type; + model.Date = local.Date; + model.IsGlobal = false; + model.IsSynchronized = local.IsSynchronized; + + model.GlobalItem = globalItem; + + return model; + } + + public static DataStoreItemModel FromGlobalDataStoreItem(IDataStoreItem global) + { + DataStoreItemModel model = new DataStoreItemModel(); + + model.GlobalItem = global; + model.Guid = global.Guid; + model.Key = global.Key; + model.Type = global.Type; + model.OriginalType = global.Type; + model.Date = global.Date; + model.IsGlobal = true; + model.IsSynchronized = global.IsSynchronized; + + return model; + } + + public override string ToString() + { + if (this.Value != null) + { + return DataStoreHelper.FormatDataStoreItem(this); + } + else + { + return null; + } + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreModel.cs b/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreModel.cs new file mode 100644 index 000000000..a68cc0af9 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/DataStoreModel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; + +namespace Tango.DataStore.Editing +{ + public class DataStoreModel : ExtendedObject + { + public ObservableCollection<DataStoreCollectionModel> Collections { get; set; } + + public DataStoreModel() + { + Collections = new ObservableCollection<DataStoreCollectionModel>(); + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..9f04af8ea --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango.DataStore.Editing")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.DataStore.Editing")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file +//inside a <PropertyGroup>. For example, if you are using US english +//in your source files, set the <UICulture> to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly:ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Resources.Designer.cs b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Resources.Designer.cs new file mode 100644 index 000000000..c23f8f4eb --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Resources.Designer.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace Tango.DataStore.Editing.Properties { + + + /// <summary> + /// A strongly-typed resource class, for looking up localized strings, etc. + /// </summary> + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// <summary> + /// Returns the cached ResourceManager instance used by this class. + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if ((resourceMan == null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.DataStore.Editing.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// <summary> + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Resources.resx b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Resources.resx @@ -0,0 +1,117 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.Designer.cs b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.Designer.cs new file mode 100644 index 000000000..28f49dcd4 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace Tango.DataStore.Editing.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.settings b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/Properties/Settings.settings @@ -0,0 +1,7 @@ +<?xml version='1.0' encoding='utf-8'?> +<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> + <Profiles> + <Profile Name="(Default)" /> + </Profiles> + <Settings /> +</SettingsFile>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Tango.DataStore.Editing.csproj b/Software/Visual_Studio/Tango.DataStore.Editing/Tango.DataStore.Editing.csproj new file mode 100644 index 000000000..4707dca0b --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/Tango.DataStore.Editing.csproj @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}</ProjectGuid> + <OutputType>library</OutputType> + <RootNamespace>Tango.DataStore.Editing</RootNamespace> + <AssemblyName>Tango.DataStore.Editing</AssemblyName> + <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <WarningLevel>4</WarningLevel> + <Deterministic>true</Deterministic> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Xaml"> + <RequiredTargetFramework>4.0</RequiredTargetFramework> + </Reference> + <Reference Include="WindowsBase" /> + <Reference Include="PresentationCore" /> + <Reference Include="PresentationFramework" /> + </ItemGroup> + <ItemGroup> + <Compile Include="UpdateDataStoreRequest.cs" /> + <Compile Include="UpdateDataStoreResponse.cs" /> + <Page Include="Themes\Generic.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Compile Include="CustomControl1.cs"> + <SubType>Code</SubType> + </Compile> + </ItemGroup> + <ItemGroup> + <Compile Include="DataStoreCollectionModel.cs" /> + <Compile Include="DataStoreItemModel.cs" /> + <Compile Include="DataStoreModel.cs" /> + <Compile Include="Properties\AssemblyInfo.cs"> + <SubType>Code</SubType> + </Compile> + <Compile Include="Properties\Resources.Designer.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>Resources.resx</DependentUpon> + </Compile> + <Compile Include="Properties\Settings.Designer.cs"> + <AutoGen>True</AutoGen> + <DependentUpon>Settings.settings</DependentUpon> + <DesignTimeSharedInput>True</DesignTimeSharedInput> + </Compile> + <EmbeddedResource Include="Properties\Resources.resx"> + <Generator>ResXFileCodeGenerator</Generator> + <LastGenOutput>Resources.Designer.cs</LastGenOutput> + </EmbeddedResource> + <None Include="Properties\Settings.settings"> + <Generator>SettingsSingleFileGenerator</Generator> + <LastGenOutput>Settings.Designer.cs</LastGenOutput> + </None> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Tango.BL\Tango.BL.csproj"> + <Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project> + <Name>Tango.BL</Name> + </ProjectReference> + <ProjectReference Include="..\Tango.Core\Tango.Core.csproj"> + <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> + <Name>Tango.Core</Name> + </ProjectReference> + <ProjectReference Include="..\Tango.DataStore\Tango.DataStore.csproj"> + <Project>{e0364dfa-0721-4637-9d32-9d22aac109d6}</Project> + <Name>Tango.DataStore</Name> + </ProjectReference> + <ProjectReference Include="..\Tango.SharedUI\Tango.SharedUI.csproj"> + <Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project> + <Name>Tango.SharedUI</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/Themes/Generic.xaml b/Software/Visual_Studio/Tango.DataStore.Editing/Themes/Generic.xaml new file mode 100644 index 000000000..795842292 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/Themes/Generic.xaml @@ -0,0 +1,18 @@ +<ResourceDictionary + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:local="clr-namespace:Tango.DataStore.Editing"> + <Style TargetType="{x:Type local:CustomControl1}"> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type local:CustomControl1}"> + <Border Background="{TemplateBinding Background}" + BorderBrush="{TemplateBinding BorderBrush}" + BorderThickness="{TemplateBinding BorderThickness}"> + + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> +</ResourceDictionary> diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/UpdateDataStoreRequest.cs b/Software/Visual_Studio/Tango.DataStore.Editing/UpdateDataStoreRequest.cs new file mode 100644 index 000000000..dc95ea6ae --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/UpdateDataStoreRequest.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.DTO; + +namespace Tango.DataStore.Editing +{ + public class UpdateDataStoreRequest + { + public List<String> ToDelete { get; set; } + public List<DataStoreItemDTO> ToUpsert { get; set; } + + public UpdateDataStoreRequest() + { + ToDelete = new List<string>(); + ToUpsert = new List<DataStoreItemDTO>(); + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Editing/UpdateDataStoreResponse.cs b/Software/Visual_Studio/Tango.DataStore.Editing/UpdateDataStoreResponse.cs new file mode 100644 index 000000000..697ae341d --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Editing/UpdateDataStoreResponse.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Editing +{ + public class UpdateDataStoreResponse + { + + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCollection.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCollection.cs new file mode 100644 index 000000000..e4453fafc --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreCollection.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreCollection + { + public String Name { get; set; } + public List<RemoteDataStoreItem> Items { get; set; } + + public RemoteDataStoreCollection() + { + Items = new List<RemoteDataStoreItem>(); + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsRequest.cs new file mode 100644 index 000000000..a285cd5c1 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsRequest.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetAllItemsRequest + { + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsResponse.cs new file mode 100644 index 000000000..3afb22c1e --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreGetAllItemsResponse.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreGetAllItemsResponse + { + public List<RemoteDataStoreCollection> Collections { get; set; } + + public RemoteDataStoreGetAllItemsResponse() + { + Collections = new List<RemoteDataStoreCollection>(); + } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreStartListenRequest.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreStartListenRequest.cs new file mode 100644 index 000000000..b8da17012 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreStartListenRequest.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public class RemoteDataStoreStartListenRequest + { + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreStartListenResponse.cs b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreStartListenResponse.cs new file mode 100644 index 000000000..c2a6c24a6 --- /dev/null +++ b/Software/Visual_Studio/Tango.DataStore.Remote/RemoteDataStoreStartListenResponse.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.DataStore.Remote +{ + public enum RemoteDataStoreChangeType + { + None, + Modified + } + + public class RemoteDataStoreStartListenResponse + { + public RemoteDataStoreChangeType ChangeType { get; set; } + public String CollectionName { get; set; } + public RemoteDataStoreItem Item { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DataStore.Remote/Tango.DataStore.Remote.csproj b/Software/Visual_Studio/Tango.DataStore.Remote/Tango.DataStore.Remote.csproj index 4d0d04054..8618affdd 100644 --- a/Software/Visual_Studio/Tango.DataStore.Remote/Tango.DataStore.Remote.csproj +++ b/Software/Visual_Studio/Tango.DataStore.Remote/Tango.DataStore.Remote.csproj @@ -50,12 +50,15 @@ <Compile Include="..\Versioning\GlobalVersionInfo.cs"> <Link>GlobalVersionInfo.cs</Link> </Compile> + <Compile Include="RemoteDataStoreCollection.cs" /> <Compile Include="RemoteDataStoreCountRequest.cs" /> <Compile Include="RemoteDataStoreCountResponse.cs" /> <Compile Include="RemoteDataStoreDeleteAllRequest.cs" /> <Compile Include="RemoteDataStoreDeleteAllResponse.cs" /> <Compile Include="RemoteDataStoreDeleteRequest.cs" /> <Compile Include="RemoteDataStoreDeleteResponse.cs" /> + <Compile Include="RemoteDataStoreGetAllItemsRequest.cs" /> + <Compile Include="RemoteDataStoreGetAllItemsResponse.cs" /> <Compile Include="RemoteDataStoreGetAllRequest.cs" /> <Compile Include="RemoteDataStoreGetAllResponse.cs" /> <Compile Include="RemoteDataStoreGetCollectionNamesRequest.cs" /> @@ -65,6 +68,8 @@ <Compile Include="RemoteDataStoreGetRequest.cs" /> <Compile Include="RemoteDataStoreGetResponse.cs" /> <Compile Include="RemoteDataStoreItem.cs" /> + <Compile Include="RemoteDataStoreStartListenRequest.cs" /> + <Compile Include="RemoteDataStoreStartListenResponse.cs" /> <Compile Include="RemoteDataStorePutRequest.cs" /> <Compile Include="RemoteDataStorePutResponse.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> diff --git a/Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs b/Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs index 96a905120..0ca8e484e 100644 --- a/Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs +++ b/Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs @@ -84,14 +84,7 @@ namespace Tango.DataStore { if (item.Type == DataType.Bytes) { - byte[] bytes = (byte[])item.Value; - - StringBuilder hex = new StringBuilder(); - foreach (byte b in bytes) - { - hex.AppendFormat("{0:x2} ", b); - } - return hex.ToString(); + return GetByteArrayHexString((byte[])item.Value); } else if (item.Type == DataType.Proto) { @@ -99,8 +92,69 @@ namespace Tango.DataStore } else { - return $"{item.Key}: {item.Value}"; + return item.Value.ToStringSafe(); + } + } + + /// <summary> + /// Returns a byte array string representation in hex format. + /// </summary> + /// <param name="data">The data.</param> + /// <returns></returns> + public static String GetByteArrayHexString(byte[] data) + { + StringBuilder hex = new StringBuilder(); + foreach (byte b in data) + { + hex.Append(b.ToString("X2") + " "); } + return hex.ToString(); + } + + /// <summary> + /// Parses a data store value from a string. + /// </summary> + /// <param name="type">The type.</param> + /// <param name="text">The string.</param> + /// <param name="protoMessageType">Type of the proto message (if type is Proto).</param> + /// <returns></returns> + /// <exception cref="ArgumentNullException">No PMR message type specified.</exception> + /// <exception cref="NotSupportedException">The specified data store type is not supported.</exception> + public static Object ParseDataStoreValue(DataType type, String text, MessageType? protoMessageType = null) + { + switch (type) + { + case DataType.String: + return text; + case DataType.Int32: + return int.Parse(text); + case DataType.Float: + return float.Parse(text); + case DataType.Double: + return double.Parse(text); + case DataType.Boolean: + return bool.Parse(text); + case DataType.Proto: + if (protoMessageType == null) throw new ArgumentNullException("No PMR message type specified."); + var messageType = MessageFactory.GetPMRTypeFromMessageType(protoMessageType.Value); + var instance = Activator.CreateInstance(messageType) as IMessage; + instance = instance.GetParser().ParseJson(text); + return DataStoreProtoObject.FromMessage(instance); + case DataType.Bytes: + string[] hexValuesSplit = text.Split(' '); + List<byte> bytes = new List<byte>(); + foreach (string hex in hexValuesSplit) + { + if (hex.IsNotNullOrEmpty()) + { + byte b = (byte)Convert.ToInt32(hex.Trim(), 16); + bytes.Add(b); + } + } + return bytes.ToArray(); + } + + throw new NotSupportedException("The specified data store type is not supported."); } } } diff --git a/Software/Visual_Studio/Tango.DataStore/DataStoreProtoObject.cs b/Software/Visual_Studio/Tango.DataStore/DataStoreProtoObject.cs index 6661c2017..5aa7c5342 100644 --- a/Software/Visual_Studio/Tango.DataStore/DataStoreProtoObject.cs +++ b/Software/Visual_Studio/Tango.DataStore/DataStoreProtoObject.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core.Bson; +using Tango.Core.ExtensionMethods; using Tango.PMR; using Tango.PMR.Common; using Tango.PMR.DataStore; @@ -73,5 +74,10 @@ namespace Tango.DataStore proto.Data = item.BytesValue.ToByteArray(); return proto; } + + public override string ToString() + { + return Message?.ToJsonString(); + } } } diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs index 1d420e33f..9cdf6dcae 100644 --- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs +++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs @@ -473,6 +473,9 @@ namespace Tango.Emulations.Emulators case MessageType.AttemptThreadJoggingRequest: HandleAttemptThreadJoggingRequest(MessageFactory.ParseTangoMessageFromContainer<AttemptThreadJoggingRequest>(container)); break; + case MessageType.DataStoreItemModifiedRequest: + HandleDataStoreItemModifiedRequest(MessageFactory.ParseTangoMessageFromContainer<DataStoreItemModifiedRequest>(container)); + break; } } @@ -1736,6 +1739,17 @@ namespace Tango.Emulations.Emulators } } + private async void HandleDataStoreItemModifiedRequest(TangoMessage<DataStoreItemModifiedRequest> request) + { + await Transporter.SendResponse<DataStoreItemModifiedResponse>(new DataStoreItemModifiedResponse(), request.Container.Token); + + GetDataStoreItem(new GetDataStoreItemRequest() + { + Collection = request.Message.Collection, + Key = request.Message.Key + }); + } + #endregion #region Public Methods @@ -2132,6 +2146,33 @@ namespace Tango.Emulations.Emulators } } + public async void PutDataStoreItem(PutDataStoreItemRequest request) + { + LogManager.Log($"Sending PutDataStoreItemRequest:\n{request.ToJsonString()}"); + try + { + var response = await Transporter.SendRequest<PutDataStoreItemRequest, PutDataStoreItemResponse>(request); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error putting data store item."); + } + } + + public async void GetDataStoreItem(GetDataStoreItemRequest request) + { + LogManager.Log($"Sending GetDataStoreItemRequest:\n{request.ToJsonString()}"); + try + { + var response = await Transporter.SendRequest<GetDataStoreItemRequest, GetDataStoreItemResponse>(request); + LogManager.Log($"Received GetDataStoreItemResponse:\n{response.Message.ToJsonString()}"); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error getting data store item."); + } + } + #endregion } } diff --git a/Software/Visual_Studio/Tango.Emulations/Tango.Emulations.csproj b/Software/Visual_Studio/Tango.Emulations/Tango.Emulations.csproj index e01f0be8d..022188335 100644 --- a/Software/Visual_Studio/Tango.Emulations/Tango.Emulations.csproj +++ b/Software/Visual_Studio/Tango.Emulations/Tango.Emulations.csproj @@ -90,7 +90,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs b/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs index e7e14f988..d6d287166 100644 --- a/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs +++ b/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs @@ -23,6 +23,7 @@ namespace Tango.PMR.Common { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "ChFNZXNzYWdlVHlwZS5wcm90bxIQVGFuZ28uUE1SLkNvbW1vbiqhPgoLTWVz", + "ChFNZXNzYWdlVHlwZS5wcm90bxIQVGFuZ28uUE1SLkNvbW1vbiqjPgoLTWVz", "c2FnZVR5cGUSCAoETm9uZRAAEhEKDUVycm9yUmVzcG9uc2UQARIUChBDYWxj", "dWxhdGVSZXF1ZXN0EAMSFQoRQ2FsY3VsYXRlUmVzcG9uc2UQBBITCg9Qcm9n", "cmVzc1JlcXVlc3QQBRIUChBQcm9ncmVzc1Jlc3BvbnNlEAYSHAoYU3R1YkNh", @@ -201,6 +202,13 @@ namespace Tango.PMR.Common { "GFB1dERhdGFTdG9yZUl0ZW1SZXNwb25zZRDJZRIcChdHZXREYXRhU3RvcmVJ", "dGVtUmVxdWVzdBDKZRIdChhHZXREYXRhU3RvcmVJdGVtUmVzcG9uc2UQy2VC", "HAoaY29tLnR3aW5lLnRhbmdvLnBtci5jb21tb25iBnByb3RvMw==")); + "b25zZRD/VRIhChxTdGFydElua0ZpbGxpbmdTdGF0dXNSZXF1ZXN0EOBdEiIK", + "HVN0YXJ0SW5rRmlsbGluZ1N0YXR1c1Jlc3BvbnNlEOFdEhwKF1B1dERhdGFT", + "dG9yZUl0ZW1SZXF1ZXN0EMhlEh0KGFB1dERhdGFTdG9yZUl0ZW1SZXNwb25z", + "ZRDJZRIcChdHZXREYXRhU3RvcmVJdGVtUmVxdWVzdBDKZRIdChhHZXREYXRh", + "U3RvcmVJdGVtUmVzcG9uc2UQy2USIQocRGF0YVN0b3JlSXRlbU1vZGlmaWVk", + "UmVxdWVzdBDMZRIiCh1EYXRhU3RvcmVJdGVtTW9kaWZpZWRSZXNwb25zZRDN", + "ZUIcChpjb20udHdpbmUudGFuZ28ucG1yLmNvbW1vbmIGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.Common.MessageType), }, null)); @@ -532,6 +540,8 @@ namespace Tango.PMR.Common { [pbr::OriginalName("PutDataStoreItemResponse")] PutDataStoreItemResponse = 13001, [pbr::OriginalName("GetDataStoreItemRequest")] GetDataStoreItemRequest = 13002, [pbr::OriginalName("GetDataStoreItemResponse")] GetDataStoreItemResponse = 13003, + [pbr::OriginalName("DataStoreItemModifiedRequest")] DataStoreItemModifiedRequest = 13004, + [pbr::OriginalName("DataStoreItemModifiedResponse")] DataStoreItemModifiedResponse = 13005, } #endregion diff --git a/Software/Visual_Studio/Tango.PMR/DataStore/DataStoreItemModifiedRequest.cs b/Software/Visual_Studio/Tango.PMR/DataStore/DataStoreItemModifiedRequest.cs new file mode 100644 index 000000000..c4a8163fd --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/DataStore/DataStoreItemModifiedRequest.cs @@ -0,0 +1,188 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DataStoreItemModifiedRequest.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.DataStore { + + /// <summary>Holder for reflection information generated from DataStoreItemModifiedRequest.proto</summary> + public static partial class DataStoreItemModifiedRequestReflection { + + #region Descriptor + /// <summary>File descriptor for DataStoreItemModifiedRequest.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static DataStoreItemModifiedRequestReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CiJEYXRhU3RvcmVJdGVtTW9kaWZpZWRSZXF1ZXN0LnByb3RvEhNUYW5nby5Q", + "TVIuRGF0YVN0b3JlIj8KHERhdGFTdG9yZUl0ZW1Nb2RpZmllZFJlcXVlc3QS", + "EgoKQ29sbGVjdGlvbhgBIAEoCRILCgNLZXkYAiABKAlCHwodY29tLnR3aW5l", + "LnRhbmdvLnBtci5kYXRhc3RvcmViBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.DataStore.DataStoreItemModifiedRequest), global::Tango.PMR.DataStore.DataStoreItemModifiedRequest.Parser, new[]{ "Collection", "Key" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class DataStoreItemModifiedRequest : pb::IMessage<DataStoreItemModifiedRequest> { + private static readonly pb::MessageParser<DataStoreItemModifiedRequest> _parser = new pb::MessageParser<DataStoreItemModifiedRequest>(() => new DataStoreItemModifiedRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<DataStoreItemModifiedRequest> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.DataStore.DataStoreItemModifiedRequestReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DataStoreItemModifiedRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DataStoreItemModifiedRequest(DataStoreItemModifiedRequest other) : this() { + collection_ = other.collection_; + key_ = other.key_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DataStoreItemModifiedRequest Clone() { + return new DataStoreItemModifiedRequest(this); + } + + /// <summary>Field number for the "Collection" field.</summary> + public const int CollectionFieldNumber = 1; + private string collection_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Collection { + get { return collection_; } + set { + collection_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// <summary>Field number for the "Key" field.</summary> + public const int KeyFieldNumber = 2; + private string key_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Key { + get { return key_; } + set { + key_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DataStoreItemModifiedRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DataStoreItemModifiedRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Collection != other.Collection) return false; + if (Key != other.Key) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Collection.Length != 0) hash ^= Collection.GetHashCode(); + if (Key.Length != 0) hash ^= Key.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Collection.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Collection); + } + if (Key.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Key); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Collection.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Collection); + } + if (Key.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Key); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DataStoreItemModifiedRequest other) { + if (other == null) { + return; + } + if (other.Collection.Length != 0) { + Collection = other.Collection; + } + if (other.Key.Length != 0) { + Key = other.Key; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Collection = input.ReadString(); + break; + } + case 18: { + Key = input.ReadString(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/DataStore/DataStoreItemModifiedResponse.cs b/Software/Visual_Studio/Tango.PMR/DataStore/DataStoreItemModifiedResponse.cs new file mode 100644 index 000000000..fc70186aa --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/DataStore/DataStoreItemModifiedResponse.cs @@ -0,0 +1,131 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: DataStoreItemModifiedResponse.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.DataStore { + + /// <summary>Holder for reflection information generated from DataStoreItemModifiedResponse.proto</summary> + public static partial class DataStoreItemModifiedResponseReflection { + + #region Descriptor + /// <summary>File descriptor for DataStoreItemModifiedResponse.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static DataStoreItemModifiedResponseReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CiNEYXRhU3RvcmVJdGVtTW9kaWZpZWRSZXNwb25zZS5wcm90bxITVGFuZ28u", + "UE1SLkRhdGFTdG9yZSIfCh1EYXRhU3RvcmVJdGVtTW9kaWZpZWRSZXNwb25z", + "ZUIfCh1jb20udHdpbmUudGFuZ28ucG1yLmRhdGFzdG9yZWIGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.DataStore.DataStoreItemModifiedResponse), global::Tango.PMR.DataStore.DataStoreItemModifiedResponse.Parser, null, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class DataStoreItemModifiedResponse : pb::IMessage<DataStoreItemModifiedResponse> { + private static readonly pb::MessageParser<DataStoreItemModifiedResponse> _parser = new pb::MessageParser<DataStoreItemModifiedResponse>(() => new DataStoreItemModifiedResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<DataStoreItemModifiedResponse> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.DataStore.DataStoreItemModifiedResponseReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DataStoreItemModifiedResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DataStoreItemModifiedResponse(DataStoreItemModifiedResponse other) : this() { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DataStoreItemModifiedResponse Clone() { + return new DataStoreItemModifiedResponse(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DataStoreItemModifiedResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DataStoreItemModifiedResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DataStoreItemModifiedResponse other) { + if (other == null) { + return; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj index 18b1e2aa1..5debc8864 100644 --- a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj +++ b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj @@ -79,6 +79,8 @@ <Compile Include="Connection\KeepAliveRequest.cs" /> <Compile Include="Connection\KeepAliveResponse.cs" /> <Compile Include="DataStore\DataStoreItem.cs" /> + <Compile Include="DataStore\DataStoreItemModifiedRequest.cs" /> + <Compile Include="DataStore\DataStoreItemModifiedResponse.cs" /> <Compile Include="DataStore\DataType.cs" /> <Compile Include="DataStore\GetDataStoreItemRequest.cs" /> <Compile Include="DataStore\GetDataStoreItemResponse.cs" /> diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs index 583d7b810..1f2856a32 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Controls/SearchComboBox.cs @@ -12,6 +12,7 @@ using System.Windows.Input; using System.Linq; using System.Windows.Media; using System.Windows.Threading; +using Tango.Core.ExtensionMethods; namespace Tango.SharedUI.Controls { @@ -73,6 +74,11 @@ namespace Tango.SharedUI.Controls { IsOpened = false; SelectedItem = _listBox.SelectedItem; + + if (SelectedValuePath.IsNotNullOrEmpty() && SelectedItem != null) + { + SelectedValue = SelectedItem.GetPropertyValueByPath(SelectedValuePath); + } } else if (e.Key == Key.Up && _listBox.SelectedIndex == 0) { @@ -120,6 +126,11 @@ namespace Tango.SharedUI.Controls { IsOpened = false; SelectedItem = _listBox.SelectedItem; + + if (SelectedValuePath.IsNotNullOrEmpty() && SelectedItem != null) + { + SelectedValue = SelectedItem.GetPropertyValueByPath(SelectedValuePath); + } } } } @@ -152,12 +163,17 @@ namespace Tango.SharedUI.Controls if (x != null) { - var prop = x.GetType().GetProperty(SearchProperty, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); - if (prop != null) + if (!String.IsNullOrWhiteSpace(SearchProperty)) { - String propValue = prop.GetValue(x).ToString(); - return propValue.ToLower().Contains(SearchFilter.ToLower()); + var prop = x.GetType().GetProperty(SearchProperty, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); + if (prop != null) + { + String propValue = prop.GetValue(x).ToString(); + return propValue.ToLower().Contains(SearchFilter.ToLower()); + } } + + return x.ToStringSafe().ToLower().Contains(SearchFilter.ToLower()); } return false; diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToItemsSourceConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToItemsSourceConverter.cs index c551f7d49..5c725e524 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToItemsSourceConverter.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/EnumToItemsSourceConverter.cs @@ -10,6 +10,17 @@ namespace Tango.SharedUI.Converters { public class EnumToItemsSourceConverter : IValueConverter { + public class EnumValue + { + public Object Value { get; set; } + public String DisplayName { get; set; } + + public override string ToString() + { + return DisplayName; + } + } + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Type result = value as Type; @@ -20,7 +31,7 @@ namespace Tango.SharedUI.Converters } else { - return Enum.GetValues(result).Cast<object>().Select(e => new { Value = e, DisplayName = (e as Enum).ToDescription() }).ToList(); + return Enum.GetValues(result).Cast<object>().Select(e => new EnumValue() { Value = e, DisplayName = (e as Enum).ToDescription() }).ToList(); } } diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 615dc2154..64f19da67 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -427,6 +427,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.Remote", "T EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.EF", "Tango.DataStore.EF\Tango.DataStore.EF.csproj", "{88D9906B-8FC4-4FE0-B7EB-127A0A8FCEE4}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.FSE.MachineConfiguration", "FSE\Modules\Tango.FSE.MachineConfiguration\Tango.FSE.MachineConfiguration.csproj", "{15BCB5BB-731E-4E2D-AA28-75485050A8DC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.DataStore.Editing", "Tango.DataStore.Editing\Tango.DataStore.Editing.csproj", "{EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -4034,6 +4038,46 @@ Global {88D9906B-8FC4-4FE0-B7EB-127A0A8FCEE4}.Release|x64.Build.0 = Release|Any CPU {88D9906B-8FC4-4FE0-B7EB-127A0A8FCEE4}.Release|x86.ActiveCfg = Release|Any CPU {88D9906B-8FC4-4FE0-B7EB-127A0A8FCEE4}.Release|x86.Build.0 = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|ARM.ActiveCfg = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|ARM.Build.0 = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|ARM64.Build.0 = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|x64.ActiveCfg = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|x64.Build.0 = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|x86.ActiveCfg = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Debug|x86.Build.0 = Debug|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|ARM.ActiveCfg = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|ARM.Build.0 = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|ARM64.ActiveCfg = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|ARM64.Build.0 = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x64.ActiveCfg = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x64.Build.0 = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x86.ActiveCfg = Release|Any CPU + {15BCB5BB-731E-4E2D-AA28-75485050A8DC}.Release|x86.Build.0 = Release|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|ARM.ActiveCfg = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|ARM.Build.0 = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|ARM64.Build.0 = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|x64.ActiveCfg = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|x64.Build.0 = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|x86.ActiveCfg = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Debug|x86.Build.0 = Debug|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|Any CPU.Build.0 = Release|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|ARM.ActiveCfg = Release|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|ARM.Build.0 = Release|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|ARM64.ActiveCfg = Release|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|ARM64.Build.0 = Release|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|x64.ActiveCfg = Release|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|x64.Build.0 = Release|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|x86.ActiveCfg = Release|Any CPU + {EE088FF7-04D1-41FB-9D6A-CEDEEE7A7B9C}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -4177,6 +4221,7 @@ Global {59643ABC-DF9A-497F-8A7C-4A131C7CF438} = {E728CBD9-1AF4-4814-A218-E4BD26E7EDEA} {69168924-9AA8-447D-AD64-F07DBF4F0909} = {5F6BBAA8-EAD0-4B18-97E5-55B4F56DD760} {EA4233F1-4B7B-4CCF-A6DE-2D17612EBA90} = {E728CBD9-1AF4-4814-A218-E4BD26E7EDEA} + {15BCB5BB-731E-4E2D-AA28-75485050A8DC} = {4EE6DBA1-71BC-49E2-8DC7-266487E61050} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution BuildVersion_UseGlobalSettings = False diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Converters/EventTypeToStringConverter.cs b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Converters/EventTypeToStringConverter.cs new file mode 100644 index 000000000..de771f2a8 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Converters/EventTypeToStringConverter.cs @@ -0,0 +1,29 @@ +using Google.Protobuf.Reflection; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.PMR.Diagnostics; + +namespace Tango.MachineEM.UI.Converters +{ + public class EventTypeToStringConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + EventType eventType = (EventType)value; + FieldInfo fi = value.GetType().GetField(eventType.ToString()); + String name = fi.GetCustomAttribute<OriginalNameAttribute>().Name; + return $"{(int)eventType} {name}"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/InputWindow.xaml b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/InputWindow.xaml new file mode 100644 index 000000000..05a4b33cd --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/InputWindow.xaml @@ -0,0 +1,25 @@ +<Window x:Class="Tango.MachineEM.UI.InputWindow" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:local="clr-namespace:Tango.MachineEM.UI" + mc:Ignorable="d" + Title="Input" Height="250" Width="600"> + <Grid> + <DockPanel> + <UniformGrid Columns="2" DockPanel.Dock="Bottom" HorizontalAlignment="Right" Height="45"> + <Button x:Name="btnCancel" Width="150" Margin="5" Style="{StaticResource AccentedSquareButtonStyle}" BorderThickness="0" mahapps:ButtonHelper.PreserveTextCase="True">CANCEL</Button> + <Button IsDefault="True" x:Name="btnOK" Width="150" Margin="5" Style="{StaticResource AccentedSquareButtonStyle}" BorderThickness="0" mahapps:ButtonHelper.PreserveTextCase="True">OK</Button> + </UniformGrid> + + <Rectangle DockPanel.Dock="Bottom" Stroke="#494949" StrokeThickness="1" /> + + <StackPanel Margin="40"> + <TextBlock x:Name="txtMessage" Text="Please enter a value" Foreground="Gainsboro"></TextBlock> + <TextBox x:Name="txtValue" Margin="0 10 120 0"></TextBox> + </StackPanel> + </DockPanel> + </Grid> +</Window> diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/InputWindow.xaml.cs b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/InputWindow.xaml.cs new file mode 100644 index 000000000..191b53072 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/InputWindow.xaml.cs @@ -0,0 +1,56 @@ +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.Shapes; + +namespace Tango.MachineEM.UI +{ + /// <summary> + /// Interaction logic for InputWindow.xaml + /// </summary> + public partial class InputWindow : Window + { + public String Value { get; set; } + public String Message { get; set; } + + public InputWindow() + { + InitializeComponent(); + + btnOK.Click += BtnOK_Click; + btnCancel.Click += BtnCancel_Click; + Loaded += InputWindow_Loaded; + } + + private void InputWindow_Loaded(object sender, RoutedEventArgs e) + { + txtValue.Text = Value; + txtMessage.Text = Message; + + txtValue.Focus(); + Keyboard.Focus(txtValue); + } + + private void BtnCancel_Click(object sender, RoutedEventArgs e) + { + DialogResult = false; + Close(); + } + + private void BtnOK_Click(object sender, RoutedEventArgs e) + { + Value = txtValue.Text; + DialogResult = true; + Close(); + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml index 7bfc7f0fd..8f066800e 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml @@ -9,7 +9,7 @@ xmlns:local="clr-namespace:Tango.MachineEM.UI" xmlns:views="clr-namespace:Tango.MachineEM.UI.Views" mc:Ignorable="d" - Title="Tango Embedded Emulator" Height="720" Width="1300" TitleCaps="False" BorderBrush="Gray" BorderThickness="1" WindowStartupLocation="CenterScreen" Background="#202020" Foreground="Gainsboro" DataContext="{Binding RelativeSource={RelativeSource Self}}"> + Title="Tango Embedded Emulator" Height="820" Width="1300" TitleCaps="False" BorderBrush="Gray" BorderThickness="1" WindowStartupLocation="CenterScreen" Background="#202020" Foreground="Gainsboro" DataContext="{Binding RelativeSource={RelativeSource Self}}"> <Grid> <views:MainView DataContext="{StaticResource MainViewVM}"></views:MainView> </Grid> diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj index 705194057..c6f382afe 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj @@ -83,6 +83,10 @@ <Compile Include="Controls\InkFillingStatusView.xaml.cs"> <DependentUpon>InkFillingStatusView.xaml</DependentUpon> </Compile> + <Compile Include="Converters\EventTypeToStringConverter.cs" /> + <Compile Include="InputWindow.xaml.cs"> + <DependentUpon>InputWindow.xaml</DependentUpon> + </Compile> <Compile Include="ViewModels\MainViewVM.cs" /> <Compile Include="Views\MainView.xaml.cs"> <DependentUpon>MainView.xaml</DependentUpon> @@ -91,6 +95,10 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="InputWindow.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="MainWindow.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -200,7 +208,7 @@ </PropertyGroup> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs index b46b89a4a..c993be2d7 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs @@ -13,6 +13,8 @@ using Tango.Transport.Transporters; using Tango.Core; using Tango.Settings; using Tango.PMR.ThreadLoading; +using Tango.PMR.DataStore; +using System.Windows; namespace Tango.MachineEM.UI.ViewModels { @@ -138,6 +140,10 @@ namespace Tango.MachineEM.UI.ViewModels /// </summary> public RelayCommand AbortJobCommand { get; set; } + public RelayCommand GetDataStoreItemCommand { get; set; } + + public RelayCommand PutDataStoreItemCommand { get; set; } + public RelayCommand PerformDataStoreTestCommand { get; set; } #endregion @@ -191,6 +197,8 @@ namespace Tango.MachineEM.UI.ViewModels SelectedPort = Ports.First(); PerformDataStoreTestCommand = new RelayCommand(Emulator.PerformDataStoreTest); + GetDataStoreItemCommand = new RelayCommand(GetDataStoreItem); + PutDataStoreItemCommand = new RelayCommand(PutDataStoreItem); } #endregion @@ -282,6 +290,120 @@ namespace Tango.MachineEM.UI.ViewModels InvalidateRelayCommands(); } + private void GetDataStoreItem() + { + try + { + var result = GetUserInput<String>("Get Data Store Item", "Enter collection name", String.Empty); + if (!result.Confirmed) return; + var collectionName = result.Value; + + result = GetUserInput<String>("Get Data Store Item", "Enter item key", String.Empty); + if (!result.Confirmed) return; + var key = result.Value; + + Emulator.GetDataStoreItem(new PMR.DataStore.GetDataStoreItemRequest() + { + Collection = collectionName, + Key = key + }); + } + catch { } + } + + private void PutDataStoreItem() + { + try + { + var result = GetUserInput<String>("Put Data Store Item", "Enter collection name", String.Empty); + if (!result.Confirmed) return; + var collectionName = result.Value; + + result = GetUserInput<String>("Put Data Store Item", "Enter item key", String.Empty); + if (!result.Confirmed) return; + var key = result.Value; + + result = GetUserInput<String>("Put Data Store Item", "Enter data type", "Int32"); + if (!result.Confirmed) return; + DataType dataType = (DataType)Enum.Parse(typeof(DataType), result.Value); + + result = GetUserInput<String>("Put Data Store Item", "Enter value", "10"); + if (!result.Confirmed) return; + var value = result.Value; + + DataStoreItem item = new DataStoreItem(); + item.DataType = dataType; + + switch (dataType) + { + case DataType.Int32: + item.Int32Value = int.Parse(value); + break; + case DataType.Float: + item.FloatValue = float.Parse(value); + break; + case DataType.Double: + item.DoubleValue = double.Parse(value); + break; + case DataType.Boolean: + item.BooleanValue = bool.Parse(value); + break; + case DataType.String: + item.StringValue = value; + break; + default: + LogManager.Log("Data type not supported by this emulator."); + throw new NotSupportedException(); + } + + Emulator.PutDataStoreItem(new PutDataStoreItemRequest() + { + Collection = collectionName, + Key = key, + Item = item + }); + } + catch { } + } + + #endregion + + #region Private Methods + + private class InputResult<T> + { + public bool Confirmed { get; set; } + public T Value { get; set; } + } + + private InputResult<T> GetUserInput<T>(String title, String message, T defaultValue) + { + InputWindow window = new InputWindow(); + window.Title = title; + window.Message = message; + window.Value = defaultValue.ToStringSafe(); + window.Owner = Application.Current.MainWindow; + window.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner; + window.WindowStyle = WindowStyle.ToolWindow; + + try + { + if (window.ShowDialog().Value) + { + return new InputResult<T>() { Confirmed = true, Value = (T)Convert.ChangeType(window.Value, typeof(T)) }; + } + else + { + return new InputResult<T>(); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error parsing input."); + throw ex; + } + } + #endregion } } diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml index f553ec588..c0c4b7b97 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml @@ -11,13 +11,15 @@ xmlns:vm="clr-namespace:Tango.MachineEM.UI.ViewModels" xmlns:pmr="clr-namespace:Tango.PMR.MachineStatus;assembly=Tango.PMR" xmlns:threadLoading="clr-namespace:Tango.PMR.ThreadLoading;assembly=Tango.PMR" + xmlns:localConverters="clr-namespace:Tango.MachineEM.UI.Converters" xmlns:local="clr-namespace:Tango.MachineEM.UI.Views" mc:Ignorable="d" - d:DesignHeight="720" d:DesignWidth="1300" Foreground="Gainsboro" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" > + d:DesignHeight="780" d:DesignWidth="1300" Foreground="Gainsboro" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" > <UserControl.Resources> <converters:BooleanInverseConverter x:Key="BooleanInverseConverter"></converters:BooleanInverseConverter> <converters:EnumToItemsSourceConverter x:Key="EnumToItemsSourceConverter" /> + <localConverters:EventTypeToStringConverter x:Key="EventTypeToStringConverter" /> </UserControl.Resources> <Grid> <Grid.Background> @@ -150,14 +152,28 @@ <Button Padding="10 0 0 0" Margin="5" Height="45" HorizontalContentAlignment="Left" Style="{StaticResource AccentedSquareButtonStyle}" mahapps:ButtonHelper.PreserveTextCase="True" BorderThickness="0" Command="{Binding AbortJobCommand}"> <DockPanel> <fa:ImageAwesome Icon="ExclamationTriangle" Width="16"></fa:ImageAwesome> - <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">ABORT JOB</TextBlock> + <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" HorizontalAlignment="Center">ABORT JOB</TextBlock> </DockPanel> </Button> - <Button Padding="10 0 0 0" Margin="5" Height="45" HorizontalContentAlignment="Left" Style="{StaticResource AccentedSquareButtonStyle}" mahapps:ButtonHelper.PreserveTextCase="True" BorderThickness="0" Command="{Binding PerformDataStoreTestCommand}"> + <Button Padding="10 0 0 0" Margin="5" HorizontalContentAlignment="Left" Height="45" Style="{StaticResource AccentedSquareButtonStyle}" mahapps:ButtonHelper.PreserveTextCase="True" BorderThickness="0" Command="{Binding PerformDataStoreTestCommand}"> <DockPanel> <fa:ImageAwesome Icon="Database" Width="16"></fa:ImageAwesome> - <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">DATASTORE TEST</TextBlock> + <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" HorizontalAlignment="Center">DATASTORE TEST</TextBlock> + </DockPanel> + </Button> + + <Button Padding="10 0 0 0" Margin="5" HorizontalContentAlignment="Left" Height="45" Style="{StaticResource AccentedSquareButtonStyle}" mahapps:ButtonHelper.PreserveTextCase="True" BorderThickness="0" Command="{Binding GetDataStoreItemCommand}"> + <DockPanel> + <fa:ImageAwesome Icon="Download" Width="16"></fa:ImageAwesome> + <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" HorizontalAlignment="Center">GET DATA STORE ITEM</TextBlock> + </DockPanel> + </Button> + + <Button HorizontalContentAlignment="Left" Padding="10 0 0 0" Margin="5" Height="45" Style="{StaticResource AccentedSquareButtonStyle}" mahapps:ButtonHelper.PreserveTextCase="True" BorderThickness="0" Command="{Binding PutDataStoreItemCommand}"> + <DockPanel> + <fa:ImageAwesome Icon="Upload" Width="16"></fa:ImageAwesome> + <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" HorizontalAlignment="Center">PUT DATA STORE ITEM</TextBlock> </DockPanel> </Button> <!--BUTTONS HERE--> @@ -183,7 +199,7 @@ </ListBox.ItemContainerStyle> <ListBox.ItemTemplate> <DataTemplate> - <CheckBox FontSize="11" Content="{Binding EventType}" IsChecked="{Binding IsActive}" Margin="5"></CheckBox> + <CheckBox FontSize="11" Content="{Binding EventType,Converter={StaticResource EventTypeToStringConverter}}" IsChecked="{Binding IsActive}" Margin="5"></CheckBox> </DataTemplate> </ListBox.ItemTemplate> </ListBox> diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs index fbc4f8a0a..0e96c14c8 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs @@ -186,6 +186,15 @@ namespace Tango.MachineService.Controllers LogManager.Log(ex, $"Error resetting synchronized job runs for machine '{machine.SerialNumber}'."); } + try + { + b.DataStoreItems.Where(x => x.MachineGuid == machine.Guid).Update(x => new DataStoreItem() { IsSynchronized = false }); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error resetting synchronized data store items for machine '{machine.SerialNumber}'."); + } + //Reset Events. //b.MachinesEvents.Where(x => x.MachineGuid == machine.Guid).Update(x => new MachinesEvent() { IsSynchronized = false }); //Reset Jobs. @@ -755,7 +764,7 @@ namespace Tango.MachineService.Controllers //Send DataStore Items if (request.RequestDataStoreItems) { - var dataStoreItems = db.DataStoreItems.Where(x => x.MachineGuid == machine.Guid && !x.IsSynchronized).Take(request.MaxDataStoreItems).OrderByDescending(x => x.LastUpdated).ToList(); + var dataStoreItems = db.DataStoreItems.Where(x => x.MachineGuid == machine.Guid && !x.IsSynchronized & !x.IsDeleted).Take(request.MaxDataStoreItems).OrderByDescending(x => x.LastUpdated).ToList(); foreach (var item in dataStoreItems) { diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Web/Tango.MachineService/Properties/AssemblyInfo.cs index 41fa77771..601098814 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Properties/AssemblyInfo.cs @@ -24,4 +24,4 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("3.0.6.0")] +[assembly: AssemblyVersion("3.0.7.0")] |
