aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-08-01 11:47:10 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-08-01 11:47:10 +0300
commit00cfb0906e164487efed62bd6a65cdf681952bd1 (patch)
treee5bc283226a0f758d63da4c05f761ce7801ac36e /Software/Visual_Studio/MachineStudio
parentd5c6067365e12674e95acaef4c4af45eaead8c3e (diff)
downloadTango-00cfb0906e164487efed62bd6a65cdf681952bd1.tar.gz
Tango-00cfb0906e164487efed62bd6a65cdf681952bd1.zip
Implemented reloading of color lab module and research module when machine designer changes machine !
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs22
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs27
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MachineJobSelectionView.xaml26
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs141
4 files changed, 133 insertions, 83 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs
index 688f90817..5b317e6d2 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs
@@ -425,6 +425,26 @@ namespace Tango.MachineStudio.ColorLab.ViewModels
}).ToObservableCollection();
LiquidVolumes.ToList().ForEach(x => x.VolumeChanged += (s, e) => OnLiquidVolumeChanged());
+
+ InvalidateLiquidFactorsCalibrationData();
+
+ SelectedMachine.Modified -= SelectedMachine_Modified;
+ SelectedMachine.Modified += SelectedMachine_Modified;
+ }
+ }
+
+ private void SelectedMachine_Modified(object sender, ObservableModifiedEventArgs e)
+ {
+ if (e.IsOtherContext)
+ {
+ InvokeUI(async () =>
+ {
+ if (SelectedMachine != null)
+ {
+ await SelectedMachine.Reload(_dbContext);
+ OnSelectedMachineChanged();
+ }
+ });
}
}
@@ -433,7 +453,7 @@ namespace Tango.MachineStudio.ColorLab.ViewModels
try
{
if (LiquidsCalibrationData == null || _prevent_inverse_conversion) return;
-
+
//TODO: This is temporary because of out of range volumes.
if (LiquidVolumes.Where(x => x.IdsPack.IdsPackFormula.Code == IdsPackFormulas.StandardColor.ToInt32()).Sum(x => x.Volume) > 200)
{
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 9ac78ccec..569359066 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
@@ -180,8 +180,8 @@ namespace Tango.MachineStudio.Developer.ViewModels
if (_selectedMachine != null)
{
- _selectedMachine.Modified -= SelectedMachine_Saved;
- _selectedMachine.Modified += SelectedMachine_Saved;
+ _selectedMachine.Modified -= SelectedMachine_Modified;
+ _selectedMachine.Modified += SelectedMachine_Modified;
}
}
}
@@ -627,6 +627,11 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// Gets or sets the display job embroidery file command.
/// </summary>
public RelayCommand<Job> DisplayJobEmbroideryFileCommand { get; set; }
+
+ /// <summary>
+ /// Gets or sets the reload machines command.
+ /// </summary>
+ public RelayCommand ReloadMachinesCommand { get; set; }
#endregion
#region Constructors
@@ -703,6 +708,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
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);
+ ReloadMachinesCommand = new RelayCommand(ReloadMachine);
ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged;
@@ -850,10 +856,21 @@ 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 SelectedMachine_Saved(object sender, EventArgs e)
+ private void SelectedMachine_Modified(object sender, ObservableModifiedEventArgs e)
{
- InvalidateLiquidFactorsAndProcessTables();
- SelectedMachine.Reload(_machineDbContext);
+ if (e.IsOtherContext)
+ {
+ InvokeUI(() =>
+ {
+ SelectedMachine.Reload(_machineDbContext);
+ InvalidateLiquidFactorsAndProcessTables();
+
+ if (SelectedSegment != null)
+ {
+ OnSelectedSegmentChanged();
+ }
+ });
+ }
}
/// <summary>
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 4593ef259..c151b62bc 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
@@ -35,16 +35,22 @@
<Grid Background="#B1FFFFFF">
<StackPanel>
<TextBlock Margin="40 20" FontSize="30" FontWeight="SemiBold" FontStyle="Italic">TARGET MACHINE</TextBlock>
- <ComboBox ItemsSource="{Binding Machines}" FontSize="20" SelectedItem="{Binding SelectedMachine}" materialDesign:HintAssist.Hint="Serial Number" Margin="40 0 40 0">
- <ComboBox.ItemTemplate>
- <DataTemplate>
- <StackPanel>
- <TextBlock Text="{Binding SerialNumber}" FontWeight="Bold" FontStyle="Italic"></TextBlock>
- <TextBlock FontSize="11" Text="{Binding Name}" Foreground="Gray"></TextBlock>
- </StackPanel>
- </DataTemplate>
- </ComboBox.ItemTemplate>
- </ComboBox>
+
+ <DockPanel Margin="40 0 40 0">
+ <Button Command="{Binding ReloadMachinesCommand}" DockPanel.Dock="Right" ToolTip="Reload" Foreground="#404040" Margin="20 0 0 0" Padding="0" Width="40" Height="Auto" Style="{StaticResource MaterialDesignFlatButton}">
+ <materialDesign:PackIcon Kind="Refresh" Width="24" Height="24" />
+ </Button>
+ <ComboBox ItemsSource="{Binding Machines}" FontSize="20" SelectedItem="{Binding SelectedMachine}" materialDesign:HintAssist.Hint="Serial Number">
+ <ComboBox.ItemTemplate>
+ <DataTemplate>
+ <StackPanel>
+ <TextBlock Text="{Binding SerialNumber}" FontWeight="Bold" FontStyle="Italic"></TextBlock>
+ <TextBlock FontSize="11" Text="{Binding Name}" Foreground="Gray"></TextBlock>
+ </StackPanel>
+ </DataTemplate>
+ </ComboBox.ItemTemplate>
+ </ComboBox>
+ </DockPanel>
<designer:MachineView Width="600" IsHitTestVisible="False" Margin="0 40 0 0" DataContext="{Binding SelectedMachine}" />
<Button Command="{Binding EditMachineCommand}" HorizontalAlignment="Right" Margin="0 10 20 20" Style="{StaticResource MaterialDesignFlatButton}">
<StackPanel Orientation="Horizontal">
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs
index 99a6174a8..8d5981322 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs
@@ -28,12 +28,12 @@ namespace Tango.MachineStudio.UI
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
- public partial class App : Application
+ public partial class App : Application
{
private WpfGlobalExceptionTrapper exceptionTrapper;
private LogManager LogManager = LogManager.Default;
- protected override void OnStartup(StartupEventArgs e)
+ protected override void OnStartup(StartupEventArgs e)
{
#if DEBUG
@@ -84,90 +84,97 @@ namespace Tango.MachineStudio.UI
{
try
{
- if (Application.Current == null)
+ try
{
- new Application { ShutdownMode = ShutdownMode.OnExplicitShutdown };
+ if (Application.Current == null)
+ {
+ new Application { ShutdownMode = ShutdownMode.OnExplicitShutdown };
+ }
}
- }
- catch { }
+ catch { }
- try
- {
- var eventLogger = TangoIOC.Default.GetInstance<IEventLogger>();
- if (eventLogger != null)
+ try
{
- eventLogger.Log(e.Exception, "Application Crashed!");
+ var eventLogger = TangoIOC.Default.GetInstance<IEventLogger>();
+ if (eventLogger != null)
+ {
+ eventLogger.Log(e.Exception, "Application Crashed!");
+ }
}
- }
- catch { }
-
- Application.Current.Dispatcher.Invoke(() =>
- {
- WorkItem bug = null;
- TeamFoundationServiceExtendedClient tfsClient = null;
- INotificationProvider notification = null;
+ catch { }
- try
+ Application.Current.Dispatcher.Invoke(() =>
{
- tfsClient = TangoIOC.Default.GetInstance<TeamFoundationServiceExtendedClient>();
- notification = TangoIOC.Default.GetInstance<INotificationProvider>();
+ WorkItem bug = null;
+ TeamFoundationServiceExtendedClient tfsClient = null;
+ INotificationProvider notification = null;
+
+ try
+ {
+ tfsClient = TangoIOC.Default.GetInstance<TeamFoundationServiceExtendedClient>();
+ notification = TangoIOC.Default.GetInstance<INotificationProvider>();
- if (tfsClient != null && tfsClient.IsInitialized)
+ if (tfsClient != null && tfsClient.IsInitialized)
+ {
+ bug = tfsClient.CreateBug();
+ }
+ }
+ catch (Exception ex)
{
- bug = tfsClient.CreateBug();
+ Debug.WriteLine(ex.ToString());
}
- }
- catch (Exception ex)
- {
- Debug.WriteLine(ex.ToString());
- }
- ExceptionWindow exWin = new ExceptionWindow(e.Exception, bug != null);
- exWin.ShowDialog();
+ ExceptionWindow exWin = new ExceptionWindow(e.Exception, bug != null);
+ exWin.ShowDialog();
- switch (exWin.Resolution)
- {
- case ExceptionResolutions.Ignore:
- e.TryRecover = true;
- break;
- case ExceptionResolutions.Restart:
- e.TryRecover = false;
- LogManager.Log("User selection was to restart the application. Restarting...");
- Process.Start(Application.ResourceAssembly.Location);
- Environment.Exit(0);
- break;
- case ExceptionResolutions.Shutdown:
- e.TryRecover = false;
- LogManager.Log("User selection was to shutdown the application. Restarting...");
- Environment.Exit(0);
- break;
- case ExceptionResolutions.Report:
- e.TryRecover = true;
- LogManager.Log("User selection was to report the issue.");
+ switch (exWin.Resolution)
+ {
+ case ExceptionResolutions.Ignore:
+ e.TryRecover = true;
+ break;
+ case ExceptionResolutions.Restart:
+ e.TryRecover = false;
+ LogManager.Log("User selection was to restart the application. Restarting...");
+ Process.Start(Application.ResourceAssembly.Location);
+ Environment.Exit(0);
+ break;
+ case ExceptionResolutions.Shutdown:
+ e.TryRecover = false;
+ LogManager.Log("User selection was to shutdown the application. Restarting...");
+ Environment.Exit(0);
+ break;
+ case ExceptionResolutions.Report:
+ e.TryRecover = true;
+ LogManager.Log("User selection was to report the issue.");
- if (bug != null)
- {
- notification.ShowModalDialog<ReportIssueViewVM, ReportIssueView>(new ReportIssueViewVM(tfsClient.Project, bug), async (vm) =>
+ if (bug != null)
{
- using (notification.PushTaskItem("Uploading bug report..."))
+ notification.ShowModalDialog<ReportIssueViewVM, ReportIssueView>(new ReportIssueViewVM(tfsClient.Project, bug), async (vm) =>
{
- try
+ using (notification.PushTaskItem("Uploading bug report..."))
{
- tfsClient.FinalizeBug(vm.WorkItem);
- await tfsClient.UploadWorkItem(vm.WorkItem);
+ try
+ {
+ tfsClient.FinalizeBug(vm.WorkItem);
+ await tfsClient.UploadWorkItem(vm.WorkItem);
+ }
+ catch (Exception ex)
+ {
+ notification.ShowError("An error occurred while trying to create the issue." + Environment.NewLine + ex.Message);
+ }
}
- catch (Exception ex)
- {
- notification.ShowError("An error occurred while trying to create the issue." + Environment.NewLine + ex.Message);
- }
- }
- }, null);
- }
+ }, null);
+ }
- break;
- }
- });
+ break;
+ }
+ });
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error in global exception trapper!");
+ }
}
#endregion