public TestRollUpPanel() { InitializeComponent(); rolluppanel.HiddenMarkerWidth = -100; rolluppanel.SetPinState(true); comboBoxCustom1.Items.AddRange(new string[] { "1Fred", "Jim", "Sheila", "George" }); comboBoxCustom1.DropDownBackgroundColor = Color.Red; comboBoxCustom1.FlatStyle = FlatStyle.Popup; comboBoxCustom1.Repaint(); comboBoxCustom2.Items.AddRange(KeyObjectExtensions.KeyListString(true)); comboBoxCustom2.SelectedItem = Keys.ShiftKey.VKeyToString(); //comboBoxCustom1.FlatStyle = FlatStyle.Popup; System.Drawing.Imaging.ColorMap colormap = new System.Drawing.Imaging.ColorMap(); // any drawn panel with drawn images colormap.OldColor = Color.White; // white is defined as the forecolour colormap.NewColor = Color.Orange; System.Drawing.Imaging.ColorMap colormap2 = new System.Drawing.Imaging.ColorMap(); // any drawn panel with drawn images colormap2.OldColor = Color.FromArgb(222, 222, 222); // white is defined as the forecolour colormap2.NewColor = Color.Orange.Multiply(0.8F); foreach (Control c in rolluppanel.Controls) { if (c is ExtendedControls.CheckBoxCustom) { (c as ExtendedControls.CheckBoxCustom).SetDrawnBitmapRemapTable(new System.Drawing.Imaging.ColorMap[] { colormap, colormap2 }); } else if (c is ExtendedControls.ButtonExt) { (c as ExtendedControls.ButtonExt).SetDrawnBitmapRemapTable(new System.Drawing.Imaging.ColorMap[] { colormap, colormap2 }); } } KeyObjectExtensions.VerifyKeyOE(); }
public void PressedKey(string t, Keys k, int extsc, Keys modifiers) { bool extendedkey = (extsc & (1 << 24)) != 0; bool alt = (extsc & (1 << 29)) != 0; bool downalready = (extsc & (1 << 30)) != 0; bool up = (extsc & (1 << 31)) != 0; int sc = (int)((extsc >> 16) & 0xff); int extbits = (int)((extsc >> 24) & 0xff); string name = k.ToString(); Keys kadj = KeyObjectExtensions.VKeyAdjust(k, extendedkey, sc); string vkeyname = kadj.VKeyToString(); string res = (ws.ElapsedMilliseconds % 10000).ToString("00000") + " " + t + " " + name.PadRight(15) + " VN " + vkeyname.PadRight(15) + " keycode " + ((uint)k).ToString() + " sc:" + sc.ToString("X2") + " t:" + extbits.ToString("X2") + " " + (up ? "U" : "-") + (downalready ? "D" : "-") + (alt ? "A" : "-") + (extendedkey ? "E" : "-") + " " + modifiers.ToString(); richTextBox1.Text += res + Environment.NewLine; richTextBox1.Select(richTextBox1.Text.Length, richTextBox1.Text.Length); richTextBox1.ScrollToCaret(); }
void DisplayKeyString() { Keys shiftKey = KeyObjectExtensions.ShiftKey(checkBoxShift.Checked, checkBoxShift.Text.Contains("Right")); Keys ctrlKey = KeyObjectExtensions.ControlKey(checkBoxCtrl.Checked, checkBoxCtrl.Text.Contains("Right")); Keys altKey = KeyObjectExtensions.MenuKey(checkBoxAlt.Checked, checkBoxAlt.Text.Contains("Right")); checkBoxKey.Text = basekeystroke.HasChars() ? basekeystroke : "Press Key"; //System.Diagnostics.Debug.WriteLine("T" + textBoxKeys.Text + " at " + curinsertpoint + " " + fullname); textBoxNextDelay.ReadOnly = (curinsertpoint == 0); int nextdelay = DefaultDelay; textBoxNextDelay.Text.InvariantParse(out nextdelay); string res = textBoxKeys.Text.Substring(0, curinsertpoint); string partstring = ""; if (DefaultDelay != nextdelay) { partstring += "[" + nextdelay.ToStringInvariant() + "]"; } if (radioButtonDown.Checked) { partstring += "!"; } else if (radioButtonUp.Checked) { partstring += "^"; } string shifters = KeyObjectExtensions.ShiftersToString(shiftKey, altKey, ctrlKey); string keyname = shifters; keyname = keyname.AppendPrePad(basekeystroke, "+"); partstring += keyname; System.Diagnostics.Debug.WriteLine("Stroke " + partstring); if (partstring.Length > 0) { res = res.AppendPrePad(partstring, seperator); } buttonNext.Enabled = keyname.Length > 0; buttonDelete.Enabled = keyname.Length > 0 || curinsertpoint > 0; textBoxKeys.Text = res; textBoxKeys.Select(res.Length, res.Length); }
public override void Init() { ResetThemeList(); SetEntryThemeComboBox(); textBoxHomeSystem.SetAutoCompletor(SystemClassDB.ReturnSystemListForAutoComplete); btnDeleteCommander.Enabled = EDCommander.NumberOfCommanders > 1; comboBoxClickThruKey.Items = KeyObjectExtensions.KeyListString(inclshifts: true); comboBoxClickThruKey.SelectedItem = EDDConfig.Instance.ClickThruKey.VKeyToString(); comboBoxClickThruKey.SelectedIndexChanged += comboBoxClickThruKey_SelectedIndexChanged; discoveryform.OnRefreshCommanders += DiscoveryForm_OnRefreshCommanders; }
public void InitControl(EDDiscoveryForm discoveryForm) { _discoveryForm = discoveryForm; ResetThemeList(); SetEntryThemeComboBox(); textBoxHomeSystem.SetAutoCompletor(SystemClassDB.ReturnSystemListForAutoComplete); comboBoxTheme.ItemHeight = 20; btnDeleteCommander.Enabled = EDCommander.NumberOfCommanders > 1; comboBoxClickThruKey.Items = KeyObjectExtensions.KeyListString(inclshifts: true); comboBoxClickThruKey.SelectedItem = EDDConfig.Instance.ClickThruKey.VKeyToString(); comboBoxClickThruKey.SelectedIndexChanged += comboBoxClickThruKey_SelectedIndexChanged; }
public override void Init() { extComboBoxGameTime.Items.Add("Local"); extComboBoxGameTime.Items.Add("UTC"); extComboBoxGameTime.Items.Add("Game Time"); BaseUtils.Translator.Instance.Translate(this); BaseUtils.Translator.Instance.Translate(toolTip, this); ResetThemeList(); SetEntryThemeComboBox(); btnDeleteCommander.Enabled = EDCommander.NumberOfCommanders > 1; comboBoxClickThruKey.Items = KeyObjectExtensions.KeyListString(inclshifts: true); comboBoxClickThruKey.SelectedItem = EDDConfig.Instance.ClickThruKey.VKeyToString(); comboBoxClickThruKey.SelectedIndexChanged += comboBoxClickThruKey_SelectedIndexChanged; comboBoxCustomLanguage.Items.AddRange(BaseUtils.Translator.EnumerateLanguageNames(EDDOptions.Instance.TranslatorFolders())); comboBoxCustomLanguage.Items.Add("Auto"); comboBoxCustomLanguage.Items.Add("Default (English)"); if (comboBoxCustomLanguage.Items.Contains(EDDConfig.Instance.Language)) { comboBoxCustomLanguage.SelectedItem = EDDConfig.Instance.Language; } else { comboBoxCustomLanguage.SelectedIndex = comboBoxCustomLanguage.Items.Count - 1; } comboBoxCustomLanguage.SelectedIndexChanged += ComboBoxCustomLanguage_SelectedIndexChanged; discoveryform.OnRefreshCommanders += DiscoveryForm_OnRefreshCommanders; checkBoxOrderRowsInverted.Checked = EDDiscoveryForm.EDDConfig.OrderRowsInverted; checkBoxMinimizeToNotifyIcon.Checked = EDDiscoveryForm.EDDConfig.MinimizeToNotifyIcon; checkBoxKeepOnTop.Checked = EDDiscoveryForm.EDDConfig.KeepOnTop; checkBoxPanelSortOrder.Checked = EDDConfig.Instance.SortPanelsByName; checkBoxUseNotifyIcon.Checked = EDDiscoveryForm.EDDConfig.UseNotifyIcon; checkBoxCustomResize.Checked = EDDiscoveryForm.EDDConfig.DrawDuringResize; extComboBoxGameTime.SelectedIndex = EDDiscoveryForm.EDDConfig.DisplayTimeIndex; checkBoxOrderRowsInverted.CheckedChanged += checkBoxOrderRowsInverted_CheckedChanged; checkBoxMinimizeToNotifyIcon.CheckedChanged += checkBoxMinimizeToNotifyIcon_CheckedChanged; checkBoxKeepOnTop.CheckedChanged += checkBoxKeepOnTop_CheckedChanged; checkBoxPanelSortOrder.CheckedChanged += checkBoxPanelSortOrder_CheckedChanged; checkBoxUseNotifyIcon.CheckedChanged += checkBoxUseNotifyIcon_CheckedChanged; extComboBoxGameTime.SelectedIndexChanged += ExtComboBoxGameTime_SelectedIndexChanged; checkBoxCustomResize.CheckedChanged += checkBoxCustomResize_CheckedChanged; checkBoxMinimizeToNotifyIcon.Enabled = EDDiscoveryForm.EDDConfig.UseNotifyIcon; dataGridViewCommanders.AutoGenerateColumns = false; // BEFORE assigned to list.. dataGridViewCommanders.DataSource = EDCommander.GetListCommanders(); this.comboBoxTheme.SelectedIndexChanged += this.comboBoxTheme_SelectedIndexChanged; // now turn on the handler.. checkBoxCustomRemoveOriginals.Checked = discoveryform.screenshotconverter.RemoveOriginal; checkBoxCustomMarkHiRes.Checked = discoveryform.screenshotconverter.MarkHiRes; checkBoxCustomEnableScreenshots.Checked = discoveryform.screenshotconverter.AutoConvert; checkBoxCustomCopyToClipboard.Checked = discoveryform.screenshotconverter.CopyToClipboard; this.checkBoxCustomRemoveOriginals.CheckedChanged += new System.EventHandler(this.checkBoxCustomRemoveOriginals_CheckedChanged); this.checkBoxCustomMarkHiRes.CheckedChanged += new System.EventHandler(this.checkBoxCustomMarkHiRes_CheckedChanged); this.checkBoxCustomEnableScreenshots.CheckedChanged += new System.EventHandler(this.checkBoxCustomEnableScreenshots_CheckedChanged); this.checkBoxCustomCopyToClipboard.CheckedChanged += new System.EventHandler(this.checkBoxCustomCopyToClipboard_CheckedChanged); checkBoxCustomEDSMEDDBDownload.Checked = EDDConfig.Instance.EDSMEDDBDownload; this.checkBoxCustomEDSMEDDBDownload.CheckedChanged += new System.EventHandler(this.checkBoxCustomEDSMDownload_CheckedChanged); comboBoxCustomHistoryLoadTime.Items = new string[] { "Disabled-Load All".T(EDTx.UserControlSettings_DLA), ">7 days old".T(EDTx.UserControlSettings_7daysold), ">30 days old".T(EDTx.UserControlSettings_30daysold), ">60 days old".T(EDTx.UserControlSettings_60daysold), ">90 days old".T(EDTx.UserControlSettings_90daysold), ">180 days old".T(EDTx.UserControlSettings_180daysold), ">270 days old".T(EDTx.UserControlSettings_270daysold), "> 365 days old".T(EDTx.UserControlSettings_365daysold) }; comboBoxCustomHistoryLoadTime.Tag = new int[] { 0, 7, 30, 60, 90, 180, 270, 365 }; int ix = Array.FindIndex(comboBoxCustomHistoryLoadTime.Tag as int[], x => x == EDDConfig.Instance.FullHistoryLoadDayLimit); comboBoxCustomHistoryLoadTime.SelectedIndex = ix >= 0 ? ix : 0; comboBoxCustomHistoryLoadTime.SelectedIndexChanged += ComboBoxCustomHistoryLoadTime_SelectedIndexChanged; var eetn = new string[] { nameof(JournalEssentialEvents.EssentialEvents), nameof(JournalEssentialEvents.FullStatsEssentialEvents), nameof(JournalEssentialEvents.JumpScanEssentialEvents), nameof(JournalEssentialEvents.JumpEssentialEvents), nameof(JournalEssentialEvents.NoEssentialEvents) }; comboBoxCustomEssentialEntries.Items = new string[] { "Scans,Cargo,Missions,State,Jumps etc".T(EDTx.UserControlSettings_ESM), "All entries for Statistics".T(EDTx.UserControlSettings_FS), "Jumps and Scans".T(EDTx.UserControlSettings_EJS), "Jumps".T(EDTx.UserControlSettings_EJ), "Nothing".T(EDTx.UserControlSettings_EN) }; comboBoxCustomEssentialEntries.Tag = eetn; ix = Array.FindIndex(eetn, x => x == EDDConfig.Instance.EssentialEventTypes); comboBoxCustomEssentialEntries.SelectedIndex = ix >= 0 ? ix : 0; comboBoxCustomEssentialEntries.SelectedIndexChanged += ComboBoxCustomEssentialEntries_SelectedIndexChanged; extCheckBoxWebServerEnable.Checked = false; extButtonTestWeb.Enabled = numberBoxLongPortNo.Enabled = false; numberBoxLongPortNo.Value = EDDConfig.Instance.WebServerPort; tm.Tick += PeriodicCheck; tm.Interval = 1000; tm.Start(); extCheckBoxWebServerEnable.CheckedChanged += ExtCheckBoxWebServerEnable_CheckedChanged; }
public List <string> EventButtonNames() { return(KeyObjectExtensions.KeyListString(true)); }
public override void Init() { ResetThemeList(); SetEntryThemeComboBox(); textBoxHomeSystem.SetAutoCompletor(SystemClassDB.ReturnSystemListForAutoComplete); btnDeleteCommander.Enabled = EDCommander.NumberOfCommanders > 1; comboBoxClickThruKey.Items = KeyObjectExtensions.KeyListString(inclshifts: true); comboBoxClickThruKey.SelectedItem = EDDConfig.Instance.ClickThruKey.VKeyToString(); comboBoxClickThruKey.SelectedIndexChanged += comboBoxClickThruKey_SelectedIndexChanged; comboBoxCustomLanguage.Items.AddRange(BaseUtils.Translator.EnumerateLanguageNames(EDDOptions.Instance.TranslatorFolders())); comboBoxCustomLanguage.Items.Add("Auto"); comboBoxCustomLanguage.Items.Add("Default (English)"); if (comboBoxCustomLanguage.Items.Contains(EDDConfig.Instance.Language)) { comboBoxCustomLanguage.SelectedItem = EDDConfig.Instance.Language; } else { comboBoxCustomLanguage.SelectedIndex = comboBoxCustomLanguage.Items.Count - 1; } comboBoxCustomLanguage.SelectedIndexChanged += ComboBoxCustomLanguage_SelectedIndexChanged; discoveryform.OnRefreshCommanders += DiscoveryForm_OnRefreshCommanders; checkBoxOrderRowsInverted.Checked = EDDiscoveryForm.EDDConfig.OrderRowsInverted; checkBoxMinimizeToNotifyIcon.Checked = EDDiscoveryForm.EDDConfig.MinimizeToNotifyIcon; checkBoxKeepOnTop.Checked = EDDiscoveryForm.EDDConfig.KeepOnTop; checkBoxPanelSortOrder.Checked = EDDConfig.Instance.SortPanelsByName; checkBoxUseNotifyIcon.Checked = EDDiscoveryForm.EDDConfig.UseNotifyIcon; checkBoxUTC.Checked = EDDiscoveryForm.EDDConfig.DisplayUTC; checkBoxShowUIEvents.Checked = EDDiscoveryForm.EDDConfig.ShowUIEvents; checkBoxCustomResize.Checked = EDDiscoveryForm.EDDConfig.DrawDuringResize; checkBoxOrderRowsInverted.CheckedChanged += checkBoxOrderRowsInverted_CheckedChanged; checkBoxMinimizeToNotifyIcon.CheckedChanged += checkBoxMinimizeToNotifyIcon_CheckedChanged; checkBoxKeepOnTop.CheckedChanged += checkBoxKeepOnTop_CheckedChanged; checkBoxPanelSortOrder.CheckedChanged += checkBoxPanelSortOrder_CheckedChanged; checkBoxUseNotifyIcon.CheckedChanged += checkBoxUseNotifyIcon_CheckedChanged; checkBoxUTC.CheckedChanged += checkBoxUTC_CheckedChanged; checkBoxShowUIEvents.CheckedChanged += checkBoxShowUIEvents_CheckedChanged; checkBoxCustomResize.CheckedChanged += checkBoxCustomResize_CheckedChanged; checkBoxMinimizeToNotifyIcon.Enabled = EDDiscoveryForm.EDDConfig.UseNotifyIcon; textBoxHomeSystem.Text = EDDConfig.Instance.HomeSystem.Name; textBoxDefaultZoom.ValueNoChange = EDDConfig.Instance.MapZoom; textBoxDefaultZoom.ValueChanged += textBoxDefaultZoom_ValueChanged; bool selectionCentre = EDDConfig.Instance.MapCentreOnSelection; radioButtonHistorySelection.Checked = selectionCentre; radioButtonCentreHome.Checked = !selectionCentre; radioButtonCentreHome.CheckedChanged += radioButtonCentreHome_CheckedChanged; dataGridViewCommanders.AutoGenerateColumns = false; // BEFORE assigned to list.. dataGridViewCommanders.DataSource = EDCommander.GetListCommanders(); panel_defaultmapcolor.BackColor = Color.FromArgb(EDDConfig.Instance.DefaultMapColour); this.comboBoxTheme.SelectedIndexChanged += this.comboBoxTheme_SelectedIndexChanged; // now turn on the handler.. checkBoxCustomRemoveOriginals.Checked = discoveryform.screenshotconverter.RemoveOriginal; checkBoxCustomMarkHiRes.Checked = discoveryform.screenshotconverter.MarkHiRes; checkBoxCustomEnableScreenshots.Checked = discoveryform.screenshotconverter.AutoConvert; checkBoxCustomCopyToClipboard.Checked = discoveryform.screenshotconverter.CopyToClipboard; this.checkBoxCustomRemoveOriginals.CheckedChanged += new System.EventHandler(this.checkBoxCustomRemoveOriginals_CheckedChanged); this.checkBoxCustomMarkHiRes.CheckedChanged += new System.EventHandler(this.checkBoxCustomMarkHiRes_CheckedChanged); this.checkBoxCustomEnableScreenshots.CheckedChanged += new System.EventHandler(this.checkBoxCustomEnableScreenshots_CheckedChanged); this.checkBoxCustomCopyToClipboard.CheckedChanged += new System.EventHandler(this.checkBoxCustomCopyToClipboard_CheckedChanged); checkBoxCustomEDSMEDDBDownload.Checked = EDDConfig.Instance.EDSMEDDBDownload; this.checkBoxCustomEDSMEDDBDownload.CheckedChanged += new System.EventHandler(this.checkBoxCustomEDSMDownload_CheckedChanged); comboBoxCustomHistoryLoadTime.Items = new string[] { "Disabled-Load All".Tx(this, "DLA"), ">7 days old".Tx(this), ">30 days old".Tx(this), ">60 days old".Tx(this), ">90 days old".Tx(this), ">180 days old".Tx(this), ">270 days old".Tx(this), "> 365 days old".Tx(this) }; comboBoxCustomHistoryLoadTime.Tag = new int[] { 0, 7, 30, 60, 90, 180, 270, 365 }; int ix = Array.FindIndex(comboBoxCustomHistoryLoadTime.Tag as int[], x => x == EDDConfig.Instance.FullHistoryLoadDayLimit); comboBoxCustomHistoryLoadTime.SelectedIndex = ix >= 0 ? ix : 0; comboBoxCustomHistoryLoadTime.SelectedIndexChanged += ComboBoxCustomHistoryLoadTime_SelectedIndexChanged; var eetn = new string[] { nameof(JournalEntry.EssentialEvents), nameof(JournalEntry.FullStatsEssentialEvents), nameof(JournalEntry.JumpScanEssentialEvents), nameof(JournalEntry.JumpEssentialEvents), nameof(JournalEntry.NoEssentialEvents) }; comboBoxCustomEssentialEntries.Items = new string[] { "Scans,Cargo,Missions,State,Jumps etc".Tx(this, "ESM"), "All entries for Statistics".Tx(this, "FS"), "Jumps and Scans".Tx(this, "EJS"), "Jumps".Tx(this, "EJ"), "Nothing".Tx(this, "EN") }; comboBoxCustomEssentialEntries.Tag = eetn; ix = Array.FindIndex(eetn, x => x == EDDConfig.Instance.EssentialEventTypes); comboBoxCustomEssentialEntries.SelectedIndex = ix >= 0 ? ix : 0; comboBoxCustomEssentialEntries.SelectedIndexChanged += ComboBoxCustomEssentialEntries_SelectedIndexChanged; BaseUtils.Translator.Instance.Translate(this); BaseUtils.Translator.Instance.Translate(toolTip, this); }
} // Tell dragger no resizing. public void Init(Icon i, bool showprocess, string separ = " ", // and separ between entries string keystring = "", // current key string string process = "", // empty means program default, return empty back int defdelay = 50, // -1 means program default, return -1 back bool allowkeysedit = false, List <string> additionalkeys = null, BaseUtils.EnhancedSendKeysParser.IAdditionalKeyParser parser = null) { var enumlist = new Enum[] { ECIDs.KeyForm, ECIDs.KeyForm_radioButtonUp, ECIDs.KeyForm_radioButtonDown, ECIDs.KeyForm_radioButtonPress, ECIDs.KeyForm_checkBoxShift, ECIDs.KeyForm_checkBoxCtrl, ECIDs.KeyForm_checkBoxAlt, ECIDs.KeyForm_checkBoxKey, ECIDs.KeyForm_labelNextDelay, ECIDs.KeyForm_labelSelKeys, ECIDs.KeyForm_labelDelay, ECIDs.KeyForm_labelSendTo, ECIDs.KeyForm_buttonReset, ECIDs.KeyForm_labelKeys, ECIDs.KeyForm_buttonDelete, ECIDs.KeyForm_buttonNext, ECIDs.KeyForm_buttonTest }; BaseUtils.Translator.Instance.TranslateControls(this, enumlist); if (i != null) { Icon = i; } seperator = separ; textBoxKeys.Text = keystring; curinsertpoint = keystring.Length; textBoxSendTo.Text = process.Alt(DefaultProcessID); textBoxNextDelay.Text = textBoxDelay.Text = defdelay != DefaultDelayID?defdelay.ToStringInvariant() : "Default"; radioButtonPress.Checked = true; if (additionalkeys != null) { comboBoxKeySelector.Items.AddRange(additionalkeys); } comboBoxKeySelector.Items.AddRange(KeyObjectExtensions.KeyListString()); additionalkeyparser = parser; //System.Diagnostics.Debug.WriteLine(String.Join(",",KeyObjectExtensions.VKeyList())); comboBoxKeySelector.Text = ""; comboBoxKeySelector.SelectedIndexChanged += new System.EventHandler(this.comboBoxKeySelector_SelectedIndexChanged); if (!showprocess) { textBoxNextDelay.Visible = panelRadio.Visible = labelNextDelay.Visible = labelDelay.Visible = textBoxDelay.Visible = labelSendTo.Visible = textBoxSendTo.Visible = buttonTest.Visible = false; int d = textBoxKeys.Top - textBoxDelay.Top; foreach (Control c in new Control[] { buttonReset, buttonDelete, buttonNext, textBoxKeys, labelKeys }) { c.Top -= d; // shift down } d += 40; // cause of the Send foreach (Control c in new Control[] { buttonOK, buttonCancel }) { c.Top -= d; } panelOuter.Height -= d; this.Height -= d; } //System.Diagnostics.Debug.WriteLine("T" + textBoxKeys.Text + " at " + curinsertpoint + " >" + textBoxSendTo.Text); bool border = true; Theme theme = Theme.Current; if (theme != null) // paranoid { border = theme.ApplyDialog(this); } labelCaption.Visible = !border; AddMF(); AddMF(); if (allowkeysedit) { textBoxKeys.ReadOnly = false; } DisplayKeyString(); labelCaption.Text = this.Text; }
} // Tell dragger no resizing. public void Init(Icon i, bool showprocess, string separ, string keystring = "", string process = "", List <string> additionalkeys = null, int defdelay = 50, bool allowkeysedit = false) { if (i != null) { Icon = i; } seperator = separ; textBoxKeys.Text = keystring; curinsertpoint = keystring.Length; textBoxSendTo.Text = process.Alt(BaseUtils.EnhancedSendKeys.CurrentWindow); textBoxDelay.Text = textBoxNextDelay.Text = defdelay.ToStringInvariant(); radioButtonPress.Checked = true; if (additionalkeys != null) { comboBoxKeySelector.Items.AddRange(additionalkeys); } comboBoxKeySelector.Items.AddRange(KeyObjectExtensions.KeyListString()); //System.Diagnostics.Debug.WriteLine(String.Join(",",KeyObjectExtensions.VKeyList())); comboBoxKeySelector.Text = ""; comboBoxKeySelector.SelectedIndexChanged += new System.EventHandler(this.comboBoxKeySelector_SelectedIndexChanged); if (!showprocess) { textBoxNextDelay.Visible = panelRadio.Visible = labelNextDelay.Visible = labelDelay.Visible = textBoxDelay.Visible = labelSendTo.Visible = textBoxSendTo.Visible = buttonTest.Visible = false; int d = textBoxKeys.Top - textBoxDelay.Top; foreach (Control c in new Control[] { buttonReset, buttonDelete, buttonNext, textBoxKeys, labelKeys }) { c.Top -= d; // shift down } d += 40; // cause of the Send foreach (Control c in new Control[] { buttonOK, buttonCancel }) { c.Top -= d; } panelOuter.Height -= d; this.Height -= d; } //System.Diagnostics.Debug.WriteLine("T" + textBoxKeys.Text + " at " + curinsertpoint + " >" + textBoxSendTo.Text); bool border = true; ThemeableForms theme = ThemeableFormsInstance.Instance; if (theme != null) // paranoid { border = theme.ApplyToForm(this); } labelCaption.Visible = !border; AddMF(); if (allowkeysedit) { textBoxKeys.ReadOnly = false; } DisplayKeyString(); }
public override void Init() { extComboBoxGameTime.Items.Add("Local".T(EDTx.UserControlSettings_Local)); extComboBoxGameTime.Items.Add("UTC"); extComboBoxGameTime.Items.Add("Game Time".T(EDTx.UserControlSettings_GameTime)); ConfigureHelpButton(extButtonDrawnHelpTheme, "Theming"); ConfigureHelpButton(extButtonDrawnHelpScreenshots, "Screenshots"); ConfigureHelpButton(extButtonDrawnHelpTransparency, "Transparency"); ConfigureHelpButton(extButtonDrawnHelpWebServer, "Webserver"); ConfigureHelpButton(extButtonDrawnHelpSafeMode, "SafeMode"); ConfigureHelpButton(extButtonDrawnHelpMemory, "Memory"); ConfigureHelpButton(extButtonDrawnHelpEDSM, "EDSMSettings"); ConfigureHelpButton(extButtonDrawnHelpHistory, "HistoryDisplay"); ConfigureHelpButton(extButtonDrawnHelpDLL, "DLL"); ConfigureHelpButton(extButtonDrawnHelpWindowOptions, "WindowOptions"); ConfigureHelpButton(extButtonDrawnHelpCommanders, "Commanders"); var enumlist = new Enum[] { EDTx.UserControlSettings_groupBoxCommanders, EDTx.UserControlSettings_ColumnCommander, EDTx.UserControlSettings_EdsmName, EDTx.UserControlSettings_JournalDirCol, EDTx.UserControlSettings_NotesCol, EDTx.UserControlSettings_btnDeleteCommander, EDTx.UserControlSettings_buttonEditCommander, EDTx.UserControlSettings_buttonAddCommander, EDTx.UserControlSettings_groupBoxTheme, EDTx.UserControlSettings_button_edittheme, EDTx.UserControlSettings_buttonSaveTheme, EDTx.UserControlSettings_groupBoxCustomHistoryLoad, EDTx.UserControlSettings_checkBoxOrderRowsInverted, EDTx.UserControlSettings_labelTimeDisplay, EDTx.UserControlSettings_extGroupBoxWebServer, EDTx.UserControlSettings_labelPortNo, EDTx.UserControlSettings_extButtonTestWeb, EDTx.UserControlSettings_extCheckBoxWebServerEnable, EDTx.UserControlSettings_groupBoxInteraction, EDTx.UserControlSettings_labelTKey, EDTx.UserControlSettings_groupBoxMemory, EDTx.UserControlSettings_labelHistoryEssItems, EDTx.UserControlSettings_labelHistorySel, EDTx.UserControlSettings_groupBoxCustomScreenShots, EDTx.UserControlSettings_buttonExtScreenshot, EDTx.UserControlSettings_checkBoxCustomEnableScreenshots, EDTx.UserControlSettings_groupBoxCustomEDSM, EDTx.UserControlSettings_buttonExtEDSMConfigureArea, EDTx.UserControlSettings_checkBoxCustomEDSMDownload, EDTx.UserControlSettings_groupBoxPopOuts, EDTx.UserControlSettings_checkBoxPanelSortOrder, EDTx.UserControlSettings_checkBoxKeepOnTop, EDTx.UserControlSettings_checkBoxCustomResize, EDTx.UserControlSettings_checkBoxMinimizeToNotifyIcon, EDTx.UserControlSettings_checkBoxUseNotifyIcon, EDTx.UserControlSettings_extGroupBoxDLLPerms, EDTx.UserControlSettings_extButtonDLLConfigure, EDTx.UserControlSettings_extButtonDLLPerms, EDTx.UserControlSettings_groupBoxCustomLanguage, EDTx.UserControlSettings_groupBoxCustomSafeMode, EDTx.UserControlSettings_buttonExtSafeMode, EDTx.UserControlSettings_labelSafeMode }; var enumlisttt = new Enum[] { EDTx.UserControlSettings_btnDeleteCommander_ToolTip, EDTx.UserControlSettings_buttonEditCommander_ToolTip, EDTx.UserControlSettings_buttonAddCommander_ToolTip, EDTx.UserControlSettings_comboBoxTheme_ToolTip, EDTx.UserControlSettings_button_edittheme_ToolTip, EDTx.UserControlSettings_buttonSaveTheme_ToolTip, EDTx.UserControlSettings_checkBoxOrderRowsInverted_ToolTip, EDTx.UserControlSettings_comboBoxClickThruKey_ToolTip, EDTx.UserControlSettings_comboBoxCustomEssentialEntries_ToolTip, EDTx.UserControlSettings_comboBoxCustomHistoryLoadTime_ToolTip, EDTx.UserControlSettings_buttonExtScreenshot_ToolTip, EDTx.UserControlSettings_checkBoxCustomEnableScreenshots_ToolTip, EDTx.UserControlSettings_buttonExtEDSMConfigureArea_ToolTip, EDTx.UserControlSettings_checkBoxCustomEDSMDownload_ToolTip, EDTx.UserControlSettings_checkBoxPanelSortOrder_ToolTip, EDTx.UserControlSettings_checkBoxKeepOnTop_ToolTip, EDTx.UserControlSettings_checkBoxCustomResize_ToolTip, EDTx.UserControlSettings_checkBoxMinimizeToNotifyIcon_ToolTip, EDTx.UserControlSettings_checkBoxUseNotifyIcon_ToolTip, EDTx.UserControlSettings_buttonExtSafeMode_ToolTip }; BaseUtils.Translator.Instance.TranslateControls(this, enumlist); BaseUtils.Translator.Instance.TranslateTooltip(toolTip, enumlisttt, this); ResetThemeList(); btnDeleteCommander.Enabled = EDCommander.NumberOfCommanders > 1; comboBoxClickThruKey.Items = KeyObjectExtensions.KeyListString(inclshifts: true); comboBoxClickThruKey.SelectedItem = EDDConfig.Instance.ClickThruKey.VKeyToString(); comboBoxClickThruKey.SelectedIndexChanged += comboBoxClickThruKey_SelectedIndexChanged; comboBoxCustomLanguage.Items.AddRange(BaseUtils.Translator.EnumerateLanguageNames(EDDOptions.Instance.TranslatorFolders())); comboBoxCustomLanguage.Items.Add("Auto"); comboBoxCustomLanguage.Items.Add("Default (English)"); if (comboBoxCustomLanguage.Items.Contains(EDDConfig.Instance.Language)) { comboBoxCustomLanguage.SelectedItem = EDDConfig.Instance.Language; } else { comboBoxCustomLanguage.SelectedIndex = comboBoxCustomLanguage.Items.Count - 1; } comboBoxCustomLanguage.SelectedIndexChanged += ComboBoxCustomLanguage_SelectedIndexChanged; discoveryform.OnRefreshCommanders += DiscoveryForm_OnRefreshCommanders; checkBoxOrderRowsInverted.Checked = EDDConfig.Instance.OrderRowsInverted; checkBoxMinimizeToNotifyIcon.Checked = EDDConfig.Instance.MinimizeToNotifyIcon; checkBoxKeepOnTop.Checked = EDDConfig.Instance.KeepOnTop; checkBoxPanelSortOrder.Checked = EDDConfig.Instance.SortPanelsByName; checkBoxUseNotifyIcon.Checked = EDDConfig.Instance.UseNotifyIcon; checkBoxCustomResize.Checked = EDDConfig.Instance.DrawDuringResize; extComboBoxGameTime.SelectedIndex = EDDConfig.Instance.DisplayTimeIndex; checkBoxOrderRowsInverted.CheckedChanged += checkBoxOrderRowsInverted_CheckedChanged; checkBoxMinimizeToNotifyIcon.CheckedChanged += checkBoxMinimizeToNotifyIcon_CheckedChanged; checkBoxKeepOnTop.CheckedChanged += checkBoxKeepOnTop_CheckedChanged; checkBoxPanelSortOrder.CheckedChanged += checkBoxPanelSortOrder_CheckedChanged; checkBoxUseNotifyIcon.CheckedChanged += checkBoxUseNotifyIcon_CheckedChanged; extComboBoxGameTime.SelectedIndexChanged += ExtComboBoxGameTime_SelectedIndexChanged; checkBoxCustomResize.CheckedChanged += checkBoxCustomResize_CheckedChanged; checkBoxMinimizeToNotifyIcon.Enabled = EDDConfig.Instance.UseNotifyIcon; dataGridViewCommanders.AutoGenerateColumns = false; // BEFORE assigned to list.. dataGridViewCommanders.DataSource = EDCommander.GetListCommanders(); this.comboBoxTheme.SelectedIndexChanged += this.comboBoxTheme_SelectedIndexChanged; // now turn on the handler.. checkBoxCustomEnableScreenshots.Checked = discoveryform.ScreenshotConverter.AutoConvert; this.checkBoxCustomEnableScreenshots.CheckedChanged += new System.EventHandler(this.checkBoxCustomEnableScreenshots_CheckedChanged); checkBoxCustomEDSMDownload.Checked = EDDConfig.Instance.EDSMDownload; this.checkBoxCustomEDSMDownload.CheckedChanged += new System.EventHandler(this.checkBoxCustomEDSMDownload_CheckedChanged); comboBoxCustomHistoryLoadTime.Items = new string[] { "Disabled-Load All".T(EDTx.UserControlSettings_DLA), ">7 days old".T(EDTx.UserControlSettings_7daysold), ">30 days old".T(EDTx.UserControlSettings_30daysold), ">60 days old".T(EDTx.UserControlSettings_60daysold), ">90 days old".T(EDTx.UserControlSettings_90daysold), ">180 days old".T(EDTx.UserControlSettings_180daysold), ">270 days old".T(EDTx.UserControlSettings_270daysold), "> 365 days old".T(EDTx.UserControlSettings_365daysold) }; comboBoxCustomHistoryLoadTime.Tag = new int[] { 0, 7, 30, 60, 90, 180, 270, 365 }; int ix = Array.FindIndex(comboBoxCustomHistoryLoadTime.Tag as int[], x => x == EDDConfig.Instance.FullHistoryLoadDayLimit); comboBoxCustomHistoryLoadTime.SelectedIndex = ix >= 0 ? ix : 0; comboBoxCustomHistoryLoadTime.SelectedIndexChanged += ComboBoxCustomHistoryLoadTime_SelectedIndexChanged; var eetn = new string[] { nameof(JournalEssentialEvents.EssentialEvents), nameof(JournalEssentialEvents.FullStatsEssentialEvents), nameof(JournalEssentialEvents.JumpScanEssentialEvents), nameof(JournalEssentialEvents.JumpEssentialEvents), nameof(JournalEssentialEvents.NoEssentialEvents) }; comboBoxCustomEssentialEntries.Items = new string[] { "Scans,Cargo,Missions,State,Jumps etc".T(EDTx.UserControlSettings_ESM), "All entries for Statistics".T(EDTx.UserControlSettings_FS), "Jumps and Scans".T(EDTx.UserControlSettings_EJS), "Jumps".T(EDTx.UserControlSettings_EJ), "Nothing".T(EDTx.UserControlSettings_EN) }; comboBoxCustomEssentialEntries.Tag = eetn; ix = Array.FindIndex(eetn, x => x == EDDConfig.Instance.EssentialEventTypes); comboBoxCustomEssentialEntries.SelectedIndex = ix >= 0 ? ix : 0; comboBoxCustomEssentialEntries.SelectedIndexChanged += ComboBoxCustomEssentialEntries_SelectedIndexChanged; extCheckBoxWebServerEnable.Checked = false; extButtonTestWeb.Enabled = numberBoxLongPortNo.Enabled = false; numberBoxLongPortNo.Value = EDDConfig.Instance.WebServerPort; tm.Tick += PeriodicCheck; tm.Interval = 1000; tm.Start(); extCheckBoxWebServerEnable.CheckedChanged += ExtCheckBoxWebServerEnable_CheckedChanged; }
public static string ParseKeys(Queue <SKEvent> events, string s, int defdelay, int defshiftdelay, int defupdelay, IAdditionalKeyParser additionalkeyparser = null) { //debugevents = null; s = s.Trim(); IntPtr hwnd = (IntPtr)0; while (s.Length > 0) { if (additionalkeyparser != null) // See if key needs translating out - moved to here to allow for control sequences before this key { Tuple <string, int, string> t = additionalkeyparser.Parse(s); // Allow the parser to sniff the string if (t.Item3 != null) // error condition here, such as no matching key binding { return(t.Item3); } if (t.Item1 != null) // if replace.. (and the parser can return multiple keys) { s = t.Item1 + " " + s.Substring(t.Item2); // its the replace string, followed by the cut out current string } } int d1 = -1, d2 = -1, d3 = -1; if (s.Length >= 1 && s[0] == '[') { if (!s.Contains(']')) { return("Missing closing ] in delay"); } s = s.Substring(1); string word = ObjectExtensionsStrings.FirstWord(ref s, new char[] { ']', ',' }); if (!word.InvariantParse(out d1)) { return("Delay not properly given"); } if (s.Length >= 1 && s[0] == ',') { s = s.Substring(1); word = ObjectExtensionsStrings.FirstWord(ref s, new char[] { ']', ',' }); if (!word.InvariantParse(out d2)) { return("Second Delay not properly given"); } } if (s.Length >= 1 && s[0] == ',') { s = s.Substring(1); word = ObjectExtensionsStrings.FirstWord(ref s, new char[] { ']' }); if (!word.InvariantParse(out d3)) { return("Third Delay not properly given"); } } if (s.Length >= 1 && s[0] == ']') { s = s.Substring(1); } else { return("Missing closing ] in delay"); } } KMode kmd = KMode.press; if (s.Length == 0) { return("Invalid no characters after delay"); } if (s[0] == '^' || s[0] == '<') { kmd = KMode.up; s = s.Substring(1); } else if (s[0] == '!' || s[0] == '>') { kmd = KMode.down; s = s.Substring(1); } if (additionalkeyparser != null) // Also see here if key needs translating out - 9.0.3.0 { Tuple <string, int, string> t = additionalkeyparser.Parse(s); // Allow the parser to sniff the string if (t.Item3 != null) // error condition here, such as no matching key binding { return(t.Item3); } if (t.Item1 != null) // if replace.. (and the parser can return multiple keys) { s = t.Item1 + " " + s.Substring(t.Item2); // its the replace string, followed by the cut out current string } } Keys shift = KeyObjectExtensions.IsShiftPrefix(ref s); Keys ctrl = Keys.None; Keys alt = Keys.None; if (shift == Keys.None || s.StartsWith("+")) { s = s.Skip("+"); alt = KeyObjectExtensions.IsAltPrefix(ref s); if (alt == Keys.None || s.StartsWith("+")) { s = s.Skip("+"); ctrl = KeyObjectExtensions.IsCtrlPrefix(ref s); if (ctrl != Keys.None) { s = s.Skip("+"); } } } bool mainpart = s.Length > 0 && s[0] != ' '; // keydown is d1 or def int keydowndelay = (d1 != -1) ? d1 : defdelay; // if mainpart present, its d2 or defshift. If no main part, its d1 or def shift int shiftdelay = (mainpart) ? (d2 != -1 ? d2 : defshiftdelay) : (d1 != -1 ? d1 : defshiftdelay); // if in up/down mode, its d1 or def up. If its got a main part, its d3/defup. else its d2/defup int keyupdelay = (kmd == KMode.up || kmd == KMode.down) ? (d1 != -1 ? d1 : defupdelay) : (mainpart ? (d3 != -1 ? d3 : defupdelay) : (d2 != -1 ? d2 : defupdelay)); //System.Diagnostics.Debug.WriteLine(string.Format("{0} {1} {2} {3} {4} {5} ", d1, d2, d3, keydowndelay, shiftdelay, keyupdelay)); if (shift != Keys.None) // we already run shift keys here. If we are doing UP, we send a up, else we are doing down/press { events.Enqueue(new SKEvent(kmd == KMode.up ? BaseUtils.Win32Constants.WM.KEYUP : BaseUtils.Win32Constants.WM.KEYDOWN, shift, shiftdelay)); } if (ctrl != Keys.None) { events.Enqueue(new SKEvent(kmd == KMode.up ? BaseUtils.Win32Constants.WM.KEYUP : BaseUtils.Win32Constants.WM.KEYDOWN, ctrl, shiftdelay)); } if (alt != Keys.None) { events.Enqueue(new SKEvent(kmd == KMode.up ? BaseUtils.Win32Constants.WM.SYSKEYUP : BaseUtils.Win32Constants.WM.SYSKEYDOWN, alt, shiftdelay)); } if (mainpart) { if (s.Length == 0) { return("Invalid no characters after shifters"); } bool brackets = ObjectExtensionsStrings.IsPrefix(ref s, "("); while (s.Length > 0) { string word = ObjectExtensionsStrings.FirstWord(ref s, new char[] { ' ', ')' }); Keys key = word.ToVkey(); if (key != Keys.None) { AddMsgsForVK(events, key, alt != Keys.None && ctrl == Keys.None, keydowndelay, keyupdelay, kmd); //System.Diagnostics.Debug.WriteLine(shift + " " + alt + " " + ctrl + " press " + key.VKeyToString()); } else { while (word.Length > 0) { string ch = new string(word[0], 1); key = ch.ToVkey(); if (key.IsSingleCharName()) { AddMsgsForVK(events, key, alt != Keys.None && ctrl == Keys.None, keydowndelay, keyupdelay, kmd); //System.Diagnostics.Debug.WriteLine(shift + " " + alt + " " + ctrl + " press " + key.VKeyToString()); word = word.Substring(1); } else { return("Invalid key " + word); } } } if (!brackets) { break; } else if (s.Length > 0 && s[0] == ')') { s = s.Substring(1); break; } } } if (kmd == KMode.press) // only on a press do we release here { if (alt != Keys.None) { events.Enqueue(new SKEvent(BaseUtils.Win32Constants.WM.SYSKEYUP, alt, keyupdelay)); } if (ctrl != Keys.None) { events.Enqueue(new SKEvent(BaseUtils.Win32Constants.WM.KEYUP, ctrl, keyupdelay)); } if (shift != Keys.None) { events.Enqueue(new SKEvent(BaseUtils.Win32Constants.WM.KEYUP, shift, keyupdelay)); } } s = s.Trim(); if (s.Length > 0 && s[0] == ',') // comma can be used between key groups { s = s.Substring(1).TrimStart(); } } return(""); }
public static string ParseKeys(string s, int defdelay, int defshiftdelay, int defupdelay) { //debugevents = null; s = s.Trim(); IntPtr hwnd = (IntPtr)0; while (s.Length > 0) { KMode kmd = KMode.press; int d1 = -1, d2 = -1, d3 = -1; if (s[0] == '[') { s = s.Substring(1); string word = ObjectExtensionsStrings.FirstWord(ref s, new char[] { ']', ',' }); if (!word.InvariantParse(out d1)) { return("Delay not properly given"); } if (s[0] == ',') { s = s.Substring(1); word = ObjectExtensionsStrings.FirstWord(ref s, new char[] { ']', ',' }); if (!word.InvariantParse(out d2)) { return("Second Delay not properly given"); } } if (s[0] == ',') { s = s.Substring(1); word = ObjectExtensionsStrings.FirstWord(ref s, new char[] { ']' }); if (!word.InvariantParse(out d3)) { return("Third Delay not properly given"); } } if (s[0] == ']') { s = s.Substring(1); } else { return("Missing closing ] in delay"); } } if (s[0] == '^' || s[0] == '<') { kmd = KMode.up; s = s.Substring(1); } else if (s[0] == '!' || s[0] == '>') { kmd = KMode.down; s = s.Substring(1); } Keys shift = KeyObjectExtensions.IsShiftPrefix(ref s); Keys ctrl = Keys.None; Keys alt = Keys.None; if (shift == Keys.None || s.StartsWith("+")) { s = s.Skip("+"); alt = KeyObjectExtensions.IsAltPrefix(ref s); if (alt == Keys.None || s.StartsWith("+")) { s = s.Skip("+"); ctrl = KeyObjectExtensions.IsCtrlPrefix(ref s); if (ctrl != Keys.None) { s = s.Skip("+"); } } } bool mainpart = s.Length > 0 && s[0] != ' '; // keydown is d1 or def int keydowndelay = (d1 != -1) ? d1 : defdelay; // if mainpart present, its d2 or defshift. If no main part, its d1 or def shift int shiftdelay = (mainpart) ? (d2 != -1 ? d2 : defshiftdelay) : (d1 != -1 ? d1 : defshiftdelay); // if in up/down mode, its d1 or def up. If its got a main part, its d3/defup. else its d2/defup int keyupdelay = (kmd == KMode.up || kmd == KMode.down) ? (d1 != -1 ? d1 : defupdelay) : (mainpart ? (d3 != -1 ? d3: defupdelay) : (d2 != -1 ? d2 : defupdelay)); System.Diagnostics.Debug.WriteLine(string.Format("{0} {1} {2} {3} {4} {5} ", d1, d2, d3, keydowndelay, shiftdelay, keyupdelay)); if (shift != Keys.None) // we already run shift keys here. If we are doing UP, we send a up, else we are doing down/press { AddEvent(new SKEvent(kmd == KMode.up ? BaseUtils.Win32Constants.WM.KEYUP : BaseUtils.Win32Constants.WM.KEYDOWN, shift, shiftdelay)); } if (ctrl != Keys.None) { AddEvent(new SKEvent(kmd == KMode.up ? BaseUtils.Win32Constants.WM.KEYUP : BaseUtils.Win32Constants.WM.KEYDOWN, ctrl, shiftdelay)); } if (alt != Keys.None) { AddEvent(new SKEvent(kmd == KMode.up ? BaseUtils.Win32Constants.WM.SYSKEYUP: BaseUtils.Win32Constants.WM.SYSKEYDOWN, alt, shiftdelay)); } if (mainpart) { if (s.Length == 0) { return("Invalid no characters after shifters"); } bool brackets = ObjectExtensionsStrings.IsPrefix(ref s, "("); while (s.Length > 0) { string word = ObjectExtensionsStrings.FirstWord(ref s, new char[] { ' ', ')' }); Keys key = word.ToVkey(); if (key != Keys.None) { AddMsgsForVK(key, alt != Keys.None && ctrl == Keys.None, keydowndelay, keyupdelay, kmd); //System.Diagnostics.Debug.WriteLine(shift + " " + alt + " " + ctrl + " press " + key.VKeyToString()); } else { while (word.Length > 0) { string ch = new string(word[0], 1); key = ch.ToVkey(); if (key.IsSingleCharName()) { AddMsgsForVK(key, alt != Keys.None && ctrl == Keys.None, keydowndelay, keyupdelay, kmd); //System.Diagnostics.Debug.WriteLine(shift + " " + alt + " " + ctrl + " press " + key.VKeyToString()); word = word.Substring(1); } else { return("Invalid key " + word); } } } if (!brackets) { break; } else if (s.Length > 0 && s[0] == ')') { s = s.Substring(1); break; } } } if (kmd == KMode.press) // only on a press do we release here { if (alt != Keys.None) { AddEvent(new SKEvent(BaseUtils.Win32Constants.WM.SYSKEYUP, alt, keyupdelay)); } if (ctrl != Keys.None) { AddEvent(new SKEvent(BaseUtils.Win32Constants.WM.KEYUP, ctrl, keyupdelay)); } if (shift != Keys.None) { AddEvent(new SKEvent(BaseUtils.Win32Constants.WM.KEYUP, shift, keyupdelay)); } } s = s.Trim(); if (s.Length > 0 && s[0] == ',') // comma can be used between key groups { s = s.Substring(1).TrimStart(); } } return(""); }
// understand keycore - see above public static string KeyCore(Queue <SKEvent> events, ref string s, int defdelay, int defshiftdelay, int defupdelay, int d1, int d2, int d3, KeyPressMode kmd) { Keys shift = KeyObjectExtensions.IsShiftPrefix(ref s); Keys ctrl = Keys.None; Keys alt = Keys.None; if (shift == Keys.None || s.StartsWith("+")) { s = s.Skip("+"); alt = KeyObjectExtensions.IsAltPrefix(ref s); if (alt == Keys.None || s.StartsWith("+")) { s = s.Skip("+"); ctrl = KeyObjectExtensions.IsCtrlPrefix(ref s); if (ctrl != Keys.None) { s = s.Skip("+"); } } } bool vkeyspresent = s.Length > 0 && s[0] != ' '; bool shiftpresent = shift != Keys.None || ctrl != Keys.None || alt != Keys.None; // keydown is d1 or def int keydowndelay = (d1 != -1) ? d1 : defdelay; // if mainpart present, its d2 or defshift. If no main part, its d1 or def shift int shiftdelay = (vkeyspresent) ? (d2 != -1 ? d2 : defshiftdelay) : (d1 != -1 ? d1 : defshiftdelay); // if in up/down mode, its d1 or def up. If its got shift and vkeys, its d3/defup. else its d2/defup int keyupdelay = (kmd == KeyPressMode.Up || kmd == KeyPressMode.Down) ? (d1 != -1 ? d1 : defupdelay) : ((shiftpresent && vkeyspresent) ? (d3 != -1 ? d3 : defupdelay) : (d2 != -1 ? d2 : defupdelay)); if (shift != Keys.None) // we already run shift keys here. If we are doing UP, we send a up, else we are doing down/press { events.Enqueue(new SKEvent(kmd == KeyPressMode.Up ? BaseUtils.Win32Constants.WM.KEYUP : BaseUtils.Win32Constants.WM.KEYDOWN, shift, shiftdelay)); } if (ctrl != Keys.None) { events.Enqueue(new SKEvent(kmd == KeyPressMode.Up ? BaseUtils.Win32Constants.WM.KEYUP : BaseUtils.Win32Constants.WM.KEYDOWN, ctrl, shiftdelay)); } if (alt != Keys.None) { events.Enqueue(new SKEvent(kmd == KeyPressMode.Up ? BaseUtils.Win32Constants.WM.SYSKEYUP : BaseUtils.Win32Constants.WM.SYSKEYDOWN, alt, shiftdelay)); } if (vkeyspresent) { if (s.Length == 0) { return("Invalid no characters after shifters"); } bool brackets = ObjectExtensionsStrings.IsPrefixRemove(ref s, "("); while (s.Length > 0) { string word = ObjectExtensionsStrings.FirstWord(ref s, new char[] { ' ', ')' }); Keys key = word.ToVkey(); if (key != Keys.None) { AddMsgsForVK(events, key, alt != Keys.None && ctrl == Keys.None, keydowndelay, keyupdelay, kmd); //System.Diagnostics.Debug.WriteLine(shift + " " + alt + " " + ctrl + " press " + key.VKeyToString()); } else { while (word.Length > 0) { string ch = new string(word[0], 1); key = ch.ToVkey(); if (key.IsSingleCharName()) { AddMsgsForVK(events, key, alt != Keys.None && ctrl == Keys.None, keydowndelay, keyupdelay, kmd); //System.Diagnostics.Debug.WriteLine(shift + " " + alt + " " + ctrl + " press " + key.VKeyToString()); word = word.Substring(1); } else { return("Invalid key " + word); } } } if (!brackets) { break; } else if (s.Length > 0 && s[0] == ')') { s = s.Substring(1); break; } } } if (kmd == KeyPressMode.Press) // only on a press do we release here { if (alt != Keys.None) { events.Enqueue(new SKEvent(BaseUtils.Win32Constants.WM.SYSKEYUP, alt, keyupdelay)); } if (ctrl != Keys.None) { events.Enqueue(new SKEvent(BaseUtils.Win32Constants.WM.KEYUP, ctrl, keyupdelay)); } if (shift != Keys.None) { events.Enqueue(new SKEvent(BaseUtils.Win32Constants.WM.KEYUP, shift, keyupdelay)); } } s = s.Trim(); if (s.Length > 0 && s[0] == ',') // comma can be used between key groups { s = s.Substring(1).TrimStart(); } return(""); }
// lovely frontier uses strange naming.. its dependent on input language, except for some locals (ESP) it isn't. // do this is the best i can do.. tested UK,USA,FR,DE,IT,ESP,POL. // will probably need more bodging. static public string FrontierToKeys(string frontiername) { if (nametoscan == null) { Dictionary <char, uint> chartoscancode = KeyObjectExtensions.CharToScanCode(); //ScancodeToFrontierName(chartoscancode); nametoscan = FrontierNameToScancode(chartoscancode); mapped = IsFullyMapped(chartoscancode); //System.Diagnostics.Debug.WriteLine("Mapped " + mapped); } string output; if (frontiername.StartsWith("Key_")) { output = frontiername.Substring(4); int num; if (output.Length == 1 && ((output[0] >= '0' && output[0] <= '9') || (output[0] >= 'A' && output[0] <= 'Z'))) { // no action } else if (output.StartsWith("Numpad_") && char.IsDigit(output[7])) { output = "NumPad" + output[7]; } else if (output.StartsWith("F") && int.TryParse(output.Substring(1), out num)) { output = "F" + num; } else { int i = Array.FindIndex(frontiertovkeyname, x => x.Item2.Equals(output)); if (i >= 0) { return(frontiertovkeyname[i].Item1); } uint sc = 0; // System.Diagnostics.Debug.WriteLine("Layout " + InputLanguage.CurrentInputLanguage.LayoutName); if (InputLanguage.CurrentInputLanguage.LayoutName != "Spanish" && mapped && nametoscan.ContainsKey(output)) // spanish uses default names { sc = nametoscan[output]; } else { i = Array.FindIndex(defaultscancodes, x => x.Item1.Equals(output)); if (i >= 0) { sc = defaultscancodes[i].Item2; } } if (sc != 0) // if we have a code, convert it to a Vkey. { // System.Diagnostics.Debug.WriteLine("Name {0} ->SC {1:x}", output, sc); uint v = BaseUtils.Win32.UnsafeNativeMethods.MapVirtualKey(sc, 3); if (v != 0) { // System.Diagnostics.Debug.WriteLine(" .. {0} -> VK {1:x} {2}", sc, v, ((Keys)v).VKeyToString()); output = ((Keys)v).VKeyToString(); } else { System.Diagnostics.Debug.WriteLine("Scan code converstion failed {0} {1:x}", frontiername, sc); output = "Unknown_SCMap_" + frontiername + "_" + InputLanguage.CurrentInputLanguage.LayoutName; } } else { System.Diagnostics.Debug.WriteLine("Frontier Mapping failed {0}", frontiername); output = "Unknown_Key_" + frontiername + "_" + InputLanguage.CurrentInputLanguage.LayoutName; } } } else { output = "Unknown_Format_" + frontiername; } return(output); }