public void SaveGesture()
        {
            if (_newGesture)
            {
                Id = _provider.SaveNewDynamicGestureClass(Name, null);                 // Need to get id
            }

            var editedGesture  = new DGClass(Instances);
            var sampleInstance = (Instances.Any()) ? Instances.FirstOrDefault().Instance : null;

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

            _provider.SaveDynamicGestureClass(gestureWrapper);

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

            _mvm.UpdateDynamicGestureLibrary();
        }
        public EditDynamicGestureViewModel(MainViewModel mvm, DGClassWrapper gesture = null, bool newGesture = false)
        {
            _mvm        = mvm;
            _newGesture = newGesture;
            _provider   = _mvm.SQLiteProvider;
            _recorder   = new DGRecorder(_mvm);

            if (newGesture)
            {
                Name      = "New Dynamic Gesture";
                Instances = new ObservableCollection <DGInstanceWrapper>();
            }
            else
            {
                Name      = gesture.Name;
                Id        = gesture.Id;
                Instances = _provider.GetDynamicGestureInstances(gesture.Id);
            }

            Changeset = new EditDynamicGestureChangeset();
        }
示例#3
0
 public void EditDynamicGesture(DGClassWrapper gesture, bool newGesture = false)
 {
     _editDynamicGestureControl.VM = new EditDynamicGestureViewModel(this, gesture, newGesture);
     Mode = LGR_Mode.EditDynamic;
 }