public AddEditKeysDialog(ModulesConfiguration configuration, KeysInputVariable keys) { InitializeComponent(); Array vals = Enum.GetValues(typeof(Microsoft.DirectX.DirectInput.Key)); List <Microsoft.DirectX.DirectInput.Key> tmp = new List <Microsoft.DirectX.DirectInput.Key>(); for (int i = 0; i < vals.Length; i++) { if (tmp.Contains((Microsoft.DirectX.DirectInput.Key)vals.GetValue(i))) { continue; } tmp.Add((Microsoft.DirectX.DirectInput.Key)vals.GetValue(i)); checkedListBox1.Items.Add(new KV() { Key = (Microsoft.DirectX.DirectInput.Key)vals.GetValue(i), Name = Utils.KeyToFriendlyName((Microsoft.DirectX.DirectInput.Key)vals.GetValue(i)) }); } checkedListBox1.Sorted = true; _configuration = configuration; _keys = keys; if (_keys != null) { Text = "Edycja klawiszy '" + _keys.ID + "'"; textBox1.Text = _keys.ID; textBox2.Text = _keys.Description; checkBox1.Checked = _keys.Repeat; numericUpDown1.Value = _keys.RepeatAfter; numericUpDown2.Value = _keys.RepeatInterval; for (int i = 0; i < _keys.Keys.Length; i++) { for (int j = 0; j < checkedListBox1.Items.Count; j++) { if (((KV)checkedListBox1.Items[j]).Key == _keys.Keys[i]) { checkedListBox1.SetItemChecked(j, true); break; } } } } else { Text = "Dodaj klawisze"; } textBox1.Focus(); _defaultColor = textBox3.BackColor; _defaultColorText = textBox3.ForeColor; _keyboard = new Microsoft.DirectX.DirectInput.Device(Microsoft.DirectX.DirectInput.SystemGuid.Keyboard); _keyboard.SetDataFormat(Microsoft.DirectX.DirectInput.DeviceDataFormat.Keyboard); _keyboard.SetCooperativeLevel(IntPtr.Zero, Microsoft.DirectX.DirectInput.CooperativeLevelFlags.Background | Microsoft.DirectX.DirectInput.CooperativeLevelFlags.NonExclusive); _keyboard.Acquire(); }
public KeyboardInputConfigurationDialog(ModulesConfiguration configuration) { InitializeComponent(); Configuration = configuration; ShowKeys(); }
public bool Configuration(System.Windows.Forms.IWin32Window parent) { if (_working) { System.Windows.Forms.MessageBox.Show(parent, "Konfiguracja jest niedostępna w trakcie działania skryptu korzystającego z tego modułu.", "Uwaga", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); return(false); } KeyboardInputConfigurationDialog d = new KeyboardInputConfigurationDialog(ModulesConfiguration.Load(ModulesConfiguration.ConfigurationFilePath)); if (d.ShowDialog(parent) == System.Windows.Forms.DialogResult.OK) { d.Configuration.Save(); ModulesConfiguration.Reload(); LoadConfiguration(); return(true); } return(false); }
public static ModulesConfiguration Load(string fileName) { if (!File.Exists(fileName)) { throw new FileNotFoundException(fileName); } ModulesConfiguration c = new ModulesConfiguration(); XmlDocument xml = new XmlDocument(); xml.Load(fileName); XmlNodeList nodes = xml.SelectNodes("configuration/input/keys"); if (nodes != null && nodes.Count > 0) { List <KeysInputVariable> keys = new List <KeysInputVariable>(); foreach (XmlNode node in nodes) { keys.Add(KeysInputVariable.Read(node)); } c.Keys = keys.ToArray(); } return(c); }
private void LoadConfiguration() { _configuration = ModulesConfiguration.Load(); _keys = _configuration.Keys; }