From e952c7c3e5c4441b60dc0b2dc1641459a35731e3 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 14 Jan 2018 17:09:24 +0200 Subject: Added code comments for: MachineStudio.MachineDesigner. --- .../AutoComplete/MachinesProvider.cs | 9 + .../MachineDesignerModule.cs | 28 +++ .../ViewModels/MainViewVM.cs | 230 +++++++++++++++------ 3 files changed, 209 insertions(+), 58 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/AutoComplete/MachinesProvider.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/AutoComplete/MachinesProvider.cs index 943c52f81..7a97db2e2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/AutoComplete/MachinesProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/AutoComplete/MachinesProvider.cs @@ -9,8 +9,17 @@ using Tango.DAL.Observables; namespace Tango.MachineStudio.MachineDesigner.AutoComplete { + /// + /// Represents an auto-complete Machines provider. + /// + /// public class MachinesProvider : ISuggestionProvider { + /// + /// Gets the suggestions. + /// + /// The filter. + /// public IEnumerable GetSuggestions(string filter) { return ObservablesEntitiesAdapter.Instance.Machines.Where(x => x.SerialNumber.StartsWith(filter, StringComparison.CurrentCultureIgnoreCase)).ToList(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/MachineDesignerModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/MachineDesignerModule.cs index db937028b..ca13bd350 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/MachineDesignerModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/MachineDesignerModule.cs @@ -12,25 +12,53 @@ using Tango.SharedUI.Helpers; namespace Tango.MachineStudio.MachineDesigner { + /// + /// Represents a machine designer Machine Studio module providing an interactive GUI for managing machine configurations. + /// + /// public class MachineDesignerModule : IStudioModule { + /// + /// Gets the module name. + /// public string Name => "Machine Designer"; + /// + /// Gets the module description. + /// public string Description => "Provides a graphical control over machine configurations. Create, manage and deploy machine configurations using simple drag and drop interface."; + /// + /// Gets the module cover image. + /// public BitmapSource Image => ResourceHelper.GetImageFromResources("Images/machine-designer-module.jpg"); + /// + /// Gets the module entry point view. + /// public FrameworkElement MainView => new MainView(); + /// + /// Gets the permission required to see and load this module. + /// public Permissions Permission => Permissions.RunDeveloperModule; + /// + /// Gets a value indicating whether this module has been initialized. + /// public bool IsInitialized => true; + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// public void Dispose() { } + /// + /// Perform any operations required to initialize this module. + /// public void Initialize() { 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 ca1c95a03..89edc271e 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 @@ -21,6 +21,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels private bool _isSaving; private INotificationProvider _notification; + #region Properties + private ObservablesEntitiesAdapter _adapter; /// /// Gets or sets the db adapter. @@ -33,7 +35,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels private Machine _machine; /// - /// Gets or sets the machine. + /// Gets or sets the current editable machine. /// public Machine Machine { @@ -42,6 +44,9 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } private Machine _selectedMachine; + /// + /// Gets or sets the selected machine from the drop down. + /// public Machine SelectedMachine { get { return _selectedMachine; } @@ -50,7 +55,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels private Configuration _configuration; /// - /// Gets or sets the configuration. + /// Gets or sets the editable machine configuration. /// public Configuration Configuration { @@ -69,17 +74,18 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } private ObservableCollection _history; - + /// + /// Gets or sets the machine configuration history. + /// public ObservableCollection History { get { return _history; } set { _history = value; RaisePropertyChangedAuto(); } } - private Configuration _selectedHistoryConfiguration; /// - /// Gets or sets the selected history configuration. + /// Gets or sets the machine selected configuration from history. /// public Configuration SelectedHistoryConfiguration { @@ -88,19 +94,38 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } private String _filter; - + /// + /// Gets or sets the configuration components filter. + /// public String Filter { get { return _filter; } set { _filter = value; RaisePropertyChangedAuto(); OnFilterChanged(); } } + #endregion + + #region Commands + + /// + /// Gets or sets the save command. + /// public RelayCommand SaveCommand { get; set; } + /// + /// Gets or sets the add ids command. + /// public RelayCommand AddIdsCommand { get; set; } + /// + /// Gets or sets the remove ids command. + /// public RelayCommand RemoveIdsCommand { get; set; } + #endregion + + #region Constructors + /// /// Initializes a new instance of the class. /// @@ -119,7 +144,14 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels RemoveIdsCommand = new RelayCommand(RemoveIds, (x) => !_isSaving && SelectedIds != null); } - private void OnSelectedMachineChanged() + #endregion + + #region Virtual Methods + + /// + /// Called when the selected machine has changed. + /// + protected virtual void OnSelectedMachineChanged() { if (SelectedMachine != null) { @@ -133,136 +165,212 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } } - public void DropIdsPack(IdsPack idsPack1, IdsPack idsPack2) + /// + /// Called when the history configuration has been selected + /// + protected virtual void OnHistoryConfigurationSelected() { - Configuration.IdsPacks.Swap(idsPack1, idsPack2); + if (SelectedHistoryConfiguration != null) + { + Configuration = SelectedHistoryConfiguration.CloneConfiguration(); + } } - private void OnHistoryConfigurationSelected() + /// + /// Called when the filter has changed + /// + protected virtual void OnFilterChanged() { - if (SelectedHistoryConfiguration != null) + + + List collections = new List(); + collections.Add(Adapter.ApplicationDisplayPanelVersionsViewSource); + collections.Add(Adapter.ApplicationVersionsViewSource); + collections.Add(Adapter.EmbeddedSoftwareVersionsViewSource); + collections.Add(Adapter.EmbeddedFirmwareVersionsViewSource); + collections.Add(Adapter.ApplicationOsVersionsViewSource); + collections.Add(Adapter.ApplicationVersionsViewSource); + collections.Add(Adapter.DispensersViewSource); + collections.Add(Adapter.CartridgeTypesViewSource); + collections.Add(Adapter.LiquidTypesViewSource); + collections.Add(Adapter.MidTankTypesViewSource); + collections.Add(Adapter.HardwareVersionsViewSource); + + foreach (var collection in collections) { - Configuration = SelectedHistoryConfiguration.CloneConfiguration(); + collection.Filter = (x) => + { + foreach (var prop in x.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(y => y.PropertyType == typeof(String))) + { + String value = prop.GetValue(x).ToStringSafe(); + + if (value != null) + { + if (value.ToLower().Contains(Filter.ToLower())) + { + return true; + } + } + } + + return false; + }; } } + #endregion + + #region Drag Drop Handlers + + /// + /// Drops the ids pack. + /// + /// The ids pack1. + /// The ids pack2. + public void DropIdsPack(IdsPack idsPack1, IdsPack idsPack2) + { + Configuration.IdsPacks.Swap(idsPack1, idsPack2); + } + + /// + /// Drops the touch panel. + /// + /// The application display panel version. public void DropTouchPanel(ApplicationDisplayPanelVersion applicationDisplayPanelVersion) { Configuration.ApplicationDisplayPanelVersions = applicationDisplayPanelVersion; Configuration.ApplicationDisplayPanelVersionGuid = applicationDisplayPanelVersion.Guid; } + /// + /// Drops the application firmware version. + /// + /// The application firmware version. public void DropApplicationFirmwareVersion(ApplicationFirmwareVersion applicationFirmwareVersion) { Configuration.ApplicationFirmwareVersions = applicationFirmwareVersion; Configuration.ApplicationFirmwareVersionGuid = applicationFirmwareVersion.Guid; } + /// + /// Drops the application version. + /// + /// The application version. public void DropApplicationVersion(ApplicationVersion applicationVersion) { Configuration.ApplicationVersions = applicationVersion; Configuration.ApplicationVersionGuid = applicationVersion.Guid; } + /// + /// Drops the hardware version. + /// + /// The hardware version. public void DropHardwareVersion(HardwareVersion hardwareVersion) { Configuration.HardwareVersions = hardwareVersion; Configuration.HardwareVersionGuid = hardwareVersion.Guid; } + /// + /// Drops the embedded firmware. + /// + /// The embedded firmware version. public void DropEmbeddedFirmware(EmbeddedFirmwareVersion embeddedFirmwareVersion) { Configuration.EmbeddedFirmwareVersions = embeddedFirmwareVersion; Configuration.EmbeddedFirmwareVersionGuid = embeddedFirmwareVersion.Guid; } + /// + /// Drops the embedded software. + /// + /// The embedded software version. public void DropEmbeddedSoftware(EmbeddedSoftwareVersion embeddedSoftwareVersion) { Configuration.EmbeddedSoftwareVersions = embeddedSoftwareVersion; Configuration.EmbeddedSoftwareVersionGuid = embeddedSoftwareVersion.Guid; } + /// + /// Drops the application os version. + /// + /// The application os version. public void DropApplicationOsVersion(ApplicationOsVersion applicationOsVersion) { Configuration.ApplicationOsVersions = applicationOsVersion; Configuration.ApplicationVersionGuid = applicationOsVersion.Guid; } - private void RemoveIds() - { - Configuration.IdsPacks.Remove(SelectedIds); - SelectedIds = null; - } - - private void AddIds() - { - Configuration.IdsPacks.Add(new IdsPack() { Configuration = Configuration }); - InvalidateRelayCommands(); - } - + /// + /// Drops the type of the cartridge. + /// + /// Type of the cartridge. + /// The ids pack. public void DropCartridgeType(CartridgeType cartridgeType, IdsPack idsPack) { idsPack.CartridgeTypes = cartridgeType; idsPack.CartridgeTypeGuid = cartridgeType.Guid; } + /// + /// Drops the dispenser. + /// + /// The dispenser. + /// The ids pack. public void DropDispenser(Dispenser dispenser, IdsPack idsPack) { idsPack.Dispenser = dispenser; idsPack.DispenserGuid = dispenser.Guid; } + /// + /// Drops the type of the mid tank. + /// + /// Type of the mid tank. + /// The ids pack. public void DropMidTankType(MidTankType midTankType, IdsPack idsPack) { idsPack.MidTankTypes = midTankType; idsPack.MidTankTypeGuid = midTankType.Guid; } + /// + /// Drops the type of the liquid. + /// + /// Type of the liquid. + /// The ids pack. public void DropLiquidType(LiquidType liquidType, IdsPack idsPack) { idsPack.LiquidTypes = liquidType; idsPack.LiquidTypeGuid = liquidType.Guid; } - private void OnFilterChanged() - { + #endregion + #region Private Methods - List collections = new List(); - collections.Add(Adapter.ApplicationDisplayPanelVersionsViewSource); - collections.Add(Adapter.ApplicationVersionsViewSource); - collections.Add(Adapter.EmbeddedSoftwareVersionsViewSource); - collections.Add(Adapter.EmbeddedFirmwareVersionsViewSource); - collections.Add(Adapter.ApplicationOsVersionsViewSource); - collections.Add(Adapter.ApplicationVersionsViewSource); - collections.Add(Adapter.DispensersViewSource); - collections.Add(Adapter.CartridgeTypesViewSource); - collections.Add(Adapter.LiquidTypesViewSource); - collections.Add(Adapter.MidTankTypesViewSource); - collections.Add(Adapter.HardwareVersionsViewSource); - - foreach (var collection in collections) - { - collection.Filter = (x) => - { - foreach (var prop in x.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(y => y.PropertyType == typeof(String))) - { - String value = prop.GetValue(x).ToStringSafe(); - - if (value != null) - { - if (value.ToLower().Contains(Filter.ToLower())) - { - return true; - } - } - } + /// + /// Removes the selected IDS pack. + /// + private void RemoveIds() + { + Configuration.IdsPacks.Remove(SelectedIds); + SelectedIds = null; + } - return false; - }; - } + /// + /// Adds a new IDS pack. + /// + private void AddIds() + { + Configuration.IdsPacks.Add(new IdsPack() { Configuration = Configuration }); + InvalidateRelayCommands(); } + /// + /// Saves the current machine configuration. + /// private async void Save() { foreach (var ids in Configuration.IdsPacks) @@ -453,10 +561,16 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } } + /// + /// Sets the specified machine history. + /// + /// The machine. private void SetHistory(Machine machine) { History = machine.MachinesConfigurations.Select(x => x.Configuration).ToObservableCollection(); History.Insert(0, machine.Configuration); } + + #endregion } } -- cgit v1.3.1