From d990cf35a8816c7447fef4552ee83d041466636d Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Wed, 25 Sep 2019 18:29:12 +0300 Subject: Implemented Hardware Configuration Tab on Machine Designer !!! --- .../Models/HardwareCollection.cs | 27 ++ .../Models/HardwareComponent.cs | 27 ++ .../Models/HardwareParameter.cs | 122 ++++++ .../Tango.MachineStudio.MachineDesigner.csproj | 13 +- .../ViewModels/HardwareConfigurationViewVM.cs | 413 +++++++++++++++++++++ .../ViewModels/MainViewVM.cs | 42 +++ .../Views/HardwareConfigurationView.xaml | 239 ++++++++++++ .../Views/HardwareConfigurationView.xaml.cs | 76 ++++ .../Views/MachineDetailsView.xaml | 3 + 9 files changed, 961 insertions(+), 1 deletion(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/HardwareCollection.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/HardwareComponent.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/HardwareParameter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/HardwareConfigurationView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/HardwareConfigurationView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/HardwareCollection.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/HardwareCollection.cs new file mode 100644 index 000000000..765bc9dfd --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/HardwareCollection.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; + +namespace Tango.MachineStudio.MachineDesigner.Models +{ + public class HardwareCollection : ExtendedObject + { + public String CollectionName { get; set; } + + public SynchronizedObservableCollection Components { get; set; } + public bool HasDifferences + { + get + { + return Components.Any(item => item.HasDifferences); + } + } + public HardwareCollection() + { + Components = new SynchronizedObservableCollection(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/HardwareComponent.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/HardwareComponent.cs new file mode 100644 index 000000000..d03428ce5 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/HardwareComponent.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; + +namespace Tango.MachineStudio.MachineDesigner.Models +{ + public class HardwareComponent : ExtendedObject + { + public String ComponentName { get; set; } + public String Description { get; set; } + public SynchronizedObservableCollection Properties { get; set; } + public bool HasDifferences + { + get + { + return Properties.Any(item => item.IsDifferent); + } + } + public HardwareComponent() + { + Properties = new SynchronizedObservableCollection(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/HardwareParameter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/HardwareParameter.cs new file mode 100644 index 000000000..33dbcad71 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/HardwareParameter.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Core.Commands; + +namespace Tango.MachineStudio.MachineDesigner.Models +{ + public class HardwareParameter : ExtendedObject + { + public event EventHandler Selected; + + public HardwareComponent Component { get; set; } + + public RelayCommand DeleteCommand { get; set; } + + public String PropertyName { get; set; } + + private Object _defaultValue; + public Object DefaultValue + { + get { return _defaultValue; } + set + { + _defaultValue = value; + } + } + + public Type Type + { + get { return DefaultValue.GetType(); } + } + // updated after editing + private Object _actualValue = null; + public Object ActualValue + { + get { return _actualValue; } + set + { + _actualValue = value; + RaisePropertyChangedAuto(); + RaisePropertyChanged(nameof(IsDifferent)); + RaisePropertyChanged(nameof(IsValuesMatched)); + } + } + + // displayed during editing + private Object _editableValue = null; + public Object EditableValue + { + get { return _editableValue; } + set + { + _editableValue = value; + RaisePropertyChangedAuto(); + } + } + + private bool _isSelected; + public bool IsSelected + { + get { return _isSelected; } + set + { + _isSelected = value; + + OnIsSelectedChanged(); + + RaisePropertyChangedAuto(); + if (_isSelected) + { + Selected?.Invoke(this, new EventArgs()); + } + } + } + + + private void OnIsSelectedChanged() + { + if (IsSelected) + { + EditableValue = ActualValue != null ? ActualValue : DefaultValue; + } + else + { + if (EditableValue != null) + { + ActualValue = EditableValue; + } + } + } + + public bool IsDifferent + { + get + { + return (ActualValue != null); + } + } + + public bool IsValuesMatched + { + get + { + return ActualValue != null && ActualValue.ToString() == DefaultValue.ToString(); + } + } + + public void DeleteValue() + { + ActualValue = null; + EditableValue = null; + } + + public HardwareParameter() + { + DeleteCommand = new RelayCommand(DeleteValue); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj index 71f5ec864..855b0d196 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj @@ -81,14 +81,21 @@ + + + + ColorCalibrationView.xaml + + HardwareConfigurationView.xaml + MachineCreationDialog.xaml @@ -121,6 +128,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -292,7 +303,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs new file mode 100644 index 000000000..415a8ab72 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/HardwareConfigurationViewVM.cs @@ -0,0 +1,413 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.BL; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.BL.ValueObjects; +using Tango.Core; +using Tango.Core.Commands; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.MachineDesigner.Models; +using Tango.SharedUI; + +namespace Tango.MachineStudio.MachineDesigner.ViewModels +{ + public class HardwareConfigurationViewVM : ViewModel + { + private INotificationProvider _notification; + private HardwareConfiguration _hwConfig; + + #region Properties + + public SynchronizedObservableCollection Collections { get; set; } + + private bool _isShowDifference; + public bool IsShowDifference + { + get { return _isShowDifference; } + set + { + _isShowDifference = value; + RaisePropertyChangedAuto(); + } + } + + private ICollectionView _collectionViewSource; + public ICollectionView CollectionsViewSource + { + get { return _collectionViewSource; } + set { _collectionViewSource = value; RaisePropertyChangedAuto(); } + } + + private String _PropertyFilter; + public String PropertyFilter + { + get { return _PropertyFilter; } + set + { + _PropertyFilter = value; + RaisePropertyChangedAuto(); + OnFilterChanged(); + } + } + + private String _componentFilter; + public String ComponentFilter + { + get { return _componentFilter; } + set + { + _componentFilter = value; + RaisePropertyChangedAuto(); + OnFilterChanged(); + } + } + + #endregion + + private void OnFilterChanged() + { + CollectionsViewSource.Refresh(); + } + + public HardwareConfigurationViewVM(INotificationProvider notification) + { + _notification = notification; + Collections = new SynchronizedObservableCollection(); + CollectionsViewSource = CollectionViewSource.GetDefaultView(Collections); + CollectionsViewSource.Filter = new Predicate(FilterCollection); + + //Test(); + } + + #region Build Collection + + public void Init(Configuration configuration) + { + HardwareVersion hardwareVersion = configuration.HardwareVersion; + + _hwConfig = configuration.GetHardwareConfiguration(); + + Collections.Clear(); + Collections.Add(CreateMotorsCollection(hardwareVersion)); + Collections.Add(CreateDancerCollection(hardwareVersion)); + Collections.Add(CreatePidCollection(hardwareVersion)); + Collections.Add(CreateWindersCollection(hardwareVersion)); + Collections.Add(CreateSpeedSensorsCollection(hardwareVersion)); + Collections.Add(CreateBlowersCollection(hardwareVersion)); + Collections.Add(CreateBreakSensorCollection(hardwareVersion)); + } + + private HardwareCollection CreateMotorsCollection(HardwareVersion hardwareVersion) + { + HardwareCollection collection = new HardwareCollection() + { + CollectionName = "MOTORS" + }; + foreach (var motorTypeCode in Enum.GetValues(typeof(HardwareMotorTypes)).Cast()) + { + var motor = hardwareVersion.HardwareMotors.SingleOrDefault(x => x.HardwareMotorType.Code == motorTypeCode.ToInt32()); + if (motor != null) + { + var componentResult = CreateComponent( + motor.HardwareMotorType.Name, + motorTypeCode.ToDescription(), + GetComponentProperties(typeof(HardwareMotorBase)), + motor); + + collection.Components.Add(componentResult); + } + } + return collection; + } + private HardwareCollection CreateDancerCollection(HardwareVersion hardwareVersion) + { + HardwareCollection collection = new HardwareCollection() + { + CollectionName = "DANCERS" + }; + foreach (var dancerTypeCode in Enum.GetValues(typeof(HardwareDancerTypes)).Cast()) + { + var dancer = hardwareVersion.HardwareDancers.SingleOrDefault(x => x.HardwareDancerType.Code == dancerTypeCode.ToInt32()); + if (dancer != null) + { + var componentResult = CreateComponent( + dancer.HardwareDancerType.Name, + dancerTypeCode.ToDescription(), + GetComponentProperties(typeof(HardwareDancerBase)), + dancer); + + collection.Components.Add(componentResult); + } + } + return collection; + } + private HardwareCollection CreatePidCollection(HardwareVersion hardwareVersion) + { + HardwareCollection collection = new HardwareCollection() + { + CollectionName = "PID CONTROLS" + }; + foreach (var pidTypeCode in Enum.GetValues(typeof(HardwarePidControlTypes)).Cast()) + { + var pidControl = hardwareVersion.HardwarePidControls.SingleOrDefault(x => x.HardwarePidControlType.Code == pidTypeCode.ToInt32()); + if (pidControl != null) + { + var componentResult = CreateComponent( + pidControl.HardwarePidControlType.Name, + pidTypeCode.ToDescription(), + GetComponentProperties(typeof(HardwarePidControlBase)), + pidControl); + + collection.Components.Add(componentResult); + } + } + return collection; + } + private HardwareCollection CreateWindersCollection(HardwareVersion hardwareVersion) + { + HardwareCollection collection = new HardwareCollection() + { + CollectionName = "WINDERS" + }; + foreach (var winderTypeCode in Enum.GetValues(typeof(HardwareWinderTypes)).Cast()) + { + var winderControl = hardwareVersion.HardwareWinders.SingleOrDefault(x => x.HardwareWinderType.Code == winderTypeCode.ToInt32()); + if (winderControl != null) + { + var componentResult = CreateComponent( + winderControl.HardwareWinderType.Name, + winderTypeCode.ToDescription(), + GetComponentProperties(typeof(HardwareWinderBase)), + winderControl); + + collection.Components.Add(componentResult); + } + } + return collection; + } + private HardwareCollection CreateSpeedSensorsCollection(HardwareVersion hardwareVersion) + { + HardwareCollection collection = new HardwareCollection() + { + CollectionName = "SPEED SENSORS" + }; + foreach (var speedSensorTypeCode in Enum.GetValues(typeof(HardwareSpeedSensorTypes)).Cast()) + { + var speedSensor = hardwareVersion.HardwareSpeedSensors.SingleOrDefault(x => x.HardwareSpeedSensorType.Code == speedSensorTypeCode.ToInt32()); + if (speedSensor != null) + { + var componentResult = CreateComponent( + speedSensor.HardwareSpeedSensorType.Name, + speedSensorTypeCode.ToDescription(), + GetComponentProperties(typeof(HardwareSpeedSensorBase)), + speedSensor); + + collection.Components.Add(componentResult); + } + } + return collection; + } + private HardwareCollection CreateBlowersCollection(HardwareVersion hardwareVersion) + { + HardwareCollection collection = new HardwareCollection() + { + CollectionName = "BLOWERS" + }; + foreach (var blowersTypeCode in Enum.GetValues(typeof(HardwareBlowerTypes)).Cast()) + { + var blower = hardwareVersion.HardwareBlowers.SingleOrDefault(x => x.HardwareBlowerType.Code == blowersTypeCode.ToInt32()); + if (blower != null) + { + var componentResult = CreateComponent( + blower.HardwareBlowerType.Name, + blowersTypeCode.ToDescription(), + GetComponentProperties(typeof(HardwareBlowerBase)), + blower); + + collection.Components.Add(componentResult); + } + } + return collection; + } + private HardwareCollection CreateBreakSensorCollection(HardwareVersion hardwareVersion) + { + HardwareCollection collection = new HardwareCollection() + { + CollectionName = "BREAK SENSOR" + }; + foreach (var breakSensorsTypeCode in Enum.GetValues(typeof(HardwareBreakSensorTypes)).Cast()) + { + var breakSensor = hardwareVersion.HardwareBreakSensors.SingleOrDefault(x => x.HardwareBreakSensorType.Code == breakSensorsTypeCode.ToInt32()); + if (breakSensor != null) + { + var componentResult = CreateComponent( + breakSensor.HardwareBreakSensorType.Name, + breakSensorsTypeCode.ToDescription(), + GetComponentProperties(typeof(HardwareBreakSensorBase)), + breakSensor); + + collection.Components.Add(componentResult); + } + } + return collection; + } + private HardwareComponent CreateComponent(String name, String description, List properties, Object component) + { + HardwareComponent hwComponent = new HardwareComponent() + { + Description = description, + ComponentName = name + }; + + foreach (var prop in properties) + { + var hProp = new HardwareParameter(); + hProp.Component = hwComponent; + hProp.PropertyName = prop.Name; + hProp.DefaultValue = prop.GetValue(component); + hProp.Selected -= HProp_Selected; + hProp.Selected += HProp_Selected; + + var configParam = _hwConfig.Parameters.SingleOrDefault(x => x.ComponentName == name && x.ParameterName == prop.Name); + hProp.ActualValue = configParam != null ? configParam.Value : null; + hwComponent.Properties.Add(hProp); + } + return hwComponent; + } + + private void HProp_Selected(object sender, EventArgs e) + { + if (Collections != null) + { + Collections.SelectMany(x => x.Components).SelectMany(x => x.Properties).Where(x => x != sender).ToList().ForEach(x => x.IsSelected = false); + } + } + + public void ClearSelections() + { + if (Collections != null) + { + Collections.SelectMany(x => x.Components).SelectMany(x => x.Properties).ToList().ForEach(x => x.IsSelected = false); + } + } + + private List GetComponentProperties(Type componentType) + { + List exclude = new List() + { + "Guid", + "ID", + "LastUpdated", + "Parameters", + }; + return componentType.GetProperties(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public).Where(x => !x.PropertyType.IsClass && !exclude.Contains(x.Name)).ToList(); + } + + #endregion + + public HardwareConfiguration GetResultingHardwareConfiguration() + { + HardwareConfiguration hwConfig = new HardwareConfiguration(); + + foreach (var parameter in Collections.SelectMany(x => x.Components).SelectMany(x => x.Properties).Where(x => x.IsDifferent)) + { + hwConfig.Parameters.Add(new HardwareConfiguration.HardwareConfigurationParameter() + { + ComponentName = parameter.Component.ComponentName, + ParameterName = parameter.PropertyName, + Value = parameter.ActualValue + }); + } + + return hwConfig; + } + + #region Filter + + private bool FilterCollection(object obj) + { + HardwareCollection collection = obj as HardwareCollection; + var components = CollectionViewSource.GetDefaultView(collection.Components); + components.Filter = new Predicate(FilterComponent); + return true; + } + private bool FilterComponent(object obj) + { + HardwareComponent component = obj as HardwareComponent; + var properties = CollectionViewSource.GetDefaultView(component.Properties); + properties.Filter = new Predicate(FilterProperty); + + if (!String.IsNullOrWhiteSpace(ComponentFilter)) + { + var words = ComponentFilter.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); + return words.Any(x => component.Description.ToLower().Contains(x.ToLower())); + } + else + { + return true; + } + } + private bool FilterProperty(object obj) + { + HardwareParameter hparameter = obj as HardwareParameter; + + if (!String.IsNullOrWhiteSpace(PropertyFilter)) + { + var words = PropertyFilter.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); + return words.Any(x => hparameter.PropertyName.ToLower().Contains(x.ToLower())); + } + else + { + return true; + } + + } + + #endregion + + #region test + + private void Test() + { + HardwareCollection col1 = new HardwareCollection() + { + CollectionName = "Motors", + + }; + HardwareParameter par1 = new HardwareParameter() + { + PropertyName = "Prop1", + ActualValue = null, + DefaultValue = 12, + + }; + + HardwareParameter par2 = new HardwareParameter() + { + PropertyName = "Prop2", + ActualValue = null, + DefaultValue = true + }; + + HardwareComponent comp1 = new HardwareComponent() + { + ComponentName = "H_C_1", + Description = "HardwareComponent" + }; + comp1.Properties.Add(par1); + comp1.Properties.Add(par2); + col1.Components.Add(comp1); + Collections.Add(col1); + + } + + #endregion + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs index eaca7cd6a..5f2dcd00d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs @@ -122,6 +122,19 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels set { _colorCalibrationViewVM = value; RaisePropertyChangedAuto(); } } + private HardwareConfigurationViewVM _hardwareConfigurationViewVM; + + public HardwareConfigurationViewVM HardwareConfigurationViewVM + { + get { return _hardwareConfigurationViewVM; } + set + { + _hardwareConfigurationViewVM = value; + RaisePropertyChangedAuto(); + } + } + + #endregion #region Commands @@ -442,6 +455,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels SelectedRML = ActiveMachineAdapter.Rmls.FirstOrDefault(), }; + HardwareConfigurationViewVM = new HardwareConfigurationViewVM(_notification); + HardwareConfigurationViewVM.Init(ActiveMachine.Configuration); + + ActiveMachine.Configuration.HardwareVersionChanged += Configuration_HardwareVersionChanged; + View.NavigateTo(MachineDesignerNavigationView.MachineDetailsView); } catch (Exception ex) @@ -457,6 +475,27 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } } + private async void Configuration_HardwareVersionChanged(object sender, HardwareVersion e) + { + var version = ActiveMachine.Configuration.HardwareVersion; + + if (version != null) + { + using (_notification.PushTaskItem("Loading hardware version...")) + { + try + { + version = await new HardwareVersionBuilder(ActiveMachineAdapter.Context).Set(version.Guid).WithHardwareComponents().BuildAsync(); + HardwareConfigurationViewVM.Init(ActiveMachine.Configuration); + } + catch (Exception ex) + { + LogManager.Log(ex); + } + } + } + } + private async void SaveMachine() { foreach (var ids in ActiveMachine.Configuration.IdsPacks) @@ -585,6 +624,9 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels ColorCalibrationViewVM.Save(); + var hwConfig = HardwareConfigurationViewVM.GetResultingHardwareConfiguration(); + ActiveMachine.Configuration.SetHardwareConfiguration(hwConfig); + await ActiveMachineAdapter.Context.SaveChangesAsync(); if (SelectedMachine != null) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/HardwareConfigurationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/HardwareConfigurationView.xaml new file mode 100644 index 000000000..78f5dad59 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/HardwareConfigurationView.xaml @@ -0,0 +1,239 @@ + + + + + + + + + + + + + + + + + + + Find component + + + + + + + + Find parameter + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + : + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/HardwareConfigurationView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/HardwareConfigurationView.xaml.cs new file mode 100644 index 000000000..0103b3220 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/HardwareConfigurationView.xaml.cs @@ -0,0 +1,76 @@ +using MahApps.Metro.Controls; +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.Controls.Primitives; +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.MachineStudio.MachineDesigner.ViewModels; + +namespace Tango.MachineStudio.MachineDesigner.Views +{ + /// + /// Interaction logic for HardwereConfigurationView.xaml + /// + public partial class HardwareConfigurationView : UserControl + { + public HardwareConfigurationView() + { + InitializeComponent(); + } + + private void Property_MouseEnter(object sender, MouseEventArgs e) + { + + } + + private void Property_MouseLeave(object sender, MouseEventArgs e) + { + + } + + private void Main_container_MouseUp(object sender, MouseButtonEventArgs e) + { + ClearSelection(); + } + + private void NumericUpDown_KeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Return) + { + ClearSelection(); + } + } + + private void ClearSelection() + { + if (DataContext != null) + { + (DataContext as HardwareConfigurationViewVM).ClearSelections(); + } + } + + private async void EditPropertyButton_Checked(object sender, RoutedEventArgs e) + { + FrameworkElement toggle = sender as FrameworkElement; + FrameworkElement parent = toggle.FindAncestor() as StackPanel; + var num = parent.FindChild(); + + if (num != null) + { + await Task.Delay(50); + num.Focus(); + num.SelectAll(); + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml index 7acb4c806..1f748fe9f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml @@ -58,6 +58,9 @@ + + + -- cgit v1.3.1