aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-02-19 17:17:25 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-02-19 17:17:25 +0200
commit8feeef663f8984c609cb3aa530d09ffcffda5709 (patch)
tree6b69a7a62ea1234ba5b16948dd3781078834a973 /Software/Visual_Studio
parent95b4e14bc4e06ffb94199f5ec4e0d2d9bebceeff (diff)
downloadTango-8feeef663f8984c609cb3aa530d09ffcffda5709.tar.gz
Tango-8feeef663f8984c609cb3aa530d09ffcffda5709.zip
Working on new developer module...
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetLimitConverter.cs4
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetValueConverter.cs4
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToBrushConverter.cs2
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToBrushConverterMulti.cs2
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverter.cs2
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverterMulti.cs2
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs488
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml87
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml.cs13
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml5
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs8
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml6
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml87
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj4
-rw-r--r--Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs13
-rw-r--r--Software/Visual_Studio/Tango.Integration/Observables/IObservableEntity.cs8
-rw-r--r--Software/Visual_Studio/Tango.Integration/Observables/ObservableEntity.cs34
-rw-r--r--Software/Visual_Studio/Tango.Integration/Observables/Partials/Configuration.cs16
-rw-r--r--Software/Visual_Studio/Tango.Integration/Observables/Partials/Machine.cs2
-rw-r--r--Software/Visual_Studio/Tango.Integration/Observables/Partials/MachineVersion.cs2
-rw-r--r--Software/Visual_Studio/Tango.Integration/Printing/BrushStop.cs28
-rw-r--r--Software/Visual_Studio/Tango.Integration/Printing/Job.cs8
-rw-r--r--Software/Visual_Studio/Tango.Integration/Printing/Segment.cs6
23 files changed, 551 insertions, 280 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetLimitConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetLimitConverter.cs
index 62d678888..96c44a5a0 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetLimitConverter.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetLimitConverter.cs
@@ -22,11 +22,11 @@ namespace Tango.MachineStudio.Developer.Converters
if (stop != null && segment != null)
{
- if (segment.BrushStops.IndexOf(stop) == segment.BrushStops.Count - 1)
+ if (stop.IsLast)
{
return 100d;
}
- else if (segment.BrushStops.IndexOf(stop) == 0)
+ else if (stop.IsFirst)
{
return 0d;
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetValueConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetValueConverter.cs
index d8ac744a9..d78ef0c8e 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetValueConverter.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetValueConverter.cs
@@ -20,11 +20,11 @@ namespace Tango.MachineStudio.Developer.Converters
if (stop != null && segment != null)
{
- if (segment.BrushStops.IndexOf(stop) == segment.BrushStops.Count - 1)
+ if (stop.IsLast)
{
return 100d;
}
- else if (segment.BrushStops.IndexOf(stop) == 0)
+ else if (stop.IsFirst)
{
return 0d;
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToBrushConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToBrushConverter.cs
index 8aef260ff..1ac498070 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToBrushConverter.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToBrushConverter.cs
@@ -21,7 +21,7 @@ namespace Tango.MachineStudio.Developer.Converters
GradientStopCollection stops = new GradientStopCollection();
- foreach (var stop in segment.BrushStops)
+ foreach (var stop in segment.BrushStops.OrderBy(x => x.StopIndex))
{
stops.Add(new GradientStop(stop.Color, stop.OffsetPercent / 100d));
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToBrushConverterMulti.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToBrushConverterMulti.cs
index 0248fd730..41c1dd4df 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToBrushConverterMulti.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToBrushConverterMulti.cs
@@ -23,7 +23,7 @@ namespace Tango.MachineStudio.Developer.Converters
{
GradientStopCollection stops = new GradientStopCollection();
- foreach (var stop in segment.BrushStops)
+ foreach (var stop in segment.BrushStops.OrderBy(x => x.StopIndex))
{
stops.Add(new GradientStop(stop.Color, stop.OffsetPercent / 100d));
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverter.cs
index 37908c940..f28a0b594 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverter.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverter.cs
@@ -20,7 +20,7 @@ namespace Tango.MachineStudio.Developer.Converters
GradientStopCollection stops = new GradientStopCollection();
- foreach (var stop in segment.BrushStops)
+ foreach (var stop in segment.BrushStops.OrderBy(x => x.StopIndex))
{
stops.Add(new GradientStop(stop.Color, stop.OffsetPercent / 100d));
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverterMulti.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverterMulti.cs
index 68ff95a9c..c50fbb06c 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverterMulti.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverterMulti.cs
@@ -22,7 +22,7 @@ namespace Tango.MachineStudio.Developer.Converters
{
GradientStopCollection stops = new GradientStopCollection();
- foreach (var stop in segment.BrushStops)
+ foreach (var stop in segment.BrushStops.OrderBy(x => x.StopIndex))
{
stops.Add(new GradientStop(stop.Color, stop.OffsetPercent / 100d));
}
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 5c5531063..c8a6aa89f 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
@@ -36,6 +36,8 @@ using Tango.MachineStudio.Developer.Navigation;
using System.Data.Entity;
using Tango.MachineStudio.Common.Authentication;
using DeepEqual.Syntax;
+using System.ComponentModel;
+using System.Windows.Data;
namespace Tango.MachineStudio.Developer.ViewModels
{
@@ -45,6 +47,8 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// <seealso cref="Tango.SharedUI.ViewModel" />
public class MainViewVM : ViewModel<IMainView>, IShutdownRequestBlocker
{
+ private static object _syncLock = new object();
+
private INotificationProvider _notification;
private TimeSpan _runningJobEstimatedDuration;
private Dictionary<String, GraphControllerBase> _controllers;
@@ -52,9 +56,9 @@ namespace Tango.MachineStudio.Developer.ViewModels
private JobHandler _jobHandler;
private DeveloperNavigationManager _navigation;
private ObservablesContext _dbJobContext;
- private Job _jobFromList;
private bool _blockInvalidateCommands;
private IAuthenticationProvider _authentication;
+ private ObservablesContext _machineDBContext;
#region Properties
@@ -103,7 +107,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
set
{
_selectedMachine = value;
- OnMachineChanged();
+ OnSelectedMachineChanged();
RaisePropertyChangedAuto();
InvalidateRelayCommands();
@@ -136,6 +140,21 @@ namespace Tango.MachineStudio.Developer.ViewModels
{ _rmlProcessParametersTablesGroup = value; RaisePropertyChangedAuto(); OnProcessParametersTableGroupChanged(); }
}
+ public void OnDropSegment(Segment dragged, Segment dropped)
+ {
+ dragged.SegmentIndex = dropped.SegmentIndex;
+ dropped.SegmentIndex++;
+
+ int index = 1;
+
+ foreach (var segment in ActiveJob.Segments.OrderBy(x => x.SegmentIndex))
+ {
+ segment.SegmentIndex = index++;
+ }
+
+ SegmentsCollectionView.Refresh();
+ }
+
private ObservableCollection<ProcessParametersTablesGroup> _groupsHistory;
/// <summary>
/// Gets or sets the RML process parameters groups history.
@@ -166,20 +185,31 @@ namespace Tango.MachineStudio.Developer.ViewModels
set { _selectedProcessParametersTable = value; RaisePropertyChangedAuto(); OnSelectedParametersTableChanged(); }
}
- private Job _selectedJob;
+ private Job _activeJob;
/// <summary>
/// Gets or sets the selected machine job.
/// </summary>
- public Job SelectedJob
+ public Job ActiveJob
{
- get { return _selectedJob; }
+ get { return _activeJob; }
set
{
- _selectedJob = value;
+ _activeJob = value;
RaisePropertyChangedAuto();
+ OnActiveJobChanged();
}
}
+ private Job _selectedMachineJob;
+ /// <summary>
+ /// Gets or sets the selected machine job.
+ /// </summary>
+ public Job SelectedMachineJob
+ {
+ get { return _selectedMachineJob; }
+ set { _selectedMachineJob = value; RaisePropertyChangedAuto(); }
+ }
+
private ObservableCollection<Job> _selectedJobs;
/// <summary>
/// Gets or sets the selected jobs.
@@ -396,6 +426,52 @@ namespace Tango.MachineStudio.Developer.ViewModels
set { _runningJobSegments = value; RaisePropertyChangedAuto(); }
}
+ private ICollectionView _jobsCollectionView;
+ /// <summary>
+ /// Gets or sets the jobs collection view.
+ /// </summary>
+ public ICollectionView JobsCollectionView
+ {
+ get { return _jobsCollectionView; }
+ set
+ {
+ _jobsCollectionView = value;
+ BindingOperations.EnableCollectionSynchronization(_jobsCollectionView, _syncLock);
+
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private ICollectionView _segmentsCollectionView;
+ /// <summary>
+ /// Gets or sets the segments collection view.
+ /// </summary>
+ public ICollectionView SegmentsCollectionView
+ {
+ get { return _segmentsCollectionView; }
+ set
+ {
+ _segmentsCollectionView = value;
+ BindingOperations.EnableCollectionSynchronization(_segmentsCollectionView, _syncLock);
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private ICollectionView _brushStopsCollectionView;
+ /// <summary>
+ /// Gets or sets the brush stops collection view.
+ /// </summary>
+ public ICollectionView BrushStopsCollectionView
+ {
+ get { return _brushStopsCollectionView; }
+ set
+ {
+ _brushStopsCollectionView = value;
+ BindingOperations.EnableCollectionSynchronization(_brushStopsCollectionView, _syncLock);
+ RaisePropertyChangedAuto();
+ }
+ }
+
#endregion
#region Commands
@@ -500,6 +576,16 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// </summary>
public RelayCommand DuplicateJobCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the duplicate segment command.
+ /// </summary>
+ public RelayCommand DuplicateSegmentCommand { get; set; }
+
+ /// <summary>
+ /// Gets or sets the duplicate brush stop command.
+ /// </summary>
+ public RelayCommand DuplicateBrushStopCommand { get; set; }
+
#endregion
#region Constructors
@@ -527,6 +613,8 @@ namespace Tango.MachineStudio.Developer.ViewModels
[PreferredConstructor]
public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IMainView view, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication) : this(view)
{
+ _machineDBContext = ObservablesContext.CreateDefault();
+
SelectedJobs = new ObservableCollection<Job>();
_authentication = authentication;
@@ -543,20 +631,22 @@ namespace Tango.MachineStudio.Developer.ViewModels
ToggleSideBarCommand = new RelayCommand(() => IsSideBarOpened = !IsSideBarOpened);
SaveProcessParametersCommand = new RelayCommand(SaveProcessParameters, () => SelectedRML != null && SelectedRML.ProcessParametersTablesGroups.Count > 0);
SaveLiquidFactorsCommand = new RelayCommand(SaveLiquidFactors, () => SelectedRML != null);
- AddSegmentCommand = new RelayCommand(AddSegment, () => SelectedJob != null);
- RemoveSegmentCommand = new RelayCommand(RemoveSegment, () => SelectedSegment != null);
+ AddSegmentCommand = new RelayCommand(AddSegment, () => ActiveJob != null);
+ RemoveSegmentCommand = new RelayCommand(RemoveSelectedSegments, () => SelectedSegment != null);
AddJobCommand = new RelayCommand(AddJob, () => SelectedMachine != null);
- RemoveJobCommand = new RelayCommand(RemoveJob, () => SelectedJob != null);
+ RemoveJobCommand = new RelayCommand(RemoveSelectedJobs, () => SelectedMachineJob != null);
AddBrushStopCommand = new RelayCommand(AddBrushStop, () => SelectedSegment != null);
- RemoveBrushStopCommand = new RelayCommand(RemoveBrushStop, () => SelectedBrushStop != null);
+ RemoveBrushStopCommand = new RelayCommand(RemoveSelectedBrushStops, () => SelectedBrushStop != null);
SaveJobCommand = new RelayCommand(SaveJob, () => SelectedMachine != null);
DiscardJobCommand = new RelayCommand(DiscardJob, () => SelectedMachine != null);
- StartJobCommand = new RelayCommand(StartJob, () => SelectedJob != null && !IsJobRunning);
+ StartJobCommand = new RelayCommand(StartJob, () => ActiveJob != null && !IsJobRunning);
StopJobCommand = new RelayCommand(StopJob, () => IsJobRunning);
CloseJobCompletionStatusCommand = new RelayCommand(CloseJobCompletionStatusBar);
ExitFullScreenCommand = new RelayCommand(ExitFullScreen);
- LoadJobCommand = new RelayCommand(LoadJob, () => SelectedJob != null);
- DuplicateJobCommand = new RelayCommand(DuplicateJob, () => SelectedJob != null);
+ LoadJobCommand = new RelayCommand(LoadJob, () => SelectedMachineJob != null);
+ DuplicateJobCommand = new RelayCommand(DuplicateSelectedJobs, () => SelectedMachineJob != null);
+ DuplicateSegmentCommand = new RelayCommand(DuplicateSelectedSegments, () => SelectedSegment != null);
+ DuplicateBrushStopCommand = new RelayCommand(DuplicateSelectedBrushStops, () => SelectedBrushStop != null);
ToggleCameraCommand = new RelayCommand<CaptureDevice>(ToggleCamera);
@@ -595,7 +685,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
private void SelectedMachine_Saved(object sender, EventArgs e)
{
InvalidateLiquidFactorsAndProcessTables();
- SelectedMachine.Reload();
+ SelectedMachine.Reload(_machineDBContext);
}
/// <summary>
@@ -603,7 +693,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
- private void SelectedJob_LengthChanged(object sender, EventArgs e)
+ private void ActiveJob_LengthChanged(object sender, EventArgs e)
{
UpdateEstimatedDuration();
}
@@ -639,6 +729,8 @@ namespace Tango.MachineStudio.Developer.ViewModels
}
SetSegmentBrushStopsLiquidVolumes(SelectedSegment);
+
+ UpdateEstimatedDuration();
}
/// <summary>
@@ -663,6 +755,9 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
SetSegmentBrushStopsLiquidVolumes(SelectedSegment);
SelectedBrushStop = SelectedSegment.BrushStops.FirstOrDefault();
+
+ BrushStopsCollectionView = CollectionViewSource.GetDefaultView(SelectedSegment.BrushStops);
+ BrushStopsCollectionView.SortDescriptions.Add(new SortDescription(nameof(BrushStop.StopIndex), ListSortDirection.Ascending));
}
}
@@ -680,38 +775,45 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// <summary>
/// Called when the machine has been changed
/// </summary>
- protected virtual void OnMachineChanged()
+ protected virtual void OnSelectedMachineChanged()
{
- InvalidateLiquidFactorsAndProcessTables();
+ if (SelectedMachine != null)
+ {
+ ReloadMachine();
+ JobsCollectionView = CollectionViewSource.GetDefaultView(SelectedMachine.Jobs);
+ JobsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Job.LastUpdated), ListSortDirection.Descending));
+ InvalidateLiquidFactorsAndProcessTables();
+ }
+ }
+
+ private void ReloadMachine()
+ {
+ _machineDBContext.Dispose();
+ _machineDBContext = ObservablesContext.CreateDefault();
+ _machineDBContext.Configuration.LazyLoadingEnabled = true;
+ _selectedMachine = _machineDBContext.Machines.SingleOrDefault(x => x.Guid == _selectedMachine.Guid);
+ RaisePropertyChanged(nameof(SelectedMachine));
+
+ JobsCollectionView = CollectionViewSource.GetDefaultView(SelectedMachine.Jobs);
+ JobsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Job.LastUpdated), ListSortDirection.Descending));
}
#endregion
#region Private Methods
- private async void DuplicateJob()
+ private void OnActiveJobChanged()
{
- if (SelectedJobs.Count > 0)
+ if (ActiveJob != null)
{
- using (_notification.PushTaskItem("Cloning selected jobs..."))
- {
- int index = SelectedMachine.Jobs.Max(x => x.JobIndex);
-
- foreach (var job in SelectedJobs)
- {
- var cloned = job.Clone();
- cloned.JobIndex = ++index;
- SelectedMachine.Jobs.Add(cloned);
- }
-
- await SelectedMachine.SaveAsync();
- }
+ SegmentsCollectionView = CollectionViewSource.GetDefaultView(ActiveJob.Segments);
+ SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending));
}
}
- private async void LoadJob()
+ private void LoadJob()
{
- if (SelectedJob != null)
+ if (SelectedMachineJob != null)
{
SelectedSegments = new ObservableCollection<Segment>();
SelectedBrushStops = new ObservableCollection<BrushStop>();
@@ -726,33 +828,34 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
//await Task.Factory.StartNew(() =>
//{
- _blockInvalidateCommands = false;
+ _blockInvalidateCommands = false;
+
+ _dbJobContext = ObservablesContext.CreateDefault();
+ _dbJobContext.Configuration.LazyLoadingEnabled = true;
- _dbJobContext = ObservablesContext.CreateDefault();
- _dbJobContext.Configuration.LazyLoadingEnabled = true;
+ ColorSpaces = _dbJobContext.ColorSpaces.ToObservableCollection();
+ Rmls = _dbJobContext.Rmls.ToObservableCollection();
- ColorSpaces = _dbJobContext.ColorSpaces.ToObservableCollection();
- Rmls = _dbJobContext.Rmls.ToObservableCollection();
+ _activeJob = _dbJobContext.Jobs.SingleOrDefault(x => x.Guid == SelectedMachineJob.Guid);
- _jobFromList = SelectedJob;
- _selectedJob = _dbJobContext.Jobs.SingleOrDefault(x => x.Guid == SelectedJob.Guid);
- _selectedRML = SelectedJob.Rml;
+ _selectedRML = ActiveJob.Rml;
- _selectedSegment = SelectedJob.Segments.FirstOrDefault();
+ _selectedSegment = ActiveJob.Segments.FirstOrDefault();
- SelectedJob.LengthChanged -= SelectedJob_LengthChanged;
- SelectedJob.LengthChanged += SelectedJob_LengthChanged;
+ ActiveJob.LengthChanged -= ActiveJob_LengthChanged;
+ ActiveJob.LengthChanged += ActiveJob_LengthChanged;
- SelectedJob = _selectedJob;
- SelectedRML = _selectedRML;
- SelectedSegment = _selectedSegment;
+ ActiveJob = _activeJob;
- UpdateEstimatedDuration();
+ SelectedRML = _selectedRML;
+ SelectedSegment = _selectedSegment;
- _blockInvalidateCommands = false;
- InvalidateRelayCommands();
+ UpdateEstimatedDuration();
- InvokeUI(() => _navigation.NavigateTo(DeveloperNavigationView.JobView));
+ _blockInvalidateCommands = false;
+ InvalidateRelayCommands();
+
+ InvokeUI(() => _navigation.NavigateTo(DeveloperNavigationView.JobView));
//});
}
}
@@ -760,45 +863,27 @@ namespace Tango.MachineStudio.Developer.ViewModels
private async void SaveJob()
{
- if (SelectedJob != null)
+ if (ActiveJob != null)
{
using (_notification.PushTaskItem("Saving job to database..."))
{
- SelectedJob.LastUpdated = DateTime.UtcNow;
- SelectedJob.Rml = SelectedRML;
- await SelectedJob.SaveAsync(_dbJobContext);
- _jobFromList = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == SelectedJob.Guid);
- await _jobFromList.Reload();
-
- foreach (var segment in _jobFromList.Segments)
- {
- await segment.Reload();
+ ActiveJob.LastUpdated = DateTime.UtcNow;
+ ActiveJob.Rml = SelectedRML;
- foreach (var stop in segment.BrushStops)
- {
- await stop.Reload();
- }
- }
+ await ActiveJob.SaveAsync(_dbJobContext);
+ ReloadMachine();
+ SelectedMachineJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == ActiveJob.Guid);
}
}
}
private void DiscardJob()
{
- //bool jobModified = !SelectedJob.WithDeepEqual(_jobFromList)
- // .IgnoreSourceProperty(x => x.Machine)
- // .IgnoreSourceProperty(x => x.JobRuns)
- // .IgnoreSourceProperty(x => x.Parameters)
- // .IgnoreSourceProperty(x => x.Rml)
- // .IgnoreSourceProperty(x => x.User)
- // .IgnoreSourceProperty(x => x.Segments)
- // .Compare();
-
- bool jobModified = !SelectedJob.CompareUsingJson(_jobFromList);
+ bool jobModified = !ActiveJob.CompareUsingJson(SelectedMachineJob);
if (jobModified)
{
- if (_notification.ShowQuestion("This will discard the current job changes. Are you sue?"))
+ if (_notification.ShowQuestion("This will discard the current job changes. Are you sure?"))
{
_dbJobContext.Dispose();
_navigation.NavigateTo(DeveloperNavigationView.MachineJobSelectionView);
@@ -914,14 +999,14 @@ namespace Tango.MachineStudio.Developer.ViewModels
IsJobCompleted = false;
IsJobRunning = true;
ShowJobStatus = true;
- RunningJob = SelectedJob;
+ RunningJob = ActiveJob;
_runningJobEstimatedDuration = EstimatedDuration;
RunningJobSegments = CreateRunningJobEffectiveSegments(RunningJob);
_navigation.NavigateTo(DeveloperNavigationView.RunningJobView);
- _jobHandler = MachineOperator.Print(SelectedJob, SelectedProcessParametersTable);
+ _jobHandler = MachineOperator.Print(ActiveJob, SelectedProcessParametersTable);
_jobHandler.StatusReceived += (x, status) =>
{
@@ -973,9 +1058,9 @@ namespace Tango.MachineStudio.Developer.ViewModels
private void UpdateEstimatedDuration()
{
- if (SelectedJob != null && SelectedProcessParametersTable != null && SelectedProcessParametersTable.DyeingSpeed > 0)
+ if (ActiveJob != null && SelectedProcessParametersTable != null && SelectedProcessParametersTable.DyeingSpeed > 0)
{
- EstimatedDuration = TimeSpan.FromSeconds(SelectedJob.Length / (SelectedProcessParametersTable.DyeingSpeed / 100d));
+ EstimatedDuration = TimeSpan.FromSeconds(ActiveJob.Length / (SelectedProcessParametersTable.DyeingSpeed / 100d));
}
}
@@ -1090,14 +1175,93 @@ namespace Tango.MachineStudio.Developer.ViewModels
}
}
+ private List<Segment> CreateRunningJobEffectiveSegments(Job job)
+ {
+ List<Segment> segments = new List<Segment>();
+ foreach (var s in job.Segments)
+ {
+ s.Completed = false;
+ s.Started = false;
+ segments.Add(s);
+
+ if (job.EnableInterSegment && job.Segments.IndexOf(s) != job.Segments.Count - 1)
+ {
+ segments.Add(new Segment()
+ {
+ Length = job.InterSegmentLength,
+ BrushStops = new System.Collections.ObjectModel.ObservableCollection<BrushStop>()
+ {
+ new BrushStop()
+ {
+ Color = Colors.White,
+ }
+ },
+ Started = false,
+ Completed = false
+ });
+ }
+ }
+
+ return segments;
+ }
+
+ #endregion
+
+ #region Add / Remove / Duplicate Jobs, Segments & Brush Stops
+
+ private void ArrangeSegmentsIndices()
+ {
+ int index = 1;
+
+ foreach (var segment in ActiveJob.Segments.OrderBy(x => x.SegmentIndex))
+ {
+ segment.SegmentIndex = index++;
+ }
+
+ SegmentsCollectionView.Refresh();
+ }
+
+ private void ArrangeBrushStopsIndices()
+ {
+ int index = 0;
+
+ foreach (var stop in SelectedSegment.BrushStops.OrderBy(x => x.StopIndex))
+ {
+ stop.SetStopIndex(index++);
+ }
+
+ if (SelectedSegment.BrushStops.Count > 1)
+ {
+ SelectedSegment.BrushStops.OrderBy(x => x.StopIndex).First().OffsetPercent = 0;
+ SelectedSegment.BrushStops.OrderBy(x => x.StopIndex).Last().OffsetPercent = 100;
+ }
+
+ foreach (var stop in SelectedSegment.BrushStops.OrderBy(x => x.StopIndex))
+ {
+ stop.RaiseStopIndex();
+ stop.RaiseOffsetChanged();
+ }
+
+ BrushStopsCollectionView.Refresh();
+ }
+
/// <summary>
- /// Removes the selected segment.
+ /// Removes the selected segments.
/// </summary>
- private void RemoveSegment()
+ private void RemoveSelectedSegments()
{
- if (SelectedJob != null && SelectedSegment != null)
+ if (ActiveJob != null && SelectedSegment != null)
{
- SelectedJob.Segments.Remove(SelectedSegment);
+ if (_notification.ShowQuestion("Are you sure you want to delete the selected segments?"))
+ {
+ SelectedSegments.ToList().ForEach(x =>
+ {
+ ActiveJob.Segments.Remove(x);
+ x.DefferedDelete(_dbJobContext);
+ });
+
+ ArrangeSegmentsIndices();
+ }
}
}
@@ -1106,31 +1270,46 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// </summary>
private void AddSegment()
{
- if (SelectedJob != null)
+ if (ActiveJob != null)
{
Segment seg = new Segment();
seg.Name = "Untitled Segment";
- seg.Length = 1;
- SelectedJob.Segments.Add(seg);
+ seg.Length = 10;
+
+ if (ActiveJob.Segments.Count > 0)
+ {
+ seg.SegmentIndex = ActiveJob.Segments.Max(x => x.SegmentIndex) + 1;
+ }
+ else
+ {
+ seg.SegmentIndex = 1;
+ }
+ ActiveJob.Segments.Add(seg);
SelectedSegment = seg;
AddBrushStop();
+ ArrangeSegmentsIndices();
}
}
/// <summary>
- /// Removes the selected job.
+ /// Removes the selected jobs.
/// </summary>
- private async void RemoveJob()
+ private async void RemoveSelectedJobs()
{
- if (SelectedMachine != null && SelectedJob != null)
+ if (SelectedMachine != null && SelectedMachineJob != null)
{
if (_notification.ShowQuestion("Are you sure you want to delete the selected jobs?"))
{
SelectedJobs.ToList().ForEach(x =>
{
- x.DefferedDelete();
+ SelectedMachine.Jobs.Remove(x);
+ x.DefferedDelete(_machineDBContext);
});
- await SelectedMachine.SaveAsync();
+
+ using (_notification.PushTaskItem("Removing selected jobs..."))
+ {
+ await SelectedMachine.SaveAsync(_machineDBContext);
+ }
}
}
}
@@ -1138,7 +1317,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// <summary>
/// Adds a new job to the selected machine.
/// </summary>
- private void AddJob()
+ private async void AddJob()
{
if (SelectedMachine != null)
{
@@ -1151,9 +1330,14 @@ namespace Tango.MachineStudio.Developer.ViewModels
newJob.CreationDate = DateTime.UtcNow;
newJob.User = _authentication.CurrentUser;
newJob.Rml = Adapter.Rmls.FirstOrDefault();
+ newJob.WindingMethod = Adapter.WindingMethods.FirstOrDefault();
+ newJob.Machine = SelectedMachine;
- SelectedJob = newJob;
+ SelectedMachine.Jobs.Add(newJob);
+ await SelectedMachine.SaveAsync(_machineDBContext);
+ SelectedMachineJob = newJob;
LoadJob();
+ AddSegment();
}
}
}
@@ -1161,18 +1345,20 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// <summary>
/// Removes the selected brush stop.
/// </summary>
- private void RemoveBrushStop()
+ private void RemoveSelectedBrushStops()
{
if (SelectedBrushStop != null && SelectedSegment != null)
{
- SelectedSegment.BrushStops.Remove(SelectedBrushStop);
-
- if (SelectedSegment.BrushStops.Count > 1)
+ if (_notification.ShowQuestion("Are you sure you want to delete the selected colors?"))
{
- SelectedSegment.BrushStops.Last().OffsetPercent = 100;
- }
+ SelectedBrushStops.ToList().ForEach(x =>
+ {
+ SelectedSegment.BrushStops.Remove(x);
+ x.DefferedDelete(_dbJobContext);
+ });
- SelectedSegment.BrushStops.ToList().ForEach(x => x.RaiseOffsetChanged());
+ ArrangeBrushStopsIndices();
+ }
}
}
@@ -1184,44 +1370,78 @@ namespace Tango.MachineStudio.Developer.ViewModels
if (SelectedSegment != null)
{
var stop = new BrushStop();
+
+ if (SelectedSegment.BrushStops.Count > 0)
+ {
+ stop.StopIndex = SelectedSegment.BrushStops.Max(x => x.StopIndex) + 1;
+ }
+ else
+ {
+ stop.StopIndex = 0;
+ }
+
stop.OffsetPercent = 100;
stop.Segment = SelectedSegment;
- stop.ColorSpace = Adapter.ColorSpaces.FirstOrDefault();
+ stop.ColorSpace = _dbJobContext.ColorSpaces.FirstOrDefault();
stop.Color = Colors.Black;
stop.SetLiquidVolumes(SelectedMachine.Configuration, SelectedRML, SelectedProcessParametersTable);
SelectedSegment.BrushStops.Add(stop);
SelectedSegment.BrushStops.ToList().ForEach(x => x.RaiseOffsetChanged());
+ ArrangeBrushStopsIndices();
}
}
- private List<Segment> CreateRunningJobEffectiveSegments(Job job)
+ /// <summary>
+ /// Duplicates the selected brush stops.
+ /// </summary>
+ private void DuplicateSelectedBrushStops()
{
- List<Segment> segments = new List<Segment>();
- foreach (var s in job.Segments)
+ foreach (var stop in SelectedBrushStops.OrderBy(x => x.StopIndex))
{
- s.Completed = false;
- s.Started = false;
- segments.Add(s);
+ var cloned = stop.Clone();
+ cloned.StopIndex = SelectedSegment.BrushStops.Max(x => x.StopIndex) + 1;
+ SelectedSegment.BrushStops.Add(cloned);
+ }
- if (job.EnableInterSegment && job.Segments.IndexOf(s) != job.Segments.Count - 1)
+ ArrangeBrushStopsIndices();
+ }
+
+ /// <summary>
+ /// Duplicates the selected segments.
+ /// </summary>
+ private void DuplicateSelectedSegments()
+ {
+ foreach (var segment in SelectedSegments.OrderBy(x => x.SegmentIndex))
+ {
+ var cloned = segment.Clone();
+ cloned.SegmentIndex = ActiveJob.Segments.Max(x => x.SegmentIndex) + 1;
+ ActiveJob.Segments.Add(cloned);
+ }
+
+ ArrangeSegmentsIndices();
+ }
+
+ /// <summary>
+ /// Duplicates the selected jobs.
+ /// </summary>
+ private async void DuplicateSelectedJobs()
+ {
+ if (SelectedMachineJob != null)
+ {
+ using (_notification.PushTaskItem("Cloning selected jobs..."))
{
- segments.Add(new Segment()
+ int index = SelectedMachine.Jobs.Max(x => x.JobIndex);
+
+ foreach (var job in SelectedJobs)
{
- Length = job.InterSegmentLength,
- BrushStops = new System.Collections.ObjectModel.ObservableCollection<BrushStop>()
- {
- new BrushStop()
- {
- Color = Colors.White,
- }
- },
- Started = false,
- Completed = false
- });
+ var cloned = job.Clone();
+ cloned.JobIndex = ++index;
+ SelectedMachine.Jobs.Add(cloned);
+ }
+
+ await SelectedMachine.SaveAsync(_machineDBContext);
}
}
-
- return segments;
}
#endregion
@@ -1311,17 +1531,9 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// <param name="droppedStop">The dropped stop.</param>
public void OnDropBrushStop(BrushStop draggedStop, BrushStop droppedStop)
{
- SelectedSegment.BrushStops.Swap(draggedStop, droppedStop);
-
- int tmpIndex = draggedStop.StopIndex;
- draggedStop.StopIndex = droppedStop.StopIndex;
- droppedStop.StopIndex = tmpIndex;
-
- if (SelectedSegment.BrushStops.Count > 1)
- {
- SelectedSegment.BrushStops.First().OffsetPercent = 0;
- SelectedSegment.BrushStops.Last().OffsetPercent = 100;
- }
+ draggedStop.SetStopIndex(droppedStop.StopIndex);
+ droppedStop.SetStopIndex(droppedStop.StopIndex + 1);
+ ArrangeBrushStopsIndices();
}
/// <summary>
@@ -1354,7 +1566,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
}
SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid = SelectedMachine != null ? SelectedMachine.Guid : null;
- SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid = SelectedJob != null ? SelectedJob.Guid : null;
+ SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid = ActiveJob != null ? ActiveJob.Guid : null;
return Task.FromResult(true);
}
@@ -1374,7 +1586,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid != null && SelectedMachine != null)
{
- SelectedJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid);
+ ActiveJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid);
}
}
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 35a30e91e..cf7af21d9 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
@@ -75,39 +75,6 @@
<Color x:Key="dummyColor">Transparent</Color>
- <Style x:Key="droppableGrid" TargetType="Grid">
- <Setter Property="RenderTransform">
- <Setter.Value>
- <ScaleTransform ScaleX="1" ScaleY="1"></ScaleTransform>
- </Setter.Value>
- </Setter>
- <Setter Property="RenderTransformOrigin" Value="0.5,0.5"></Setter>
- <Setter Property="Background" Value="Transparent"></Setter>
- <Setter Property="dragAndDrop:DragAndDropService.Droppable" Value="True"></Setter>
- <Setter Property="dragAndDrop:DragAndDropService.DraggingSurface" Value="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DraggingSurface}"></Setter>
- <Style.Triggers>
- <Trigger Property="dragAndDrop:DragAndDropService.IsDraggableOver" Value="True">
- <Setter Property="Opacity" Value="0.5"></Setter>
- <Trigger.EnterActions>
- <BeginStoryboard>
- <Storyboard>
- <DoubleAnimation To="0.95" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleX"></DoubleAnimation>
- <DoubleAnimation To="0.95" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleY"></DoubleAnimation>
- </Storyboard>
- </BeginStoryboard>
- </Trigger.EnterActions>
- <Trigger.ExitActions>
- <BeginStoryboard>
- <Storyboard>
- <DoubleAnimation To="1" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleX"></DoubleAnimation>
- <DoubleAnimation To="1" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleY"></DoubleAnimation>
- </Storyboard>
- </BeginStoryboard>
- </Trigger.ExitActions>
- </Trigger>
- </Style.Triggers>
- </Style>
-
<Style x:Key="brushStopBorder" TargetType="Border">
<Setter Property="RenderTransform">
<Setter.Value>
@@ -142,18 +109,6 @@
</Style.Triggers>
</Style>
- <Style x:Key="draggableGrid" TargetType="Grid">
- <Setter Property="RenderTransform">
- <Setter.Value>
- <ScaleTransform ScaleX="1" ScaleY="1"></ScaleTransform>
- </Setter.Value>
- </Setter>
- <Setter Property="RenderTransformOrigin" Value="0.5,0.5"></Setter>
- <Setter Property="Background" Value="Transparent"></Setter>
- <Setter Property="dragAndDrop:DragAndDropService.Draggable" Value="True"></Setter>
- <Setter Property="dragAndDrop:DragAndDropService.DraggingSurface" Value="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DraggingSurface}"></Setter>
- </Style>
-
<Style TargetType="Border" x:Key="JobFieldBorder">
<Setter Property="BorderBrush" Value="#A5A4A4"></Setter>
<Setter Property="BorderThickness" Value="0 0 1 1"></Setter>
@@ -281,7 +236,7 @@
</StackPanel>
</Border>
- <controls:MultiSelectListBox Style="{StaticResource {x:Type ListBox}}" SelectionMode="Extended" SelectionChanged="ListBox_SelectionChanged" ItemsSource="{Binding SelectedJob.Segments}" SelectedItem="{Binding SelectedSegment}" SelectedItemsList="{Binding SelectedSegments,Mode=TwoWay}" HorizontalContentAlignment="Stretch">
+ <controls:MultiSelectListBox Style="{StaticResource {x:Type ListBox}}" SelectionMode="Extended" SelectionChanged="ListBox_SelectionChanged" ItemsSource="{Binding SegmentsCollectionView}" SelectedItem="{Binding SelectedSegment}" SelectedItemsList="{Binding SelectedSegments,Mode=TwoWay}" HorizontalContentAlignment="Stretch">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource basicListBoxItem}">
@@ -289,8 +244,8 @@
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
- <Grid Margin="5 10">
- <Polygon Points="40,0 290,0 290,100 0,100 0,30" StrokeThickness="0.2">
+ <Grid Margin="5 10" Style="{StaticResource draggableDroppableGrid}" dragAndDrop:DragAndDropService.Drop="OnSegmentDrop">
+ <Polygon Points="40,0 290,0 290,100 0,100 0,30" StrokeThickness="0.2" IsHitTestVisible="False">
<Polygon.Effect>
<DropShadowEffect Opacity="0.5" />
</Polygon.Effect>
@@ -321,8 +276,7 @@
</Style>
</Polygon.Style>
</Polygon>
- <Border Height="100" Padding="5">
-
+ <Border Height="100" Padding="5" IsHitTestVisible="False">
<Grid>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" FontStyle="Italic">
<Run>#</Run>
@@ -333,13 +287,12 @@
<Rectangle.Fill>
<MultiBinding Converter="{StaticResource SegmentToBrushConverterMulti}">
<Binding Path="."></Binding>
- <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.SelectedJob"></Binding>
- <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.SelectedJob.Length"></Binding>
+ <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.ActiveJob"></Binding>
+ <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.ActiveJob.Length"></Binding>
<Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.SelectedBrushStop.Color"></Binding>
</MultiBinding>
</Rectangle.Fill>
</Rectangle>
-
</Grid>
</Border>
@@ -378,11 +331,11 @@
<Grid>
<StackPanel Orientation="Horizontal" Margin="10">
<Image Source="../Images/rgb.png" Width="24"></Image>
- <TextBlock Margin="5 0 0 0" Text="{Binding SelectedJob.Name,FallbackValue='UNSET'}" FontSize="16" FontWeight="SemiBold" VerticalAlignment="Center"></TextBlock>
+ <TextBlock Margin="5 0 0 0" Text="{Binding ActiveJob.Name,FallbackValue='UNSET'}" FontSize="16" FontWeight="SemiBold" VerticalAlignment="Center"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 5 0 0" HorizontalAlignment="Right">
- <TextBlock Margin="0 0 5 0" Text="{Binding SelectedJob.CreationDate,FallbackValue='UNSET'}" FontSize="12" Foreground="Gray" FontStyle="Italic" VerticalAlignment="Center"></TextBlock>
+ <TextBlock Margin="0 0 5 0" Text="{Binding ActiveJob.CreationDate,FallbackValue='UNSET'}" FontSize="12" Foreground="Gray" FontStyle="Italic" VerticalAlignment="Center"></TextBlock>
<Image Source="../Images/calendar.png" Width="16"></Image>
</StackPanel>
</Grid>
@@ -394,7 +347,7 @@
<Image Source="../Images/name.png" Width="32"></Image>
<TextBlock VerticalAlignment="Center" Margin="5 0 0 0" FontSize="10">Name</TextBlock>
</StackPanel>
- <TextBox Margin="0 3 0 0" Width="100" HorizontalAlignment="Left" Text="{Binding SelectedJob.Name,UpdateSourceTrigger=PropertyChanged}"></TextBox>
+ <TextBox Margin="0 3 0 0" Width="100" HorizontalAlignment="Left" Text="{Binding ActiveJob.Name,UpdateSourceTrigger=PropertyChanged}"></TextBox>
</StackPanel>
</Border>
@@ -404,7 +357,7 @@
<Image Source="../Images/wind.png" Width="32"></Image>
<TextBlock VerticalAlignment="Center" Margin="5 0 0 0" FontSize="10">Winding Method</TextBlock>
</StackPanel>
- <ComboBox Width="90" HorizontalAlignment="Left" ItemsSource="{Binding Adapter.WindingMethods}" SelectedItem="{Binding SelectedJob.WindingMethod}" DisplayMemberPath="Name" ></ComboBox>
+ <ComboBox Width="90" HorizontalAlignment="Left" ItemsSource="{Binding Adapter.WindingMethods}" SelectedItem="{Binding ActiveJob.WindingMethod}" DisplayMemberPath="Name" ></ComboBox>
</StackPanel>
</Border>
@@ -415,8 +368,8 @@
<TextBlock VerticalAlignment="Center" Margin="5 0 0 0" FontSize="10">Inter Segment</TextBlock>
</StackPanel>
<DockPanel LastChildFill="True">
- <ToggleButton Margin="10 0 25 0" DockPanel.Dock="Right" VerticalAlignment="Bottom" HorizontalAlignment="Right" IsChecked="{Binding SelectedJob.EnableInterSegment}"></ToggleButton>
- <mahapps:NumericUpDown Width="70" HorizontalAlignment="Left" StringFormat="{}{0:N1} m" FontFamily="{StaticResource digital-7}" IsEnabled="{Binding SelectedJob.EnableInterSegment}" Margin="0 2 0 0" HideUpDownButtons="True" Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0 0 0 1" BorderBrush="DimGray" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding SelectedJob.InterSegmentLength,Mode=TwoWay}"></mahapps:NumericUpDown>
+ <ToggleButton Margin="10 0 25 0" DockPanel.Dock="Right" VerticalAlignment="Bottom" HorizontalAlignment="Right" IsChecked="{Binding ActiveJob.EnableInterSegment}"></ToggleButton>
+ <mahapps:NumericUpDown Width="70" HorizontalAlignment="Left" StringFormat="{}{0:N1} m" FontFamily="{StaticResource digital-7}" IsEnabled="{Binding ActiveJob.EnableInterSegment}" Margin="0 2 0 0" HideUpDownButtons="True" Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0 0 0 1" BorderBrush="DimGray" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding ActiveJob.InterSegmentLength,Mode=TwoWay}"></mahapps:NumericUpDown>
</DockPanel>
</StackPanel>
</Border>
@@ -428,7 +381,7 @@
<TextBlock VerticalAlignment="Center" Margin="5 0 0 0" FontSize="10">Lubrication</TextBlock>
</StackPanel>
<DockPanel LastChildFill="True" Margin="0 10 30 0">
- <ToggleButton DockPanel.Dock="Right" VerticalAlignment="Center" HorizontalAlignment="Center" IsChecked="{Binding SelectedJob.EnableLubrication}"></ToggleButton>
+ <ToggleButton DockPanel.Dock="Right" VerticalAlignment="Center" HorizontalAlignment="Center" IsChecked="{Binding ActiveJob.EnableLubrication}"></ToggleButton>
</DockPanel>
</StackPanel>
</Border>
@@ -441,7 +394,7 @@
</StackPanel>
<Border BorderThickness="0" BorderBrush="Silver" CornerRadius="5" Margin="0 0 5 5">
- <TextBox Padding="5 0 0 0" FontStyle="Italic" Background="Transparent" Style="{x:Null}" BorderThickness="0" Margin="5" Height="40" Text="{Binding SelectedJob.Description}" VerticalAlignment="Stretch" materialDesign:HintAssist.Hint="Enter description" AcceptsReturn="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto"></TextBox>
+ <TextBox Padding="5 0 0 0" FontStyle="Italic" Background="Transparent" Style="{x:Null}" BorderThickness="0" Margin="5" Height="40" Text="{Binding ActiveJob.Description}" VerticalAlignment="Stretch" materialDesign:HintAssist.Hint="Enter description" AcceptsReturn="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto"></TextBox>
</Border>
</StackPanel>
</Border>
@@ -619,7 +572,7 @@
</Rectangle>
</Grid>
<Grid Margin="0 10 10 0">
- <controls:MultiSelectListBox SelectionMode="Extended" Style="{x:Null}" Background="Transparent" ScrollViewer.CanContentScroll="False" BorderThickness="0" ItemsSource="{Binding SelectedSegment.BrushStops}" SelectedItem="{Binding SelectedBrushStop}" SelectedItemsList="{Binding SelectedBrushStops,Mode=TwoWay}" HorizontalContentAlignment="Stretch">
+ <controls:MultiSelectListBox SelectionMode="Extended" Style="{x:Null}" Background="Transparent" ScrollViewer.CanContentScroll="False" BorderThickness="0" ItemsSource="{Binding BrushStopsCollectionView}" SelectedItem="{Binding SelectedBrushStop}" SelectedItemsList="{Binding SelectedBrushStops,Mode=TwoWay}" HorizontalContentAlignment="Stretch">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource basicListBoxItem}">
@@ -1097,8 +1050,8 @@
<Grid>
<Grid.Width>
<MultiBinding Converter="{StaticResource SegmentLengthToWidthConverter}">
- <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.SelectedJob"></Binding>
- <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.SelectedJob.Length"></Binding>
+ <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.ActiveJob"></Binding>
+ <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.ActiveJob.Length"></Binding>
<Binding RelativeSource="{RelativeSource AncestorType=ItemsControl}" Path="ActualWidth"></Binding>
<Binding Path="Length"></Binding>
</MultiBinding>
@@ -1107,8 +1060,8 @@
<Rectangle.Fill>
<MultiBinding Converter="{StaticResource SegmentToBrushConverterMulti}">
<Binding Path="."></Binding>
- <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.SelectedJob"></Binding>
- <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.SelectedJob.Length"></Binding>
+ <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.ActiveJob"></Binding>
+ <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.ActiveJob.Length"></Binding>
<Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.SelectedBrushStop.Color"></Binding>
</MultiBinding>
</Rectangle.Fill>
@@ -1142,7 +1095,7 @@
<StackPanel Margin="0 -5 -20 0" HorizontalAlignment="Right">
<TextBlock FontSize="12" Foreground="Black">
- <Run Text="{Binding SelectedJob.Length,Mode=OneWay}"></Run>
+ <Run Text="{Binding ActiveJob.Length,Mode=OneWay}"></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 a030cf885..41886357b 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
@@ -55,18 +55,18 @@ namespace Tango.MachineStudio.Developer.Views
private void _jobBrushTimer_Tick(object sender, EventArgs e)
{
- if (_vm != null && _vm.SelectedJob != null)
+ if (_vm != null && _vm.ActiveJob != null)
{
List<Segment> segments = new List<Segment>();
- foreach (var s in _vm.SelectedJob.Segments)
+ foreach (var s in _vm.ActiveJob.Segments)
{
segments.Add(s);
- if (_vm.SelectedJob.EnableInterSegment && _vm.SelectedJob.Segments.IndexOf(s) != _vm.SelectedJob.Segments.Count - 1)
+ if (_vm.ActiveJob.EnableInterSegment && _vm.ActiveJob.Segments.IndexOf(s) != _vm.ActiveJob.Segments.Count - 1)
{
segments.Add(new Segment()
{
- Length = _vm.SelectedJob.InterSegmentLength,
+ Length = _vm.ActiveJob.InterSegmentLength,
BrushStops = new System.Collections.ObjectModel.ObservableCollection<BrushStop>()
{
new BrushStop()
@@ -136,5 +136,10 @@ namespace Tango.MachineStudio.Developer.Views
{
e.Handled = true;
}
+
+ private void OnSegmentDrop(object sender, DropEventArgs e)
+ {
+ _vm.OnDropSegment(e.Draggable.DataContext as Segment, e.Droppable.DataContext as Segment);
+ }
}
}
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 b8d423026..8881e4f57 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
@@ -116,7 +116,7 @@
</Grid>
<Grid Margin="0 20 0 0">
- <controls:MultiSelectDataGrid Style="{StaticResource {x:Type DataGrid}}" CanUserAddRows="False" CanUserDeleteRows="False" CanUserResizeColumns="True" CanUserSortColumns="True" AutoGenerateColumns="False" Background="Transparent" ItemsSource="{Binding SelectedMachine.Jobs}" SelectedItem="{Binding SelectedJob}" SelectedItemsList="{Binding SelectedJobs,Mode=TwoWay}">
+ <controls:MultiSelectDataGrid Style="{StaticResource {x:Type DataGrid}}" CanUserAddRows="False" CanUserDeleteRows="False" CanUserResizeColumns="True" CanUserSortColumns="True" AutoGenerateColumns="False" Background="Transparent" ItemsSource="{Binding JobsCollectionView}" SelectedItem="{Binding SelectedMachineJob}" SelectedItemsList="{Binding SelectedJobs,Mode=TwoWay}">
<DataGrid.CellStyle>
<Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
<Setter Property="BorderThickness" Value="0"/>
@@ -180,9 +180,6 @@
<Border.Background>
<MultiBinding Converter="{StaticResource SegmentToBrushConverterMulti}">
<Binding Path="."></Binding>
- <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.SelectedJob"></Binding>
- <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.SelectedJob.Length"></Binding>
- <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.SelectedBrushStop.Color"></Binding>
</MultiBinding>
</Border.Background>
</Border>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs
index e52a686bc..2bd36e449 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs
@@ -77,18 +77,18 @@ namespace Tango.MachineStudio.Developer.Views
private void _jobBrushTimer_Tick(object sender, EventArgs e)
{
- if (_vm != null && _vm.SelectedJob != null)
+ if (_vm != null && _vm.ActiveJob != null)
{
List<Segment> segments = new List<Segment>();
- foreach (var s in _vm.SelectedJob.Segments)
+ foreach (var s in _vm.ActiveJob.Segments)
{
segments.Add(s);
- if (_vm.SelectedJob.EnableInterSegment && _vm.SelectedJob.Segments.IndexOf(s) != _vm.SelectedJob.Segments.Count - 1)
+ if (_vm.ActiveJob.EnableInterSegment && _vm.ActiveJob.Segments.IndexOf(s) != _vm.ActiveJob.Segments.Count - 1)
{
segments.Add(new Segment()
{
- Length = _vm.SelectedJob.InterSegmentLength,
+ Length = _vm.ActiveJob.InterSegmentLength,
BrushStops = new System.Collections.ObjectModel.ObservableCollection<BrushStop>()
{
new BrushStop()
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml
index 691fa6987..4d75651f7 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml
@@ -81,16 +81,16 @@
<Rectangle Stroke="Gray" VerticalAlignment="Top" StrokeThickness="1" StrokeDashArray="5" RenderTransformOrigin="0.5,0.5"/>
</Grid>
- <Button Command="{Binding AddIdsCommand}" Style="{StaticResource MaterialDesignFlatButton}" Height="24" Width="24" Padding="0" Canvas.Left="402" Canvas.Top="253">
+ <Button Style="{StaticResource MaterialDesignFlatButton}" Height="24" Width="24" Padding="0" Canvas.Left="402" Canvas.Top="253">
<materialDesign:PackIcon Kind="Plus" Width="24" Height="24"></materialDesign:PackIcon>
</Button>
- <Button Command="{Binding RemoveIdsCommand}" Style="{StaticResource MaterialDesignFlatButton}" Height="24" Width="24" Padding="0" Canvas.Left="430" Canvas.Top="252">
+ <Button Style="{StaticResource MaterialDesignFlatButton}" Height="24" Width="24" Padding="0" Canvas.Left="430" Canvas.Top="252">
<materialDesign:PackIcon Kind="Minus" Width="24" Height="24"></materialDesign:PackIcon>
</Button>
<Grid x:Name="gridIds" Width="310" Height="195" Canvas.Top="314" Canvas.Left="420">
- <ListBox ItemsSource="{Binding Configuration.IdsPacks}" SelectedItem="{Binding SelectedIds}" ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
+ <ListBox ItemsSource="{Binding Configuration.IdsPacks}" ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Setter Property="Padding" Value="0"></Setter>
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml
index 9c7a869b7..ca0685f3c 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/MaterialDesign.xaml
@@ -1,8 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters;assembly=MaterialDesignThemes.Wpf"
+ xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters;assembly=MaterialDesignThemes.Wpf"
xmlns:editors="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete"
- xmlns:sys="clr-namespace:System;assembly=mscorlib"
+ xmlns:dragAndDrop="clr-namespace:Tango.DragAndDrop;assembly=Tango.DragAndDrop"
+ xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:local="clr-namespace:Tango.MachineStudio.Common.Resources">
<ResourceDictionary.MergedDictionaries>
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
@@ -392,7 +393,87 @@
</Style>
-
+ <!--Drag & Drop-->
+ <Style x:Key="draggableGrid" TargetType="Grid">
+ <Setter Property="RenderTransform">
+ <Setter.Value>
+ <ScaleTransform ScaleX="1" ScaleY="1"></ScaleTransform>
+ </Setter.Value>
+ </Setter>
+ <Setter Property="RenderTransformOrigin" Value="0.5,0.5"></Setter>
+ <Setter Property="Background" Value="Transparent"></Setter>
+ <Setter Property="dragAndDrop:DragAndDropService.Draggable" Value="True"></Setter>
+ <Setter Property="dragAndDrop:DragAndDropService.DraggingSurface" Value="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DraggingSurface}"></Setter>
+ </Style>
+
+ <Style x:Key="droppableGrid" TargetType="Grid">
+ <Setter Property="RenderTransform">
+ <Setter.Value>
+ <ScaleTransform ScaleX="1" ScaleY="1"></ScaleTransform>
+ </Setter.Value>
+ </Setter>
+ <Setter Property="RenderTransformOrigin" Value="0.5,0.5"></Setter>
+ <Setter Property="Background" Value="Transparent"></Setter>
+ <Setter Property="dragAndDrop:DragAndDropService.Droppable" Value="True"></Setter>
+ <Setter Property="dragAndDrop:DragAndDropService.DraggingSurface" Value="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DraggingSurface}"></Setter>
+ <Style.Triggers>
+ <Trigger Property="dragAndDrop:DragAndDropService.IsDraggableOver" Value="True">
+ <Setter Property="Opacity" Value="0.5"></Setter>
+ <Trigger.EnterActions>
+ <BeginStoryboard>
+ <Storyboard>
+ <DoubleAnimation To="0.95" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleX"></DoubleAnimation>
+ <DoubleAnimation To="0.95" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleY"></DoubleAnimation>
+ </Storyboard>
+ </BeginStoryboard>
+ </Trigger.EnterActions>
+ <Trigger.ExitActions>
+ <BeginStoryboard>
+ <Storyboard>
+ <DoubleAnimation To="1" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleX"></DoubleAnimation>
+ <DoubleAnimation To="1" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleY"></DoubleAnimation>
+ </Storyboard>
+ </BeginStoryboard>
+ </Trigger.ExitActions>
+ </Trigger>
+ </Style.Triggers>
+ </Style>
+
+ <Style x:Key="draggableDroppableGrid" TargetType="Grid">
+ <Setter Property="RenderTransform">
+ <Setter.Value>
+ <ScaleTransform ScaleX="1" ScaleY="1"></ScaleTransform>
+ </Setter.Value>
+ </Setter>
+ <Setter Property="RenderTransformOrigin" Value="0.5,0.5"></Setter>
+ <Setter Property="Background" Value="Transparent"></Setter>
+ <Setter Property="dragAndDrop:DragAndDropService.Draggable" Value="True"></Setter>
+ <Setter Property="dragAndDrop:DragAndDropService.Droppable" Value="True"></Setter>
+ <Setter Property="dragAndDrop:DragAndDropService.DraggingSurface" Value="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DraggingSurface}"></Setter>
+ <Style.Triggers>
+ <Trigger Property="dragAndDrop:DragAndDropService.IsDraggableOver" Value="True">
+ <Setter Property="Opacity" Value="0.5"></Setter>
+ <Trigger.EnterActions>
+ <BeginStoryboard>
+ <Storyboard>
+ <DoubleAnimation To="0.95" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleX"></DoubleAnimation>
+ <DoubleAnimation To="0.95" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleY"></DoubleAnimation>
+ </Storyboard>
+ </BeginStoryboard>
+ </Trigger.EnterActions>
+ <Trigger.ExitActions>
+ <BeginStoryboard>
+ <Storyboard>
+ <DoubleAnimation To="1" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleX"></DoubleAnimation>
+ <DoubleAnimation To="1" Duration="00:00:0.2" Storyboard.TargetProperty="RenderTransform.ScaleY"></DoubleAnimation>
+ </Storyboard>
+ </BeginStoryboard>
+ </Trigger.ExitActions>
+ </Trigger>
+ </Style.Triggers>
+ </Style>
+ <!--Drag & Drop-->
+
<!--Extensions-->
</ResourceDictionary>
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj
index 7e0ef2eb5..cd4fc1aeb 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj
@@ -185,6 +185,10 @@
<Project>{38197109-8610-4d3f-92b9-16d48df94d7c}</Project>
<Name>Tango.DAL.Remote</Name>
</ProjectReference>
+ <ProjectReference Include="..\..\Tango.DragAndDrop\Tango.DragAndDrop.csproj">
+ <Project>{b112d89a-a106-41ae-a0c1-4abc84c477f5}</Project>
+ <Name>Tango.DragAndDrop</Name>
+ </ProjectReference>
<ProjectReference Include="..\..\Tango.Editors\Tango.Editors.csproj">
<Project>{de2f2b86-025b-4f26-83a4-38bd48224ed5}</Project>
<Name>Tango.Editors</Name>
diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs
index d7161953f..948be3c4a 100644
--- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs
+++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs
@@ -41,5 +41,18 @@ public static class ObservableCollectionExtensions
collection[index1] = collection[index2];
collection[index2] = tmp;
}
+
+ /// <summary>
+ /// Removes the dragged element and inserts it after the dropped element position.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="collection">The collection.</param>
+ /// <param name="dragged">The dragged element.</param>
+ /// <param name="dropped">The dropped element.</param>
+ public static void DragAndDrop<T>(this ObservableCollection<T> collection, T dragged, T dropped)
+ {
+ collection.Remove(dragged);
+ collection.Insert(collection.IndexOf(dropped), dragged);
+ }
}
diff --git a/Software/Visual_Studio/Tango.Integration/Observables/IObservableEntity.cs b/Software/Visual_Studio/Tango.Integration/Observables/IObservableEntity.cs
index eb16d150d..15fb521ba 100644
--- a/Software/Visual_Studio/Tango.Integration/Observables/IObservableEntity.cs
+++ b/Software/Visual_Studio/Tango.Integration/Observables/IObservableEntity.cs
@@ -54,12 +54,12 @@ namespace Tango.Integration.Observables
/// <summary>
/// Attaches this observable to the proper DbSet.
/// </summary>
- void Attach();
+ void Attach(ObservablesContext context = null);
/// <summary>
/// Detaches this observable from the proper DbSet.
/// </summary>
- void Detach();
+ void Detach(ObservablesContext context = null);
/// <summary>
/// Saves the changes on this entity to database asynchronously.
@@ -76,12 +76,12 @@ namespace Tango.Integration.Observables
/// <summary>
/// Deletes this entity from the database.
/// </summary>
- void Delete();
+ void Delete(ObservablesContext context = null);
/// <summary>
/// Deletes this entity without saving changes to data base.
/// </summary>
- void DefferedDelete();
+ void DefferedDelete(ObservablesContext context = null);
/// <summary>
/// Deletes this entity from the database.
diff --git a/Software/Visual_Studio/Tango.Integration/Observables/ObservableEntity.cs b/Software/Visual_Studio/Tango.Integration/Observables/ObservableEntity.cs
index d5b218453..f92d9dfa0 100644
--- a/Software/Visual_Studio/Tango.Integration/Observables/ObservableEntity.cs
+++ b/Software/Visual_Studio/Tango.Integration/Observables/ObservableEntity.cs
@@ -44,6 +44,7 @@ namespace Tango.Integration.Observables
/// Gets or sets the entity identifier.
/// </summary>
[Column("ID")]
+ [JsonIgnore]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public Int32 ID
{
@@ -57,6 +58,7 @@ namespace Tango.Integration.Observables
/// </summary>
[Key]
[Column("GUID")]
+ [JsonIgnore]
public String Guid
{
get { return _guid; }
@@ -121,17 +123,17 @@ namespace Tango.Integration.Observables
/// <summary>
/// Attaches this entity to the proper DbSet.
/// </summary>
- public virtual void Attach()
+ public virtual void Attach(ObservablesContext context = null)
{
- GetDbSet().Add(this as T);
+ GetDbSet(context).Add(this as T);
}
/// <summary>
/// Detaches this observable from the proper DbSet.
/// </summary>
- public virtual void Detach()
+ public virtual void Detach(ObservablesContext context = null)
{
- GetDbSet().Remove(this as T);
+ GetDbSet(context).Remove(this as T);
}
/// <summary>
@@ -150,15 +152,15 @@ namespace Tango.Integration.Observables
/// Reloads this observable entity.
/// </summary>
/// <returns></returns>
- public Task Reload()
+ public Task Reload(ObservablesContext context)
{
- return ObservablesEntitiesAdapter.Instance.Context.Entry(this).ReloadAsync();
+ return context.Entry(this).ReloadAsync();
}
/// <summary>
/// Deletes this entity from the database
/// </summary>
- public virtual void Delete()
+ public virtual void Delete(ObservablesContext context = null)
{
var delProp = this.GetType().GetProperty("Deleted");
@@ -169,7 +171,7 @@ namespace Tango.Integration.Observables
}
else
{
- GetDbSet().Remove(this as T);
+ GetDbSet(context).Remove(this as T);
Save();
}
}
@@ -177,9 +179,9 @@ namespace Tango.Integration.Observables
/// <summary>
/// Deletes this entity without saving changes to data base.
/// </summary>
- public virtual void DefferedDelete()
+ public virtual void DefferedDelete(ObservablesContext context = null)
{
- GetDbSet().Remove(this as T);
+ GetDbSet(context).Remove(this as T);
}
/// <summary>
@@ -193,17 +195,15 @@ namespace Tango.Integration.Observables
});
}
- /// <summary>
- /// Gets the observable database set.
- /// </summary>
- /// <returns></returns>
- public DbSet<T> GetDbSet()
+ public DbSet<T> GetDbSet(ObservablesContext context)
{
+ context = context != null ? context : ObservablesEntitiesAdapter.Instance.Context;
+
String tabelName = this.GetType().Name.PluralizeMVC();
var p = typeof(ObservablesContext).GetProperty(tabelName);
if (p != null)
{
- var set1 = p.GetValue(ObservablesEntitiesAdapter.Instance.Context) as DbSet<T>;
+ var set1 = p.GetValue(context) as DbSet<T>;
return set1;
}
else
@@ -212,7 +212,7 @@ namespace Tango.Integration.Observables
p = typeof(ObservablesContext).GetProperty(tabelName);
if (p != null)
{
- var set2 = p.GetValue(ObservablesEntitiesAdapter.Instance.Context) as DbSet<T>;
+ var set2 = p.GetValue(context) as DbSet<T>;
return set2;
}
}
diff --git a/Software/Visual_Studio/Tango.Integration/Observables/Partials/Configuration.cs b/Software/Visual_Studio/Tango.Integration/Observables/Partials/Configuration.cs
index c60102671..3622169c9 100644
--- a/Software/Visual_Studio/Tango.Integration/Observables/Partials/Configuration.cs
+++ b/Software/Visual_Studio/Tango.Integration/Observables/Partials/Configuration.cs
@@ -8,21 +8,21 @@ namespace Tango.Integration.Observables
{
public partial class Configuration
{
- public override void DefferedDelete()
+ public override void DefferedDelete(ObservablesContext context = null)
{
- IdsPacks.ToList().ForEach(x => x.DefferedDelete());
+ IdsPacks.ToList().ForEach(x => x.DefferedDelete(context));
var machine_configurations = ObservablesEntitiesAdapter.Instance.MachinesConfigurations.Where(x => x.Configuration == this);
- MachinesConfigurations.ToList().ForEach(x => x.DefferedDelete());
- base.DefferedDelete();
+ MachinesConfigurations.ToList().ForEach(x => x.DefferedDelete(context));
+ base.DefferedDelete(context);
IdsPacks.Clear();
}
- public override void Delete()
+ public override void Delete(ObservablesContext context = null)
{
- IdsPacks.ToList().ForEach(x => x.DefferedDelete());
+ IdsPacks.ToList().ForEach(x => x.DefferedDelete(context));
var machine_configurations = ObservablesEntitiesAdapter.Instance.MachinesConfigurations.Where(x => x.Configuration == this);
- MachinesConfigurations.ToList().ForEach(x => x.DefferedDelete());
- base.Delete();
+ MachinesConfigurations.ToList().ForEach(x => x.DefferedDelete(context));
+ base.Delete(context);
IdsPacks.Clear();
}
}
diff --git a/Software/Visual_Studio/Tango.Integration/Observables/Partials/Machine.cs b/Software/Visual_Studio/Tango.Integration/Observables/Partials/Machine.cs
index 850003e60..bb26acc39 100644
--- a/Software/Visual_Studio/Tango.Integration/Observables/Partials/Machine.cs
+++ b/Software/Visual_Studio/Tango.Integration/Observables/Partials/Machine.cs
@@ -12,7 +12,7 @@ namespace Tango.Integration.Observables
/// <summary>
/// Deletes this entity from the database
/// </summary>
- public override void Delete()
+ public override void Delete(ObservablesContext context = null)
{
foreach (var machine_config in MachinesConfigurations)
{
diff --git a/Software/Visual_Studio/Tango.Integration/Observables/Partials/MachineVersion.cs b/Software/Visual_Studio/Tango.Integration/Observables/Partials/MachineVersion.cs
index c7d1f8321..18799b7ed 100644
--- a/Software/Visual_Studio/Tango.Integration/Observables/Partials/MachineVersion.cs
+++ b/Software/Visual_Studio/Tango.Integration/Observables/Partials/MachineVersion.cs
@@ -8,7 +8,7 @@ namespace Tango.Integration.Observables
{
public partial class MachineVersion
{
- public override void Delete()
+ public override void Delete(ObservablesContext context = null)
{
this.DefaultConfiguration.Delete();
base.Delete();
diff --git a/Software/Visual_Studio/Tango.Integration/Printing/BrushStop.cs b/Software/Visual_Studio/Tango.Integration/Printing/BrushStop.cs
index ebc77e615..ae8aa0e37 100644
--- a/Software/Visual_Studio/Tango.Integration/Printing/BrushStop.cs
+++ b/Software/Visual_Studio/Tango.Integration/Printing/BrushStop.cs
@@ -37,7 +37,6 @@ namespace Tango.Integration.Observables
set { _liquidVolumes = value; RaisePropertyChangedAuto(); }
}
- private Color _color;
/// <summary>
/// Gets or sets the brush stop color.
/// </summary>
@@ -45,13 +44,12 @@ namespace Tango.Integration.Observables
[JsonIgnore]
public Color Color
{
- get { return _color; }
+ get { return Color.FromRgb((byte)_red, (byte)_green,(byte)_blue); }
set
{
- _color = value;
- _red = _color.R;
- _green = _color.G;
- _blue = _color.B;
+ _red = value.R;
+ _green = value.G;
+ _blue = value.B;
RaisePropertyChanged(nameof(Color));
}
}
@@ -62,7 +60,7 @@ namespace Tango.Integration.Observables
[NotMapped]
public int Index
{
- get { return Segment.BrushStops.IndexOf(this); }
+ get { return StopIndex; }
}
/// <summary>
@@ -72,7 +70,7 @@ namespace Tango.Integration.Observables
[JsonIgnore]
public bool IsFirst
{
- get { return Segment.BrushStops.IndexOf(this) == 0; }
+ get { return StopIndex == 0; }
}
/// <summary>
@@ -82,7 +80,7 @@ namespace Tango.Integration.Observables
[JsonIgnore]
public bool IsLast
{
- get { return Segment.BrushStops.IndexOf(this) == Segment.BrushStops.Count - 1; }
+ get { return StopIndex == Segment.BrushStops.Count - 1; }
}
/// <summary>
@@ -146,6 +144,16 @@ namespace Tango.Integration.Observables
}
}
+ public void SetStopIndex(int index)
+ {
+ _stopindex = index;
+ }
+
+ public void RaiseStopIndex()
+ {
+ StopIndex = _stopindex;
+ }
+
#endregion
#region Override Methods
@@ -229,8 +237,6 @@ namespace Tango.Integration.Observables
_l = lab.L;
_a = lab.A;
_b = lab.B;
-
- _color = Color.FromRgb((byte)_red, (byte)_green, (byte)_blue);
}
#endregion
diff --git a/Software/Visual_Studio/Tango.Integration/Printing/Job.cs b/Software/Visual_Studio/Tango.Integration/Printing/Job.cs
index 1cc4865f2..49c5fbdae 100644
--- a/Software/Visual_Studio/Tango.Integration/Printing/Job.cs
+++ b/Software/Visual_Studio/Tango.Integration/Printing/Job.cs
@@ -124,7 +124,7 @@ namespace Tango.Integration.Observables
{
for (int i = 0; i < Segments.Count; i++)
{
- Segments[i].SegmentIndex = i;
+ Segments[i].SegmentIndex = i + 1;
for (int j = 0; j < Segments[i].BrushStops.Count; j++)
{
@@ -146,11 +146,11 @@ namespace Tango.Integration.Observables
return cloned;
}
- public override void DefferedDelete()
+ public override void DefferedDelete(ObservablesContext context = null)
{
- Segments.ToList().ForEach(x => x.DefferedDelete());
+ Segments.ToList().ForEach(x => x.DefferedDelete(context));
Segments.Clear();
- base.DefferedDelete();
+ base.DefferedDelete(context);
}
#endregion
diff --git a/Software/Visual_Studio/Tango.Integration/Printing/Segment.cs b/Software/Visual_Studio/Tango.Integration/Printing/Segment.cs
index 6213240ed..d3e50ec37 100644
--- a/Software/Visual_Studio/Tango.Integration/Printing/Segment.cs
+++ b/Software/Visual_Studio/Tango.Integration/Printing/Segment.cs
@@ -68,11 +68,11 @@ namespace Tango.Integration.Observables
return cloned;
}
- public override void DefferedDelete()
+ public override void DefferedDelete(ObservablesContext context = null)
{
- BrushStops.ToList().ForEach(x => x.DefferedDelete());
+ BrushStops.ToList().ForEach(x => x.DefferedDelete(context));
BrushStops.Clear();
- base.DefferedDelete();
+ base.DefferedDelete(context);
}
}
}