Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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;
            }
        }
Esempio n. 4
0
        private void UpdateResultLabel()
        {
            KeysConverter kc = new KeysConverter();

            if (KeyBindsList.Count == KeyCount)
            {
                PreviousBoxLabel.Content = KeyBindsList[ListIndex].ToString();
                InputBoxLabel.Content    = kc.ConvertToString(CurrentBindingKey);
            }
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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;
                }
            }
        }
Esempio n. 7
0
        private void textBox1_TextChanged(object sender, RoutedEventArgs e)
        {
            KeysConverter kc = new KeysConverter();

            InputBox.Content = kc.ConvertToString(CurrentBindingKey);
        }
        //
        // 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;
            }
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
 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);
 }
Esempio n. 11
0
 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();
         }
     }
 }