diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer')
9 files changed, 266 insertions, 7 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/sewing-machine.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/sewing-machine.png Binary files differnew file mode 100644 index 000000000..3d2864fc3 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/sewing-machine.png diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index 8c9f297a3..7bf4d22cd 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -120,7 +120,11 @@ <Compile Include="Navigation\DeveloperNavigationManager.cs" /> <Compile Include="Navigation\DeveloperNavigationView.cs" /> <Compile Include="ViewModelLocator.cs" /> + <Compile Include="ViewModels\EmbroideryImportViewVM.cs" /> <Compile Include="ViewModels\MainViewVM.cs" /> + <Compile Include="Views\EmbroideryImportView.xaml.cs"> + <DependentUpon>EmbroideryImportView.xaml</DependentUpon> + </Compile> <Compile Include="Views\MainView.xaml.cs"> <DependentUpon>MainView.xaml</DependentUpon> </Compile> @@ -137,6 +141,10 @@ <Compile Include="Views\RunningJobView.xaml.cs"> <DependentUpon>RunningJobView.xaml</DependentUpon> </Compile> + <Page Include="Views\EmbroideryImportView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Views\MainView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -180,6 +188,10 @@ </None> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\..\Embroidery\Tango.EmbroideryUI\Tango.EmbroideryUI.csproj"> + <Project>{bdbbe284-f564-4f51-af41-3df0434cec62}</Project> + <Name>Tango.EmbroideryUI</Name> + </ProjectReference> <ProjectReference Include="..\..\..\SideChains\ColorMine\ColorMine.csproj"> <Project>{37e4ceab-b54b-451f-b535-04cf7da9c459}</Project> <Name>ColorMine</Name> @@ -192,6 +204,10 @@ <Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project> <Name>Tango.BL</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.BrushPicker\Tango.BrushPicker.csproj"> + <Project>{40085232-aced-4cbe-945b-90ba8153c151}</Project> + <Name>Tango.BrushPicker</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Tango.ColorPicker\Tango.ColorPicker.csproj"> <Project>{a2f5af44-29ff-45d6-9d25-ecda5cce88b5}</Project> <Name>Tango.ColorPicker</Name> @@ -317,5 +333,8 @@ <ItemGroup> <Resource Include="Images\thread.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\sewing-machine.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/EmbroideryImportViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/EmbroideryImportViewVM.cs new file mode 100644 index 000000000..a0f4314dc --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/EmbroideryImportViewVM.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.EmbroideryUI; +using Tango.MachineStudio.Common.Notifications; +using Tango.PMR.Embroidery; + +namespace Tango.MachineStudio.Developer.ViewModels +{ + public class EmbroideryImportViewVM : DialogViewVM + { + private String _fileName; + + public String FileName + { + get { return _fileName; } + set { _fileName = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand ImportCommand { get; set; } + + public EmbroideryFile EmbroideryFile { get; set; } + + public ObservableCollection<EmbroideryPath> Paths { get; set; } + + public EmbroideryImportViewVM() : base() + { + ImportCommand = new RelayCommand(Import); + } + + private void Import() + { + Accept(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 31c20eda4..c265c7d25 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -25,6 +25,9 @@ using Tango.Settings; using Tango.SharedUI; using Tango.Transport; using Tango.BL; +using Microsoft.Win32; +using Tango.PMR.Embroidery; +using Tango.EmbroideryUI; namespace Tango.MachineStudio.Developer.ViewModels { @@ -35,6 +38,7 @@ namespace Tango.MachineStudio.Developer.ViewModels public class MainViewVM : ViewModel<IMainView>, IShutdownRequestBlocker, IShutdownListener { private static object _syncLock = new object(); + private const string EMB_FORMATS = "Embroidery Files|*.pes;*.hus"; private INotificationProvider _notification; private TimeSpan _runningJobEstimatedDuration; @@ -568,6 +572,11 @@ namespace Tango.MachineStudio.Developer.ViewModels /// </summary> public RelayCommand PushProcessParametersCommand { get; set; } + /// <summary> + /// Gets or sets the import embroidery file command. + /// </summary> + public RelayCommand ImportEmbroideryFileCommand { get; set; } + #endregion #region Constructors @@ -638,6 +647,7 @@ namespace Tango.MachineStudio.Developer.ViewModels DuplicateBrushStopCommand = new RelayCommand(DuplicateSelectedBrushStops, () => SelectedBrushStop != null); SaveProcessParametersCommand = new RelayCommand(SaveProcessParameters, () => SelectedRML != null && SelectedRML.ProcessParametersTablesGroups.Count > 0); PushProcessParametersCommand = new RelayCommand(PushProcessParameters, () => SelectedRML != null && SelectedRML.ProcessParametersTablesGroups.Count > 0 && SelectedProcessParametersTable != null && MachineOperator != null); + ImportEmbroideryFileCommand = new RelayCommand(ImportEmbroideryFile, () => SelectedMachine != null); ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; } @@ -1438,7 +1448,7 @@ namespace Tango.MachineStudio.Developer.ViewModels Job newJob = new Job(); newJob.Name = jobName; newJob.CreationDate = DateTime.UtcNow; - newJob.User = _authentication.CurrentUser; + newJob.UserGuid = _authentication.CurrentUser.Guid; newJob.Rml = _machineDbContext.Rmls.FirstOrDefault(); newJob.WindingMethod = _machineDbContext.WindingMethods.FirstOrDefault(); newJob.SpoolType = _machineDbContext.SpoolTypes.FirstOrDefault(); @@ -1569,6 +1579,99 @@ namespace Tango.MachineStudio.Developer.ViewModels #endregion + #region Embroidery + + /// <summary> + /// Imports embroidery file. + /// </summary> + private void ImportEmbroideryFile() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Select embroidery file"; + dlg.Filter = EMB_FORMATS; + if (dlg.ShowDialog().Value) + { + _notification.ShowModalDialog<EmbroideryImportViewVM, EmbroideryImportView>( + new EmbroideryImportViewVM() { FileName = dlg.FileName }, + (vm) => + { + String jobName = _notification.ShowTextInput("Please provide a job name", "Name"); + + if (jobName != null) + { + AddJobFromEmbroideryFile(jobName, vm.Paths.ToList(), vm.EmbroideryFile); + } + }, + () => + { + + }); + } + } + + private async void AddJobFromEmbroideryFile(String jobName, List<EmbroideryPath> paths, EmbroideryFile embroideryFile) + { + LogManager.Log(String.Format("Adding new job from embroidery file {0}...", jobName)); + + Job job = new Job(); + job.Name = jobName; + job.Name = jobName; + job.CreationDate = DateTime.UtcNow; + job.UserGuid = _authentication.CurrentUser.Guid; + job.Rml = _machineDbContext.Rmls.FirstOrDefault(); + job.WindingMethod = _machineDbContext.WindingMethods.FirstOrDefault(); + job.SpoolType = _machineDbContext.SpoolTypes.FirstOrDefault(); + job.Machine = SelectedMachine; + + foreach (var path in paths.Skip(1)) + { + Segment segment = new Segment(); + segment.Length = path.Length / 1000d; + segment.Name = "Embroidery Segment"; + segment.SegmentIndex = paths.IndexOf(path) + 1; + + if (path.Brush is SolidColorBrush) + { + var brush = (path.Brush as SolidColorBrush); + + segment.BrushStops.Add(new BrushStop() + { + Red = brush.Color.R, + Green = brush.Color.G, + Blue = brush.Color.B, + ColorSpace = _machineDbContext.ColorSpaces.ToList().SingleOrDefault(x => x.Code == BL.Entities.ColorSpaces.RGB.ToInt32()), + }); + } + else + { + var brush = (path.Brush as LinearGradientBrush); + + foreach (var stop in brush.GradientStops) + { + segment.BrushStops.Add(new BrushStop() + { + StopIndex = brush.GradientStops.IndexOf(stop), + Red = stop.Color.R, + Green = stop.Color.G, + Blue = stop.Color.B, + OffsetPercent = stop.Offset, + ColorSpace = _machineDbContext.ColorSpaces.ToList().SingleOrDefault(x => x.Code == BL.Entities.ColorSpaces.RGB.ToInt32()), + }); + } + } + + job.Segments.Add(segment); + } + + SelectedMachine.Jobs.Add(job); + LogManager.Log("Saving selected machine to database..."); + await SelectedMachine.SaveAsync(_machineDbContext); + SelectedMachineJob = job; + LoadSelectedJob(); + } + + #endregion + #region Override Methods protected override void RaisePropertyChangedAuto([CallerMemberName] string caller = null) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml new file mode 100644 index 000000000..220e7d3ab --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml @@ -0,0 +1,59 @@ +<UserControl x:Class="Tango.MachineStudio.Developer.Views.EmbroideryImportView" + 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:emb="clr-namespace:Tango.EmbroideryUI;assembly=Tango.EmbroideryUI" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:vm="clr-namespace:Tango.MachineStudio.Developer.ViewModels" + xmlns:brushPicker="clr-namespace:Tango.BrushPicker;assembly=Tango.BrushPicker" + xmlns:local="clr-namespace:Tango.MachineStudio.Developer.Views" + mc:Ignorable="d" + Height="720" Width="1280" Background="White" d:DataContext="{d:DesignInstance Type=vm:EmbroideryImportViewVM, IsDesignTimeCreatable=False}"> + <Grid> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="250"/> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="60"/> + <RowDefinition Height="593*"/> + <RowDefinition Height="60"/> + </Grid.RowDefinitions> + + <Grid> + <StackPanel Orientation="Horizontal"> + <Image Source="../Images/sewing-machine.png" Width="48"></Image> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" FontSize="20">Import Embroidery File</TextBlock> + </StackPanel> + </Grid> + + <Grid Grid.ColumnSpan="2"> + <Rectangle VerticalAlignment="Bottom" Stroke="Silver"></Rectangle> + </Grid> + + <Grid Grid.Row="1"> + <emb:EmbroideryFileEditor x:Name="editor" Background="White" FileName="{Binding FileName}" EmbroideryFile="{Binding EmbroideryFile,Mode=OneWayToSource}" Paths="{Binding Paths,Mode=OneWayToSource}" /> + </Grid> + + <Grid Grid.Column="1" Grid.Row="1"> + <StackPanel> + <TextBlock Margin="5">Region Brush</TextBlock> + <brushPicker:BrushPicker Margin="0 10 0 0" Background="White" BorderThickness="0" Brush="{Binding ElementName=editor,Path=SelectedPath.Brush,Mode=TwoWay}" /> + </StackPanel> + + <Rectangle HorizontalAlignment="Left" Stroke="Silver" /> + </Grid> + + <Grid Grid.Row="2" Grid.Column="1"> + <Button Height="50" Command="{Binding ImportCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="Import" Width="24" Height="24" /> + <TextBlock Margin="5 0 0 0" FontSize="16">IMPORT</TextBlock> + </StackPanel> + </Button> + </Grid> + </Grid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml.cs new file mode 100644 index 000000000..c34b6fef7 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.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.Developer.Views +{ + /// <summary> + /// Interaction logic for EmbroideryImportDialog.xaml + /// </summary> + public partial class EmbroideryImportView : UserControl + { + public EmbroideryImportView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml index 49444750f..9ba41f688 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml @@ -377,7 +377,7 @@ <ComboBox.ToolTip> <TextBlock> <Run Text="{Binding ActiveJob.SpoolType.Name}"></Run> - <Run FontSize="9" Foreground="#D9D9D9" Text="{Binding ActiveJob.SpoolType.Length}"></Run> + <Run FontSize="9" Foreground="#D9D9D9" Text="{Binding ActiveJob.SpoolType.Length,Mode=OneWay}"></Run> <Run FontSize="9" Foreground="#DEDEDE" Text="m"></Run> </TextBlock> </ComboBox.ToolTip> @@ -385,7 +385,7 @@ <DataTemplate> <TextBlock TextTrimming="CharacterEllipsis"> <Run Text="{Binding Name}"></Run> - <Run FontSize="9" Foreground="Gray" Text="{Binding Length}"></Run> + <Run FontSize="9" Foreground="Gray" Text="{Binding Length,Mode=OneWay}"></Run> <Run FontSize="9" Foreground="Gray" Text="m"></Run> </TextBlock> </DataTemplate> @@ -1102,7 +1102,7 @@ <StackPanel Margin="0 0 0 0" HorizontalAlignment="Center"> <TextBlock FontSize="12" HorizontalAlignment="Right" Foreground="Black"> - <Run Text="{Binding Length,Mode=OneWay}"></Run> + <Run Text="{Binding Length,Mode=OneWay,StringFormat=N2}"></Run> <Run Foreground="Gray" FontSize="10" Text="m"></Run> </TextBlock> <materialDesign:PackIcon HorizontalAlignment="Center" RenderTransformOrigin="0.5,0.5" Kind="Triangle" Width="8" Height="8" Foreground="DimGray"> @@ -1128,7 +1128,7 @@ <StackPanel Margin="0 -5 -20 0" HorizontalAlignment="Right"> <TextBlock FontSize="12" Foreground="Black"> - <Run Text="{Binding ActiveJob.Length,Mode=OneWay}"></Run> + <Run Text="{Binding ActiveJob.Length,Mode=OneWay,StringFormat=N2}"></Run> <Run Foreground="Gray" FontSize="10" Text="m"></Run> </TextBlock> <materialDesign:PackIcon HorizontalAlignment="Right" RenderTransformOrigin="0.5,0.5" Kind="FlagCheckered" Width="16" Height="16" Foreground="DimGray"> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs index b2ca55217..905caa96d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs @@ -18,6 +18,7 @@ using Tango.DragAndDrop; using Tango.BL.Entities; using Tango.MachineStudio.Developer.Converters; using Tango.MachineStudio.Developer.ViewModels; +using Tango.BL; namespace Tango.MachineStudio.Developer.Views { @@ -72,6 +73,7 @@ namespace Tango.MachineStudio.Developer.Views { new BrushStop() { + ColorSpace = new ColorSpace(), Color = Colors.White, } }, diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml index 49735d345..2115f2503 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml @@ -88,6 +88,7 @@ </Grid> <Grid DockPanel.Dock="Bottom" Margin="0 20 0 0"> + <StackPanel VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Left" Margin="20 0 0 0"> <Button Margin="0 0 10 0" MinWidth="160" Height="50" Background="#FF7575" BorderBrush="#FF7575" Command="{Binding RemoveJobCommand}"> <StackPanel Orientation="Horizontal"> @@ -174,7 +175,7 @@ <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock VerticalAlignment="Center" FontSize="14"> - <Run Text="{Binding Length,Mode=OneWay}"></Run> + <Run Text="{Binding Length,Mode=OneWay,StringFormat=N2}"></Run> <Run Text="m" Foreground="Gray"></Run> </TextBlock> </DataTemplate> @@ -197,7 +198,7 @@ <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" MaxWidth="110"> - + </StackPanel> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> @@ -235,6 +236,13 @@ </controls:MultiSelectDataGrid> </Grid> </DockPanel> + + <Button Command="{Binding ImportEmbroideryFileCommand}" Margin="20 0 0 -100" Foreground="Black" FontSize="16" VerticalAlignment="Bottom" HorizontalAlignment="Left" Style="{StaticResource emptyButton}" Cursor="Hand"> + <StackPanel Orientation="Horizontal"> + <Image Source="../Images/sewing-machine.png" Width="32"></Image> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" TextDecorations="Underline">Import Embroidery File</TextBlock> + </StackPanel> + </Button> </Grid> </Grid> </Grid> |
