aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2020-01-27 09:19:11 +0200
committerShlomo Hecht <shlomo@twine-s.com>2020-01-27 09:19:11 +0200
commitddda6089bff56e80703c8d2dce297919edc58bf1 (patch)
tree7702c5cf169124d522eacc7f1a9e0878373baedd /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner
parent1d4d327571d4c0c9f4e17411551bd4dae1e2aed0 (diff)
parentbf2f3245339b9fd9148a2ad25b5ba3320e970cc1 (diff)
downloadTango-ddda6089bff56e80703c8d2dce297919edc58bf1.tar.gz
Tango-ddda6089bff56e80703c8d2dce297919edc58bf1.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Tango.MachineStudio.HardwareDesigner_ijdp5tm3_wpftmp.csproj184
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/ComparisonWizardViewVM.cs8
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs134
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml16
4 files changed, 329 insertions, 13 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Tango.MachineStudio.HardwareDesigner_ijdp5tm3_wpftmp.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Tango.MachineStudio.HardwareDesigner_ijdp5tm3_wpftmp.csproj
new file mode 100644
index 000000000..0ef643858
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Tango.MachineStudio.HardwareDesigner_ijdp5tm3_wpftmp.csproj
@@ -0,0 +1,184 @@
+<?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>{69DB0564-268C-4B3C-B5D6-A3CDC7D14EAE}</ProjectGuid>
+ <OutputType>library</OutputType>
+ <RootNamespace>Tango.MachineStudio.HardwareDesigner</RootNamespace>
+ <AssemblyName>Tango.MachineStudio.HardwareDesigner</AssemblyName>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>..\..\..\Build\Machine Studio\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\Machine Studio\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="..\..\..\Versioning\GlobalVersionInfo.cs">
+ <Link>GlobalVersionInfo.cs</Link>
+ </Compile>
+ <Compile Include="Comparison\HardwareCompareResult.cs" />
+ <Compile Include="Comparison\HardwareComponentCollectionCompareResult.cs" />
+ <Compile Include="Comparison\HardwareComponentCompareResult.cs" />
+ <Compile Include="Comparison\HardwareComponentPropertyResult.cs" />
+ <Compile Include="Comparison\IHasDifference.cs" />
+ <Compile Include="Report\ReportModel.cs" />
+ <Compile Include="ViewModelLocator.cs" />
+ <Compile Include="ViewModels\ComparisonWizardViewVM.cs" />
+ <Compile Include="Views\ComparisonWizardView.xaml.cs">
+ <DependentUpon>ComparisonWizardView.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="ViewModels\MainViewVM.cs" />
+ <Compile Include="Views\MainView.xaml.cs">
+ <DependentUpon>MainView.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="HardwareDesignerModule.cs" />
+ </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="..\..\..\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.DragAndDrop\Tango.DragAndDrop.csproj">
+ <Project>{b112d89a-a106-41ae-a0c1-4abc84c477f5}</Project>
+ <Name>Tango.DragAndDrop</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.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.MachineStudio.Common\Tango.MachineStudio.Common.csproj">
+ <Project>{cb0b0aa2-bb24-4bca-a720-45e397684e12}</Project>
+ <Name>Tango.MachineStudio.Common</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+ <ItemGroup />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <ProjectExtensions>
+ <VisualStudio>
+ <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
+ </VisualStudio>
+ </ProjectExtensions>
+ <ItemGroup>
+ <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\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll" />
+ <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\packages\MaterialDesignColors.1.1.2\lib\net45\MaterialDesignColors.dll" />
+ <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\packages\MaterialDesignThemes.2.3.1.953\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:\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\Expression.Blend.Sdk.1.0.2\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\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\Build\Core\Debug\Tango.CSV.dll" />
+ <ReferencePath Include="C:\DATA\Development\Tango\Software\Visual_Studio\Build\Core\Debug\Tango.DragAndDrop.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\Machine Studio\Debug\Tango.MachineStudio.Common.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:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\WindowsBase.dll" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="C:\DATA\Development\Tango\Software\Visual_Studio\MachineStudio\Modules\Tango.MachineStudio.HardwareDesigner\obj\Debug\App.g.cs" />
+ <Compile Include="C:\DATA\Development\Tango\Software\Visual_Studio\MachineStudio\Modules\Tango.MachineStudio.HardwareDesigner\obj\Debug\Views\ComparisonWizardView.g.cs" />
+ <Compile Include="C:\DATA\Development\Tango\Software\Visual_Studio\MachineStudio\Modules\Tango.MachineStudio.HardwareDesigner\obj\Debug\Views\MainView.g.cs" />
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/ComparisonWizardViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/ComparisonWizardViewVM.cs
index 47a40ade4..a58d69a93 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/ComparisonWizardViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/ComparisonWizardViewVM.cs
@@ -281,6 +281,7 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
collection.Components.Add(componentResult);
}
+ collection.Components = collection.Components.OrderByAlphaNumeric(x => x.ComponentName).ToSynchronizedObservableCollection();
return collection;
}
@@ -303,6 +304,7 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
collection.Components.Add(componentResult);
}
+ collection.Components = collection.Components.OrderByAlphaNumeric(x => x.ComponentName).ToSynchronizedObservableCollection();
return collection;
}
@@ -325,6 +327,7 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
collection.Components.Add(componentResult);
}
+ collection.Components = collection.Components.OrderByAlphaNumeric(x => x.ComponentName).ToSynchronizedObservableCollection();
return collection;
}
@@ -347,6 +350,7 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
collection.Components.Add(componentResult);
}
+ collection.Components = collection.Components.OrderByAlphaNumeric(x => x.ComponentName).ToSynchronizedObservableCollection();
return collection;
}
@@ -369,6 +373,7 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
collection.Components.Add(componentResult);
}
+ collection.Components = collection.Components.OrderByAlphaNumeric(x => x.ComponentName).ToSynchronizedObservableCollection();
return collection;
}
@@ -391,6 +396,7 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
collection.Components.Add(componentResult);
}
+ collection.Components = collection.Components.OrderByAlphaNumeric(x => x.ComponentName).ToSynchronizedObservableCollection();
return collection;
}
@@ -413,6 +419,7 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
collection.Components.Add(componentResult);
}
+ collection.Components = collection.Components.OrderByAlphaNumeric(x => x.ComponentName).ToSynchronizedObservableCollection();
return collection;
}
@@ -432,7 +439,6 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
result.Properties.Add(hProp);
}
-
return result;
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs
index 918eb02d4..0a8780346 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs
@@ -14,6 +14,11 @@ using System.Runtime.CompilerServices;
using Tango.MachineStudio.Common;
using Tango.Core.ExtensionMethods;
using Tango.MachineStudio.HardwareDesigner.Views;
+using Microsoft.Win32;
+using System.IO;
+using Tango.BL.ActionLogs;
+using Tango.MachineStudio.Common.Authentication;
+using Tango.BL.DTO;
namespace Tango.MachineStudio.HardwareDesigner.ViewModels
{
@@ -22,6 +27,9 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
private INotificationProvider _notification;
private bool _isNew;
private ObservablesContext _db;
+ private IActionLogManager _actionLogManager;
+ private IAuthenticationProvider _authentication;
+ private HardwareVersionDTO _hwBeforeSave;
private HardwareVersion _selectedVersion;
public HardwareVersion SelectedVersion
@@ -43,6 +51,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
get { return _selectedHardwareObject; }
set
{
+ _selectedHardwareObject = null;
+ RaisePropertyChangedAuto();
_selectedHardwareObject = value;
RaisePropertyChangedAuto();
RaisePropertyChanged(nameof(SelectedHardwareObjectTypeName));
@@ -87,7 +97,7 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
return name;
}
}
-
+
private ObservableCollection<HardwareVersion> _hardwareVersions;
public ObservableCollection<HardwareVersion> HardwareVersions
{
@@ -107,9 +117,15 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
public RelayCommand OpenComparisonWizardCommand { get; set; }
- public MainViewVM(INotificationProvider notification)
+ public RelayCommand ExportHardwareVersionCommand { get; set; }
+
+ public RelayCommand ImportHardwareVersionCommand { get; set; }
+
+ public MainViewVM(INotificationProvider notification, IActionLogManager actionLogManager, IAuthenticationProvider authentication)
{
_notification = notification;
+ _actionLogManager = actionLogManager;
+ _authentication = authentication;
CurrentVersion = new HardwareVersion();
@@ -122,7 +138,88 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
CopyParametersCommand = new RelayCommand(CopyParameters, (x) => SelectedVersion != null && IsFree);
CloneCommand = new RelayCommand(CloneCurrentVersion, () => SelectedVersion != null && IsFree);
- OpenComparisonWizardCommand = new RelayCommand(OpenComparisonWizard);
+ OpenComparisonWizardCommand = new RelayCommand(OpenComparisonWizard, () => IsFree);
+ ExportHardwareVersionCommand = new RelayCommand(ExportHardwareVersion, () => IsFree && SelectedVersion != null && CurrentVersion != null);
+ ImportHardwareVersionCommand = new RelayCommand(ImportHardwareVersion, () => IsFree);
+ }
+
+ private async void ExportHardwareVersion()
+ {
+ SaveFileDialog dlg = new SaveFileDialog();
+ dlg.Title = "Export hardware version";
+ dlg.DefaultExt = ".hv";
+ dlg.Filter = "Hardware Version Files|*.hv";
+
+ if (dlg.ShowDialog().Value)
+ {
+ try
+ {
+ var json = await CurrentVersion.ToHardwareVersionFile();
+ File.WriteAllText(dlg.FileName, json);
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error exporting hardware version.");
+ _notification.ShowError($"An error occurred while trying to export the selected hardware version.\n{ex.FlattenMessage()}");
+ }
+ }
+ }
+
+ private async void ImportHardwareVersion()
+ {
+ OpenFileDialog dlg = new OpenFileDialog();
+ dlg.Title = "Import hardware version";
+ dlg.DefaultExt = ".hv";
+ dlg.Filter = "Hardware Version Files|*.hv";
+
+ if (dlg.ShowDialog().Value)
+ {
+ try
+ {
+ var hv = await HardwareVersion.FromHardwareVersionFile(File.ReadAllText(dlg.FileName));
+
+ String name = _notification.ShowTextInput("Enter hardware version name", "Name", hv.Name);
+ if (!String.IsNullOrWhiteSpace(name))
+ {
+ using (_notification.PushTaskItem("Importing hardware version..."))
+ {
+ try
+ {
+ IsFree = false;
+
+ hv.Name = name;
+ hv.Version = HardwareVersions.Max(x => x.Version) + 1;
+
+ _db.HardwareVersions.Add(hv);
+ await _db.SaveChangesAsync();
+
+ _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.HardwareVersionImported, _authentication.CurrentUser, CurrentVersion.Name, CurrentVersion, "New hardware version imported using Machine Studio.");
+
+ RefreshVersions();
+
+ InvokeUI(() =>
+ {
+ SelectedVersion = HardwareVersions.SingleOrDefault(x => x.Guid == hv.Guid);
+ });
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error importing hardware version.");
+ _notification.ShowError($"An error occurred while trying to import the selected hardware version.\n{ex.FlattenMessage()}");
+ }
+ finally
+ {
+ IsFree = true;
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error importing hardware version.");
+ _notification.ShowError($"An error occurred while trying to load the selected hardware version file.\n{ex.FlattenMessage()}");
+ }
+ }
}
public override void OnApplicationReady()
@@ -136,7 +233,7 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
private void CopyParameters(object obj)
{
- obj.MapPrimitivesTo(SelectedHardwareObject,
+ obj.MapPropertiesTo(SelectedHardwareObject, MappingFlags.PrimitivesOnly,
(prop) =>
!prop.PropertyType.IsEnum
&&
@@ -151,13 +248,13 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
_db = ObservablesContext.CreateDefault();
- CurrentVersion.HardwareMotors = _db.HardwareMotorTypes.ToList().Select(x => new HardwareMotor() { HardwareMotorType = x }).ToSynchronizedObservableCollection();
- CurrentVersion.HardwareDancers = _db.HardwareDancerTypes.ToList().Select(x => new HardwareDancer() { HardwareDancerType = x }).ToSynchronizedObservableCollection();
- CurrentVersion.HardwarePidControls = _db.HardwarePidControlTypes.ToList().Select(x => new HardwarePidControl() { HardwarePidControlType = x }).ToSynchronizedObservableCollection();
- CurrentVersion.HardwareWinders = _db.HardwareWinderTypes.ToList().Select(x => new HardwareWinder() { HardwareWinderType = x }).ToSynchronizedObservableCollection();
- CurrentVersion.HardwareSpeedSensors = _db.HardwareSpeedSensorTypes.ToList().Select(x => new HardwareSpeedSensor() { HardwareSpeedSensorType = x }).ToSynchronizedObservableCollection();
- CurrentVersion.HardwareBlowers = _db.HardwareBlowerTypes.ToList().Select(x => new HardwareBlower() { HardwareBlowerType = x }).ToSynchronizedObservableCollection();
- CurrentVersion.HardwareBreakSensors = _db.HardwareBreakSensorTypes.ToList().Select(x => new HardwareBreakSensor() { HardwareBreakSensorType = x }).ToSynchronizedObservableCollection();
+ CurrentVersion.HardwareMotors = _db.HardwareMotorTypes.ToList().Select(x => new HardwareMotor() { HardwareMotorType = x }).OrderByAlphaNumeric(x => x.HardwareMotorType.Description).ToSynchronizedObservableCollection();
+ CurrentVersion.HardwareDancers = _db.HardwareDancerTypes.ToList().Select(x => new HardwareDancer() { HardwareDancerType = x }).OrderByAlphaNumeric(x => x.HardwareDancerType.Description).ToSynchronizedObservableCollection();
+ CurrentVersion.HardwarePidControls = _db.HardwarePidControlTypes.ToList().Select(x => new HardwarePidControl() { HardwarePidControlType = x }).OrderByAlphaNumeric(x => x.HardwarePidControlType.Description).ToSynchronizedObservableCollection();
+ CurrentVersion.HardwareWinders = _db.HardwareWinderTypes.ToList().Select(x => new HardwareWinder() { HardwareWinderType = x }).OrderByAlphaNumeric(x => x.HardwareWinderType.Description).ToSynchronizedObservableCollection();
+ CurrentVersion.HardwareSpeedSensors = _db.HardwareSpeedSensorTypes.ToList().Select(x => new HardwareSpeedSensor() { HardwareSpeedSensorType = x }).OrderByAlphaNumeric(x => x.HardwareSpeedSensorType.Description).ToSynchronizedObservableCollection();
+ CurrentVersion.HardwareBlowers = _db.HardwareBlowerTypes.ToList().Select(x => new HardwareBlower() { HardwareBlowerType = x }).OrderByAlphaNumeric(x => x.HardwareBlowerType.Description).ToSynchronizedObservableCollection();
+ CurrentVersion.HardwareBreakSensors = _db.HardwareBreakSensorTypes.ToList().Select(x => new HardwareBreakSensor() { HardwareBreakSensorType = x }).OrderByAlphaNumeric(x => x.HardwareBreakSensorType.Description).ToSynchronizedObservableCollection();
}
private void RefreshVersions()
@@ -252,6 +349,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
});
CurrentVersion.HardwareBreakSensors = CurrentVersion.HardwareBreakSensors.OrderBy(x => x.HardwareBreakSensorType.Code).ToSynchronizedObservableCollection();
+
+ _hwBeforeSave = HardwareVersionDTO.FromObservable(CurrentVersion);
});
}
@@ -306,6 +405,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
_db.HardwareVersions.Add(CurrentVersion);
_db.SaveChanges();
+ _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.HardwareVersionCreated, _authentication.CurrentUser, CurrentVersion.Name, CurrentVersion, "New hardware version created using Machine Studio.");
+
RefreshVersions();
InvokeUI(() =>
@@ -333,7 +434,13 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
await Task.Factory.StartNew(() =>
{
+ CurrentVersion.LastUpdated = DateTime.UtcNow;
_db.SaveChanges();
+
+ var dtoAfter = HardwareVersionDTO.FromObservable(CurrentVersion);
+ _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.HardwareVersionSaved, _authentication.CurrentUser, _hwBeforeSave.Name, _hwBeforeSave, dtoAfter, "Hardware Version saved using Machine Studio.");
+ _hwBeforeSave = dtoAfter;
+
RefreshVersions();
InvokeUI(() =>
@@ -375,6 +482,9 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
cloned.Version = HardwareVersions.Max(x => x.Version) + 1;
_db.HardwareVersions.Add(cloned);
_db.SaveChanges();
+
+ _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.HardwareVersionCreated, _authentication.CurrentUser, cloned.Name, cloned, "New hardware version cloned using Machine Studio.");
+
RefreshVersions();
InvokeUI(() =>
@@ -410,6 +520,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels
await CurrentVersion.DeleteCascadeAsync(_db);
+ _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.HardwareVersionDeleted, _authentication.CurrentUser, CurrentVersion.Name, _hwBeforeSave, "Hardware version deleted using Machine Studio.", true);
+
await Task.Factory.StartNew(() =>
{
SelectedVersion = null;
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml
index 86cc089e5..1c00397aa 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml
@@ -66,12 +66,26 @@
</ComboBox>
</StackPanel>
- <Button Margin="100,10,0,0" Cursor="Hand" Height="40" FontSize="12" ToolTip="Open Comparison Wizard" Command="{Binding OpenComparisonWizardCommand}">
+ <Button Margin="100 10 0 0" Cursor="Hand" Height="40" FontSize="12" ToolTip="Open Comparison Wizard" Command="{Binding OpenComparisonWizardCommand}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Width="24" Height="24" Kind="Compare"/>
<TextBlock Margin="10 0 0 0" VerticalAlignment="Center" FontSize="16">Comparison Wizard</TextBlock>
</StackPanel>
</Button>
+
+ <Button Margin="10 10 0 0" Cursor="Hand" MinWidth="150" Height="40" FontSize="12" ToolTip="Import hardware version to file" Command="{Binding ImportHardwareVersionCommand}">
+ <StackPanel Orientation="Horizontal">
+ <materialDesign:PackIcon Width="24" Height="24" Kind="FileImport"/>
+ <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" FontSize="16">IMPORT</TextBlock>
+ </StackPanel>
+ </Button>
+
+ <Button Margin="10 10 0 0" Cursor="Hand" MinWidth="150" Height="40" FontSize="12" ToolTip="Export hardware version to file" Command="{Binding ExportHardwareVersionCommand}">
+ <StackPanel Orientation="Horizontal">
+ <materialDesign:PackIcon Width="24" Height="24" Kind="FileExport"/>
+ <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" FontSize="16">EXPORT</TextBlock>
+ </StackPanel>
+ </Button>
</StackPanel>
</Grid>