aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/EmbroideryDisplayViewVM.cs38
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs98
2 files changed, 124 insertions, 12 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/EmbroideryDisplayViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/EmbroideryDisplayViewVM.cs
new file mode 100644
index 000000000..74cb2ffa6
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/EmbroideryDisplayViewVM.cs
@@ -0,0 +1,38 @@
+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.MachineStudio.Common.Notifications;
+using Tango.SharedUI;
+
+namespace Tango.MachineStudio.Developer.ViewModels
+{
+ public class EmbroideryDisplayViewVM : DialogViewVM
+ {
+ private Job _job;
+
+ public Job Job
+ {
+ get { return _job; }
+ set { _job = value; RaisePropertyChangedAuto(); }
+ }
+
+ public RelayCommand ExportCommand { get; set; }
+
+ public EmbroideryDisplayViewVM()
+ {
+ ExportCommand = new RelayCommand(() =>
+ {
+ Accept();
+ });
+ }
+
+ public EmbroideryDisplayViewVM(Job job) : this()
+ {
+ Job = job;
+ }
+ }
+}
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 c265c7d25..76fe33a87 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
@@ -28,6 +28,11 @@ using Tango.BL;
using Microsoft.Win32;
using Tango.PMR.Embroidery;
using Tango.EmbroideryUI;
+using System.IO;
+using System.Windows;
+using Tango.Core.Helpers;
+using System.Speech.Synthesis;
+using System.Media;
namespace Tango.MachineStudio.Developer.ViewModels
{
@@ -38,7 +43,8 @@ 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 const string EMB_FORMATS_EXPORT = "Baby Lock (PES)|*.pes|Tajima (DST)|*.dst|EXP|*.exp|PCS|*.pcs|HUS|*.hus|KSM|*.ksm";
+ private const string EMB_FORMATS_IMPORT = "Embroidery Files|*.pes;*.hus;*.dst";
private INotificationProvider _notification;
private TimeSpan _runningJobEstimatedDuration;
@@ -49,6 +55,8 @@ namespace Tango.MachineStudio.Developer.ViewModels
private ObservablesContext _machineDbContext;
private ObservablesContext _activeJobDbContext;
private LogManager LogManager = LogManager.Default;
+ private SpeechSynthesizer _speech;
+ private SoundPlayer _soundPlayer;
#region Properties
@@ -577,6 +585,10 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// </summary>
public RelayCommand ImportEmbroideryFileCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the display job embroidery file command.
+ /// </summary>
+ public RelayCommand<Job> DisplayJobEmbroideryFileCommand { get; set; }
#endregion
#region Constructors
@@ -625,6 +637,10 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log("Initializing relay commands...");
+ _speech = new SpeechSynthesizer();
+ _soundPlayer = new SoundPlayer(EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.MachineStudio.Developer.bip.wav"));
+ _speech.SelectVoice(_speech.GetInstalledVoices().LastOrDefault(x => x.VoiceInfo.Gender == VoiceGender.Female).VoiceInfo.Name);
+
//Initialize Commands...
EditMachineCommand = new RelayCommand(EditMachine, () => SelectedMachine != null);
EditRMLCommand = new RelayCommand(EditRML, () => SelectedRML != null);
@@ -648,6 +664,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
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);
+ DisplayJobEmbroideryFileCommand = new RelayCommand<Job>(DisplayJobEmbroideryFile);
ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged;
}
@@ -891,6 +908,9 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log("Setting job failed state...");
IsJobRunning = false;
IsJobFailed = true;
+
+ _soundPlayer.Play();
+ _speech.SpeakAsync("Job Failed!");
}
/// <summary>
@@ -901,6 +921,8 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log("Setting job completed state...");
IsJobRunning = false;
IsJobCompleted = true;
+ _soundPlayer.Play();
+ _speech.SpeakAsync("Job Completed!");
}
/// <summary>
@@ -958,12 +980,27 @@ namespace Tango.MachineStudio.Developer.ViewModels
}
if (remaining < segmentDuration)
{
- segment.Started = true;
+ if (!segment.Started)
+ {
+ segment.Started = true;
+ _soundPlayer.Play();
+
+ if (segment.ID != -1)
+ {
+ _speech.SpeakAsync(String.Format("Segment {0} Started.", segment.SegmentIndex));
+ }
+ else
+ {
+ _speech.SpeakAsync(String.Format("Inter Segment Started."));
+ }
+ }
}
if (remaining <= TimeSpan.Zero)
{
- segment.Completed = true;
- segment.Started = false;
+ if (!segment.Completed)
+ {
+ segment.Completed = true;
+ }
}
}
};
@@ -1020,6 +1057,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
segments.Add(new Segment()
{
Length = job.InterSegmentLength,
+ ID = -1,
BrushStops = new System.Collections.ObjectModel.ObservableCollection<BrushStop>()
{
new BrushStop()
@@ -1588,18 +1626,20 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = "Select embroidery file";
- dlg.Filter = EMB_FORMATS;
- if (dlg.ShowDialog().Value)
+ dlg.Filter = EMB_FORMATS_IMPORT;
+ if (dlg.ShowDialogCenter())
{
+ var view = new EmbroideryImportView();
+
_notification.ShowModalDialog<EmbroideryImportViewVM, EmbroideryImportView>(
- new EmbroideryImportViewVM() { FileName = dlg.FileName },
+ new EmbroideryImportViewVM() { FileName = dlg.FileName }, view,
(vm) =>
{
String jobName = _notification.ShowTextInput("Please provide a job name", "Name");
if (jobName != null)
{
- AddJobFromEmbroideryFile(jobName, vm.Paths.ToList(), vm.EmbroideryFile);
+ AddJobFromEmbroideryFile(jobName, vm.Paths.ToList(), vm.EmbroideryFile, dlg.FileName, view.EmbroideryImageBytes);
}
},
() =>
@@ -1609,7 +1649,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
}
}
- private async void AddJobFromEmbroideryFile(String jobName, List<EmbroideryPath> paths, EmbroideryFile embroideryFile)
+ private async void AddJobFromEmbroideryFile(String jobName, List<EmbroideryPath> paths, EmbroideryFile embroideryFile, String fileName, byte[] imageBytes)
{
LogManager.Log(String.Format("Adding new job from embroidery file {0}...", jobName));
@@ -1623,12 +1663,17 @@ namespace Tango.MachineStudio.Developer.ViewModels
job.SpoolType = _machineDbContext.SpoolTypes.FirstOrDefault();
job.Machine = SelectedMachine;
+ job.EmbroideryFileName = Path.GetFileName(fileName);
+ job.EmbroideryFileData = File.ReadAllBytes(fileName);
+ job.EmbroideryJpeg = imageBytes;
+ job.HasEmbroideryFile = true;
+
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;
+ segment.SegmentIndex = paths.IndexOf(path) + 2;
if (path.Brush is SolidColorBrush)
{
@@ -1639,7 +1684,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
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()),
+ ColorSpace = _machineDbContext.ColorSpaces.ToList().SingleOrDefault(x => x.Code == BL.Enumerations.ColorSpaces.RGB.ToInt32()),
});
}
else
@@ -1655,7 +1700,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
Green = stop.Color.G,
Blue = stop.Color.B,
OffsetPercent = stop.Offset,
- ColorSpace = _machineDbContext.ColorSpaces.ToList().SingleOrDefault(x => x.Code == BL.Entities.ColorSpaces.RGB.ToInt32()),
+ ColorSpace = _machineDbContext.ColorSpaces.ToList().SingleOrDefault(x => x.Code == BL.Enumerations.ColorSpaces.RGB.ToInt32()),
});
}
}
@@ -1670,6 +1715,35 @@ namespace Tango.MachineStudio.Developer.ViewModels
LoadSelectedJob();
}
+ private void DisplayJobEmbroideryFile(Job job)
+ {
+ _notification.ShowModalDialog<EmbroideryDisplayViewVM, EmbroideryDisplayView>(new EmbroideryDisplayViewVM(job), (vm) =>
+ {
+
+ SaveFileDialog dlg = new SaveFileDialog();
+ dlg.Title = "Select embroidery file location and format";
+ dlg.Filter = EMB_FORMATS_EXPORT;
+ dlg.FileName = job.EmbroideryFileName;
+ if (dlg.ShowDialogCenter())
+ {
+ try
+ {
+ String tempPath = PathHelper.GetTempFolderPath();
+ String filePath = Path.Combine(tempPath, job.EmbroideryFileName);
+ File.WriteAllBytes(filePath, job.EmbroideryFileData);
+ EmbroideryFileConverter.ConvertEmbroideryFile(filePath, dlg.FileName);
+ _notification.ShowInfo("Embroidery file exported successfully.");
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "An error has occurred while trying to export the attached embroidery file.");
+ _notification.ShowError("An error has occurred while trying to export the attached embroidery file.");
+ }
+ }
+
+ }, () => { });
+ }
+
#endregion
#region Override Methods