From 9da3e0256092cc21398bda66b96b996a0de55dd3 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Tue, 13 Jul 2021 12:21:32 +0300 Subject: RML Extension changes --- .../Converters/ComboBoxVisibleConverter.cs | 30 ++ .../Tango.MachineStudio.ThreadExtensions.csproj | 18 ++ .../ViewModelLocator.cs | 9 + .../ViewModels/AddItemDialogVM.cs | 45 +++ .../ViewModels/MainViewVM.cs | 339 +++++++++++++++++---- .../ViewModels/TestResultsViewVM.cs | 26 +- .../Views/AddItemDialog.xaml | 21 ++ .../Views/AddItemDialog.xaml.cs | 28 ++ .../Views/ComboboxEditable.xaml | 39 +++ .../Views/ComboboxEditable.xaml.cs | 89 ++++++ .../Views/RMLExtensionView.xaml | 10 + .../Views/RMLExtensionsView.xaml | 38 +-- .../Views/ThreadCharacteristicsView.xaml | 121 ++++++-- 13 files changed, 691 insertions(+), 122 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Converters/ComboBoxVisibleConverter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/AddItemDialogVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/AddItemDialog.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/AddItemDialog.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ComboboxEditable.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ComboboxEditable.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Converters/ComboBoxVisibleConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Converters/ComboBoxVisibleConverter.cs new file mode 100644 index 000000000..015290448 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Converters/ComboBoxVisibleConverter.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.BL.Enumerations; + +namespace Tango.MachineStudio.ThreadExtensions.Converters +{ + public class ComboBoxVisibleConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if(value is RMLExtensionStatus) + { + RMLExtensionStatus enumerationMember = (RMLExtensionStatus)value; + if (enumerationMember == RMLExtensionStatus.New) + return true; + } + return false; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj index 1c9ac345b..e700de3d3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj @@ -66,7 +66,9 @@ + + ..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll @@ -91,19 +93,27 @@ + + + + AddItemDialog.xaml + ColorParametersView.xaml + + ComboboxEditable.xaml + MachineTestResultsView.xaml @@ -127,10 +137,18 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModelLocator.cs index bd1b1dcb2..596332f8d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModelLocator.cs @@ -16,6 +16,7 @@ namespace Tango.MachineStudio.ThreadExtensions static ViewModelLocator() { TangoIOC.Default.Register(); + TangoIOC.Default.Register(); } public static MainViewVM MainViewVM @@ -25,5 +26,13 @@ namespace Tango.MachineStudio.ThreadExtensions return TangoIOC.Default.GetInstance(); } } + + public static AddItemDialogVM AddItemDialogVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/AddItemDialogVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/AddItemDialogVM.cs new file mode 100644 index 000000000..0187f3bee --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/AddItemDialogVM.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.SharedUI; + +namespace Tango.MachineStudio.ThreadExtensions.ViewModels +{ + public class AddItemDialogVM : DialogViewVM + { + private string _name; + + public string Name + { + get { return _name; } + set { _name = value; + RaisePropertyChangedAuto(); + SaveCommand.RaiseCanExecuteChanged(); + } + } + + + /// + /// Gets or sets the login command. + /// + public RelayCommand SaveCommand { get; set; } + + /// + /// Gets or sets the cancel command. + /// + public RelayCommand CancelCommand { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public AddItemDialogVM() + { + SaveCommand = new RelayCommand(Accept, () => false == String.IsNullOrEmpty(Name)); + CancelCommand = new RelayCommand(Cancel); + } + + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs index 09befb26f..928102f12 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs @@ -35,7 +35,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels private INotificationProvider _notification; private IAuthenticationProvider _authentication; private IActionLogManager _actionLogManager; - + private ObservablesContext _rmlExtentions_context; private ObservablesContext _active_context; @@ -86,19 +86,19 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels InvalidateRelayCommands(); } } - private ICollectionView _rmlExtCollectionView; - /// - /// Gets or sets the RML collection view. - /// - public ICollectionView RmlExtCollectionView - { - get { return _rmlExtCollectionView; } - set - { - _rmlExtCollectionView = value; - RaisePropertyChangedAuto(); - } - } + //private ICollectionView _rmlExtCollectionView; + ///// + ///// Gets or sets the RML collection view. + ///// + //public ICollectionView RmlExtCollectionView + //{ + // get { return _rmlExtCollectionView; } + // set + // { + // _rmlExtCollectionView = value; + // RaisePropertyChangedAuto(); + // } + //} private ObservableCollection _applications; public ObservableCollection Applications @@ -161,13 +161,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels get { return _group; } set { _group = value; RaisePropertyChangedAuto(); } } - - //private ObservableCollection _manufacturer; - //public ObservableCollection Manufacturer - //{ - // get { return _manufacturer; } - // set { _manufacturer = value; RaisePropertyChangedAuto(); } - //} + private List _manufacturers; public List Manufacturers @@ -185,7 +179,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels get { return _materials; } set { _materials = value; RaisePropertyChangedAuto(); } } - + private ObservableCollection _subFamilies; public ObservableCollection SubFamilies { @@ -213,7 +207,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels get { return _industrySector; } set { _industrySector = value; RaisePropertyChangedAuto(); } } - + private String _Filter; /// /// Gets or sets the search filter. @@ -243,11 +237,11 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels set { _testResultsViewVM = value; RaisePropertyChangedAuto(); } } - protected Machine _selectedMachine; + protected MachineModel _selectedMachine; /// /// Gets or sets the selected machine. /// - public Machine SelectedMachine + public MachineModel SelectedMachine { get { return _selectedMachine; } set @@ -287,30 +281,260 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels public RelayCommand SaveCommand { get; set; } public RelayCommand ManageRmlExtensionCommand { get; set; } - + public RelayCommand BackToThreadExtensionViewsCommand { get; set; } - + private async void BackToThreadExtensionViews(object obj) { View.NavigateTo(RMLExtensionNavigationView.RMLExtensionsView); await LoadRmlExtentions(); } - #endregion - + public RelayCommand AddManufacturerItemCommand { get; set;} + public RelayCommand EditManufacturerItemCommand { get; set; } + public RelayCommand DeleteManufacturerItemCommand { get; set; } + + public RelayCommand AddBrandItemCommand { get; set; } + public RelayCommand EditBrandItemCommand { get; set; } + public RelayCommand DeleteBrandItemCommand { get; set; } + + public RelayCommand AddEndUseItemCommand { get; set; } + public RelayCommand EditEndUseItemCommand { get; set; } + public RelayCommand DeleteEndUseItemCommand { get; set; } + + public RelayCommand AddApplicationItemCommand { get; set; } + public RelayCommand EditApplicationItemCommand { get; set; } + public RelayCommand DeleteApplicationItemCommand { get; set; } + + public RelayCommand AddIndustrySectorItemCommand { get; set; } + public RelayCommand EditIndustrySectorItemCommand { get; set; } + public RelayCommand DeleteIndustrySectorItemCommand { get; set; } + + public RelayCommand AddMaterialItemCommand { get; set; } + public RelayCommand EditMaterialItemCommand { get; set; } + public RelayCommand DeleteMaterialItemCommand { get; set; } + + public RelayCommand AddYarnTypeItemCommand { get; set; } + public RelayCommand EditYarnTypeItemCommand { get; set; } + public RelayCommand DeleteYarnTypeItemCommand { get; set; } + + public RelayCommand AddSubFamilyItemCommand { get; set; } + public RelayCommand EditSubFamilyItemCommand { get; set; } + public RelayCommand DeleteSubFamilyItemCommand { get; set; } + + public RelayCommand AddFamilyItemCommand { get; set; } + public RelayCommand EditFamilyItemCommand { get; set; } + public RelayCommand DeleteFamilyItemCommand { get; set; } + + public RelayCommand AddGroupItemCommand { get; set; } + public RelayCommand EditGroupItemCommand { get; set; } + public RelayCommand DeleteGroupItemCommand { get; set; } + + public RelayCommand AddTexturingItemCommand { get; set; } + public RelayCommand EditTexturingItemCommand { get; set; } + public RelayCommand DeleteTexturingItemCommand { get; set; } + + public RelayCommand AddGeometryItemCommand { get; set; } + public RelayCommand EditGeometryItemCommand { get; set; } + public RelayCommand DeleteGeometryItemCommand { get; set; } + + public RelayCommand AddYarnWhiteShadeItemCommand { get; set; } + public RelayCommand EditYarnWhiteShadeItemCommand { get; set; } + public RelayCommand DeleteYarnWhiteShadeItemCommand { get; set; } + + public RelayCommand AddGlossLevelItemCommand { get; set; } + public RelayCommand EditGlossLevelItemCommand { get; set; } + public RelayCommand DeleteGlossLevelItemCommand { get; set; } + #endregion + + #region Command Functions + + private void AddManufacturerItem(object obj) + { + AddItemDialogVM vm = ViewModelLocator.AddItemDialogVM; + + _notification.ShowModalDialog(vm, (x) => + { + if (Manufacturers.Any(y => y.ToLower() == vm.Name.ToLower())) + { + _notification.ShowError("Manufacturer already exists."); + return; + } + Manufacturers.Add(vm.Name); + RaisePropertyChanged("Manufacturers"); + _active_context.YarnManufacturers.Add(new YarnManufacturer() { Name = vm.Name }); + + + }, () => { }); + } + + private void DeleteManufacturerItem(object obj) + { + if (_notification.ShowQuestion("Are you sure you want to delete the selected item?")) + { + string deletedname = ActiveRML.Manufacturer; + Manufacturers.Remove(deletedname); + RaisePropertyChanged("Manufacturers"); + var deletedItem = _active_context.YarnManufacturers.Where(x => x.Name == deletedname).FirstOrDefault(); + if (deletedItem != null) + { + _active_context.YarnManufacturers.Remove(deletedItem); + ActiveRML.Manufacturer = _active_context.YarnManufacturers.FirstOrDefault().Name; + } + } + } + + private void EditManufacturerItem(object obj) + { + AddItemDialogVM vm = ViewModelLocator.AddItemDialogVM; + vm.Name = ActiveRML.Manufacturer; + + _notification.ShowModalDialog(vm, (x) => + { + if (ActiveRML.Manufacturer == x.Name) + return; + if (Manufacturers.Any(y => y == x.Name)) + { + _notification.ShowError("Manufacturer already exists."); + return; + } + var editItem = _active_context.YarnManufacturers.Where(z => z.Name == ActiveRML.Manufacturer).FirstOrDefault(); + if (editItem != null) + { + editItem.Name = x.Name; + ActiveRML.Manufacturer = x.Name; + } + Manufacturers = _active_context.YarnManufacturers.Select(z => z.Name).ToList(); + }, () => { }); + } + + private void AddBrandItem(object obj) + { + AddItemDialogVM vm = ViewModelLocator.AddItemDialogVM; + + _notification.ShowModalDialog(vm, async (x) => + { + if (Brands.Any(y => y.Name.ToLower() == x.Name.ToLower())) + { + _notification.ShowError("Brand already exists."); + return; + } + YarnBrand newItem = new YarnBrand() { Name = x.Name }; + _active_context.YarnBrands.Add(newItem); + await _active_context.SaveChangesAsync(); + Brands = _active_context.YarnBrands.ToObservableCollection(); + ActiveRMLExtension.YarnBrand = Brands.FirstOrDefault(b => b.Name == vm.Name); + }, () => { }); + } + + private void EditBrandItem(object obj) + { + AddItemDialogVM vm = ViewModelLocator.AddItemDialogVM; + vm.Name = ActiveRMLExtension.YarnBrand.Name; + + _notification.ShowModalDialog(vm, async (x) => + { + if (ActiveRMLExtension.YarnBrand.Name == vm.Name) + return; + if (Brands.Any(y => y.Name == vm.Name)) + { + _notification.ShowError("The Brand already exists."); + return; + } + ActiveRMLExtension.YarnBrand.Name = vm.Name; + await _active_context.SaveChangesAsync(); + }, () => { }); + } + + private async void DeleteBrandItem(object obj) + { + if (_notification.ShowQuestion("Are you sure you want to delete the selected item?")) + { + var deletedItem = _active_context.YarnBrands.Where(x => x.Guid == ActiveRMLExtension.YarnBrand.Guid).FirstOrDefault(); + if (deletedItem != null) + { + _active_context.YarnBrands.Remove(deletedItem); + await _active_context.SaveChangesAsync(); + Brands = _active_context.YarnBrands.ToObservableCollection(); + ActiveRMLExtension.YarnBrand = Brands.FirstOrDefault(); + } + } + } + + private void AddEndUseItem(object ob) + { + AddItemDialogVM vm = ViewModelLocator.AddItemDialogVM; + + _notification.ShowModalDialog(vm, async (x) => + { + if (Brands.Any(y => y.Name.ToLower() == x.Name.ToLower())) + { + _notification.ShowError("This item already exists."); + return; + } + MediaPurpos newItem = new MediaPurpos() { Name = x.Name }; + _active_context.MediaPurposes.Add(newItem); + await _active_context.SaveChangesAsync(); + EndUse = _active_context.MediaPurposes.ToObservableCollection(); + ActiveRML.MediaPurpose = EndUse.FirstOrDefault(b => b.Name == x.Name); + }, () => { }); + } + private void EditEndUseItem(object ob) + { + + } + private void DeleteEndUseItem(object ob) + { + + } + #endregion + + public MainViewVM(INotificationProvider notificationProvider, IAuthenticationProvider authentication, IActionLogManager actionLogManager) { _notification = notificationProvider; _authentication = authentication; _actionLogManager = actionLogManager; - + BackToThreadExtensionViewsCommand = new RelayCommand(BackToThreadExtensionViews, () => IsFree); SaveCommand = new RelayCommand(Save, () => IsFree); ManageRmlExtensionCommand = new RelayCommand(() => LoadActiveRMLExtension(SelectedRMLExtension.Guid), () => SelectedRMLExtension != null); - } - - public override void OnApplicationReady() + + DeleteManufacturerItemCommand = new RelayCommand(DeleteManufacturerItem, () => ActiveRML.Manufacturer != ""); + AddManufacturerItemCommand = new RelayCommand(AddManufacturerItem); + EditManufacturerItemCommand = new RelayCommand(EditManufacturerItem, () => ActiveRML.Manufacturer != ""); + + AddBrandItemCommand = new RelayCommand(AddBrandItem); + EditBrandItemCommand = new RelayCommand(EditBrandItem, () => ActiveRMLExtension.YarnBrand != null); + DeleteBrandItemCommand = new RelayCommand(DeleteBrandItem, () => ActiveRMLExtension.YarnBrand != null); + + AddEndUseItemCommand = new RelayCommand(AddEndUseItem); + EditEndUseItemCommand = new RelayCommand(EditEndUseItem); + DeleteEndUseItemCommand = new RelayCommand(DeleteEndUseItem); + + AddApplicationItemCommand = new RelayCommand(AddEndUseItem); + EditApplicationItemCommand = new RelayCommand(EditEndUseItem); + DeleteApplicationItemCommand = new RelayCommand(DeleteEndUseItem); + + AddIndustrySectorItemCommand = new RelayCommand(AddEndUseItem); + EditIndustrySectorItemCommand = new RelayCommand(EditEndUseItem); + DeleteIndustrySectorItemCommand = new RelayCommand(DeleteEndUseItem); + + AddMaterialItemCommand = new RelayCommand(AddEndUseItem); + EditMaterialItemCommand = new RelayCommand(EditEndUseItem); + DeleteMaterialItemCommand = new RelayCommand(DeleteEndUseItem); + + AddYarnTypeItemCommand = new RelayCommand(AddEndUseItem); + EditYarnTypeItemCommand = new RelayCommand(EditEndUseItem); + DeleteYarnTypeItemCommand = new RelayCommand(DeleteEndUseItem); + + } + + + + + public override void OnApplicationReady() { } @@ -351,8 +575,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels Status = x.RMLExtesion == null ? RMLExtensionStatus.New : x.RMLExtesion.RMLStatus }).ToList(); RmlExtensions = q; - RmlExtCollectionView = CollectionViewSource.GetDefaultView(RmlExtensions); - RmlExtCollectionView.SortDescriptions.Add(new SortDescription(nameof(Rml.LastUpdated), ListSortDirection.Ascending)); + // RmlExtCollectionView = CollectionViewSource.GetDefaultView(RmlExtensions); + // RmlExtCollectionView.SortDescriptions.Add(new SortDescription(nameof(Rml.LastUpdated), ListSortDirection.Ascending)); //RmlExtCollectionView.Filter = (rml) => //{ @@ -468,33 +692,40 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels ActiveRML = new RmlBuilder(_active_context) .Set(SelectedRMLExtension.RMLGuid) .Build(); + + var machineIdsHasTest = (from c in _active_context.ColorProcessParameters.Where(x => x.RmlsExtensionsGuid == guid) + select new { MichineGUID = c.MachineGuid }). + Union (from p in _active_context.RmlExtensionTestResults.Where(x => x.RmlsExtensionsGuid == guid) + select new { MichineGUID = p.MachineGuid }).DistinctBy(x => x).ToList(); - var machinesWithTest = _active_context.RmlExtensionTestResults.Select(x => x.MachineGuid).ToList(); - var machinesWithTest2 = - Join(_active_context.ColorProcessParameters.Select(y => y.MachineGuid), st1 => st1, st2=> st2, (st1, st2)=>).ToList(); - Machines = ObservablesStaticCollections.Instance.Machines.Select(x => new MachineModel() + if(machineIdsHasTest.Count > 0) + { + var MachineGuid = machineIdsHasTest.First().MichineGUID; + Machines.Where(x => machineIdsHasTest.Any(y => y.MichineGUID == x.Guid)).ToList().ForEach(x => x.HasRMLTest = true); + SelectedMachine = Machines.First(x => x.Guid == MachineGuid); + } + else + { + var settings = SettingsManager.Default.GetOrCreate(); + if(settings.LastVirtualMachineSerialNumber != null) { - Guid = x.Guid, - Name = x.Name, - SerialNumber = x.SerialNumber - }).ToObservableCollection(); - var settings = SettingsManager.Default.GetOrCreate(); - SelectedMachine = ObservablesStaticCollections.Instance.Machines.SingleOrDefault(x => x.SerialNumber == settings.LastVirtualMachineSerialNumber); - + SelectedMachine = Machines.SingleOrDefault(x => x.SerialNumber == settings.LastVirtualMachineSerialNumber); + } + else + { + SelectedMachine = Machines.First(); + } + } + ColorParametersVewVM = new ColorParametersVewVM(_notification, _actionLogManager); ColorParametersVewVM.RMLExtemtionGUID = guid; - ColorParametersVewVM.SelectedMachineGUID = SelectedMachine.Guid; + ColorParametersVewVM.SelectedMachineGUID = SelectedMachine != null ? SelectedMachine.Guid : null ; TestResultsViewVM = new TestResultsViewVM(_notification, _actionLogManager); TestResultsViewVM.RMLExtemtionGUID = guid; + TestResultsViewVM.SelectedMachineGUID = SelectedMachine != null ? SelectedMachine.Guid : null; TestResultsViewVM.ThreadName = ActiveRML.Manufacturer; - - var machineGuidsWithTests = await _active_context.RmlExtensionTestResults.Where(x => x.RmlsExtensionsGuid == guid).Select(y => y.MachineGuid).ToListAsync(); - if(machineGuidsWithTests.Count > 0) - { - - } - + if (ActiveRMLExtension.RMLStatus == RMLExtensionStatus.New) { ColorParametersVewVM.SaveColorParameters -= UpdateStatus; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultsViewVM.cs index c60d5e4fa..24196a3f6 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultsViewVM.cs @@ -16,6 +16,7 @@ using Tango.Core.Commands; using Tango.Logging; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.ThreadExtensions.Models; using Tango.Settings; using Tango.SharedUI; @@ -73,23 +74,19 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels //EnableRenderingForSelectedTabGraphs(); } } - /// - /// Gets or sets the machines providers. - /// - //public ISuggestionProvider MachinesProvider { get; set; } - protected Machine _selectedMachine; + protected string _selectedMachineGuid; /// /// Gets or sets the selected machine. /// - public Machine SelectedMachine + public String SelectedMachineGUID { - get { return _selectedMachine; } + get { return _selectedMachineGuid; } set { - if (value != null && _selectedMachine != value) + if (value != null && _selectedMachineGuid != value) { - _selectedMachine = value; + _selectedMachineGuid = value; SelectedMachineChanged(); RaisePropertyChangedAuto(); InvalidateRelayCommands(); @@ -236,9 +233,6 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { ResultTabs.Clear(); SelectedTab = null; - var settings = SettingsManager.Default.GetOrCreate(); - - SelectedMachine = ObservablesStaticCollections.Instance.Machines.SingleOrDefault(x => x.SerialNumber == settings.LastVirtualMachineSerialNumber); } private void SelectedMachineChanged() @@ -249,7 +243,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels } public async void LoadTestResults() { - if (SelectedMachine == null || SelectedMachine.Guid == null) + if (String.IsNullOrEmpty(SelectedMachineGUID)) { _notification.ShowWarning(LogManager.Log($" Please, select machine.", LogCategory.Warning)); return; @@ -268,7 +262,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels using (_notification.PushTaskItem("Loading Test Results Parameters ...")) { - var testResults = await new RMLExtensionTestResultsCollectionBuilder(_active_context).SetAll().ForRMLExtension(RMLExtemtionGUID).ForMachine(SelectedMachine.Guid).WithRubbingAndTensileResults().BuildAsync(); + var testResults = await new RMLExtensionTestResultsCollectionBuilder(_active_context).SetAll().ForRMLExtension(RMLExtemtionGUID).ForMachine(SelectedMachineGUID).WithRubbingAndTensileResults().BuildAsync(); SelectedTestResults = testResults.OrderBy(x => x.ResultIndex).ToSynchronizedObservableCollection(); foreach (var result in SelectedTestResults) { @@ -301,7 +295,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels private TestResultViewVM CreateNewTestResultVM(string name, int index) { TestResultViewVM newtab = new TestResultViewVM(_notification, _actionLogManager) { ThreadName = ThreadName }; - newtab.TestResult = new RmlExtensionTestResult() { RmlsExtensionsGuid = RMLExtemtionGUID, MachineGuid = SelectedMachine.Guid, ResultIndex = index, Name = name, BtsrMax = 0.0, BtsrMin = 0.0, DryerTemperature = 0, TunnelTemperature = 0, TunnelFlow = 0.0, TunnelAvgTemperature = 0.0, TensionHeadMax = 0.0, + newtab.TestResult = new RmlExtensionTestResult() { RmlsExtensionsGuid = RMLExtemtionGUID, MachineGuid = SelectedMachineGUID, ResultIndex = index, Name = name, BtsrMax = 0.0, BtsrMin = 0.0, DryerTemperature = 0, TunnelTemperature = 0, TunnelFlow = 0.0, TunnelAvgTemperature = 0.0, TensionHeadMax = 0.0, TensionHeadMin = 0.0, TensioinAfterDryerMax = 0.0, TensionAfterDryerMin = 0.0, TensionWinderMax = 0.0, TensionWinderMin = 0.0, PullerTensionMax = 0.0, PullerTensionMin = 0.0, ExitTensionMax = 0.0, ExitTensionMin = 0.0, SeverityZone1Max = 0.0, SeverityZone1Min = 0.0, SeverityZone2Max = 0.0, SeverityZone2Min = 0.0, RefLubVersion="", RefCof = 0.0, RefLub = 0.0, ThreadLubVersion = "", ThreadCof = 0.0, ThreadLub = 0.0, Conclusions="", Comment=""}; var rubbingresults = new SynchronizedObservableCollection(); @@ -331,7 +325,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels public async void Save() { - if (SelectedMachine == null || SelectedMachine.Guid == null) + if (String.IsNullOrEmpty(SelectedMachineGUID)) { _notification.ShowWarning(LogManager.Log($"Could not save Test Results. Please, select machine.", LogCategory.Warning)); return; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/AddItemDialog.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/AddItemDialog.xaml new file mode 100644 index 000000000..c529eabe0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/AddItemDialog.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/AddItemDialog.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/AddItemDialog.xaml.cs new file mode 100644 index 000000000..6bd81343e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/AddItemDialog.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.ThreadExtensions.Views +{ + /// + /// Interaction logic for AddItemDialog.xaml + /// + public partial class AddItemDialog : UserControl + { + public AddItemDialog() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ComboboxEditable.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ComboboxEditable.xaml new file mode 100644 index 000000000..88b1bbc62 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ComboboxEditable.xaml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ComboboxEditable.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ComboboxEditable.xaml.cs new file mode 100644 index 000000000..e5b542f45 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ComboboxEditable.xaml.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.Core.Commands; + +namespace Tango.MachineStudio.ThreadExtensions.Views +{ + /// + /// Interaction logic for ComboboxEditable.xaml + /// + public partial class ComboboxEditable : UserControl + { + public ComboboxEditable() + { + InitializeComponent(); + } + + + public IEnumerable ItemsSource + { + get { return (IEnumerable)GetValue(ItemsSourceProperty); } + set { SetValue(ItemsSourceProperty, value); } + } + + // Using a DependencyProperty as the backing store for ItemsSource. This enables animation, styling, binding, etc... + public static readonly DependencyProperty ItemsSourceProperty = + DependencyProperty.Register("ItemsSource", typeof(IEnumerable), typeof(ComboboxEditable), new PropertyMetadata(null)); + + + + public object SelectedItem + { + get { return (object)GetValue(SelectedItemProperty); } + set { SetValue(SelectedItemProperty, value); } + } + + // Using a DependencyProperty as the backing store for SelectedItem. This enables animation, styling, binding, etc... + public static readonly DependencyProperty SelectedItemProperty = + DependencyProperty.Register("SelectedItem", typeof(object), typeof(ComboboxEditable), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); + + + + + + public RelayCommand AddCommand + { + get { return (RelayCommand)GetValue(AddCommandProperty); } + set { SetValue(AddCommandProperty, value); } + } + + // Using a DependencyProperty as the backing store for DeleteCommand. This enables animation, styling, binding, etc... + public static readonly DependencyProperty AddCommandProperty = + DependencyProperty.Register("AddCommand", typeof(RelayCommand), typeof(ComboboxEditable)); + + public RelayCommand EditCommand + { + get { return (RelayCommand)GetValue(EditCommandProperty); } + set { SetValue(EditCommandProperty, value); } + } + + // Using a DependencyProperty as the backing store for DeleteCommand. This enables animation, styling, binding, etc... + public static readonly DependencyProperty EditCommandProperty = + DependencyProperty.Register("EditCommand", typeof(RelayCommand), typeof(ComboboxEditable)); + + public RelayCommand DeleteCommand + { + get { return (RelayCommand)GetValue(DeleteCommandProperty); } + set { SetValue(DeleteCommandProperty, value); } + } + + // Using a DependencyProperty as the backing store for DeleteCommand. This enables animation, styling, binding, etc... + public static readonly DependencyProperty DeleteCommandProperty = + DependencyProperty.Register("DeleteCommand", typeof(RelayCommand), typeof(ComboboxEditable)); + + + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionView.xaml index 7e9d85f49..cd131d76d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionView.xaml @@ -18,6 +18,7 @@ + @@ -43,6 +44,15 @@ + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionsView.xaml index 6a1436348..b2bff1dae 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionsView.xaml @@ -33,26 +33,6 @@ -