public KeyPictureBox(int scanCode, int extended, BlankButton button, float scale, int horizontalStretch, int verticalStretch) { this.scanCode = scanCode; this.extended = extended; this.button = button; this.scale = scale; this.horizontalStretch = horizontalStretch; this.verticalStretch = verticalStretch; dragIconScale = 0.75F; dragbox = Rectangle.Empty; Map = MappingsManager.GetKeyMapping(scanCode, extended); mapped = (Map.To.ScanCode != -1); AllowDrop = true; // Box controls itself. DragOver += KeyPictureBoxDragOver; DragDrop += KeyPictureBoxDragDrop; DragLeave += KeyPictureBoxDragLeave; GiveFeedback += KeyPictureBoxGiveFeedback; MouseDown += KeyPictureBoxMouseDown; MouseMove += KeyPictureBoxMouseMove; MouseUp += KeyPictureBoxMouseUp; QueryContinueDrag += KeyPictureBoxQueryContinueDrag; DrawKey(); Width = Image.Width; Height = Image.Height; }
// Use this for initialization void Start() { annotationSetupManager = GameObject.Find("Boss Object").GetComponent <AnnotationSetupManager> (); tiersByModifiableAction = annotationSetupManager.ModifiableActionManager.TiersByModifiableAction; ParametersByModifiableAction = new Dictionary <string, Dictionary <string, string> > (); MappingsManager mappingsManager = annotationSetupManager.MappingsSetupPanel.GetComponent <MappingsManager> (); List <string> mappingsOutputManager = new List <string>(mappingsManager.MappingInputOutput.Values); contentMappingsPosition = contentPanelMappings.position; actions = new List <string>(tiersByModifiableAction.Keys); if (actions.Count > 0) { currentAction = actions [0]; List <string> tiers = tiersByModifiableAction [currentAction]; currentParameterList = annotationSetupManager.getParametersByTierString(tiers); foreach (string param in currentParameterList) { GameObject spriteNameGO = GameObject.Instantiate(itemPrefab); Button currentButton = spriteNameGO.GetComponent <Button> (); spriteNameGO.GetComponent <SampleItemButton> ().SetItemListText(param); spriteNameGO.transform.SetParent(contentPanelParameters); } actions.RemoveAt(0); } dropdownItem.GetComponent <Dropdown> ().ClearOptions(); mappingsOutputManager.Insert(0, ""); dropdownItem.GetComponent <Dropdown> ().AddOptions(mappingsOutputManager); }
public KeyPictureBox(int scancode, int extended, BlankButton button, float scale, int horizontalStretch, int verticalStretch) { _scancode = scancode; _extended = extended; _button = button; _scale = scale; _horizontalStretch = horizontalStretch; _verticalStretch = verticalStretch; _dragIconScale = 0.75F; _dragbox = Rectangle.Empty; Map = MappingsManager.GetKeyMapping(_scancode, _extended); _mapped = (Map.To.Scancode != -1); this.AllowDrop = true; // Box controls itself. this.DragOver += KeyPictureBoxDragOver; this.DragDrop += KeyPictureBoxDragDrop; this.DragLeave += KeyPictureBoxDragLeave; this.GiveFeedback += KeyPictureBoxGiveFeedback; this.MouseDown += KeyPictureBoxMouseDown; this.MouseMove += KeyPictureBoxMouseMove; this.MouseUp += KeyPictureBoxMouseUp; this.QueryContinueDrag += KeyPictureBoxQueryContinueDrag; DrawKey(); this.Width = this.Image.Width; this.Height = this.Image.Height; }
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 LoadUserSettings() { Properties.Settings userSettings = new Properties.Settings(); // As user.config is writeable (if you can find it!) // don't want to trust the settings. bool firstrun = true; Point savedPosition = Point.Empty; int savedWidth = 0; MappingFilter oldFilter = MappingFilter.All; firstrun = (userSettings.UserHasSavedSettings == false); savedPosition = userSettings.KeyboardFormLocation; savedWidth = userSettings.KeyboardFormWidth; _hasNumberPad = userSettings.KeyboardFormHasNumberPad; _isMacKeyboard = userSettings.KeyboardFormHasMacKeyboard; oldFilter = (MappingFilter)userSettings.LastMappingsFilter; //if (firstrun == false) //{ // // AppController.SwitchKeyboardLayout((KeyboardLayoutType)userSettings.KeyboardLayout); //} if (firstrun || savedPosition.IsEmpty || savedPosition.X == -32000) { FormsManager.PositionMainForm(); } else { this.Location = savedPosition; } if (firstrun || savedWidth < this.MinimumSize.Width) { FormsManager.SizeMainForm(); } else { this.Width = savedWidth; } // If there are boot mappings and no user mappings and the last view mode was boot, then // start in boot mode - as long as user has the rights to change them (or is running Vista) if (oldFilter == MappingFilter.Boot && MappingsManager.GetMappingCount(MappingFilter.Boot) > 0 && MappingsManager.GetMappingCount(MappingFilter.User) == 0 && (AppController.UserCanWriteBootMappings || operatingSystemCapability.ImplementsUAC)) { MappingsManager.SetFilter(MappingFilter.Boot); } }
private void SetReadonlyStatusLabelText() { if (MappingsManager.IsRestartRequired()) { StatusLabelRestartLogoff.Text = "Restart to complete the mappings"; StatusLabelRestartLogoff.Visible = true; } else { StatusLabelRestartLogoff.Text = string.Empty; StatusLabelRestartLogoff.Visible = false; } }
private void KeyPictureBoxDragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent("KeyMapper.KeyMapping")) { var draggedmap = (KeyMapping)e.Data.GetData("KeyMapper.KeyMapping"); if (MappingsManager.AddMapping(new KeyMapping(Map.From, draggedmap.From)) == false) { // Mapping failed. Need to revert our appearance.. DrawKey(); } } }
void SetMappingsMenuButtonStates() { // Mappings - view all, user, boot. if (operatingSystemCapability.SupportsUserMappings) { switch (MappingsManager.Filter) { case MappingFilter.All: clearAllToolStripMenuItem.Text = "C&lear All Mappings"; break; case MappingFilter.Boot: clearAllToolStripMenuItem.Text = "C&lear All Boot Mappings"; break; case MappingFilter.User: clearAllToolStripMenuItem.Text = "C&lear All User Mappings"; break; } } else { clearAllToolStripMenuItem.Text = "C&lear All Mappings"; } // Disable "Clear Mappings" and "Revert To Saved Mappings" if user can't write mappings at all // and the latter if there haven't been any changes clearAllToolStripMenuItem.Enabled = !AppController.UserCannotWriteMappings; revertToSavedToolStripMenuItem.Enabled = ( AppController.UserCannotWriteMappings == false && (MappingsManager.IsRestartRequired() || MappingsManager.IsLogOnRequired())); onlyShowBootMappingsToolStripMenuItem.Text = "Boot Mappings" + (AppController.UserCanWriteBootMappings || operatingSystemCapability.ImplementsUAC ? String.Empty : " (Read Only)"); // Mappings - check current view showAllMappingsToolStripMenuItem.Checked = (MappingsManager.Filter == MappingFilter.All); onlyShowBootMappingsToolStripMenuItem.Checked = (MappingsManager.Filter == MappingFilter.Boot); onlyShowUserMappingsToolStripMenuItem.Checked = (MappingsManager.Filter == MappingFilter.User); // Whether to allow the option of viewing user mappings (ie not on W2K) chooseMappingsToolStripMenuItem.Visible = (operatingSystemCapability.SupportsUserMappings); selectFromCaptureToolStripMenuItem.Enabled = !AppController.UserCannotWriteMappings; }
private void DisableButtonClick(object sender, EventArgs e) { // Disable or enable, close form anyway. if (disabled) { // Enable MappingsManager.DeleteMapping(map); } else { // Disable map = new KeyMapping(map.From, new Key(0, 0)); MappingsManager.AddMapping(map); } Close(); }
void SetMappingStatusLabelText() { int allmaps = MappingsManager.GetMappingCount(MappingFilter.All); int bootmaps = MappingsManager.GetMappingCount(MappingFilter.Boot); int usermaps = MappingsManager.GetMappingCount(MappingFilter.User); // TODO: Localizing issue. How to do plurals in other cultures??? string mapstatustext; if (allmaps > 0) { string bootmaptext = string.Empty; if (bootmaps != 0) { bootmaptext = operatingSystemCapability.SupportsUserMappings ? string.Format("{0} boot mapping{1}", bootmaps, (bootmaps != 1 ? "s" : "")) : string.Format("{0} mapping{1}", bootmaps, (bootmaps != 1 ? "s" : "")); } if (usermaps != 0) { string usermaptext = usermaps.ToString(CultureInfo.InvariantCulture.NumberFormat) + " user mapping" + (usermaps != 1 ? "s" : ""); mapstatustext = bootmaptext + (String.IsNullOrEmpty(bootmaptext) ? "" : ", ") + usermaptext; } else { mapstatustext = bootmaptext; } } else { // Need to have *something* on the status bar otherwise it doesn't work // properly in W2K (it doesn't show on startup) mapstatustext = "No mappings"; } StatusLabelMappings.Text = mapstatustext; }
private void SetMappingStatusLabelText() { int bootmaps = MappingsManager.GetMappingCount(MappingFilter.Boot); string mapstatustext; if (bootmaps != 0) { mapstatustext = string.Format("{0} mapping{1}", bootmaps, (bootmaps != 1 ? "s" : "")); } else { // Need to have *something* on the status bar otherwise it doesn't work // properly in W2K (it doesn't show on startup) mapstatustext = "No mappings"; } StatusLabelMappings.Text = mapstatustext; }
void SetReadonlyStatusLabelText() { if (MappingsManager.IsRestartRequired()) { StatusLabelRestartLogoff.Text = "Restart to complete the mappings"; StatusLabelRestartLogoff.Visible = true; } else if (MappingsManager.IsLogOnRequired()) { StatusLabelRestartLogoff.Text = "Log on again to complete the mappings"; StatusLabelRestartLogoff.Visible = true; } else { StatusLabelRestartLogoff.Text = String.Empty; StatusLabelRestartLogoff.Visible = false; } StatusLabelReadOnly.Visible = (AppController.UserCannotWriteMappings && !operatingSystemCapability.ImplementsUAC); }
private void grdMappingsCellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex != 3) { return; } int row = e.RowIndex; if (_clearedKeys.Contains(row)) { return; // Shouldn't happen anyway } if (row >= 0) { DataGridViewRow currentRow = grdMappings.Rows[row]; if (currentRow.Tag != null) { MappingsManager.DeleteMapping((KeyMapping)currentRow.Tag); } } }
private void grdMappingsCellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex != 3) { return; } int row = e.RowIndex; if (this._clearedKeys.Contains(row)) { return; // Shouldn't happen anyway } if (row >= 0) { DataGridViewRow currentRow = this.grdMappings.Rows[row]; if (currentRow.Tag != null) { MappingFilter filter; if (currentRow.Cells[1].Value.ToString() == "User") { filter = MappingFilter.User; } else if (currentRow.Cells[1].Value.ToString() == "Boot") { filter = MappingFilter.Boot; } else { return; } MappingsManager.DeleteMapping((KeyMapping)currentRow.Tag, filter); } } }
private void exportAsRegistryFileMenuItemClick(object sender, EventArgs e) { MappingsManager.ExportMappingsAsRegistryFile(false); }
private void revertToSavedMenuItemClick(object sender, EventArgs e) { MappingsManager.RevertToStartupMappings(); OnMappingsChanged(null, null); }
private void clearAllMenuItemClick(object sender, EventArgs e) { MappingsManager.ClearMappings(); OnMappingsChanged(null, null); }
private void onlyShowUserMappingsMenuItemClick(object sender, EventArgs e) { MappingsManager.SetFilter(MappingFilter.User); Redraw(); }
private void redoMenuItemClick(object sender, EventArgs e) { MappingsManager.RedoMappingChange(); }
private void showAllMappingsMenuItemClick(object sender, EventArgs e) { MappingsManager.SetFilter(MappingFilter.All); Redraw(); }
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 MapSelected() { if (disabled) { // Nono - Can't map while disabled. Shouldn't be here anyway! return; } if (mapped) { // Unmap. MappingsManager.DeleteMapping(map); SetMapToBlankMapping(); Close(); return; } if (capturingToKey) { // Ah, but have we caught a "to" key yet? if (!map.IsValid()) { return; } capturingToKey = false; StopCapture(); MappingsManager.AddMapping(map); Close(); return; } if (selectingFromKeyFromLists) { Key selectedKey = GetKeyFromListboxValue(); // Have we been sent a dud?? if (selectedKey.Scancode == 0) { // Something went wrong. map = new KeyMapping(); } else { SetMapToBlankMapping(selectedKey.Scancode, selectedKey.Extended); // Need to move panel back to where it was and set the image in the picturebox KeyListsPanel.Location = savedPanelLocation; FromKeyPictureBox.SetImage(ButtonImages.GetButtonImage(map.From.Scancode, map.From.Extended)); selectingFromKeyFromLists = false; keyThreshold = 1; SetListOptionsComboIndex(); SetupForm(); return; } } if (capturingFromKey == false) { // Not mapped, not capturing From or To keys, so this is mapping from list. // Need to call method to create map from name. if (CreateMappingFromListboxValue()) { MappingsManager.AddMapping(map); Close(); } return; } else { // Setting the From key. Map has already been created from keypress capturingFromKey = false; StopCapture(); direction = FadeDirection.FromBlankToUnmapped; SetupForm(); Transition(); } }
private void forceUserMappingsToolStripMenuItem_Click(object sender, EventArgs e) { MappingsManager.SaveUserMappingsToKeyMapperKey(true); }
private void DisableKey() { MappingsManager.AddMapping(new KeyMapping(Map.From, new Key(0, 0))); }
private void DeleteCurrentMapping() { MappingsManager.DeleteMapping(Map); }
private void SetMapToBlankMapping() { map = MappingsManager.GetEmptyMapping(map.From); }
private void SetMapToBlankMapping(int scancode, int extended) { map = MappingsManager.GetEmptyMapping(new Key(scancode, extended)); }
private void SetButtonImages() { // Set the buttons' bitmap as required. Always call SetImage as that // handles releasing the existing bitmap if any.. // From key is straightforward. float scale = (DpiInfo.Dpi / 96F); if (FromKeyPictureBox.Image == null && map.IsEmpty()) { FromKeyPictureBox.SetImage(ButtonImages.GetButtonImage (-1, -1, BlankButton.Blank, 0, 0, scale, ButtonEffect.None)); } else { FromKeyPictureBox.SetImage(ButtonImages.GetButtonImage (map.From.Scancode, map.From.Extended, BlankButton.Blank, 0, 0, scale, ButtonEffect.None)); } // To Key depends more on state int scancode = 0; int extended = 0; ButtonEffect effect = ButtonEffect.None; // 'Disabled' is a special case of 'Mapped' if (disabled) { effect = MappingsManager.IsMappingPending(map) ? ButtonEffect.DisabledPending : ButtonEffect.Disabled; } else { if (!mapped) { // Not mapped. What are we doing then?? if (capturingToKey) { scancode = map.To.Scancode; extended = map.To.Extended; if (map.To.Scancode == 0) { // Can't map to a disabled key - show button as disabled.. effect = ButtonEffect.Disabled; } else { effect = ButtonEffect.MappedPending; } } else if (capturingFromKey) { if (map.IsEmpty()) { // Show a blank key. scancode = -1; extended = -1; } } } else { // Mapped to a specific key scancode = map.To.Scancode; extended = map.To.Extended; effect = MappingsManager.IsMappingPending(map) ? ButtonEffect.MappedPending : ButtonEffect.Mapped; } } ToKeyPictureBox.SetImage(ButtonImages.GetButtonImage(scancode, extended, BlankButton.Blank, 0, 0, scale, effect)); }
private void DrawKey() { int scanCode = this.scanCode; int extended = this.extended; ButtonEffect effect; if (MappingsManager.IsEmptyMapping(Map) == false) { // Remapped or disabled? if (MappingsManager.IsDisabledMapping(Map)) { // Disabled if (MappingsManager.IsMappingPending(Map)) { effect = ButtonEffect.DisabledPending; } else { effect = ButtonEffect.Disabled; } } else { // Is this key mapped under the current filter? if (MappingsManager.IsMappingPending(Map)) { effect = ButtonEffect.MappedPending; } else { effect = ButtonEffect.Mapped; } // Either way, we want the button to show what it is (will be) mapped to: scanCode = Map.To.ScanCode; extended = Map.To.Extended; } } else { // Not mapped now, but was this key mapped before under the current filter?? var km = MappingsManager.GetClearedMapping(scanCode, extended); if (MappingsManager.IsEmptyMapping(km)) { effect = ButtonEffect.None; } else if (MappingsManager.IsDisabledMapping(km)) { effect = ButtonEffect.EnabledPending; } else { effect = ButtonEffect.UnmappedPending; } } var keybmp = ButtonImages.GetButtonImage( scanCode, extended, button, horizontalStretch, verticalStretch, scale, effect); SetImage(keybmp); }
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++; } } } }