// NOTE: A new EditGestureViewModel is instantiated on every call to EditGesture()
        public EditStaticGestureViewModel(MainViewModel mvm, SGClassWrapper gesture = null, bool newGesture = false)
        {
            _mvm        = mvm;
            _newGesture = newGesture;
            _provider   = _mvm.SQLiteProvider;
            _recorder   = new SGRecorder(this, _mvm);

            _recorder.RecordingSessionFinished += OnRecordingSessionFinished;

            var featureWeightsDict = new Dictionary <string, int>();

            if (newGesture)
            {
                Name               = "New Static Gesture";
                Instances          = new ObservableCollection <SGInstanceWrapper>();
                featureWeightsDict = SGClass.GetDefaultFeatureWeights();
            }
            else
            {
                Name               = gesture.Name;
                Id                 = gesture.Id;
                Instances          = _provider.GetStaticGestureInstances(gesture.Id);
                featureWeightsDict = gesture.Gesture.FeatureWeights;
            }

            setFeatureWeights(featureWeightsDict);

            Changeset = new EditStaticGestureChangeset();
        }
        public void TestAddingClass_FluentAPI()
        {
            // Arrange
            string  namespaceName = "SlnGen";
            string  className     = "TestClass";
            SGClass @class        = new SGClass(className);

            // Act
            SGNamespace @namespace = new SGNamespace(namespaceName).WithClasses(@class);

            // Assert
            Assert.IsTrue(@namespace.Classes.Contains(@class));
        }
        public void TestAddingMultipleClasses_FluentAPI()
        {
            // Arrange
            string  namespaceName = "SlnGen";
            string  className1    = "TestClass1";
            string  className2    = "TestClass2";
            SGClass @class        = new SGClass(className1);
            SGClass class2        = new SGClass(className2);

            // Act
            SGNamespace @namespace = new SGNamespace(namespaceName).WithClasses(@class, class2);

            // Assert
            Assert.IsTrue(@namespace.Classes.ContainsAll(@class, class2));
        }
        public void SaveGesture()
        {
            Dictionary <string, int> featureWeightsDict = null;

            if (_newGesture)
            {
                Id = _provider.SaveNewStaticGestureClass(Name, null);                 // Need to get id
            }
            else
            {
                // Fill featureWeightsDict
                featureWeightsDict = new Dictionary <string, int>();
                foreach (var fw in FeatureWeights)
                {
                    featureWeightsDict.Add(fw.Name, fw.Weight);
                }
            }

            var editedGesture  = new SGClass(Instances, featureWeightsDict);
            var sampleInstance = (Instances.Any()) ? Instances.FirstOrDefault().Gesture : null;

            var gestureWrapper = new SGClassWrapper()
            {
                Id             = this.Id,
                Name           = this.Name,
                Gesture        = editedGesture,
                SampleInstance = sampleInstance
            };

            _provider.SaveStaticGestureClass(gestureWrapper);

            if (Changeset.ChangesExist())
            {
                // Update the StaticGestureInstances table
                foreach (int instanceId in Changeset.DeletedGestureInstances)
                {
                    _provider.DeleteStaticGestureInstance(instanceId);
                }
                foreach (var instance in Changeset.NewGestureInstances)
                {
                    _provider.SaveNewStaticGestureInstance(Id, instance.Gesture);
                }
            }

            _mvm.UpdateStaticGestureLibrary();
        }
        public void TestAddingClasses_PropertyInitializer()
        {
            // Arrange
            string  namespaceName = "SlnGen";
            string  className1    = "TestClass1";
            string  className2    = "TestClass2";
            SGClass @class        = new SGClass(className1);
            SGClass class2        = new SGClass(className2);

            // Act
            SGNamespace @namespace = new SGNamespace(namespaceName)
            {
                Classes =
                {
                    @class,
                    class2
                }
            };

            // Assert
            Assert.IsTrue(@namespace.Classes.ContainsAll(@class, class2));
        }