private void addMapping(MenuItemViewModel item) { int index = _mappings.Count; //add on the last row by default if (_selectedMappings.Count > 0) //if something is selected, add it at the end of the selection { index = _mappings.IndexOf(_selectedMappings.Last()) + 1; } var proxy = item.Tag as CommandProxy; Mapping m; try { m = _device.CreateMapping(proxy); } catch (Exception e) { if (true || CmdrSettings.Instance.VerboseExceptions) { MessageBoxHelper.ShowException("Error adding mapping " + item.Text, e); } return; } _device.InsertMapping(index, m); // this is to add the mapping itelf var mvm = new MappingViewModel(_device, m); var row = new RowItemViewModel(mvm); _mappings.Insert(index, row); //this is to add the row to the grid selectExclusive(row); row.BringIntoView(); }
private void addMapping(MenuItemViewModel item) { int index = _mappings.Count; if (_selectedMappings.Count > 0) { index = _mappings.IndexOf(_selectedMappings.Last()) + 1; } var proxy = item.Tag as CommandProxy; var m = _device.CreateMapping(proxy); _device.InsertMapping(index, m); var mvm = new MappingViewModel(_device, m); var row = new RowItemViewModel(mvm); _mappings.Insert(index, row); selectExclusive(row); row.BringIntoView(); }
private void addMapping(MenuItemViewModel item) { int index = _mappings.Count; //add on the last row by default if (_selectedMappings.Count > 0) //if something is selected, add it at the end of the selection { index = _mappings.IndexOf(_selectedMappings.Last()) + 1; } var proxy = item.Tag as CommandProxy; var m = _device.CreateMapping(proxy); _device.InsertMapping(index, m); // this is to add the mapping itelf var mvm = new MappingViewModel(_device, m); var row = new RowItemViewModel(mvm); _mappings.Insert(index, row); //this is to add the row to the grid selectExclusive(row); row.BringIntoView(); row.ClearFiltering(); // HACK: investigate why there is a duplication on the very first paste or "add-in". Clearing grid filters avoids this bug }
private void updateAddMappingContextMenus() { if (OutCommands.Contains(_separator)) { OutCommands.Remove(_separator); OutCommands.RemoveAt(OutCommands.Count - 1); } MappingViewModel selectedMapping = null; if (_selectedMappings.Count != 1 || (selectedMapping = _selectedMappings.Single().Item as MappingViewModel).Command.MappingType != MappingType.In) { return; } if (All.KnownOutCommands.ContainsKey(selectedMapping.Command.Id)) { var commandProxy = All.KnownOutCommands[selectedMapping.Command.Id]; if (!OutCommands.Contains(_separator)) { OutCommands.Add(_separator); OutCommands.Add(new MenuItemViewModel { Text = commandProxy.Name + " (" + selectedMapping.AssignmentExpression + ")", Tag = commandProxy, Command = new CommandHandler <MenuItemViewModel>(i => { int index = _mappings.Count; if (_selectedMappings.Count > 0) { index = _mappings.IndexOf(_selectedMappings.Last()) + 1; } var proxy = i.Tag as CommandProxy; var m = _device.CreateMapping(proxy); _device.InsertMapping(index, m); var mvm = new MappingViewModel(_device, m); mvm.Assignment = selectedMapping.Assignment; if (selectedMapping.CanOverrideFactoryMap) { mvm.OverrideFactoryMap = selectedMapping.OverrideFactoryMap; } if (selectedMapping.MidiBinding != null && MidiOutDefinitions.ContainsKey(selectedMapping.MidiBinding.Note)) { mvm.SetBinding(MidiOutDefinitions[selectedMapping.MidiBinding.Note]); } if (selectedMapping.Conditions.Condition1 != null) { mvm.SetCondition(TsiLib.Conditions.ConditionNumber.One, selectedMapping.Conditions.Condition1); } if (selectedMapping.Conditions.Condition2 != null) { mvm.SetCondition(TsiLib.Conditions.ConditionNumber.Two, selectedMapping.Conditions.Condition2); } var row = new RowItemViewModel(mvm); _mappings.Insert(index, row); selectExclusive(row); row.BringIntoView(); }) }); } } }
private void highlight(RowItemViewModel item) { item.BringIntoView(); _dvm.SelectedMappings.Clear(); _dvm.SelectedMappings.Add(item); }