public static void LoadCustomSettings() { RegistryKey rk = null; try { rk = Registry.CurrentUser.OpenSubKey(SubKey + "\\CustomUserSettings"); if (rk == null) { return; } System.Windows.Forms.KeysConverter converter = new System.Windows.Forms.KeysConverter(); keyFullScreen = (System.Windows.Forms.Keys)converter.ConvertFromString(rk.GetValue("KeyFullScreen").ToString()); keyNextMusic = (System.Windows.Forms.Keys)converter.ConvertFromString(rk.GetValue("KeyNextMusic").ToString()); keyPlayPause = (System.Windows.Forms.Keys)converter.ConvertFromString(rk.GetValue("KeyPlayPause").ToString()); keyPreviousMusic = (System.Windows.Forms.Keys)converter.ConvertFromString(rk.GetValue("KeyPreviousMusic").ToString()); keyNextShift = (System.Windows.Forms.Keys)converter.ConvertFromString(rk.GetValue("KeyNextShift").ToString()); keyPreviousShift = (System.Windows.Forms.Keys)converter.ConvertFromString(rk.GetValue("KeyPreviousShift").ToString()); keyVolumeDown = (System.Windows.Forms.Keys)converter.ConvertFromString(rk.GetValue("KeyVolumeDown").ToString()); keyVolumeUp = (System.Windows.Forms.Keys)converter.ConvertFromString(rk.GetValue("KeyVolumeUp").ToString()); defaultOffsetShift = Convert.ToDouble(rk.GetValue("OffsetShift")); defaultOffsetVolume = Convert.ToInt32(rk.GetValue("OffsetVolume")); styleImage = Convert.ToInt32(rk.GetValue("StyleImage")); } finally { if (rk != null) { rk.Close(); } } }
private void EditKeyCombo(object sender, RoutedEventArgs e) { if (!(sender is Button)) { return; } Button KeyBind = sender as Button; bool state = true; if (state) { string keybindName = KeyBind.Tag.ToString(); List <string> keyBindList = Properties.Settings.MyKeyBinds.GetInput(keybindName) as List <string>; KeyBindConfigurator keybinder = new KeyBindConfigurator(keybindName); keybinder.ShowDialog(); if (keybinder.DialogResult == true) { KeysConverter kc = new KeysConverter(); System.Windows.Forms.Keys keyBindtoSet = keybinder.CurrentBindingKey; int keyIndex = keybinder.ListIndex; var keybindDict = Properties.Settings.MyKeyBinds.GetInput(keybindName) as List <string>; String KeyString = kc.ConvertToString(keyBindtoSet); keybindDict.RemoveAt(keyIndex); keybindDict.Add(KeyString); Properties.Settings.MyKeyBinds.SetInput(keybindName, keybindDict); } } SetAllKeybindTextboxes(); }
private void TextBlock_PreviewKeyDown(object sender, KeyEventArgs e) { TextBox tb = sender as TextBox; System.Windows.Forms.KeysConverter kc = new System.Windows.Forms.KeysConverter(); int key = System.Windows.Input.KeyInterop.VirtualKeyFromKey(e.Key); int systemKey = System.Windows.Input.KeyInterop.VirtualKeyFromKey(e.SystemKey); if (SDLAsciiDescMap.ContainsKey(key)) { tb.Text = SDLAsciiDescMap[key]; } else if (SDLAsciiDescMap.ContainsKey(systemKey)) { tb.Text = SDLAsciiDescMap[systemKey]; } else { tb.Text = key + " " + e.SystemKey + " (none)"; } //todo, implement a map e.Handled = true; }
private void ChangeStandardKey(object sender, KeyEventArgs e) { System.Windows.Forms.KeysConverter kc = new System.Windows.Forms.KeysConverter(); string a = ""; PressedKeys.Sort(); PressedKeys.Reverse(); foreach (Key k in PressedKeys) { if (a != "") a += "+"; a += kc.ConvertToString(k); } if (e.Key == Key.RightAlt) { PressedKeys.Remove(Key.LeftCtrl); } PressedKeys.Remove(e.Key); StandardKeyInput.Focus(); e.Handled = true; if (Ignore) { if (PressedKeys.Count == 0) Ignore = false; return; } else { ((ModProjectButtonViewModel)DataContext).StandardKey = a; if (PressedKeys.Count > 0) Ignore = true; } }
private void UpdateResultLabel() { KeysConverter kc = new KeysConverter(); if (KeyBindsList.Count == KeyCount) { PreviousBoxLabel.Content = KeyBindsList[ListIndex].ToString(); InputBoxLabel.Content = kc.ConvertToString(CurrentBindingKey); } }
/// <summary> /// Constructor to initialize all stuff /// </summary> /// <param name="aConfiguration">Reference to the the Configuration object</param> public Settings(Configuration aConfiguration, IPluginManager aPluginManager) { _myConfiguration = aConfiguration; _myConfiguration.AddObserver(this); _pluginManager = aPluginManager; _converter = new System.Windows.Forms.KeysConverter(); _cultConvert = new CultureInfoConverter(); InitializeComponent(); WriteThanks(); }
public void ConvertKeyCodes() { var keysConverter = new System.Windows.Forms.KeysConverter(); var areaKey = (System.Windows.Forms.Keys)vobla.Properties.Settings.Default.CaptureAreaVKCode; var areaModifierKeys = (System.Windows.Input.ModifierKeys)vobla.Properties.Settings.Default.CaptureAreaVKModifier; this.captureAreaHotkey = areaModifierKeys.ToString() + " + " + keysConverter.ConvertToString(areaKey); var screenKey = (System.Windows.Forms.Keys)vobla.Properties.Settings.Default.CaptureScreenVKCode; var screeModifierKeys = (System.Windows.Input.ModifierKeys)vobla.Properties.Settings.Default.CaptureScreenVKModifier; this.captureScreenHotkey = screeModifierKeys.ToString() + " + " + keysConverter.ConvertToString(screenKey); }
public ControlBox(String s) { TextAnchor = global::Graphics.Orientation.Center; keyConverter = new System.Windows.Forms.KeysConverter(); if (s == "") { Key = System.Windows.Forms.Keys.None; } else { Key = (System.Windows.Forms.Keys)keyConverter.ConvertFromString(s); } Text = s; AutoCheck = false; }
private void ResetButton_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("You can not reverse this, do you want to continue?", "WARNING!", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { Properties.Settings.MyKeyBinds.SetInput(KeyRefrence, Properties.Settings.MyDefaultKeyBinds.GetInput(KeyRefrence)); Classes.Options.InputPreferences.Save(); Classes.Options.InputPreferences.Reload(); KeysConverter kc = new KeysConverter(); CurrentBindingKey = (Keys)kc.ConvertFromString(KeyBindsList[ListIndex].ToString()); UpdateResultLabel(); SetupExistingKeybinds(KeyRefrence); SetupListBox(); } }
private void ChangeStandardKey(object sender, KeyEventArgs e) { System.Windows.Forms.KeysConverter kc = new System.Windows.Forms.KeysConverter(); string a = ""; PressedKeys.Sort(); PressedKeys.Reverse(); foreach (Key k in PressedKeys) { if (a != "") { a += "+"; } a += kc.ConvertToString(k); } if (e.Key == Key.RightAlt) { PressedKeys.Remove(Key.LeftCtrl); } PressedKeys.Remove(e.Key); StandardKeyInput.Focus(); e.Handled = true; if (Ignore) { if (PressedKeys.Count == 0) { Ignore = false; } return; } else { ((ModProjectButtonViewModel)DataContext).StandardKey = a; if (PressedKeys.Count > 0) { Ignore = true; } } }
public override void TriggerApply() { System.Windows.Forms.KeysConverter a = new System.Windows.Forms.KeysConverter(); int i = 0; foreach (var v in typeof(PublicControlsSettings).GetProperties()) { var a1 = Attribute.GetCustomAttributes(v, false); foreach (ControlsAttribute c in a1) { string text = textBoxes[i++].Text; if (text == "") { v.SetValue(Program.ControlsSettings, System.Windows.Forms.Keys.None, null); // textBoxes[i].Key, null); } else { v.SetValue(Program.ControlsSettings, (System.Windows.Forms.Keys)a.ConvertFromString(text), null); } } } }
private void AddSoundToList(SaveFile.Sound Snd) { System.Windows.Forms.ListViewItem Item = new System.Windows.Forms.ListViewItem { Text = GetSoundListText(Snd.FilePath) }; string HotKeyPreview = ""; if (Snd.HasHotKey) { System.Windows.Forms.KeysConverter KeyConverter = new System.Windows.Forms.KeysConverter(); if (Snd.HotKeyControl) { HotKeyPreview += KeyConverter.ConvertToString(System.Windows.Forms.Keys.Control); } if (Snd.HotKeyAlt) { HotKeyPreview += (HotKeyPreview.Length != 0 ? "+" : "") + KeyConverter.ConvertToString(System.Windows.Forms.Keys.Alt); } if (Snd.HotKeyShift) { HotKeyPreview += (HotKeyPreview.Length != 0 ? "+" : "") + KeyConverter.ConvertToString(System.Windows.Forms.Keys.Shift); } if (Snd.Key != System.Windows.Forms.Keys.None) { HotKeyPreview += (HotKeyPreview.Length != 0 ? "+" : "") + KeyConverter.ConvertToString(Snd.Key); } } Item.SubItems.Add(HotKeyPreview.Length != 0 ? HotKeyPreview : "(none)"); Item.Tag = Snd; Snd.Item = Item; this.listView1.Items.Add(Item); }
private int GetKeys() { //获得组合键值string string strKeys = this.txtKey.Text.Trim(); //检查是否为空 if (!string.IsNullOrEmpty(strKeys)) { System.Windows.Forms.KeysConverter keyCvt = new System.Windows.Forms.KeysConverter(); //合法标志置否 this.Available = false; //转全小写 strKeys = strKeys.ToLower(); //声明键状态 bool Ctrl = false; bool Alt = false; bool Shift = false; System.Windows.Forms.Keys key = System.Windows.Forms.Keys.None; //检查是否包含Ctrl if (strKeys.IndexOf("ctrl") >= 0) { Ctrl = true; strKeys = strKeys.Replace("ctrl+", ""); } //检查是否包含Alt if (strKeys.IndexOf("alt") >= 0) { Alt = true; strKeys = strKeys.Replace("alt+", ""); } //检查是否包含Shift if (strKeys.IndexOf("shift") >= 0) { Shift = true; strKeys = strKeys.Replace("shift+", ""); } //确保字符串不包含空格 strKeys = strKeys.Trim(); //检查是否为空,此步骤非必要,为了健壮加上 if (!string.IsNullOrEmpty(strKeys)) { //从字符串转换键值 key = (System.Windows.Forms.Keys)keyCvt.ConvertFromString(strKeys.ToUpper()); } //最后检查合法性 //至少一个Key + 一种控制键 if (key != System.Windows.Forms.Keys.None && (Ctrl || Alt || Shift)) { this.KeyValue = key; if (Ctrl && !Alt && !Shift) //Ctrl + Key { this.ModifiersValue = (uint)HotKey.KeyModifiers.Ctrl; } else if (Ctrl && Alt && !Shift) //Ctrl + Alt + Key { this.ModifiersValue = (uint)HotKey.KeyModifiers.Ctrl | (uint)HotKey.KeyModifiers.Alt; } else if (Ctrl && Alt && Shift) //Ctrl + Alt + Shift + Key { this.ModifiersValue = (uint)HotKey.KeyModifiers.Ctrl | (uint)HotKey.KeyModifiers.Alt | (uint)HotKey.KeyModifiers.Shift; } else if (!Ctrl && Alt && Shift) // Alt + Shift + Key { this.ModifiersValue = (uint)HotKey.KeyModifiers.Alt | (uint)HotKey.KeyModifiers.Shift; } else if (!Ctrl && !Alt && Shift) //Shift + Key { this.ModifiersValue = (uint)HotKey.KeyModifiers.Shift; } else //非法组合件 { this.Available = false; this.KeyValue = System.Windows.Forms.Keys.None; this.ModifiersValue = 0; this.bdrAC.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red); return(-1); } } else { //非法 this.Available = false; this.bdrAC.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red); this.KeyValue = System.Windows.Forms.Keys.None; this.ModifiersValue = 0; return(-1); } this.Available = true; if (HotKey.TestHotKey(this.ModifiersValue, this.KeyValue)) { this.bdrAC.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Green); } else { this.bdrAC.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red); } return(0); } else { return(-1); } }
// // Keyboard mapping key down // private void TextKeyboard_PreviewKeyDown(object sender, KeyEventArgs e) { System.Windows.Forms.KeysConverter keysConverter = new System.Windows.Forms.KeysConverter(); CultureInfo cultureInfo = new CultureInfo("en-US"); int keyCode; List <string> keys = new List <string>(); HashSet <string> keyAdded = new HashSet <string>(); foreach (Key value in Enum.GetValues(typeof(Key))) { Key key = (Key)value; if (key > Key.None && Keyboard.IsKeyDown(key)) { keyCode = KeyInterop.VirtualKeyFromKey(key); string keyName = keysConverter.ConvertToString(null, cultureInfo, keyCode).ToUpper(); switch (key) { case Key.LeftAlt: keyName = "LALT"; break; case Key.RightAlt: keyName = "RALT"; break; case Key.LeftCtrl: keyName = "LCTRL"; break; case Key.RightCtrl: keyName = "RCTRL"; break; case Key.LeftShift: keyName = "LSHIFT"; break; case Key.RightShift: keyName = "RSHIFT"; break; default: break; } if (!keyAdded.Contains(keyName)) { keys.Add(keyName); keyAdded.Add(keyName); } } } keys.Sort( (a, b) => { int value = 0; if (a.Contains("CTRL")) { value--; } if (a.Contains("ALT")) { value--; } if (a.Contains("SHIFT")) { value--; } if (b.Contains("CTRL")) { value++; } if (b.Contains("ALT")) { value++; } if (b.Contains("SHIFT")) { value++; } return(value); } ); // Set textboxes string keyText = string.Join("+", keys.ToArray()); textKeyboard.Text = keyText; textCustom.Text = keyText; comboBoxMouse.SelectedIndex = 0; if (e != null) { e.Handled = true; } }
public override void DoChecks(Data.IProject project, Ares.ModelInfo.IModelErrors errors, CancellationToken ct) { System.Windows.Forms.KeysConverter converter = new System.Windows.Forms.KeysConverter(); for (int i = 0; i < project.GetModes().Count; ++i) { IMode mode = project.GetModes()[i]; // check: no empty key if (mode.KeyCode == 0) { /* * AddError(errors, ModelError.ErrorSeverity.Warning, * String.Format(StringResources.ModeNoKey, mode.Title), mode); */ } else { // check: no globally reserved key if (s_GlobalReservedKeys.ContainsKey(mode.KeyCode)) { AddError(errors, Ares.ModelInfo.ModelError.ErrorSeverity.Error, String.Format(StringResources.ModeKeyGloballyReserved, converter.ConvertToString((System.Windows.Forms.Keys)mode.KeyCode)), mode); } // check: key not used by another mode for (int j = i + 1; j < project.GetModes().Count; ++j) { if (project.GetModes()[j].KeyCode == mode.KeyCode) { AddError(errors, Ares.ModelInfo.ModelError.ErrorSeverity.Error, String.Format(StringResources.DuplicateModeKey, converter.ConvertToString((System.Windows.Forms.Keys)mode.KeyCode), mode.Title, project.GetModes()[j].Title), mode); } } } // check mode elements for (int j = 0; j < mode.GetElements().Count; ++j) { IModeElement modeElement = mode.GetElements()[j]; // get key code, if there is one int keyCode = 0; if (modeElement.Trigger != null) { if (modeElement.Trigger.TriggerType == TriggerType.Key) { keyCode = ((IKeyTrigger)modeElement.Trigger).KeyCode; } else { // no key trigger, no checks continue; } } // check: no empty key if (keyCode == 0) { /* * AddError(errors, ModelError.ErrorSeverity.Warning, * String.Format(StringResources.ModeElementNoKey, modeElement.Title), modeElement); */ } else { // check: no globally reserved key if (s_GlobalReservedKeys.ContainsKey(keyCode)) { AddError(errors, Ares.ModelInfo.ModelError.ErrorSeverity.Error, String.Format(StringResources.ModeElementKeyGloballyReserved, converter.ConvertToString((System.Windows.Forms.Keys)keyCode)), modeElement); } // check: key not used by a mode for (int k = 0; k < project.GetModes().Count; ++k) { if (project.GetModes()[k].KeyCode == keyCode) { AddError(errors, Ares.ModelInfo.ModelError.ErrorSeverity.Error, String.Format(StringResources.ModeElementKeyUsedByMode, converter.ConvertToString((System.Windows.Forms.Keys)keyCode), modeElement.Title, project.GetModes()[k].Title), modeElement); } } // check: key not used by another element in the same mode for (int k = j + 1; k < mode.GetElements().Count; ++k) { IModeElement other = mode.GetElements()[k]; if (other.Trigger != null && other.Trigger.TriggerType == TriggerType.Key) { if (((IKeyTrigger)other.Trigger).KeyCode == keyCode) { AddError(errors, Ares.ModelInfo.ModelError.ErrorSeverity.Error, String.Format(StringResources.DuplicateModeElementKey, converter.ConvertToString((System.Windows.Forms.Keys)keyCode), modeElement.Title, other.Title), modeElement); } } } } ct.ThrowIfCancellationRequested(); } } }
private void nS_OnReceived(object sender, NetClientReceivedEventArgs<byte[]> e) { bool canConnect =true; Application.Current.Dispatcher.Invoke(new Action(() => { MainWindow mw = (MainWindow)Application.Current.MainWindow; canConnect = (bool)mw.canConnect.IsChecked; })); if (canConnect) { String by = System.Text.Encoding.UTF8.GetString(e.Data); by = by.Replace("\n", ""); bool isSQ = false; string[] files = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + "\\custom\\"); string[] fl = new string[3]; foreach (string item in files) { fl = File.ReadAllText(item).Split('!'); if (fl[0] == by) isSQ = true; } if (!isSQ) { if (by.Contains("^")) InputSimulator.SimulateKeyDown(VirtualKeyCode.LCONTROL); if (by.Contains("+")) InputSimulator.SimulateKeyDown(VirtualKeyCode.LSHIFT); if (by.Contains("%")) InputSimulator.SimulateKeyDown(VirtualKeyCode.MENU); usesText = by.Contains("$"); by = by.Replace("^", "").Replace("+", "").Replace("%", "").Replace("$", ""); System.Windows.Forms.KeysConverter kc = new System.Windows.Forms.KeysConverter(); if (!usesText) { by = by.ToUpper(); bool isChar = false; if (by == "TAB") { InputSimulator.SimulateKeyPress(VirtualKeyCode.TAB); isChar = true; } if (by == "ENTER") { InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); isChar = true; } if (by == "DEL") { InputSimulator.SimulateKeyPress(VirtualKeyCode.BACK); isChar = true; } if (by == "CLICK"){ InputSimulator.SimulateKeyPress(VirtualKeyCode.LBUTTON); isChar = true; } if (by == "CLICK2"){ InputSimulator.SimulateKeyPress(VirtualKeyCode.RBUTTON); isChar = true; } if (by == "SUPR"){ InputSimulator.SimulateKeyPress(VirtualKeyCode.DELETE); isChar = true; } if(!isChar) InputSimulator.SimulateKeyPress(getKey(by[0].ToString())); int isFKey = 0; for (int i = 1; i < 13; i++) if (by.Contains("F" + i.ToString())) isFKey = i; if (isFKey != 0) { VirtualKeyCode KEY = (VirtualKeyCode)Convert.ToByte(isFKey + 111); InputSimulator.SimulateKeyPress(KEY); } } else { InputSimulator.SimulateTextEntry(by); } Thread.Sleep(100); InputSimulator.SimulateKeyUp(VirtualKeyCode.LCONTROL); InputSimulator.SimulateKeyUp(VirtualKeyCode.LSHIFT); InputSimulator.SimulateKeyUp(VirtualKeyCode.MENU); } else { ProcessStartInfo start = new ProcessStartInfo(); start.Arguments = fl[2]; start.FileName = fl[1]; Process.Start(start); } Application.Current.Dispatcher.Invoke(new Action(() => { MainWindow mw = (MainWindow)Application.Current.MainWindow; mw.appendConsole("[" + DateTime.Now.ToString() + "] " + by); })); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { if (chbAutoLogon.IsChecked.HasValue) { Settings.Default.AutoLogon = chbAutoLogon.IsChecked.Value; } if (chbAutoStart.IsChecked.HasValue) { Settings.Default.AutoStart = chbAutoStart.IsChecked.Value; AutoStart.Current.EnabledThroughStartupMenu = chbAutoStart.IsChecked.Value; } if (chbAlwaysInTray.IsChecked.HasValue) { Settings.Default.AlwaysInTray = chbAlwaysInTray.IsChecked.Value; } if (chbMinimalizeToTray.IsChecked.HasValue) { Settings.Default.MinimalizeToTray = chbMinimalizeToTray.IsChecked.Value; } if (chbPlaySoundWhenNewStatus.IsChecked.HasValue) { Settings.Default.PlaySoundWhenNewStatus = chbPlaySoundWhenNewStatus.IsChecked.Value; } if (chbHotKeyEnabled.IsChecked.HasValue) { Settings.Default.HotKeyEnabled = chbHotKeyEnabled.IsChecked.Value; } System.Windows.Forms.KeysConverter keysConverter = new System.Windows.Forms.KeysConverter(); Settings.Default.HotKey = (System.Windows.Forms.Keys)keysConverter.ConvertFromString(HotKeyComboBox.SelectedItem.ToString()); Settings.Default.Save(); Close(); }
public void lanuchBAM(string tpath, string tname, string executable, string wpath, string defaultExe, int keycode, string system, string scriptType, bool desktop, int camera = 0, string BAMExe="") { System.Windows.Forms.KeysConverter converter = new System.Windows.Forms.KeysConverter(); string text = converter.ConvertToString(keycode); if (executable == string.Empty) executable = defaultExe; string Arguments = string.Empty; string exe = BAMExe; var p = Path.Combine(tpath, tname); if (scriptType != string.Empty) Arguments = @"/STAYINRAM /FPEXE:" + "\"" + executable + "\"" + " /open " + "\"" + p + "\"" + " /play /exit /arcaderender,,hide UseErrorLevel"; else Arguments = @"/STAYINRAM /FPEXE:" + "\"" + executable + "\"" + " /open " + "\"" + p + "\"" + " /play /exit /arcaderender,,hide UseErrorLevel"; ProcessStartInfo si = new ProcessStartInfo(exe, Arguments); si.WorkingDirectory = wpath; si.UseShellExecute = true; si.CreateNoWindow = true; Process.Start(si); }
static public System.Windows.Forms.Keys KeyFromString(string str) { var kc = new System.Windows.Forms.KeysConverter(); return((System.Windows.Forms.Keys)kc.ConvertFromString(str)); }
private string MapString(string Text) { string result = ""; uint curNeutralLangID = (uint)(System.Windows.Forms.InputLanguage.CurrentInputLanguage.Culture.LCID & 0xff); System.Windows.Forms.KeysConverter conv = new System.Windows.Forms.KeysConverter(); //foreach ( char achar in Text ) for (int i = 0; i < Text.Length; ++i) { System.Windows.Forms.Keys keyData = ResolveKey(Text[i]); if (keyData == m_ControlKeyReplacement) { // we misuse tab as command key, avoid common processing continue; } System.Windows.Forms.Keys bareKey = keyData & ~(System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift | System.Windows.Forms.Keys.ShiftKey | System.Windows.Forms.Keys.Alt); bareKey = keyData; if ((bareKey & System.Windows.Forms.Keys.Shift) == System.Windows.Forms.Keys.Shift) { bareKey &= ~System.Windows.Forms.Keys.Shift; } if (MainForm.Settings.BASICKeyMap.KeymapEntryExists(keyData)) { KeymapEntry key = MainForm.Settings.BASICKeyMap.GetKeymapEntry(keyData); if (key.Commodore != 65535) { if ((keyData & System.Windows.Forms.Keys.Shift) == System.Windows.Forms.Keys.Shift) { result += key.Shifted; continue; } if (GR.Win32.KeyboardInfo.GetKeyState(System.Windows.Forms.Keys.Tab).IsPressed) //if ( ( keyData & m_ControlKeyReplacement ) == m_ControlKeyReplacement ) { result += key.Commodore; continue; } result += key.Normal; continue; } } else if (MainForm.Settings.BASICKeyMap.KeymapEntryExists(bareKey)) { KeymapEntry key = MainForm.Settings.BASICKeyMap.GetKeymapEntry(bareKey); if ((keyData & System.Windows.Forms.Keys.Shift) == System.Windows.Forms.Keys.Shift) { result += key.Shifted; continue; } else if (GR.Win32.KeyboardInfo.GetKeyState(System.Windows.Forms.Keys.Tab).IsPressed) //else if ( ( keyData & m_ControlKeyReplacement ) == m_ControlKeyReplacement ) { result += key.Commodore; continue; } result += key.Normal; continue; } } return(result); }
private void textBox1_TextChanged(object sender, RoutedEventArgs e) { KeysConverter kc = new KeysConverter(); InputBox.Content = kc.ConvertToString(CurrentBindingKey); }
/// <summary> /// 从数据文件路径初始化内部数据 /// </summary> /// <param name="path"></param> /// <returns></returns> private int ConnectDB() { if (objDB != null) { this.data.Name = objDB.ReadFirstByName("Name") as string; this.data.ID = objDB.ReadFirstByName("ID") as string; int Count = Convert.ToInt32(objDB.ReadFirstByName("Icon")); try { using (BinaryReader br = new BinaryReader(new FileStream(Manage.IconPath + data.ID + ".ib", FileMode.Open))) { data.Icon = br.ReadBytes(Count); } data.IS = GetIcon.ByteArrayToIS(data.Icon); } catch { } this.data.Path = objDB.ReadFirstByName("Path") as string; this.data.Arguments = objDB.ReadFirstByName("Arguments") as string; this.data.RunAs = Convert.ToInt32(objDB.ReadFirstByName("Runas")); this.data.AutoRun = Convert.ToInt32(objDB.ReadFirstByName("Autorun")); this.data.Levels = Convert.ToInt32(objDB.ReadFirstByName("Levels")); this.data.WorkingDirectory = objDB.ReadFirstByName("WorkingDirectory"); this.data.tagName = objDB.ReadFirstByName("TagName"); string strHKI = objDB.ReadFirstByName("HotKey"); if (strHKI != null) { if (!string.IsNullOrEmpty(strHKI.Replace(",", "").Replace(" ", ""))) { string[] HKISplit; try { HKISplit = strHKI.Split(','); } catch { HKISplit = new string[] { }; } if (HKISplit.Length >= 3) { System.Windows.Forms.KeysConverter keyCvt = new System.Windows.Forms.KeysConverter(); this.data.HotKey = new HotKeyItem(this, (System.Windows.Forms.Keys)keyCvt.ConvertFromString(HKISplit[0]), Convert.ToUInt32(HKISplit[1]), Convert.ToInt32(HKISplit[2]), HotKeyItem.HotKeyParentType.Item); if (Manage.CheckAndRegisterHotKey(data.HotKey)) { Anything_wpf_main_.cls.HotKey.CurrentID++; data.EnableHotKey = true; } } else { this.data.HotKey = new HotKeyItem(null, System.Windows.Forms.Keys.None, 0, 0, HotKeyItem.HotKeyParentType.Item); } } else { data.HotKey = new HotKeyItem(this, System.Windows.Forms.Keys.None, 0, 0, HotKeyItem.HotKeyParentType.Item); } } return(0); } return(-1); }
public void launchVP(string tpath, string tname, string executable, string wpath, string defaultExe, int keycode, string system, string scriptType, bool desktop, int camera = 0) { System.Windows.Forms.KeysConverter converter = new System.Windows.Forms.KeysConverter(); string text = converter.ConvertToString(keycode); if (executable == string.Empty) executable = defaultExe; string Arguments = string.Empty; string exe = string.Empty; if (system == "Visual Pinball") exe = "VPLaunch.exe"; else if (system == "P-ROC") exe = "PROCLaunch.exe"; Arguments = tpath + " " + tname + " " + executable + " " + wpath + " " + text + " " + scriptType + " " + desktop + " " + camera; ProcessStartInfo si = new ProcessStartInfo(exe, Arguments); si.UseShellExecute = true; si.CreateNoWindow = true; Process.Start(si); }