diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-12-31 15:59:02 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-12-31 15:59:02 +0200 |
| commit | e86fb1e3f847ee5646fe40b52bcf478bc9ce4b64 (patch) | |
| tree | 8faab087dbc6e13d5c83960ff344a77825dc21b7 /Software/Visual_Studio | |
| parent | 650af0554b902837f8e146d690aca24e4f60ec29 (diff) | |
| download | Tango-e86fb1e3f847ee5646fe40b52bcf478bc9ce4b64.tar.gz Tango-e86fb1e3f847ee5646fe40b52bcf478bc9ce4b64.zip | |
Added Trigger for machine delete to erase configuration & IDS Packs also!
Implemented Machine creation dialog in machine designer.
Diffstat (limited to 'Software/Visual_Studio')
8 files changed, 130 insertions, 33 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj index 6857df3c7..1cb95a076 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj @@ -78,8 +78,12 @@ <Compile Include="AutoComplete\MachineVersionsProvider.cs" /> <Compile Include="Contracts\IMainView.cs" /> <Compile Include="ViewModelLocator.cs" /> + <Compile Include="ViewModels\MachineCreationDialogVM.cs" /> <Compile Include="ViewModels\MachineVersionDialogVM.cs" /> <Compile Include="ViewModels\MainViewVM.cs" /> + <Compile Include="Views\MachineCreationDialog.xaml.cs"> + <DependentUpon>MachineCreationDialog.xaml</DependentUpon> + </Compile> <Compile Include="Views\MachineDetailsView.xaml.cs"> <DependentUpon>MachineDetailsView.xaml</DependentUpon> </Compile> @@ -105,6 +109,10 @@ <Compile Include="Views\SpoolsView.xaml.cs"> <DependentUpon>SpoolsView.xaml</DependentUpon> </Compile> + <Page Include="Views\MachineCreationDialog.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Views\MachineDetailsView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineCreationDialogVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineCreationDialogVM.cs new file mode 100644 index 000000000..0f6ab3314 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineCreationDialogVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.SharedUI; + +namespace Tango.MachineStudio.MachineDesigner.ViewModels +{ + public class MachineCreationDialogVM : DialogViewVM + { + public List<MachineVersion> MachineVersions { get; set; } + + public MachineVersion SelectedMachineVersion { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs index 2f77b0d14..33e5b4ad7 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs @@ -192,9 +192,9 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels #region Application Ready - public override void OnApplicationReady() + public override async void OnApplicationReady() { - + MachinesAdapter.MachineVersions = (await MachinesAdapter.Context.MachineVersions.ToListAsync()).ToObservableCollection(); } #endregion @@ -349,7 +349,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels InvalidateRelayCommands(); } - private async void LoadSelectedMachine(bool newMachine = false, bool clone = false) + private async void LoadSelectedMachine(bool newMachine = false, bool clone = false, MachineVersion selectedVersion = null) { using (_notification.PushTaskItem("Loading machine details...")) { @@ -389,16 +389,24 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels if (clone) { ActiveMachine = ActiveMachine.Clone(); - ActiveMachine.Name = "Untitled"; + ActiveMachine.Name = ""; ActiveMachine.SerialNumber = ""; ActiveMachineAdapter.Context.Machines.Add(ActiveMachine); } } else { - ActiveMachine = new Machine(); - ActiveMachine.Configuration = new Configuration(); - ActiveMachineAdapter.Context.Machines.Add(ActiveMachine); + if (selectedVersion == null) + { + ActiveMachine = new Machine(); + ActiveMachine.Configuration = new Configuration(); + ActiveMachineAdapter.Context.Machines.Add(ActiveMachine); + } + else + { + ActiveMachine = selectedVersion.CreatePrototypeMachine(ActiveMachineAdapter.Context); + ActiveMachineAdapter.Context.Machines.Add(ActiveMachine); + } } View.NavigateTo(MachineDesignerNavigationView.MachineDetailsView); @@ -563,7 +571,18 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels private void AddNewMachine() { - LoadSelectedMachine(true); + MachineCreationDialogVM vm = new MachineCreationDialogVM(); + vm.MachineVersions = MachinesAdapter.MachineVersions.ToList(); + _notification.ShowModalDialog<MachineCreationDialogVM, Views.MachineCreationDialog>(vm, (x) => + { + if (String.IsNullOrWhiteSpace(vm.SelectedMachineVersion.PrototypeMachineData)) + { + _notification.ShowError("The selected version does not contain any prototype machine data."); + return; + } + + LoadSelectedMachine(true, false, vm.SelectedMachineVersion); + }, () => { }); } private async void RemoveSelectedMachine() diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml new file mode 100644 index 000000000..e3ba1bff4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml @@ -0,0 +1,46 @@ +<UserControl x:Class="Tango.MachineStudio.MachineDesigner.Views.MachineCreationDialog" + 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:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:vm="clr-namespace:Tango.MachineStudio.MachineDesigner.ViewModels" + xmlns:local="clr-namespace:Tango.MachineStudio.MachineDesigner.Views" + mc:Ignorable="d" + d:DesignHeight="400" d:DesignWidth="700" Height="400" Width="700" Background="White" d:DataContext="{d:DesignInstance Type=vm:MachineCreationDialogVM, IsDesignTimeCreatable=False}"> + <Grid Margin="10"> + <DockPanel> + <Grid DockPanel.Dock="Top"> + <StackPanel Orientation="Horizontal"> + <Grid> + <Image Source="../Images/machine-full-fx.png" Width="120" RenderOptions.BitmapScalingMode="Fant"></Image> + <materialDesign:PackIcon HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0 0 -10 -10" Kind="PlusCircle" Foreground="#15C315" Width="42" Height="42" /> + </Grid> + <TextBlock Margin="30 0 0 0" VerticalAlignment="Bottom" FontSize="22">NEW MACHINE</TextBlock> + </StackPanel> + </Grid> + + <Grid DockPanel.Dock="Bottom"> + <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right" DockPanel.Dock="Bottom"> + <Button Command="{Binding CloseCommand}" Width="140" Height="40" Margin="0 0 10 0"> + CANCEL + </Button> + <Button Command="{Binding OKCommand}" IsDefault="True" Width="140" Height="40"> + CREATE + </Button> + </StackPanel> + </Grid> + + <Grid> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="400"> + <TextBlock TextWrapping="Wrap" TextAlignment="Center"> + <Run>Please specify the machine version in order to prototype the new machine with default machine settings and configuartion.</Run> + </TextBlock> + + <ComboBox ItemsSource="{Binding MachineVersions}" SelectedItem="{Binding SelectedMachineVersion}" DisplayMemberPath="Name" Margin="0 10 0 0" FontSize="16" materialDesign:HintAssist.Hint="NONE"></ComboBox> + </StackPanel> + </Grid> + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml.cs new file mode 100644 index 000000000..3901309a9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.MachineDesigner.Views +{ + /// <summary> + /// Interaction logic for MachineCreationDialog.xaml + /// </summary> + public partial class MachineCreationDialog : UserControl + { + public MachineCreationDialog() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs index 2192483c9..46bf63194 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs @@ -226,7 +226,7 @@ namespace Tango.MachineStudio.UI.TFS sysModel.Machine = machine; sysModel.EmbeddedVersion = app.ConnectedMachine.DeviceInformation.Version; - sysModel.ConfigurationString = machine.Configuration.Clone().ToJsonString(nameof(Configuration.MachineVersions)); + sysModel.ConfigurationString = machine.Configuration.Clone().ToJsonString(); if (app.ConnectedMachine.CurrentProcessParameters != null) { diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/MachineVersion.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/MachineVersion.cs index 2b8d99652..1cd43dcf1 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/MachineVersion.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/MachineVersion.cs @@ -23,7 +23,7 @@ namespace Tango.BL.Entities PrototypeMachineData = machine.ToJson(); } - public async Task<Machine> CreatePrototypeMachine(ObservablesContext context) + public Machine CreatePrototypeMachine(ObservablesContext context) { Machine machine = Machine.FromJson(PrototypeMachineData); machine.OrganizationGuid = null; @@ -32,42 +32,21 @@ namespace Tango.BL.Entities foreach (var cat in machine.Cats) { - cat.LiquidType = await context.LiquidTypes.SingleOrDefaultAsync(x => x.Guid == cat.LiquidTypeGuid); cat.MachineGuid = machine.Guid; - cat.Machine = machine; - cat.Rml = await context.Rmls.SingleOrDefaultAsync(x => x.Guid == cat.RmlGuid); } - machine.DefaultColorSpace = await context.ColorSpaces.SingleOrDefaultAsync(x => x.Guid == machine.Guid); - machine.ConfigurationGuid = machine.Configuration.Guid; - machine.MachineVersion = this; - machine.MachineVersionGuid = this.Guid; + machine.MachineVersionGuid = Guid; machine.ProductionDate = DateTime.UtcNow; - machine.Configuration.ApplicationDisplayPanelVersion = await context.ApplicationDisplayPanelVersions.SingleOrDefaultAsync(x => x.Guid == machine.Configuration.ApplicationDisplayPanelVersionGuid); - machine.Configuration.ApplicationFirmwareVersion = await context.ApplicationFirmwareVersions.SingleOrDefaultAsync(x => x.Guid == machine.Configuration.ApplicationFirmwareVersionGuid); - machine.Configuration.ApplicationOsVersion = await context.ApplicationOsVersions.SingleOrDefaultAsync(x => x.Guid == machine.Configuration.ApplicationOsVersionGuid); - machine.Configuration.EmbeddedFirmwareVersion = await context.EmbeddedFirmwareVersions.SingleOrDefaultAsync(x => x.Guid == machine.Configuration.EmbeddedFirmwareVersionGuid); - machine.Configuration.HardwareVersion = await context.HardwareVersions.SingleOrDefaultAsync(x => x.Guid == machine.Configuration.HardwareVersionGuid); - foreach (var idsPack in machine.Configuration.IdsPacks) { - idsPack.CartridgeType = await context.CartridgeTypes.SingleOrDefaultAsync(x => x.Guid == idsPack.CartridgeTypeGuid); - idsPack.CartridgeType = await context.CartridgeTypes.SingleOrDefaultAsync(x => x.Guid == idsPack.CartridgeTypeGuid); - idsPack.LiquidType = await context.LiquidTypes.SingleOrDefaultAsync(x => x.Guid == idsPack.LiquidTypeGuid); - idsPack.IdsPackFormula = await context.IdsPackFormulas.SingleOrDefaultAsync(x => x.Guid == idsPack.IdsPackFormulaGuid); - idsPack.MidTankType = await context.MidTankTypes.SingleOrDefaultAsync(x => x.Guid == idsPack.MidTankTypeGuid); - idsPack.DispenserGuid = null; - idsPack.Configuration = machine.Configuration; idsPack.ConfigurationGuid = machine.ConfigurationGuid; } foreach (var spool in machine.Spools) { - spool.Machine = machine; spool.MachineGuid = machine.Guid; - spool.SpoolType = await context.SpoolTypes.SingleOrDefaultAsync(x => x.Guid == spool.SpoolTypeGuid); } return machine; diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs index 673136df9..0b06438b1 100644 --- a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs +++ b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs @@ -45,7 +45,7 @@ namespace Tango.UITests MachineVersion version = db.MachineVersions.First(); await version.ApplyPrototypeMachine(machine, db); - Machine m = await version.CreatePrototypeMachine(db); + Machine m = version.CreatePrototypeMachine(db); } } |
