private void CellUpdate(TwoKeysCombination addedCombination, string cellContent) { var openCloseBrackets = Globals.OpenCloseBrackets .Where(x => x.keys.SequenceEqual(addedCombination.Action.VirtualKeys)) .Select(x => x.sign) .FirstOrDefault(); if (!string.IsNullOrEmpty(openCloseBrackets)) { ConfigGrid.CurrentCell.Value = cellContent; } else { ConfigGrid.CurrentCell.Value = cellContent.TrimStart('-').ToLowerInvariant(); } }
private void SaveAction() { if (ConfigGrid.CurrentRow != null) { if (currentCombination?.Action != null) { var modKeys = currentCombination.Action.GetActionModKeys(); var noModKeys = currentCombination.Action.GetActionNoModKeys(); var cellContent = currentCombination.Action.ToString(); var addedCombination = new TwoKeysCombination() { Action = currentCombination.Action, FirstKeyVirtualCode = ConfigGrid.CurrentCell.RowIndex.ToString(), SecondKeyVirtualCode = (ConfigGrid.CurrentCell.ColumnIndex - 1).ToString(), Keys = currentCombination.Keys, logger = logger }; if (!newCombinations.Contains(addedCombination, new KeyCombinationsComparer())) { newCombinations.Add(addedCombination); CellUpdate(addedCombination, cellContent); } else { var editedConfig = newCombinations .FirstOrDefault(x => x.Equals(addedCombination)); if (editedConfig != null) { editedConfig.Action = addedCombination.Action; CellUpdate(addedCombination, editedConfig.Action.ToString()); } } currentCombination.Clear(); MoveToNextCell(); } } }