diff options
| author | Roy <roy.mail.net@gmail.com> | 2018-03-04 02:26:30 +0200 |
|---|---|---|
| committer | Roy <roy.mail.net@gmail.com> | 2018-03-04 02:26:30 +0200 |
| commit | 485f8da4b55ae19f0a21792314ae2b096d48dab4 (patch) | |
| tree | 5a7402d91175f409330c052980c596a77e813d7a /Software | |
| parent | 9dedf143c3ac44ca593e735861f4e1e2e6f947c9 (diff) | |
| download | Tango-485f8da4b55ae19f0a21792314ae2b096d48dab4.tar.gz Tango-485f8da4b55ae19f0a21792314ae2b096d48dab4.zip | |
Implemented Embroidery Editor.
Implemented Create job from embroidery file.
Diffstat (limited to 'Software')
17 files changed, 377 insertions, 20 deletions
diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf Binary files differindex 0f07ef035..fbab29fff 100644 --- a/Software/DB/Tango.mdf +++ b/Software/DB/Tango.mdf diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf Binary files differindex b7f348c1f..67cbad44d 100644 --- a/Software/DB/Tango_log.ldf +++ b/Software/DB/Tango_log.ldf diff --git a/Software/Graphics/sewing-machine.png b/Software/Graphics/sewing-machine.png Binary files differnew file mode 100644 index 000000000..3d2864fc3 --- /dev/null +++ b/Software/Graphics/sewing-machine.png diff --git a/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryFileEditor.xaml.cs b/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryFileEditor.xaml.cs index f8ae8faa1..9d7475aea 100644 --- a/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryFileEditor.xaml.cs +++ b/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryFileEditor.xaml.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Text; @@ -43,7 +44,7 @@ namespace Tango.EmbroideryUI public EmbroideryFile EmbroideryFile { get { return (EmbroideryFile)GetValue(EmbroideryFileProperty); } - private set { SetValue(EmbroideryFileProperty, value); } + set { SetValue(EmbroideryFileProperty, value); } } public static readonly DependencyProperty EmbroideryFileProperty = DependencyProperty.Register("EmbroideryFile", typeof(EmbroideryFile), typeof(EmbroideryFileEditor), new PropertyMetadata(null)); @@ -54,7 +55,7 @@ namespace Tango.EmbroideryUI set { SetValue(FileNameProperty, value); } } public static readonly DependencyProperty FileNameProperty = - DependencyProperty.Register("FileName", typeof(String), typeof(EmbroideryFileEditor), new PropertyMetadata(null,(d,e) => (d as EmbroideryFileEditor).OnFileNameChanged())); + DependencyProperty.Register("FileName", typeof(String), typeof(EmbroideryFileEditor), new PropertyMetadata(null, (d, e) => (d as EmbroideryFileEditor).OnFileNameChanged())); public double ScaleFactor { @@ -62,7 +63,7 @@ namespace Tango.EmbroideryUI set { SetValue(ScaleFactorProperty, value); } } public static readonly DependencyProperty ScaleFactorProperty = - DependencyProperty.Register("ScaleFactor", typeof(double), typeof(EmbroideryFileEditor), new PropertyMetadata(1.0,(d,e) => (d as EmbroideryFileEditor).OnScaleFactorChanged())); + DependencyProperty.Register("ScaleFactor", typeof(double), typeof(EmbroideryFileEditor), new PropertyMetadata(1.0, (d, e) => (d as EmbroideryFileEditor).OnScaleFactorChanged())); public EmbroideryPath SelectedPath { @@ -89,6 +90,8 @@ namespace Tango.EmbroideryUI protected virtual void OnFileNameChanged() { + if (!File.Exists(FileName)) return; + AnalyzeInput input = new AnalyzeInput(); input.FilePath = FileName; @@ -180,12 +183,18 @@ namespace Tango.EmbroideryUI Point _currentPoint = new Point(); Point _lastPoint = new Point(); + Stitch _lastStitch = new Stitch(); StitchFlag _mode = StitchFlag.Jump; + if (Paths == null) + { + Paths = new ObservableCollection<EmbroideryPath>(); + } + Paths.Clear(); Color color = ConvertStitchColorToColor(EmbroideryFile.Colors[0]); - PathFigure path = CreatePathFigure(color, _currentPoint); + var path = CreatePathFigure(color, _currentPoint); foreach (var stitch in EmbroideryFile.Stitches) { @@ -204,12 +213,15 @@ namespace Tango.EmbroideryUI if (_mode == StitchFlag.Normal) { - path.Segments.Add(new LineSegment(new Point(_currentPoint.X, _currentPoint.Y), true)); + path.PathFigure.Segments.Add(new LineSegment(new Point(_currentPoint.X, _currentPoint.Y), true)); + path.Length += Math.Abs(GetDistance(_lastStitch.XX, _lastStitch.YY, stitch.XX, stitch.YY)); } _mode = StitchFlag.Normal; break; } + + _lastStitch = stitch; _lastPoint = _currentPoint; } } @@ -219,7 +231,7 @@ namespace Tango.EmbroideryUI return Color.FromRgb((byte)stitchColor.Red, (byte)stitchColor.Green, (byte)stitchColor.Blue); } - private PathFigure CreatePathFigure(Color color, Point startPoint) + private EmbroideryPath CreatePathFigure(Color color, Point startPoint) { PathFigure figure = new PathFigure(); figure.StartPoint = startPoint; @@ -227,10 +239,16 @@ namespace Tango.EmbroideryUI EmbroideryPath path = new EmbroideryPath(new PathGeometry(new PathFigureCollection() { figure })); + path.PathFigure = figure; path.StrokeThickness = 1; path.Brush = new SolidColorBrush(color); Paths.Add(path); - return figure; + return path; + } + + private static double GetDistance(double x1, double y1, double x2, double y2) + { + return Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2)); } #endregion diff --git a/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryPath.cs b/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryPath.cs index a45c2a344..385266228 100644 --- a/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryPath.cs +++ b/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryPath.cs @@ -21,6 +21,24 @@ namespace Tango.EmbroideryUI public static readonly DependencyProperty BrushProperty = DependencyProperty.Register("Brush", typeof(Brush), typeof(EmbroideryPath), new PropertyMetadata(null,(d,e) => (d as EmbroideryPath).OnBrushChanged())); + public double Length + { + get { return (double)GetValue(LengthProperty); } + set { SetValue(LengthProperty, value); } + } + public static readonly DependencyProperty LengthProperty = + DependencyProperty.Register("Length", typeof(double), typeof(EmbroideryPath), new PropertyMetadata(0.0)); + + public PathFigure PathFigure + { + get { return (PathFigure)GetValue(PathFigureProperty); } + set { SetValue(PathFigureProperty, value); } + } + public static readonly DependencyProperty PathFigureProperty = + DependencyProperty.Register("PathFigure", typeof(PathFigure), typeof(EmbroideryPath), new PropertyMetadata(null)); + + + private void OnBrushChanged() { Stroke = Brush; @@ -38,7 +56,7 @@ namespace Tango.EmbroideryUI { if (IsSelected) { - Stroke = Brushes.White; + Stroke = Brushes.Black; } else { 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> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs index e1b6275bd..79bcc9bf9 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs @@ -92,6 +92,16 @@ namespace Tango.MachineStudio.Common.Notifications void ShowModalDialog<VM>(Action<VM> onAccept, Action onCancel) where VM : DialogViewVM; /// <summary> + /// Shows the specified view with the specified view model as it's data context. + /// </summary> + /// <typeparam name="VM">The type of the mm.</typeparam> + /// <typeparam name="View">The type of the view.</typeparam> + /// <param name="vm">The view model.</param> + /// <param name="onAccept">The accept action.</param> + /// <param name="onCancel">The cancel action.</param> + void ShowModalDialog<VM, View>(VM vm, Action<VM> onAccept, Action onCancel) where View : FrameworkElement where VM : DialogViewVM; + + /// <summary> /// Creates a new view by a naming convention of the specified view model type. /// </summary> /// <typeparam name="VM">The type of the view model.</typeparam> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs index 4dd17b500..a07c0ef13 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs @@ -142,6 +142,57 @@ namespace Tango.MachineStudio.UI.Notifications } /// <summary> + /// Shows the specified view with the specified view model as it's data context. + /// </summary> + /// <typeparam name="VM">The type of the mm.</typeparam> + /// <typeparam name="View">The type of the view.</typeparam> + /// <param name="vm">The view model.</param> + /// <param name="view">The view.</param> + /// <param name="onAccept">The accept action.</param> + /// <param name="onCancel">The cancel action.</param> + public void ShowModalDialog<VM, View>(VM vm, Action<VM> onAccept, Action onCancel) where View : FrameworkElement where VM : DialogViewVM + { + var view = Activator.CreateInstance<View>(); + DialogWindow dialog = new DialogWindow(); + dialog.Owner = Application.Current.MainWindow; + dialog.InnerContent = view; + MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; + view.Loaded += (x, y) => + { + VM context = vm; + dialog.DataContext = context; + + Action onAcceptAction = null; + onAcceptAction = new Action(() => + { + dialog.Close(); + onAccept(context); + context.Accepted -= onAcceptAction; + }); + + Action onCancelAction = null; + onCancelAction = new Action(() => + { + dialog.Close(); + + if (onCancel != null) + { + onCancel(); + } + + context.Canceled -= onCancelAction; + }); + + context.Accepted += onAcceptAction; + context.Canceled += onCancelAction; + + context.OnShow(); + }; + dialog.ShowDialog(); + MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; + } + + /// <summary> /// Creates a new view by a naming convention of the specified view model type. /// </summary> /// <typeparam name="VM">The type of the view model.</typeparam> diff --git a/Software/Visual_Studio/Tango.BL/ObservablesExtensions/BrushStop.cs b/Software/Visual_Studio/Tango.BL/ObservablesExtensions/BrushStop.cs index 0f65f32d5..deeb9a68d 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesExtensions/BrushStop.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesExtensions/BrushStop.cs @@ -55,11 +55,6 @@ namespace Tango.BL.Entities switch ((ColorSpaces)ColorSpace.Code) { - case ColorSpaces.RGB: - _red = (byte)rgb.R; - _green = (byte)rgb.G; - _blue = (byte)rgb.B; - break; case ColorSpaces.CMYK: Cmyk cmyk = rgb.To<Cmyk>(); _cyan = cmyk.C; @@ -73,6 +68,12 @@ namespace Tango.BL.Entities _a = lab.A; _b = lab.B; break; + case ColorSpaces.RGB: + default: + _red = (byte)rgb.R; + _green = (byte)rgb.G; + _blue = (byte)rgb.B; + break; } RaisePropertyChanged(nameof(Color)); |
