From 3fdcdac577d552bbdf6d7320c6ffb0753e810a08 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 10 Dec 2017 19:01:05 +0200 Subject: Started working on machine designer view models. Added NAME field to MACHINE table. --- .../Visual_Studio/Tango.Core/ExtendedObject.cs | 10 ++++++++++ .../ExtensionMethods/IEnumerableExtensions.cs | 22 ++++++++++++++++++++++ .../Visual_Studio/Tango.Core/Tango.Core.csproj | 1 + 3 files changed, 33 insertions(+) create mode 100644 Software/Visual_Studio/Tango.Core/ExtensionMethods/IEnumerableExtensions.cs (limited to 'Software/Visual_Studio/Tango.Core') diff --git a/Software/Visual_Studio/Tango.Core/ExtendedObject.cs b/Software/Visual_Studio/Tango.Core/ExtendedObject.cs index 84a73bf7c..8ac80034d 100644 --- a/Software/Visual_Studio/Tango.Core/ExtendedObject.cs +++ b/Software/Visual_Studio/Tango.Core/ExtendedObject.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; using System.Windows; @@ -31,6 +32,15 @@ namespace Tango.Core PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName)); } + /// + /// Raises the property changed event. + /// + /// Name of the property. + protected virtual void RaisePropertyChangedAuto([CallerMemberName] string caller = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(caller)); + } + /// /// Raises all relay commands CanExecute methods in the current instance. /// diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/IEnumerableExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/IEnumerableExtensions.cs new file mode 100644 index 000000000..0e430e631 --- /dev/null +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/IEnumerableExtensions.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +public static class IEnumerableExtensions +{ + /// + /// Creates a new observable collection from the specified enumerable. + /// + /// + /// The enumerable. + /// + public static ObservableCollection ToObservableCollection(this IEnumerable enumerable) + { + return new ObservableCollection(enumerable); + } +} + diff --git a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj index 7af35f628..fd3eeddf9 100644 --- a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj +++ b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj @@ -59,6 +59,7 @@ + -- cgit v1.3.1