public static void Initialise() { //ini stuff InitializationFile ini = new InitializationFile("Plugins/LSPDFR/British Policing Script.ini"); ini.Create(); try { ToggleMenuKey = (Keys)kc.ConvertFromString(ini.ReadString("General", "ToggleMenuKey", "F9")); ToggleMenuModifierKey = (Keys)kc.ConvertFromString(ini.ReadString("General", "ToggleMenuModifierKey", "None")); FailtostopEnabled = ini.ReadBoolean("Callouts", "FailToStopEnabled", true); FailtostopFrequency = ini.ReadInt32("Callouts", "FailToStopFrequency", 2); ANPRHitEnabled = ini.ReadBoolean("Callouts", "ANPRHitEnabled", true); ANPRHitFrequency = ini.ReadInt32("Callouts", "ANPRHitFrequency", 2); TWOCEnabled = ini.ReadBoolean("Callouts", "TWOCEnabled", true); TWOCFrequency = ini.ReadInt32("Callouts", "TWOCFrequency", 2); CourtSystem.RealisticCourtDates = ini.ReadBoolean("General", "RealisticCourtDates", true); } catch (Exception e) { Game.LogTrivial(e.ToString()); Game.LogTrivial("Error loading British Policing Script INI file. Loading defaults"); Game.DisplayNotification("~r~Error loading British Policing Script INI file. Loading defaults"); } BetaCheck(); }
/// <summary> /// Main process that enters our key and makes the menu enabled /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public static void Process(object sender, GraphicsEventArgs e) { //A keys converter is used to convert a string to a key. KeysConverter kc = new KeysConverter(); //We create two variables: one is a System.Windows.Keys, the other is a string. Keys EndCalloutKey; Keys EndCalloutKeyModifier; //Use a try/catch, because reading values from files is risky: we can never be sure what we're going to get and we don't want our plugin to crash. try { //We assign myKeyBinding the value of the string read by the method getMyKeyBinding(). We then use the kc.ConvertFromString method to convert this to a key. //If the string does not represent a valid key (see .ini file for a link) an exception is thrown. That's why we need a try/catch. EndCalloutKey = (Keys)kc.ConvertFromString(getEndKey()); EndCalloutKeyModifier = (Keys)kc.ConvertFromString(getEndCalloutKeyModifier()); } //If there was an error reading the values, we set them to their defaults. We also let the user know via a notification. catch { EndCalloutKey = Keys.End; EndCalloutKeyModifier = Keys.LShiftKey; Game.DisplayNotification("There was an error reading the .ini file. Setting defaults..."); } if (Game.IsKeyDownRightNow(EndCalloutKeyModifier) && Game.IsKeyDownRightNow(EndCalloutKey) && !_menuPool.IsAnyMenuOpen()) // Our menu on/off switch. { mainMenu.Visible = !mainMenu.Visible; } _menuPool.ProcessMenus(); // Process all our menus: draw the menu and process the key strokes and the mouse. }
public static void LoadSettings() { InitializationFile settings = initialiseFile($"{Globals.Application.ConfigPath}{Globals.Application.ConfigFileName}"); //Makes a new key converter to convert a string to a key KeysConverter kc = new KeysConverter(); string OpenDoorKey, OpenDoorModifier; //GENERAL //Reads the settings from the general section in the ini file Globals.GeneralConfig.DebugLogging = settings.ReadBoolean("General", "DebugLogging", false); Globals.GeneralConfig.OpenDoorHelp = settings.ReadBoolean("General", "OpenDoorHelp", true); //KEYBINDINGS //Reads the keybindings from the ini file OpenDoorKey = settings.ReadString("Keybindings", "OpenDoorKey", "T"); OpenDoorModifier = settings.ReadString("Keybindings", "OpenDoorModifierKey", "None"); //KEY CONVERTERS //Converts strings to keys Globals.Controls.OpenDoorKey = (Keys)kc.ConvertFromString(OpenDoorKey); Globals.Controls.OpenDoorModifier = (Keys)kc.ConvertFromString(OpenDoorModifier); Game.LogTrivial($"[KEYBINDINGS] OpenDoorKey is set to {Globals.Controls.OpenDoorKey}"); Game.LogTrivial("-----------------------------------------------------------------------------------------------------"); }
public static void LoadConfig() { InitializationFile settings = initialiseFile(Global.Application.ConfigPath + "SilencerKI.ini"); Logger.DebugLog("General Config Loading Started."); Global.Application.DebugLogging = (settings.ReadBoolean("General", "DebugLogging", false)); KeysConverter KeyCV = new KeysConverter(); string AttachKey, AttachKeyModifier, AttachSilencerController, AttachSilencerControllerModifier; AttachKey = settings.ReadString("Keybinds", "AttachSilencer", "F10"); AttachKeyModifier = settings.ReadString("Keybinds", "AttachSilencerModifier", "LShiftKey"); AttachSilencerController = settings.ReadString("Keybinds", "AttachSilencerController", "DPadRight"); AttachSilencerControllerModifier = settings.ReadString("Keybinds", "AttachSilencerControllerModifier", "LShiftKey"); Global.Controls.AttachSilencer = (Keys)KeyCV.ConvertFromString(AttachKey); Global.Controls.AttachSilencerModifier = (Keys)KeyCV.ConvertFromString(AttachKeyModifier); TypeConverter typeConverter = TypeDescriptor.GetConverter(Global.Controls.AttachSilencerController); ControllerButtons CVController = (ControllerButtons)typeConverter.ConvertFromString(AttachSilencerController); ControllerButtons CVControllerModifier = (ControllerButtons)typeConverter.ConvertFromString(AttachSilencerControllerModifier); Global.Controls.AttachSilencerController = CVController; Global.Controls.AttachSilencerControllerModifier = CVControllerModifier; Logger.DebugLog("General Config Loading Finished."); }
public Form1() { InitializeComponent(); this.Opacity = 0; inputSim = new InputSimulator(); m_GlobalHook = Hook.GlobalEvents(); m_GlobalHook.KeyDown += M_GlobalHook_KeyDown; m_GlobalHook.KeyUp += M_GlobalHook_KeyUp; lblStatus.Location = new Point(lblStatus.Location.X, lblStatus.Location.Y + 40); pbStatus.Location = new Point(pbStatus.Location.X, pbStatus.Location.Y + 40); btnExport.Location = new Point(btnExport.Location.X, pbStatus.Location.Y - 5); btnImport.Location = new Point(btnImport.Location.X, pbStatus.Location.Y - 5); tbLog.Size = new Size(tbLog.Size.Width, tbLog.Size.Height + 30); Directory.CreateDirectory(Path.GetDirectoryName(Database.databaseFile)); AppDomain.CurrentDomain.SetData("DataDirectory", Database.databaseFile); Database.CreateDatabaseIfNotExist(); kc = new KeysConverter(); StartStopRecording = (Keys)kc.ConvertFromString(Database.HotKeyStartStopRecording); PlaybackRecording = (Keys)kc.ConvertFromString(Database.HotKeyPlaybackRecording); SetControlValues(); random = new Random(); tbLog.AppendText(" == Initialized MousePlayBack V" + IO.ApplicationVersion + " ==\r\n"); tmrFadeIn.Start(); }
public static void LoadSettings() { InitializationFile settings = initialiseFile(Globals.Application.ConfigPath + Globals.Application.ConfigFileName); //Makes a new key converter to convert a string to a key KeysConverter kc = new KeysConverter(); string TouchRearKey, TouchRearModifier; //KEYS //Reads the keys from the ini file TouchRearKey = settings.ReadString("Keybindings", "TouchRearKey", "U"); TouchRearModifier = settings.ReadString("Keybindings", "TouchRearModifier", "None"); //KEY CONVERTERS //Converts a string to a key Globals.Keybindings.TouchRearKey = (Keys)kc.ConvertFromString(TouchRearKey); Globals.Keybindings.TouchRearModifier = (Keys)kc.ConvertFromString(TouchRearModifier); //GENERAL //Reads the values in the General section from the ini file Globals.GeneralConfig.DebugLogging = settings.ReadBoolean("General", "DebugLogging", false); //LOGGERS //Logs the values set in the ini file Logger.Log("[GENERAL] DebugLogging is set to " + Globals.GeneralConfig.DebugLogging); Logger.Log("[KEYBINDINGS] TouchRearKey is set to " + Globals.Keybindings.TouchRearKey); Logger.Log("[KEYBINDINGS] TouchRearModifier is set to " + Globals.Keybindings.TouchRearModifier); Game.LogTrivial("-----------------------------------------------------------------------------------------------------"); }
private void RegisterHotkeyForRole(SummonerModel summoner) { var converter = new KeysConverter(); try { var firstSpellKey = (Keys)converter.ConvertFromString( Settings.Default[$"{summoner.Name}FirstSpellHotkey"].ToString()); HotkeyManager.Current.AddOrReplace($"{summoner.Name}FirstSpell", firstSpellKey, delegate { summoner.FirstSummonerSpell.SpellUsedTime = DateTime.Now; }); var secondSpellKey = (Keys)converter.ConvertFromString( Settings.Default[$"{summoner.Name}SecondSpellHotkey"].ToString()); HotkeyManager.Current.AddOrReplace($"{ summoner.Name }SecondSpell", secondSpellKey, delegate { summoner.SecondSummonerSpell.SpellUsedTime = DateTime.Now; }); } catch (Exception e) { Console.WriteLine(e); MessageBox.Show(e.Message, @"Error while registering hotkey"); } }
public static void LoadConfig() { //Reads the ini file InitializationFile settings = initialiseFile(Globals.Application.ConfigPath + "ForceACallout.ini"); //Makes a new converter to convert strings to keys KeysConverter kc = new KeysConverter(); string FoceCalloutKey; string ForceCalloutModifier; string DebugLogging; string AvailabilityKey; string AvailabilityModifier; string AvailableForCalloutsText; int RectangleAlpha; //Reads the key and modifier to force a callout from the ini file FoceCalloutKey = settings.ReadString("Keybindings", "ForceCalloutKey", "X"); ForceCalloutModifier = settings.ReadString("Keybindings", "ForceCalloutModifier", "None"); //Reads the value for debug logging from the ini file DebugLogging = settings.ReadString("General", "DebugLogging", "False"); //Reads the key and modifier to set the player's availability from the ini file AvailabilityKey = settings.ReadString("Keybindings", "AvailabilityKey", "Z"); AvailabilityModifier = settings.ReadString("Keybindings", "AvailabilityModifier", "None"); //Reads the value to enable or disable the on screen text AvailableForCalloutsText = settings.ReadString("General", "AvailableForCalloutsText", "True"); //Reads the int for the rectangle alpha RectangleAlpha = settings.ReadInt16("General", "RectangleAlpha", 200); //Logs some things Logger.Log("DebugLogging is set to " + DebugLogging); Logger.Log("ForceCalloutKey is set to " + FoceCalloutKey); Logger.Log("ForceCalloutModifier is set to " + ForceCalloutModifier); Logger.Log("AvailabilityKey is set to " + AvailabilityKey); Logger.Log("AvailabilityModifier is set to " + AvailabilityModifier); Logger.Log("AvailableForCalloutsText is set to " + AvailableForCalloutsText); Logger.Log("RectangleAlpha is set to " + RectangleAlpha); //These convert strings to keys Globals.Controls.ForceCalloutKey = (Keys)kc.ConvertFromString(FoceCalloutKey); Globals.Controls.ForceCalloutModifier = (Keys)kc.ConvertFromString(ForceCalloutModifier); Globals.Controls.AvailabilityKey = (Keys)kc.ConvertFromString(AvailabilityKey); Globals.Controls.AvailabilityModifier = (Keys)kc.ConvertFromString(AvailabilityModifier); //Converts a string to a bool Globals.Application.DebugLogging = Convert.ToBoolean(DebugLogging); //Converts a string to a bool Globals.Application.AvailableForCalloutsText = Convert.ToBoolean(AvailableForCalloutsText); //Assigns the rectangle alpha int to something Globals.Application.RectangleAlpha = RectangleAlpha; }
public static void ReadIniFile() { PlayerName = iniFile.ReadString("DISPLAY", "PlayerName", "Loikas"); UseBritishPersona = iniFile.ReadBoolean("DISPLAY", "UseBritishPersona", false); KeysConverter kc = new KeysConverter(); PlateCheckKey = (Keys)kc.ConvertFromString(iniFile.ReadString("KEYBINDINGS", "PlateCheck", "C")); PedCheckKey = (Keys)kc.ConvertFromString(iniFile.ReadString("KEYBINDINGS", "PedCheck", "X")); }
private static void loadValuesFromIniFile() { try { motorcadeModifierKey = (Keys)kc.ConvertFromString(getMotorcadeModifierKey()); motorcadeEndKey = (Keys)kc.ConvertFromString(getMotorcadeEndKey()); } catch { motorcadeModifierKey = Keys.LControlKey; motorcadeEndKey = Keys.D0; } }
private static unsafe ConfigurationContainer ReadFromIni(InitializationFile initializationFile) { KeysConverter kc = new KeysConverter(); Keys forcePursuitKey; Keys forcePursuitModifier; bool allowInvestigation; try { Extensions.LogTrivial($"Attempting to read ForcePursuit keybinding"); forcePursuitKey = (Keys)kc.ConvertFromString(initializationFile.ReadString("Keybindings", "ForcePursuit", "T")); Extensions.LogTrivial($"Successfully read ForcePursuit key ({forcePursuitKey})"); } catch { forcePursuitKey = Keys.T; var log = $"Pursuit on the Fly: There was an error reading ForcePursuit keybinding from PursuitsOnTheFly.ini, make sure your preferred key is valid. Applying default key ({forcePursuitKey})."; Game.DisplayNotification(log); Game.LogTrivial(log); } try { forcePursuitModifier = (Keys)kc.ConvertFromString(initializationFile.ReadString("Keybindings", "ForcePursuitModifier", "None")); } catch { forcePursuitModifier = Keys.None; var log = "Pursuit on the Fly: There was an error reading ForcePursuitModifier keybinding from PursuitOnTheFly.ini, make sure your preferred modifier key is valid. Applying no modifier key."; Game.DisplayNotification(log); Game.LogTrivial(log); } try { allowInvestigation = initializationFile.ReadBoolean("General", "AllowInvestigativeMode", true); } catch { allowInvestigation = false; var log = "Pursuit on the Fly: There was an error reading the AllowInvestigativeMode setting from PursuitOnTheFly.ini, make sure the value is valid."; Game.DisplayNotification(log); Game.LogTrivial(log); } return(new ConfigurationContainer(allowInvestigation, forcePursuitKey, forcePursuitModifier)); }
public static void LoadConfig() { InitializationFile settings = initialiseFile(Global.Application.ConfigPath + "PassengerKI.ini"); Logger.DebugLog("General Config Loading Started."); Global.Application.DebugLogging = (settings.ReadBoolean("General", "DebugLogging", false)); KeysConverter KeyCV = new KeysConverter(); string EnterPassenger, EnterPassengerModifier, EnterPassengerController, EnterPassengerControllerModifier, DriveToMarker, DriveToMarkerModifier, DriveToMarkerController, DriveToMarkerControllerModifier; // Fetch settings from file / set default values EnterPassenger = settings.ReadString("Keybinds", "EnterPassenger", "E"); EnterPassengerModifier = settings.ReadString("Keybinds", "EnterPassengerModifier", "None"); EnterPassengerController = settings.ReadString("Keybinds", "EnterPassengerController", "Y"); EnterPassengerControllerModifier = settings.ReadString("Keybinds", "EnterPassengerControllerModifier", "DPadDown"); DriveToMarker = settings.ReadString("Keybinds", "DriveToMarker", "Space"); DriveToMarkerModifier = settings.ReadString("Keybinds", "DriveToMarkerModifier", "None"); DriveToMarkerController = settings.ReadString("Keybinds", "DriveToMarkerController", "X"); DriveToMarkerControllerModifier = settings.ReadString("Keybinds", "DriveToMarkerControllerModifier", "DPadLeft"); // Assign Keyboard Buttons to Global Variable Global.Controls.EnterPassenger = (Keys)KeyCV.ConvertFromString(EnterPassenger); Global.Controls.EnterPassengerModifier = (Keys)KeyCV.ConvertFromString(EnterPassengerModifier); Global.Controls.DriveToMarker = (Keys)KeyCV.ConvertFromString(DriveToMarker); Global.Controls.DriveToMarkerModifier = (Keys)KeyCV.ConvertFromString(DriveToMarkerModifier); // Convert Controller Buttons to the right format TypeConverter typeConverter = TypeDescriptor.GetConverter(Global.Controls.EnterPassengerController); // get type of variable ControllerButtons EPController = (ControllerButtons)typeConverter.ConvertFromString(EnterPassengerController); ControllerButtons EPControllerModifier = (ControllerButtons)typeConverter.ConvertFromString(EnterPassengerControllerModifier); ControllerButtons DMController = (ControllerButtons)typeConverter.ConvertFromString(DriveToMarkerController); ControllerButtons DMControllerModifier = (ControllerButtons)typeConverter.ConvertFromString(DriveToMarkerControllerModifier); // Assign Controller Buttons to Global Variable Global.Controls.EnterPassengerController = EPController; Global.Controls.EnterPassengerControllerModifier = EPControllerModifier; Global.Controls.DriveToMarkerController = DMController; Global.Controls.DriveToMarkerControllerModifier = DMControllerModifier; Logger.DebugLog("General Config Loading Finished."); }
internal static void GetIni() { KeysConverter kc = new KeysConverter(); InitializationFile ini = new InitializationFile("Plugins/lspdfr/Officer_Status_Plugin.ini"); ini.Create(); string menuKey = ini.ReadString("KeyBindings", "menuKey", "F7"); Globals.rank = ini.ReadString("Officer", "rank", "CPT"); Globals.firstName = ini.ReadString("Officer", "firstName", "Officer"); Globals.lastName = ini.ReadString("Officer", "lastName", "Pope"); Globals.unitNum = ini.ReadString("Officer", "unitNumber", "5H65"); try { Globals.firstName = Globals.firstName.Substring(0, 1); Globals.Unit = Globals.rank + " " + Globals.firstName + "." + Globals.lastName + " " + Globals.unitNum; Globals.menuKey = (Keys)kc.ConvertFromString(menuKey); } catch { Globals.menuKey = Keys.F7; Game.DisplayNotification("~r~Officer Status Plugin: ~w~There was an error reading the .ini file. Setting defaults..."); } }
public void SetKeyCode(string key) { KeysConverter kc = new KeysConverter(); var Object = kc.ConvertFromString(key); KeyCode = Object; }
/// <summary> /// ホットキー再構築 /// </summary> /// <param name="keyString"></param> /// <returns></returns> public static string BuildHotKey(string keyString) { string hotKey = ""; KeysConverter kc = new KeysConverter(); string[] sep = { " + " }; string[] keys = keyString.Split(sep, StringSplitOptions.None); foreach (string key in keys) { if (!key.Equals("")) { if (getControlCode(key.Trim()) != 0) { hotKey = hotKey + key + " + "; } else if (Int32.Parse(key) >= 0x30 && Int32.Parse(key) <= 0x39) { hotKey = hotKey + (char)Int32.Parse(key); } else { hotKey = hotKey + kc.ConvertFromString(key); } } } return(hotKey); }
public KeyCombo(string keystring) { string[] separators = { " + " }; string[] parts = keystring.Split(separators, StringSplitOptions.RemoveEmptyEntries); foreach (string part in parts) { switch (part) { case "Ctrl": Control = true; break; case "Alt": Alt = true; break; case "Shift": Shift = true; break; default: KeysConverter converter = new KeysConverter(); key = (Keys)converter.ConvertFromString(part); break; } } }
private void RegistShortCut(ShortcutData sc) { KeysConverter keyConv = new KeysConverter(); sc.AppKeyID = GlobalAddAtom("GlobalHotKey " + sc.AppKey); RegisterHotKey(this.Handle, sc.AppKeyID, MOD_ALT | MOD_SHIFT, (int)keyConv.ConvertFromString(sc.AppKey)); }
public void AddToToolStrip(ToolStripMenuItem MainStrip, int tag, EventHandler handler) { ToolStripMenuItem NewDisplayItem = new ToolStripMenuItem(Name); KeysConverter converter = new KeysConverter(); try { // Should solve here how to get localized "ctrl+1" names. if (Shortcut != "") { Keys sc = (Keys)converter.ConvertFromString(Shortcut); NewDisplayItem.ShortcutKeys = sc; } } catch (Exception /*ex*/) { } NewDisplayItem.Click += new System.EventHandler(handler); SelectionHandler = handler; MainStrip.DropDownItems.Add(NewDisplayItem); NewDisplayItem.Tag = tag; Tag = tag; MenuItem = NewDisplayItem; m_MainStrip = MainStrip; }
public void setHotKeyCode(int keyValue) { KeysConverter kc = new KeysConverter(); string txtHotkey = ""; hotkeyCode = keyValue; modifier = hotkeyCode << 16 >> 16; selectedKeyCode = hotkeyCode >> 16; switch (modifier) { case MOD_CONTROL: txtHotkey = "Control+"; break; case MOD_ALT: txtHotkey = "Alt+"; break; case MOD_SHIFT: txtHotkey = "Shift+"; break; } //txtHotkey += System.Convert.ToChar(selectedKeyCode).ToString(); txtHotkey += kc.ConvertToString(selectedKeyCode); KeyEventArgs k = new KeyEventArgs((Keys)kc.ConvertFromString(txtHotkey)); HotkeySelector_KeyDown(this, k); }
public static Object str2key(string str_keys) { //do stuff with pressed and modifier keys var converter = new KeysConverter(); return(converter.ConvertFromString(str_keys)); }
public static bool isComboData(KeyEventArgs e, string key) { try { if (key.Contains("Ctrl")) { key = key.Replace("Ctrl", "Control"); } if (key.Contains("Del") && !key.Contains("Delete")) { key = key.Replace("Del", "Delete"); } KeysConverter kc = new KeysConverter(); if (e.KeyData == (Keys)kc.ConvertFromString(key)) { return(true); } else { return(false); } } catch (Exception ex) { throw ex; } }
public static HotkeysMapping Parse(string s) { var result = new HotkeysMapping(); result.Clear(); var cult = Thread.CurrentThread.CurrentUICulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; var kc = new KeysConverter(); foreach (var p in s.Split(',')) { var pp = p.Split('='); var convertFromString = kc.ConvertFromString(pp[0].Trim()); if (convertFromString == null) { continue; } var k = (Keys)convertFromString; var a = (FctbAction)Enum.Parse(typeof(FctbAction), pp[1].Trim()); result[k] = a; } Thread.CurrentThread.CurrentUICulture = cult; return(result); }
// 主界面Load事件代码 private void Initiate() { try { XmlDocument doc = new XmlDocument(); doc.Load("D:\\Coding\\Github\\C-SHAPE\\C#-课程案例精编-杨恒\\俄罗斯方块游戏\\Tetris\\setting.ini"); XmlNodeList nodes = doc.DocumentElement.ChildNodes; this.startLevel = Convert.ToInt32(nodes[0].InnerText); this.level = this.startLevel; this.trans = Convert.ToBoolean(nodes[1].InnerText); keys = new Keys[5]; for (int i = 0; i < nodes[2].ChildNodes.Count; i++) { KeysConverter kc = new KeysConverter(); this.keys[i] = (Keys)(kc.ConvertFromString(nodes[2].ChildNodes[i].InnerText)); } } catch { this.trans = false; keys = new Keys[5]; keys[0] = Keys.Left; keys[1] = Keys.Right; keys[2] = Keys.Down; keys[3] = Keys.NumPad8; keys[4] = Keys.NumPad9; this.level = 1; this.startLevel = 1; } this.timer1.Interval = 500 - 50 * (level - 1); this.label4.Text = "级别: " + this.startLevel; if (trans) { this.TransparencyKey = Color.Black; } }
public static HotkeysMapping Parse(string s) { //TODO: Linux error for PgUP var result = new HotkeysMapping(); result.Clear(); var cult = Thread.CurrentThread.CurrentUICulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; var kc = new KeysConverter(); foreach (var p in s.Split(',')) { try { var pp = p.Split('='); var k = (Keys)kc.ConvertFromString(pp[0].Trim()); var a = (FCTBAction)Enum.Parse(typeof(FCTBAction), pp[1].Trim()); result[k] = a; } catch {//Ignore this exceptions for a while. } } Thread.CurrentThread.CurrentUICulture = cult; return(result); }
ssEvent pEvent(ssScanner scnr, ssForm f) { ssEvent e = new ssEvent(); try { scnr.GetStrSpDelim(); e.k = (Keys)keyconv.ConvertFromString(scnr.S); scnr.GetStrSpDelim(); e.t = pType(scnr.S); if (e.t == ssEventType.press) { scnr.GetStrSpDelim(); e.c = pChar(scnr.S); } if (scnr.C != '|' && scnr.C != '+' && scnr.C != ';') { scnr.GetStrSpDelim(); e.a = pAction(scnr.S); } if (scnr.C != '|' && scnr.C != '+' && scnr.C != ';') { scnr.GetStrSpDelim(); e.cont = bool.Parse(scnr.S); } } catch (Exception ee) { throw new ssException("error parsing event in events file" + "\r\n?" + ee.Message); } return(e); }
/// <summary> /// All callout logic should be done here. /// </summary> public override void Process() { base.Process(); GameFiber.StartNew(delegate { { //A keys converter is used to convert a string to a key. KeysConverter kc = new KeysConverter(); //We create two variables: one is a System.Windows.Keys, the other is a string. Keys EndCalloutKey; //Use a try/catch, because reading values from files is risky: we can never be sure what we're going to get and we don't want our plugin to crash. try { //We assign myKeyBinding the value of the string read by the method getMyKeyBinding(). We then use the kc.ConvertFromString method to convert this to a key. //If the string does not represent a valid key (see .ini file for a link) an exception is thrown. That's why we need a try/catch. EndCalloutKey = (Keys)kc.ConvertFromString(getEndKey()); } //If there was an error reading the values, we set them to their defaults. We also let the user know via a notification. catch { EndCalloutKey = Keys.End; Game.DisplayNotification("There was an error reading the .ini file. Setting defaults..."); } if (Game.IsKeyDown(EndCalloutKey)) { Game.DisplayNotification("The ~y~Public Disorder~w~ is ~g~Code 4~w~."); Functions.PlayScannerAudio("WE_ARE_CODE_4 NO_FURTHER_UNITS_REQUIRED"); A1.Dismiss(); this.End(); } } }, "keyCheckerForPublicDisorder"); if (A1.IsDead) { End(); } //If the player is driving to the scene, and their distance to the scene is less than 15, start the callout's logic. if (state == EDisorderState.EnRoute && Game.LocalPlayer.Character.Position.DistanceTo(spawnPoint) <= 15) { //Set the player as on scene state = EDisorderState.OnScene; //Start the callout's logic. You can paste the logic from StartMuggingScenario straight into here, but I don't, since I like it to look clean, and place any long methods towards the bottom of the class. StartDisorderLogic(); } //If the state is DecisionMade(The aggressor already decided what random outcome to execute), and the pursuit isn't running anymore, end the callout. if (state == EDisorderState.DecisionMade && !Functions.IsPursuitStillRunning(pursuit)) { this.End(); } }
private void FillOptionForm() { KeysConverter kc = new KeysConverter(); emailToEntryListCheckBox.Checked = bool.Parse(settings["AddEmailToList"]); urlToEntryListCheckBox.Checked = bool.Parse(settings["AddUrlToList"]); emailToClientCheckBox.Checked = bool.Parse(settings["CatchEmail"]); urlToClientCheckBox.Checked = bool.Parse(settings["CatchUrl"]); entryListMaxLengthTextBox.Text = settings["EntryListLength"]; firstControlModifier = bool.Parse(settings["FirstEntryCtrlMod"]); firstAltModifier = bool.Parse(settings["FirstEntryAltMod"]); firstShiftModifier = bool.Parse(settings["FirstEntryShiftMod"]); firstHotKey = (Keys)kc.ConvertFromString(settings["FirstEntryHotKey"]); selectedControlModifier = bool.Parse(settings["SelectedEntryCtrlMod"]); selectedAltModifier = bool.Parse(settings["SelectedEntryAltMod"]); selectedShiftModifier = bool.Parse(settings["SelectedEntryShiftMod"]); selectedHotKey = (Keys)kc.ConvertFromString(settings["SelectedEntryHotKey"]); previousControlModifier = bool.Parse(settings["PreviousEntryCtrlMod"]); previousAltModifier = bool.Parse(settings["PreviousEntryAltMod"]); previousShiftModifier = bool.Parse(settings["PreviousEntryShiftMod"]); previousHotKey = (Keys)kc.ConvertFromString(settings["PreviousEntryHotKey"]); nextControlModifier = bool.Parse(settings["NextEntryCtrlMod"]); nextAltModifier = bool.Parse(settings["NextEntryAltMod"]); nextShiftModifier = bool.Parse(settings["NextEntryShiftMod"]); nextHotKey = (Keys)kc.ConvertFromString(settings["NextEntryHotKey"]); firstEntryTextBox.Text = DisplayHotkey(firstControlModifier, firstAltModifier, firstShiftModifier, firstHotKey); selectedEntryTextBox.Text = DisplayHotkey(selectedControlModifier, selectedAltModifier, selectedShiftModifier, selectedHotKey); previousEntryTextBox.Text = DisplayHotkey(previousControlModifier, previousAltModifier, previousShiftModifier, previousHotKey); nextEntryTextBox.Text = DisplayHotkey(nextControlModifier, nextAltModifier, nextShiftModifier, nextHotKey); if (bool.Parse(settings["PasteType"])) { pasteOnComboBox.SelectedIndex = 0; } else { pasteOnComboBox.SelectedIndex = 1; } }
private Keys GetCurrentKey() { Keys k = Keys.None; var kc = new KeysConverter(); k = (Keys)kc.ConvertFromString(keyList.Items[keyList.SelectedIndex] as string); return(shiftPrefix.Checked ? k | Keys.Shift : k); }
/// <summary> /// 依据string生成KeyEventArgs /// </summary> /// <param name="strKey"></param> /// <returns></returns> public static KeyEventArgs GetKeyByString(string strKey) { Keys keyResult = new Keys(); string[] strKeyCodes = strKey.Split('+'); if (strKeyCodes.Length > 0) { int numberKey; foreach (string keyEach in strKeyCodes) { if (keyEach.Trim().ToUpper() == "CTRL") { keyResult = keyResult | Keys.Control; } else if (keyEach.Trim().ToUpper() == "SHIFT") { keyResult = keyResult | Keys.Shift; } else if (keyEach.Trim().ToUpper() == "ALT") { keyResult = keyResult | Keys.Alt; } //数字 else if (int.TryParse(keyEach, out numberKey)) { KeysConverter converter = new KeysConverter(); object o = converter.ConvertFromString('D' + keyEach.Trim()); if (o != null) { Keys getKey = (Keys)o; keyResult = keyResult | getKey; } } //其它(字母,F0-F12) else { try { KeysConverter converter = new KeysConverter(); object o = converter.ConvertFromString(keyEach); if (o != null) { Keys getKey = (Keys)o; keyResult = keyResult | getKey; } } catch (Exception ex) { Console.WriteLine(ex); } } } } KeyEventArgs newEventArgs = new KeyEventArgs(keyResult); return(newEventArgs); }
private static void SetupUserGeneralSettings() { KeysConverter kc = new KeysConverter(); PlayAnimations = GeneralIni.ReadBoolean("GeneralConfig", "PlayAnimations", true); PlayRadioButtonSounds = GeneralIni.ReadBoolean("GeneralConfig", "PlayRadioButtonSounds", true); PoliceSmartRadio.PlayerName = GeneralIni.ReadString("GeneralConfig", "PlayerName", "NoNameSet"); ResetRadioWhenOpening = GeneralIni.ReadBoolean("GeneralConfig", "ResetToPageOneOnOpen", false); AlwaysDisplayButtons = GeneralIni.ReadBoolean("GeneralConfig", "AlwaysDisplayButtons", false); ToggleRadioKey = (Keys)kc.ConvertFromString(KeyboardIni.ReadString("KeyboardConfig", "ToggleRadioKey", "C")); ToggleRadioModifierKey = (Keys)kc.ConvertFromString(KeyboardIni.ReadString("KeyboardConfig", "ToggleRadioModifierKey", "None")); NextButtonKey = (Keys)kc.ConvertFromString(KeyboardIni.ReadString("KeyboardConfig", "NextButtonKey", "G")); PreviousButtonKey = (Keys)kc.ConvertFromString(KeyboardIni.ReadString("KeyboardConfig", "PreviousButtonKey", "T")); SelectButtonKey = (Keys)kc.ConvertFromString(KeyboardIni.ReadString("KeyboardConfig", "SelectButtonKey", "Z")); NextPageKey = (Keys)kc.ConvertFromString(KeyboardIni.ReadString("KeyboardConfig", "NextPageKey", "Right")); PreviousPageKey = (Keys)kc.ConvertFromString(KeyboardIni.ReadString("KeyboardConfig", "PreviousPageKey", "Left")); ToggleRadioButton = ControllerIni.ReadEnum <ControllerButtons>("ControllerConfig", "ToggleRadioButton", ControllerButtons.DPadLeft); ToggleRadioModifierButton = ControllerIni.ReadEnum <ControllerButtons>("ControllerConfig", "ToggleRadioModifierButton", ControllerButtons.None); NextButtonButton = ControllerIni.ReadEnum <ControllerButtons>("ControllerConfig", "NextButtonButton", ControllerButtons.DPadDown); PreviousButtonButton = ControllerIni.ReadEnum <ControllerButtons>("ControllerConfig", "PreviousButtonButton", ControllerButtons.DPadUp); SelectButtonButton = ControllerIni.ReadEnum <ControllerButtons>("ControllerConfig", "SelectButtonButton", ControllerButtons.X); NextPageButton = ControllerIni.ReadEnum <ControllerButtons>("ControllerConfig", "NextPageButton", ControllerButtons.None); PreviousPageButton = ControllerIni.ReadEnum <ControllerButtons>("ControllerConfig", "PreviousPageButton", ControllerButtons.None); }