private void AddRowsToGrid(MappingFilter filter) { Collection <KeyMapping> maps = MappingsManager.GetMappings(filter); foreach (KeyMapping map in maps) { if (filter == MappingFilter.ClearedUser || filter == MappingFilter.ClearedBoot) { if (this._keylist.Contains(map.From)) { // Don't add an entry for a cleared key which has been remapped. break; } } else { this._keylist.Add(map.From); } int index = this.grdMappings.Rows.Add(map.ToString()); this.grdMappings.Rows[index].Tag = map; string cellvalue = string.Empty; switch (filter) { case MappingFilter.Boot: cellvalue = "Boot"; break; case MappingFilter.User: cellvalue = "User"; break; case MappingFilter.ClearedUser: case MappingFilter.ClearedBoot: cellvalue = "Cleared"; // Need to store the row to a little array as // don't want to have to access each cell to decide whether // to show the delete button for it or not. this._clearedKeys.Add(index); break; } this.grdMappings.Rows[index].Cells[1].Value = cellvalue; if (MappingsManager.IsMappingPending(map, filter)) { this.grdMappings.Rows[index].Cells[2].Value = "Pending"; } else { this.grdMappings.Rows[index].Cells[2].Value = "Mapped"; } } }
private void GetButtons() { if (showAllButtons) { buttonCount = 8; return; } // Assume there are some normal unmapped keys! buttonCount = 1; // See what's currently mapped by looking at the current mapping list var currentMaps = MappingsManager.GetMappings(MappingFilter.Current); foreach (var map in currentMaps) { if (MappingsManager.IsMappingPending(map, MappingFilter.Boot)) { // Pending if (MappingsManager.IsDisabledMapping(map)) { if (!pendingDisabled) { pendingDisabled = true; buttonCount++; } } else { if (!pendingMapped) { pendingMapped = true; buttonCount++; } } } else { // Actual if (MappingsManager.IsDisabledMapping(map)) { if (!disabledKeys) { disabledKeys = true; buttonCount++; } } else { if (!mappedKeys) { mappedKeys = true; buttonCount++; } } } } // Now look at the cleared keys. var maps = MappingsManager.ClearedMappings; foreach (var map in maps) { // Has this cleared key been remapped (in which case we ignore it) bool remapped = false; foreach (var currentmap in MappingsManager.GetMappings(MappingFilter.Current)) { if (currentmap.From == map.From) { remapped = true; break; } } if (remapped) { continue; } if (MappingsManager.IsDisabledMapping(map)) { if (!pendingEnabled) { pendingEnabled = true; buttonCount++; } } else { if (!pendingUnmapped) { pendingUnmapped = true; buttonCount++; } } } }
private void GetButtons() { if (this._showAllButtons) { this._buttonCount = 8; return; } // Assume there are some normal unmapped keys! this._buttonCount = 1; // See what's currently mapped by looking at the current mapping list Collection <KeyMapping> currentMaps = MappingsManager.GetMappings(MappingFilter.Current); foreach (KeyMapping map in currentMaps) { if (MappingsManager.IsMappingPending(map, MappingFilter.All)) { // Pending if (MappingsManager.IsDisabledMapping(map)) { if (!this._pendingdisabled) { this._pendingdisabled = true; this._buttonCount++; } } else { if (!this._pendingmapped) { this._pendingmapped = true; this._buttonCount++; } } } else { // Actual if (MappingsManager.IsDisabledMapping(map)) { if (!this._disabledkeys) { this._disabledkeys = true; this._buttonCount++; } } else { if (!this._mappedkeys) { this._mappedkeys = true; this._buttonCount++; } } } } // Now look at the cleared keys. IEnumerable <KeyMapping> maps = MappingsManager.ClearedMappings; foreach (KeyMapping map in maps) { // Has this cleared key been remapped (in which case we ignore it) bool remapped = false; foreach (KeyMapping currentmap in MappingsManager.GetMappings(MappingFilter.Current)) { if (currentmap.From == map.From) { remapped = true; break; } } if (remapped) { continue; } if (MappingsManager.IsDisabledMapping(map)) { if (!this._pendingenabled) { this._pendingenabled = true; this._buttonCount++; } } else { if (!this._pendingunmapped) { this._pendingunmapped = true; this._buttonCount++; } } } }