diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2021-07-13 12:21:32 +0300 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2021-07-13 12:21:32 +0300 |
| commit | 9da3e0256092cc21398bda66b96b996a0de55dd3 (patch) | |
| tree | b8549c5f9b5704173758d34b3cff95ea9b1c4d9f /Software/Visual_Studio/MachineStudio/Modules | |
| parent | 8a0b8f6abe3d143b43131a330e0ee39c2547ce8f (diff) | |
| download | Tango-9da3e0256092cc21398bda66b96b996a0de55dd3.tar.gz Tango-9da3e0256092cc21398bda66b96b996a0de55dd3.zip | |
RML Extension changes
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
13 files changed, 691 insertions, 122 deletions
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 @@ <Reference Include="System" /> <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Data" /> + <Reference Include="System.Drawing" /> <Reference Include="System.Printing" /> + <Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll</HintPath> </Reference> @@ -91,19 +93,27 @@ <Compile Include="Converters\BoolToDisplayStatusConverter.cs" /> <Compile Include="Converters\ColorNameToBrushConverter.cs" /> <Compile Include="Converters\ColorWithPercentToBrushConverter.cs" /> + <Compile Include="Converters\ComboBoxVisibleConverter.cs" /> <Compile Include="Models\ColorDataExcelModel.cs" /> <Compile Include="Models\FactorTarget.cs" /> <Compile Include="Models\MachineModel.cs" /> <Compile Include="Models\PlotProperties.cs" /> <Compile Include="Models\RmlExtensionModel.cs" /> <Compile Include="ViewModelLocator.cs" /> + <Compile Include="ViewModels\AddItemDialogVM.cs" /> <Compile Include="ViewModels\ColorParametersVewVM.cs" /> <Compile Include="ViewModels\MainViewVM.cs" /> <Compile Include="ViewModels\TestResultsViewVM.cs" /> <Compile Include="ViewModels\TestResultViewVM.cs" /> + <Compile Include="Views\AddItemDialog.xaml.cs"> + <DependentUpon>AddItemDialog.xaml</DependentUpon> + </Compile> <Compile Include="Views\ColorParametersView.xaml.cs"> <DependentUpon>ColorParametersView.xaml</DependentUpon> </Compile> + <Compile Include="Views\ComboboxEditable.xaml.cs"> + <DependentUpon>ComboboxEditable.xaml</DependentUpon> + </Compile> <Compile Include="Views\MachineTestResultsView.xaml.cs"> <DependentUpon>MachineTestResultsView.xaml</DependentUpon> </Compile> @@ -127,10 +137,18 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="Views\AddItemDialog.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Views\ColorParametersView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\ComboboxEditable.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Views\MachineTestResultsView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> 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<MainViewVM>(); + TangoIOC.Default.Register<AddItemDialogVM>(); } public static MainViewVM MainViewVM @@ -25,5 +26,13 @@ namespace Tango.MachineStudio.ThreadExtensions return TangoIOC.Default.GetInstance<MainViewVM>(); } } + + public static AddItemDialogVM AddItemDialogVM + { + get + { + return TangoIOC.Default.GetInstance<AddItemDialogVM>(); + } + } } } 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(); + } + } + + + /// <summary> + /// Gets or sets the login command. + /// </summary> + public RelayCommand SaveCommand { get; set; } + + /// <summary> + /// Gets or sets the cancel command. + /// </summary> + public RelayCommand CancelCommand { get; set; } + + /// <summary> + /// Initializes a new instance of the <see cref="MachineLoginViewVM"/> class. + /// </summary> + 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; - /// <summary> - /// Gets or sets the RML collection view. - /// </summary> - public ICollectionView RmlExtCollectionView - { - get { return _rmlExtCollectionView; } - set - { - _rmlExtCollectionView = value; - RaisePropertyChangedAuto(); - } - } + //private ICollectionView _rmlExtCollectionView; + ///// <summary> + ///// Gets or sets the RML collection view. + ///// </summary> + //public ICollectionView RmlExtCollectionView + //{ + // get { return _rmlExtCollectionView; } + // set + // { + // _rmlExtCollectionView = value; + // RaisePropertyChangedAuto(); + // } + //} private ObservableCollection<YarnApplication> _applications; public ObservableCollection<YarnApplication> Applications @@ -161,13 +161,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels get { return _group; } set { _group = value; RaisePropertyChangedAuto(); } } - - //private ObservableCollection<YarnManufacturer> _manufacturer; - //public ObservableCollection<YarnManufacturer> Manufacturer - //{ - // get { return _manufacturer; } - // set { _manufacturer = value; RaisePropertyChangedAuto(); } - //} + private List<String> _manufacturers; public List<String> Manufacturers @@ -185,7 +179,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels get { return _materials; } set { _materials = value; RaisePropertyChangedAuto(); } } - + private ObservableCollection<YarnSubFamily> _subFamilies; public ObservableCollection<YarnSubFamily> SubFamilies { @@ -213,7 +207,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels get { return _industrySector; } set { _industrySector = value; RaisePropertyChangedAuto(); } } - + private String _Filter; /// <summary> /// 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; /// <summary> /// Gets or sets the selected machine. /// </summary> - 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<AddItemDialogVM, Views.AddItemDialog>(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<AddItemDialogVM, Views.AddItemDialog>(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<AddItemDialogVM, Views.AddItemDialog>(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<AddItemDialogVM, Views.AddItemDialog>(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<AddItemDialogVM, Views.AddItemDialog>(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<MachineStudioSettings>(); + if(settings.LastVirtualMachineSerialNumber != null) { - Guid = x.Guid, - Name = x.Name, - SerialNumber = x.SerialNumber - }).ToObservableCollection(); - var settings = SettingsManager.Default.GetOrCreate<MachineStudioSettings>(); - 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(); } } - /// <summary> - /// Gets or sets the machines providers. - /// </summary> - //public ISuggestionProvider MachinesProvider { get; set; } - protected Machine _selectedMachine; + protected string _selectedMachineGuid; /// <summary> /// Gets or sets the selected machine. /// </summary> - 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<MachineStudioSettings>(); - - 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<RubbingResult>(); @@ -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 @@ +<UserControl x:Class="Tango.MachineStudio.ThreadExtensions.Views.AddItemDialog" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:vm="clr-namespace:Tango.MachineStudio.ThreadExtensions.ViewModels" + xmlns:global="clr-namespace:Tango.MachineStudio.ThreadExtensions" + xmlns:local="clr-namespace:Tango.MachineStudio.ThreadExtensions.Views" + mc:Ignorable="d" + d:DesignHeight="650" d:DesignWidth="800" Background="{StaticResource Dialog.Background}" Foreground="{StaticResource MainWindow.Foreground}" d:DataContext="{d:DesignInstance Type=vm:AddItemDialogVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.AddItemDialogVM}"> + <Grid> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + <TextBlock Text="New Item Name" VerticalAlignment="Center" Margin="0 20 0 0" FontSize="20"></TextBlock> + <TextBox Name="ItemlName" TextAlignment="Left" FontSize="21" MinWidth="250" Margin="0 20 10 10" Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" ></TextBox> + <StackPanel HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal"> + <Button Name="AddItem" Command="{Binding SaveCommand}" Width="Auto" HorizontalAlignment="Right" Margin="0 40 10 10">SAVE</Button> + <Button Command="{Binding CancelCommand}" Width="Auto" HorizontalAlignment="Right" Margin="0 40 10 10">CANCEL</Button> + </StackPanel> + </StackPanel> + </Grid> +</UserControl>
\ 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 +{ + /// <summary> + /// Interaction logic for AddItemDialog.xaml + /// </summary> + 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 @@ +<UserControl x:Class="Tango.MachineStudio.ThreadExtensions.Views.ComboboxEditable" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:local="clr-namespace:Tango.MachineStudio.ThreadExtensions.Views" + mc:Ignorable="d" + d:DesignHeight="450" d:DesignWidth="800"> + <Grid> + <DockPanel> + <Button Margin="2 0 0 0" Command="{Binding DeleteCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" DockPanel.Dock="Right" Padding="0" Background="Transparent" BorderThickness="0"> + <materialDesign:PackIcon Kind="Delete" Height="12" Foreground="{StaticResource RedBrush100}" Width="12"> + <materialDesign:PackIcon.LayoutTransform> + <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2" ScaleY="2"/> + </materialDesign:PackIcon.LayoutTransform> + </materialDesign:PackIcon> + </Button> + <Button Margin="2 0 0 0" Command="{Binding EditCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" DockPanel.Dock="Right" Padding="0" Background="Transparent" BorderThickness="0"> + <materialDesign:PackIcon Kind="Pencil" Height="12" Foreground="{StaticResource MainWindow.Foreground}" Width="12" FontWeight="UltraBold"> + <materialDesign:PackIcon.LayoutTransform> + <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2" ScaleY="2"/> + </materialDesign:PackIcon.LayoutTransform> + </materialDesign:PackIcon> + </Button> + + <Button Margin="2 0 0 0" Command="{Binding AddCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" DockPanel.Dock="Right" Padding="0" Background="Transparent" BorderThickness="0"> + <materialDesign:PackIcon Kind="Plus" Height="12" Foreground="{StaticResource BlueBrush100}" Width="12" FontWeight="UltraBold"> + <materialDesign:PackIcon.LayoutTransform> + <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2" ScaleY="2"/> + </materialDesign:PackIcon.LayoutTransform> + </materialDesign:PackIcon> + </Button> + + <ComboBox DockPanel.Dock="Left" VerticalAlignment="Center" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=UserControl,Mode=FindAncestor},Path=ItemsSource}" SelectedItem="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType=UserControl}}" IsEditable="False" Margin="0 0 0 0" Width="Auto"/> + + </DockPanel> + </Grid> +</UserControl> 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 +{ + /// <summary> + /// Interaction logic for ComboboxEditable.xaml + /// </summary> + 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 @@ <UserControl.Resources> <converters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter"/> + <localconv:ComboBoxVisibleConverter x:Key="ComboBoxVisibleConverter"/> <ObjectDataProvider x:Key="RMLExtensionStatus" ObjectType="{x:Type sys:Enum}" MethodName="GetValues"> <ObjectDataProvider.MethodParameters> @@ -43,6 +44,15 @@ <TextBlock Text="{Binding Converter={StaticResource EnumToDescriptionConverter}}"></TextBlock> </DataTemplate> </ComboBox.ItemTemplate> + <ComboBox.ItemContainerStyle> + <Style TargetType="ComboBoxItem"> + <Style.Triggers> + <DataTrigger Binding="{Binding Path=Content, RelativeSource={RelativeSource Self},Converter={StaticResource ComboBoxVisibleConverter}}" Value="true"> + <Setter Property="Visibility" Value="Collapsed"/> + </DataTrigger> + </Style.Triggers> + </Style> + </ComboBox.ItemContainerStyle> </ComboBox> </StackPanel> 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 @@ <Grid DockPanel.Dock="Bottom"> <StackPanel> <Grid> - <!--<StackPanel VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Left" Margin="0 0 0 0"> - <Button Margin="0 0 10 0" MinWidth="160" Height="50" Background="{StaticResource RedBrush300}" BorderBrush="{StaticResource RedBrush300}" Command="{Binding RemoveRmlExtensionCommand}"> - <StackPanel Orientation="Horizontal"> - <materialDesign:PackIcon Kind="Delete" Width="20" Height="20" /> - <TextBlock Margin="5 0 0 0" FontSize="16">DELETE</TextBlock> - </StackPanel> - </Button> - <Button Margin="0 0 10 0" MinWidth="160" Height="50" Background="{StaticResource OrangeBrush300}" BorderBrush="{StaticResource OrangeBrush300}" Command="{Binding CloneRmlExtensionCommand}"> - <StackPanel Orientation="Horizontal"> - <materialDesign:PackIcon Kind="ContentCopy" Width="20" Height="20" /> - <TextBlock Margin="5 0 0 0" FontSize="16">DUPLICATE</TextBlock> - </StackPanel> - </Button> - <Button Margin="0 0 10 0" MinWidth="160" Height="50" Background="{StaticResource GreenBrush300}" BorderBrush="{StaticResource GreenBrush300}" Command="{Binding AddRmlExtCommand}"> - <StackPanel Orientation="Horizontal"> - <materialDesign:PackIcon Kind="Plus" Width="20" Height="20" /> - <TextBlock Margin="5 0 0 0" FontSize="16">NEW</TextBlock> - </StackPanel> - </Button> - </StackPanel>--> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> <Button Margin="50 0 0 0" MinWidth="200" Height="60" Command="{Binding ManageRmlExtensionCommand}"> <StackPanel Orientation="Horizontal"> @@ -64,19 +44,7 @@ </Grid> <StackPanel Orientation="Horizontal" Margin="0 40 0 0"> - <!--<Button Command="{Binding ImportRMLFileCommand}" Foreground="{StaticResource BlackForegroundBrush}" FontSize="16" Style="{StaticResource emptyButton}" Cursor="Hand"> - <StackPanel Orientation="Horizontal"> - <materialDesign:PackIcon Kind="FileImport" VerticalAlignment="Center" Width="30" Height="30" /> - <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" TextDecorations="Underline">Import Thread File</TextBlock> - </StackPanel> - </Button> - - <Button Margin="30 0 0 0" Command="{Binding ExportRMLFileCommand}" Foreground="{StaticResource BlackForegroundBrush}" FontSize="16" Style="{StaticResource emptyButton}" Cursor="Hand"> - <StackPanel Orientation="Horizontal"> - <materialDesign:PackIcon Kind="FileExport" VerticalAlignment="Center" Width="30" Height="30" /> - <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" TextDecorations="Underline">Export Thread File</TextBlock> - </StackPanel> - </Button>--> + </StackPanel> </StackPanel> </Grid> @@ -88,7 +56,7 @@ <Setter Property="FocusVisualStyle" Value="{x:Null}"/> <Setter Property="VerticalContentAlignment" Value="Center"></Setter> <Setter Property="Padding" Value="4"></Setter> - <Setter Property="Margin" Value="0 5 0 0"></Setter> + <Setter Property="Margin" Value="0 0 0 0"></Setter> </Style> </DataGrid.CellStyle> <DataGrid.Columns> @@ -99,7 +67,7 @@ <DataGridTextColumn Header="CREATED BY" Binding="{Binding CreatedBy}" Width="Auto"/> <DataGridTextColumn Header="CREATED" Binding="{Binding Created,Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" Width="Auto" /> <DataGridTextColumn Header="LAST UPDATED" Binding="{Binding LastUpdated,Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" Width="Auto" /> - <DataGridTextColumn Header="STATUS" Binding="{Binding Status, Converter={StaticResource EnumToDescriptionConverter}}" Width="Auto" /> + <DataGridTextColumn Header="STATUS" Binding="{Binding Status, Converter={StaticResource EnumToDescriptionConverter}}" Width="1*" /> </DataGrid.Columns> </DataGrid> </Grid> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ThreadCharacteristicsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ThreadCharacteristicsView.xaml index 707991f0e..0f1003a63 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ThreadCharacteristicsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ThreadCharacteristicsView.xaml @@ -15,7 +15,7 @@ xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" mc:Ignorable="d" FontSize="16" - d:DesignHeight="450" d:DesignWidth="1200" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + d:DesignHeight="850" d:DesignWidth="1200" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> <UserControl.Resources> <converters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter"/> @@ -56,22 +56,100 @@ </Style> </controls:TableGrid.Resources> <TextBlock Text="Manufacturer:" VerticalAlignment="Center" FontSize="16" Margin="0 3 0 0"></TextBlock> - <ComboBox VerticalAlignment="Center" ItemsSource="{Binding Manufacturers}" SelectedItem="{Binding ActiveRML.Manufacturer,Mode=TwoWay}" IsEditable="False" Margin="20 0 20 0"/> - + <local:ComboboxEditable ItemsSource="{Binding Manufacturers}" SelectedItem="{Binding ActiveRML.Manufacturer,Mode=TwoWay}" DeleteCommand="{Binding DeleteBrandItemCommand}" AddCommand="{Binding AddManufacturerItemCommand}" EditCommand="{Binding EditManufacturerItemCommand}"/> + <TextBlock Text="Brand:" VerticalAlignment="Center" ></TextBlock> - <ComboBox ItemsSource="{Binding Brands}" SelectedItem="{Binding ActiveRMLExtension.YarnBrand,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True" Margin="20 0 20 0"></ComboBox> - + <local:ComboboxEditable ItemsSource="{Binding Brands}" SelectedItem="{Binding ActiveRMLExtension.YarnBrand,Mode=TwoWay}" DeleteCommand="{Binding DeleteBrandItemCommand}" AddCommand="{Binding AddBrandItemCommand}" EditCommand="{Binding EditBrandItemCommand}"/> + <TextBlock Text="Country:" ></TextBlock> <TextBox Text="{Binding ActiveRMLExtension.Country,UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center"></TextBox> <TextBlock Text="End Use:" ></TextBlock> - <ComboBox ItemsSource="{Binding EndUse}" SelectedItem="{Binding ActiveRML.MediaPurpose,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox> + <local:ComboboxEditable ItemsSource="{Binding EndUse}" SelectedItem="{Binding ActiveRML.MediaPurpose,Mode=TwoWay}" DeleteCommand="{Binding DeleteEndUseItemCommand}" AddCommand="{Binding AddEndUseItemCommand}" EditCommand="{Binding EditEndUseItemCommand}"/> + + <!--<DockPanel> + <Button Margin="2 0 0 0" Command="{Binding DeleteEndUseItemCommand}" DockPanel.Dock="Right" Padding="0" Background="Transparent" BorderThickness="0"> + <materialDesign:PackIcon Kind="Delete" Height="12" Foreground="{StaticResource RedBrush100}" Width="12"> + <materialDesign:PackIcon.LayoutTransform> + <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2" ScaleY="2"/> + </materialDesign:PackIcon.LayoutTransform> + </materialDesign:PackIcon> + </Button> + <Button Margin="2 0 0 0" Command="{Binding EditEndUseItemCommand}" DockPanel.Dock="Right" Padding="0" Background="Transparent" BorderThickness="0"> + <materialDesign:PackIcon Kind="Pencil" Height="12" Foreground="{StaticResource MainWindow.Foreground}" Width="12" FontWeight="UltraBold"> + <materialDesign:PackIcon.LayoutTransform> + <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2" ScaleY="2"/> + </materialDesign:PackIcon.LayoutTransform> + </materialDesign:PackIcon> + </Button> + + <Button Margin="2 0 0 0" Command="{Binding AddEndUseItemCommand}" DockPanel.Dock="Right" Padding="0" Background="Transparent" BorderThickness="0"> + <materialDesign:PackIcon Kind="Plus" Height="12" Foreground="{StaticResource BlueBrush100}" Width="12" FontWeight="UltraBold"> + <materialDesign:PackIcon.LayoutTransform> + <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2" ScaleY="2"/> + </materialDesign:PackIcon.LayoutTransform> + </materialDesign:PackIcon> + </Button> + <ComboBox DockPanel.Dock="Left" ItemsSource="{Binding EndUse}" SelectedItem="{Binding ActiveRML.MediaPurpose,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox> + </DockPanel>--> <TextBlock Text="Applications:" ></TextBlock> - <ComboBox ItemsSource="{Binding Applications}" SelectedItem="{Binding ActiveRMLExtension.YarnApplication,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox> + <local:ComboboxEditable ItemsSource="{Binding Applications}" SelectedItem="{Binding ActiveRMLExtension.YarnApplication,Mode=TwoWay}" DeleteCommand="{Binding DeleteApplicationItemCommand}" AddCommand="{Binding AddApplicationItemCommand}" EditCommand="{Binding EditApplicationItemCommand}"/> + + <!--<DockPanel> + <Button Margin="2 0 0 0" Command="{Binding DeleteApplicationItemCommand}" DockPanel.Dock="Right" Padding="0" Background="Transparent" BorderThickness="0"> + <materialDesign:PackIcon Kind="Delete" Height="12" Foreground="{StaticResource RedBrush100}" Width="12"> + <materialDesign:PackIcon.LayoutTransform> + <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2" ScaleY="2"/> + </materialDesign:PackIcon.LayoutTransform> + </materialDesign:PackIcon> + </Button> + <Button Margin="2 0 0 0" Command="{Binding EditApplicationItemCommand}" DockPanel.Dock="Right" Padding="0" Background="Transparent" BorderThickness="0"> + <materialDesign:PackIcon Kind="Pencil" Height="12" Foreground="{StaticResource MainWindow.Foreground}" Width="12" FontWeight="UltraBold"> + <materialDesign:PackIcon.LayoutTransform> + <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2" ScaleY="2"/> + </materialDesign:PackIcon.LayoutTransform> + </materialDesign:PackIcon> + </Button> + + <Button Margin="2 0 0 0" Command="{Binding AddApplicationItemCommand}" DockPanel.Dock="Right" Padding="0" Background="Transparent" BorderThickness="0"> + <materialDesign:PackIcon Kind="Plus" Height="12" Foreground="{StaticResource BlueBrush100}" Width="12" FontWeight="UltraBold"> + <materialDesign:PackIcon.LayoutTransform> + <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2" ScaleY="2"/> + </materialDesign:PackIcon.LayoutTransform> + </materialDesign:PackIcon> + </Button> + <ComboBox DockPanel.Dock="Left" ItemsSource="{Binding Applications}" SelectedItem="{Binding ActiveRMLExtension.YarnApplication,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox> + </DockPanel>--> <TextBlock Text="Industry Sector:" ></TextBlock> - <ComboBox ItemsSource="{Binding IndustrySector}" SelectedItem="{Binding ActiveRMLExtension.YarnIndustrysector,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox> + <local:ComboboxEditable ItemsSource="{Binding IndustrySector}" SelectedItem="{Binding ActiveRMLExtension.YarnIndustrysector}" DeleteCommand="{Binding DeleteIndustrySectorItemCommand}" AddCommand="{Binding AddIndustrySectorItemCommand}" EditCommand="{Binding EditIndustrySectorItemCommand}"/> + + <!--<DockPanel> + <Button Margin="2 0 0 0" Command="{Binding DeleteIndustrySectorItemCommand}" DockPanel.Dock="Right" Padding="0" Background="Transparent" BorderThickness="0"> + <materialDesign:PackIcon Kind="Delete" Height="12" Foreground="{StaticResource RedBrush100}" Width="12"> + <materialDesign:PackIcon.LayoutTransform> + <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2" ScaleY="2"/> + </materialDesign:PackIcon.LayoutTransform> + </materialDesign:PackIcon> + </Button> + <Button Margin="2 0 0 0" Command="{Binding EditIndustrySectorItemCommand}" DockPanel.Dock="Right" Padding="0" Background="Transparent" BorderThickness="0"> + <materialDesign:PackIcon Kind="Pencil" Height="12" Foreground="{StaticResource MainWindow.Foreground}" Width="12" FontWeight="UltraBold"> + <materialDesign:PackIcon.LayoutTransform> + <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2" ScaleY="2"/> + </materialDesign:PackIcon.LayoutTransform> + </materialDesign:PackIcon> + </Button> + + <Button Margin="2 0 0 0" Command="{Binding AddIndustrySectorItemCommand}" DockPanel.Dock="Right" Padding="0" Background="Transparent" BorderThickness="0"> + <materialDesign:PackIcon Kind="Plus" Height="12" Foreground="{StaticResource BlueBrush100}" Width="12" FontWeight="UltraBold"> + <materialDesign:PackIcon.LayoutTransform> + <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="2" ScaleY="2"/> + </materialDesign:PackIcon.LayoutTransform> + </materialDesign:PackIcon> + </Button> + <ComboBox DockPanel.Dock="Left" ItemsSource="{Binding IndustrySector}" SelectedItem="{Binding ActiveRMLExtension.YarnIndustrysector,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox> + </DockPanel>--> </controls:TableGrid> </DockPanel> @@ -92,31 +170,40 @@ </Style> </controls:TableGrid.Resources> <TextBlock Text="Material:" ></TextBlock> - <ComboBox ItemsSource="{Binding Materials}" SelectedItem="{Binding ActiveRML.MediaMaterial}" DisplayMemberPath="Name" IsEditable="False"></ComboBox> + <local:ComboboxEditable ItemsSource="{Binding Materials}" SelectedItem="{Binding ActiveRML.MediaMaterial}" DeleteCommand="{Binding DeleteMaterialItemCommand}" AddCommand="{Binding AddMaterialItemCommand}" EditCommand="{Binding EditMaterialItemCommand}"/> + <!--<ComboBox ItemsSource="{Binding Materials}" SelectedItem="{Binding ActiveRML.MediaMaterial}" DisplayMemberPath="Name" IsEditable="False"></ComboBox>--> <TextBlock Text="Type:" ></TextBlock> - <ComboBox ItemsSource="{Binding YarnTypes}" SelectedItem="{Binding ActiveRMLExtension.YarnType,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox> + <local:ComboboxEditable ItemsSource="{Binding YarnTypes}" SelectedItem="{Binding ActiveRMLExtension.YarnType}" DeleteCommand="{Binding DeleteYarnTypeItemCommand}" AddCommand="{Binding AddYarnTypeItemCommand}" EditCommand="{Binding EditYarnTypeItemCommand}"/> + <!--<ComboBox ItemsSource="{Binding YarnTypes}" SelectedItem="{Binding ActiveRMLExtension.YarnType,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox>--> <TextBlock Text="Sub family:" ></TextBlock> - <ComboBox ItemsSource="{Binding SubFamilies}" SelectedItem="{Binding ActiveRMLExtension.YarnSubFamily,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox> + <local:ComboboxEditable ItemsSource="{Binding SubFamilies}" SelectedItem="{Binding ActiveRMLExtension.YarnSubFamily}" DeleteCommand="{Binding DeleteSubFamilyItemCommand}" AddCommand="{Binding AddSubFamilyItemCommand}" EditCommand="{Binding EditSubFamilyItemCommand}"/> + <!--<ComboBox ItemsSource="{Binding SubFamilies}" SelectedItem="{Binding ActiveRMLExtension.YarnSubFamily,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox>--> <TextBlock Text="Family:" ></TextBlock> - <ComboBox ItemsSource="{Binding Family}" SelectedItem="{Binding ActiveRMLExtension.YarnFamily,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox> + <local:ComboboxEditable ItemsSource="{Binding Family}" SelectedItem="{Binding ActiveRMLExtension.YarnFamily}" DeleteCommand="{Binding DeleteFamilyItemCommand}" AddCommand="{Binding AddFamilyItemCommand}" EditCommand="{Binding EditFamilyItemCommand}"/> + <!--<ComboBox ItemsSource="{Binding Family}" SelectedItem="{Binding ActiveRMLExtension.YarnFamily,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox>--> <TextBlock Text="Group:" ></TextBlock> - <ComboBox ItemsSource="{Binding Group}" SelectedItem="{Binding ActiveRMLExtension.YarnGroup,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox> + <local:ComboboxEditable ItemsSource="{Binding Group}" SelectedItem="{Binding ActiveRMLExtension.YarnGroup}" DeleteCommand="{Binding DeleteGroupItemCommand}" AddCommand="{Binding AddGroupItemCommand}" EditCommand="{Binding EditGroupItemCommand}"/> + <!--<ComboBox ItemsSource="{Binding Group}" SelectedItem="{Binding ActiveRMLExtension.YarnGroup,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox>--> <TextBlock Text="Texturing:" ></TextBlock> - <ComboBox ItemsSource="{Binding Texturing}" SelectedItem="{Binding ActiveRMLExtension.YarnTexturing,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox> + <local:ComboboxEditable ItemsSource="{Binding Texturing}" SelectedItem="{Binding ActiveRMLExtension.YarnTexturing}" DeleteCommand="{Binding DeleteTexturingItemCommand}" AddCommand="{Binding AddTexturingItemCommand}" EditCommand="{Binding EditTexturingItemCommand}"/> + <!--<ComboBox ItemsSource="{Binding Texturing}" SelectedItem="{Binding ActiveRMLExtension.YarnTexturing,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox>--> <TextBlock Text="Geometry:" ></TextBlock> - <ComboBox ItemsSource="{Binding Geometry }" SelectedItem="{Binding ActiveRML.FiberShape ,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox> + <local:ComboboxEditable ItemsSource="{Binding Geometry}" SelectedItem="{Binding ActiveRML.FiberShape}" DeleteCommand="{Binding DeleteGeometryItemCommand}" AddCommand="{Binding AddGeometryItemCommand}" EditCommand="{Binding EditGeometryItemCommand}"/> + <!--<ComboBox ItemsSource="{Binding Geometry }" SelectedItem="{Binding ActiveRML.FiberShape ,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox>--> <TextBlock Text="Thread Shade:" ></TextBlock> - <ComboBox ItemsSource="{Binding YarnWhiteShade}" SelectedItem="{Binding ActiveRMLExtension.YarnWhiteShade,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox> + <local:ComboboxEditable ItemsSource="{Binding YarnWhiteShade}" SelectedItem="{Binding ActiveRMLExtension.YarnWhiteShade}" DeleteCommand="{Binding DeleteYarnWhiteShadeItemCommand}" AddCommand="{Binding AddYarnWhiteShadeItemCommand}" EditCommand="{Binding EditYarnWhiteShadeItemCommand}"/> + <!--<ComboBox ItemsSource="{Binding YarnWhiteShade}" SelectedItem="{Binding ActiveRMLExtension.YarnWhiteShade,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox>--> <TextBlock Text="Gloss level:" ></TextBlock> - <ComboBox ItemsSource="{Binding GlossLevel }" SelectedItem="{Binding ActiveRMLExtension.YarnGlossLevel ,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox> + <local:ComboboxEditable ItemsSource="{Binding GlossLevel}" SelectedItem="{Binding ActiveRMLExtension.YarnGlossLevel}" DeleteCommand="{Binding DeleteGlossLevelItemCommand}" AddCommand="{Binding AddGlossLevelItemCommand}" EditCommand="{Binding EditGlossLevelItemCommand}"/> + <!--<ComboBox ItemsSource="{Binding GlossLevel }" SelectedItem="{Binding ActiveRMLExtension.YarnGlossLevel ,Mode=TwoWay}" DisplayMemberPath="Name" IsEditable="True"></ComboBox>--> </controls:TableGrid> </DockPanel> </Grid> |
