aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-01-14 17:09:24 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-01-14 17:09:24 +0200
commite952c7c3e5c4441b60dc0b2dc1641459a35731e3 (patch)
treedd938c686d7efd238cc821001137a70616364376 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs
parent0bd3760bec105a00efa0fe624da2eb82d85d06c9 (diff)
downloadTango-e952c7c3e5c4441b60dc0b2dc1641459a35731e3.tar.gz
Tango-e952c7c3e5c4441b60dc0b2dc1641459a35731e3.zip
Added code comments for:
MachineStudio.MachineDesigner.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs230
1 files changed, 172 insertions, 58 deletions
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;
/// <summary>
/// Gets or sets the db adapter.
@@ -33,7 +35,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
private Machine _machine;
/// <summary>
- /// Gets or sets the machine.
+ /// Gets or sets the current editable machine.
/// </summary>
public Machine Machine
{
@@ -42,6 +44,9 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
}
private Machine _selectedMachine;
+ /// <summary>
+ /// Gets or sets the selected machine from the drop down.
+ /// </summary>
public Machine SelectedMachine
{
get { return _selectedMachine; }
@@ -50,7 +55,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
private Configuration _configuration;
/// <summary>
- /// Gets or sets the configuration.
+ /// Gets or sets the editable machine configuration.
/// </summary>
public Configuration Configuration
{
@@ -69,17 +74,18 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
}
private ObservableCollection<Configuration> _history;
-
+ /// <summary>
+ /// Gets or sets the machine configuration history.
+ /// </summary>
public ObservableCollection<Configuration> History
{
get { return _history; }
set { _history = value; RaisePropertyChangedAuto(); }
}
-
private Configuration _selectedHistoryConfiguration;
/// <summary>
- /// Gets or sets the selected history configuration.
+ /// Gets or sets the machine selected configuration from history.
/// </summary>
public Configuration SelectedHistoryConfiguration
{
@@ -88,19 +94,38 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
}
private String _filter;
-
+ /// <summary>
+ /// Gets or sets the configuration components filter.
+ /// </summary>
public String Filter
{
get { return _filter; }
set { _filter = value; RaisePropertyChangedAuto(); OnFilterChanged(); }
}
+ #endregion
+
+ #region Commands
+
+ /// <summary>
+ /// Gets or sets the save command.
+ /// </summary>
public RelayCommand SaveCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the add ids command.
+ /// </summary>
public RelayCommand AddIdsCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the remove ids command.
+ /// </summary>
public RelayCommand RemoveIdsCommand { get; set; }
+ #endregion
+
+ #region Constructors
+
/// <summary>
/// Initializes a new instance of the <see cref="MainViewVM"/> class.
/// </summary>
@@ -119,7 +144,14 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
RemoveIdsCommand = new RelayCommand(RemoveIds, (x) => !_isSaving && SelectedIds != null);
}
- private void OnSelectedMachineChanged()
+ #endregion
+
+ #region Virtual Methods
+
+ /// <summary>
+ /// Called when the selected machine has changed.
+ /// </summary>
+ protected virtual void OnSelectedMachineChanged()
{
if (SelectedMachine != null)
{
@@ -133,136 +165,212 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
}
}
- public void DropIdsPack(IdsPack idsPack1, IdsPack idsPack2)
+ /// <summary>
+ /// Called when the history configuration has been selected
+ /// </summary>
+ protected virtual void OnHistoryConfigurationSelected()
{
- Configuration.IdsPacks.Swap(idsPack1, idsPack2);
+ if (SelectedHistoryConfiguration != null)
+ {
+ Configuration = SelectedHistoryConfiguration.CloneConfiguration();
+ }
}
- private void OnHistoryConfigurationSelected()
+ /// <summary>
+ /// Called when the filter has changed
+ /// </summary>
+ protected virtual void OnFilterChanged()
{
- if (SelectedHistoryConfiguration != null)
+
+
+ List<ICollectionView> collections = new List<ICollectionView>();
+ 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
+
+ /// <summary>
+ /// Drops the ids pack.
+ /// </summary>
+ /// <param name="idsPack1">The ids pack1.</param>
+ /// <param name="idsPack2">The ids pack2.</param>
+ public void DropIdsPack(IdsPack idsPack1, IdsPack idsPack2)
+ {
+ Configuration.IdsPacks.Swap(idsPack1, idsPack2);
+ }
+
+ /// <summary>
+ /// Drops the touch panel.
+ /// </summary>
+ /// <param name="applicationDisplayPanelVersion">The application display panel version.</param>
public void DropTouchPanel(ApplicationDisplayPanelVersion applicationDisplayPanelVersion)
{
Configuration.ApplicationDisplayPanelVersions = applicationDisplayPanelVersion;
Configuration.ApplicationDisplayPanelVersionGuid = applicationDisplayPanelVersion.Guid;
}
+ /// <summary>
+ /// Drops the application firmware version.
+ /// </summary>
+ /// <param name="applicationFirmwareVersion">The application firmware version.</param>
public void DropApplicationFirmwareVersion(ApplicationFirmwareVersion applicationFirmwareVersion)
{
Configuration.ApplicationFirmwareVersions = applicationFirmwareVersion;
Configuration.ApplicationFirmwareVersionGuid = applicationFirmwareVersion.Guid;
}
+ /// <summary>
+ /// Drops the application version.
+ /// </summary>
+ /// <param name="applicationVersion">The application version.</param>
public void DropApplicationVersion(ApplicationVersion applicationVersion)
{
Configuration.ApplicationVersions = applicationVersion;
Configuration.ApplicationVersionGuid = applicationVersion.Guid;
}
+ /// <summary>
+ /// Drops the hardware version.
+ /// </summary>
+ /// <param name="hardwareVersion">The hardware version.</param>
public void DropHardwareVersion(HardwareVersion hardwareVersion)
{
Configuration.HardwareVersions = hardwareVersion;
Configuration.HardwareVersionGuid = hardwareVersion.Guid;
}
+ /// <summary>
+ /// Drops the embedded firmware.
+ /// </summary>
+ /// <param name="embeddedFirmwareVersion">The embedded firmware version.</param>
public void DropEmbeddedFirmware(EmbeddedFirmwareVersion embeddedFirmwareVersion)
{
Configuration.EmbeddedFirmwareVersions = embeddedFirmwareVersion;
Configuration.EmbeddedFirmwareVersionGuid = embeddedFirmwareVersion.Guid;
}
+ /// <summary>
+ /// Drops the embedded software.
+ /// </summary>
+ /// <param name="embeddedSoftwareVersion">The embedded software version.</param>
public void DropEmbeddedSoftware(EmbeddedSoftwareVersion embeddedSoftwareVersion)
{
Configuration.EmbeddedSoftwareVersions = embeddedSoftwareVersion;
Configuration.EmbeddedSoftwareVersionGuid = embeddedSoftwareVersion.Guid;
}
+ /// <summary>
+ /// Drops the application os version.
+ /// </summary>
+ /// <param name="applicationOsVersion">The application os version.</param>
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();
- }
-
+ /// <summary>
+ /// Drops the type of the cartridge.
+ /// </summary>
+ /// <param name="cartridgeType">Type of the cartridge.</param>
+ /// <param name="idsPack">The ids pack.</param>
public void DropCartridgeType(CartridgeType cartridgeType, IdsPack idsPack)
{
idsPack.CartridgeTypes = cartridgeType;
idsPack.CartridgeTypeGuid = cartridgeType.Guid;
}
+ /// <summary>
+ /// Drops the dispenser.
+ /// </summary>
+ /// <param name="dispenser">The dispenser.</param>
+ /// <param name="idsPack">The ids pack.</param>
public void DropDispenser(Dispenser dispenser, IdsPack idsPack)
{
idsPack.Dispenser = dispenser;
idsPack.DispenserGuid = dispenser.Guid;
}
+ /// <summary>
+ /// Drops the type of the mid tank.
+ /// </summary>
+ /// <param name="midTankType">Type of the mid tank.</param>
+ /// <param name="idsPack">The ids pack.</param>
public void DropMidTankType(MidTankType midTankType, IdsPack idsPack)
{
idsPack.MidTankTypes = midTankType;
idsPack.MidTankTypeGuid = midTankType.Guid;
}
+ /// <summary>
+ /// Drops the type of the liquid.
+ /// </summary>
+ /// <param name="liquidType">Type of the liquid.</param>
+ /// <param name="idsPack">The ids pack.</param>
public void DropLiquidType(LiquidType liquidType, IdsPack idsPack)
{
idsPack.LiquidTypes = liquidType;
idsPack.LiquidTypeGuid = liquidType.Guid;
}
- private void OnFilterChanged()
- {
+ #endregion
+ #region Private Methods
- List<ICollectionView> collections = new List<ICollectionView>();
- 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;
- }
- }
- }
+ /// <summary>
+ /// Removes the selected IDS pack.
+ /// </summary>
+ private void RemoveIds()
+ {
+ Configuration.IdsPacks.Remove(SelectedIds);
+ SelectedIds = null;
+ }
- return false;
- };
- }
+ /// <summary>
+ /// Adds a new IDS pack.
+ /// </summary>
+ private void AddIds()
+ {
+ Configuration.IdsPacks.Add(new IdsPack() { Configuration = Configuration });
+ InvalidateRelayCommands();
}
+ /// <summary>
+ /// Saves the current machine configuration.
+ /// </summary>
private async void Save()
{
foreach (var ids in Configuration.IdsPacks)
@@ -453,10 +561,16 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
}
}
+ /// <summary>
+ /// Sets the specified machine history.
+ /// </summary>
+ /// <param name="machine">The machine.</param>
private void SetHistory(Machine machine)
{
History = machine.MachinesConfigurations.Select(x => x.Configuration).ToObservableCollection();
History.Insert(0, machine.Configuration);
}
+
+ #endregion
}
}