void reportError(Exception exc) { frmException errorReport = new frmException(); errorReport.reportedException = exc; errorReport.ShowDialog(); }
public bool LoadLanguage(string LanguageFile) { if (LanguageFile == LoadedFile || LanguageFile == null || LanguageFile == string.Empty) { return(false); } if (!LanguageFile.EndsWith(".ini")) { LanguageFile += ".ini"; } if (System.IO.File.Exists(LanguageFile)) { try { string[] ReadFile = System.IO.File.ReadAllLines(LanguageFile); for (int i = 0; i < ReadFile.Length; i++) { if (ReadFile[i].StartsWith("rtb")) { System.Diagnostics.Debug.Print("Caught"); } string ReadLine = ReadFile[i]; string ReadControl = null; string ReadValue = null; string ReadHeader = null; if (ReadLine.StartsWith("//")) { continue; } if (ReadLine.StartsWith("[")) { ReadHeader = ReadHeaderValue(ReadLine); if (ReadHeader == null) { throw new Exception("Unable to read the language ini header\nReadValue returned null."); } else { continue; } } else { if (ReadLine == null || ReadLine.Split('=').Length < 2) { continue; } ReadControl = GetControlName(ReadLine); ReadValue = GetControlValue(ReadLine); } if (ReadControl == "CurrentLanguageShort") { CurrentLanguageShort = ReadValue; continue; } else if (ReadControl == "CurrentLanguageHint") { CurrentLanguageHint = ReadValue; continue; } else if (ReadControl == "CurrentLanguageVersion") { CurrentLanguageVersion = ReadValue; continue; } else if (ReadControl == "HotkeyToggle") { HotkeyToggle = ReadValue; continue; } else if (ReadControl == "HotkeyDisabled") { HotkeyDisabled = ReadValue; continue; } else if (ReadControl == "HotkeyUnavailable") { HotkeyUnavailable = ReadValue; continue; } else if (ReadControl == "frmMainAdmin") { frmMainAdmin = ReadValue; continue; } else if (ReadControl == "frmMainNoAdmin") { frmMainNoAdmin = ReadValue; continue; } else if (ReadControl == "lbDestinyOff") { lbDestinyOff = ReadValue; continue; } else if (ReadControl == "lbDestinyOn") { lbDestinyOn = ReadValue; continue; } else if (ReadControl == "lbRockstarOff") { lbRockstarOff = ReadValue; continue; } else if (ReadControl == "lbRockstarOn") { lbRockstarOn = ReadValue; continue; } else if (ReadControl == "tsmiSelectLanguage") { tsmiSelectLanguage = ReadValue; continue; } else if (ReadControl == "tabDestiny") { tabDestiny = ReadValue; continue; } else if (ReadControl == "tabRockstar") { tabRockstar = ReadValue; continue; } else if (ReadControl == "tabDebug") { tabDebug = ReadValue; continue; } else if (ReadControl == "chkEnableDestinyHotkey") { chkEnableDestinyHotkey = ReadValue; continue; } else if (ReadControl == "btnToggleDestinyOff") { btnToggleDestinyOff = ReadValue; continue; } else if (ReadControl == "btnToggleDestinyOn") { btnToggleDestinyOn = ReadValue; continue; } else if (ReadControl == "ttMainChangeDestinyHotkey") { ttMainChangeDestinyHotkey = ReadValue; continue; } else if (ReadControl == "chkEnableRockstar") { chkEnableRockstarHotkey = ReadValue; continue; } else if (ReadControl == "btnAddRockstarRange") { btnAddRockstarRange = ReadValue; continue; } else if (ReadControl == "btnRemoveRockstarRange") { btnRemoveRockstarRange = ReadValue; continue; } else if (ReadControl == "txtRockstarRange") { txtRockstarRange = ReadValue; continue; } else if (ReadControl == "btnToggleRockstarOff") { btnToggleRockstarOff = ReadValue; continue; } else if (ReadControl == "btnToggleRockstarOn") { btnToggleRockstarOn = ReadValue; continue; } else if (ReadControl == "ttMainChangeRockstarHotkey") { ttMainChangeRockstarHotkey = ReadValue; continue; } else if (ReadControl == "rtbRockstarInfo") { rtbRockstarInfo = ReadValue.Replace("\\n", "\n"); continue; } else if (ReadControl == "frmException") { frmException = ReadValue; continue; } else if (ReadControl == "lbExceptionHeader") { lbExceptionHeader = ReadValue; continue; } else if (ReadControl == "lbExceptionDescription") { lbExceptionDescription = ReadValue; continue; } else if (ReadControl == "rtbExceptionDetails") { rtbExceptionDetails = ReadValue; continue; } else if (ReadControl == "btnExceptionGithub") { btnExceptionGithub = ReadValue; continue; } else if (ReadControl == "btnExceptionOk") { btnExceptionOk = ReadValue; continue; } else if (ReadControl == "frmNewHotkey") { frmNewHotkey = ReadValue; continue; } else if (ReadControl == "lbNewHotkeyHeader") { lbNewHotkeyHeader = ReadValue; continue; } else if (ReadControl == "lbNewHotkeyDescription") { lbNewHotkeyDescription = ReadValue; continue; } else if (ReadControl == "lbNewHotkeyModifier") { lbNewHotkeyModifier = ReadValue; continue; } else if (ReadControl == "lbNewHotkeyKey") { lbNewHotkeyKey = ReadValue; continue; } else if (ReadControl == "btnNewHotkeyResetToDefault") { btnNewHotkeyResetToDefault = ReadValue; continue; } else if (ReadControl == "btnNewHotkeyCancel") { btnNewHotkeyCancel = ReadValue; continue; } else if (ReadControl == "btnNewHotkeySave") { btnNewHotkeySave = ReadValue; continue; } } LoadedFile = LanguageFile; return(true); } catch (Exception ex) { frmException error = new frmException(); error.reportedException = ex; error.FromLanguage = true; error.ShowDialog(); return(false); } } else { return(false); } }
public bool LoadLanguage(string lang) { if (System.IO.File.Exists(Environment.CurrentDirectory + "\\lang\\" + lang + ".ini")) { try { string[] ReadFile = System.IO.File.ReadAllLines(Environment.CurrentDirectory + "\\lang\\" + lang + ".ini"); for (int i = 0; i < ReadFile.Length; i++) { string ReadLine = ReadFile[i]; if (ReadLine.StartsWith("//") || ReadLine.Trim(' ') == ("")) { continue; } if (ReadLine.StartsWith("[") & ReadLine.EndsWith("]")) { CurrentLanguageLong = ReadLine.Trim('[').Trim(']'); continue; } else if (ReadLine.StartsWith("CurrentLanguageShort")) { CurrentLanguageShort = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("HotkeyToggle")) { HotkeyToggle = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("HotkeyDisabled")) { HotkeyDisabled = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("HotkeyUnavailable")) { HotkeyUnavailable = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("frmMainAdmin")) { frmMainAdmin = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("frmMain")) { frmMain = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("lbDestinyOff")) { lbDestinyOff = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("lbDestinyOn")) { lbDestinyOn = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("lbRockstarOff")) { lbRockstarOff = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("lbRockstarOn")) { lbRockstarOn = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("tsmiSelectLanguage")) { tsmiSelectLanguage = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("tabDestiny")) { tabDestiny = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("tabRockstar")) { tabRockstar = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("tabDebug")) { tabDebug = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("chkEnableDestiny")) { chkEnableDestinyHotkey = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("btnToggleDestinyOff")) { btnToggleDestinyOff = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("btnToggleDestinyOn")) { btnToggleDestinyOn = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("ttMainChangeDestinyHotkey")) { ttMainChangeDestinyHotkey = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("chkEnableRockstar")) { chkEnableRockstarHotkey = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("btnAddRockstarRange")) { btnAddRockstarRange = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("btnRemoveRockstarRange")) { btnRemoveRockstarRange = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("txtRockstarRange")) { txtRockstarRange = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("btnToggleRockstarOff")) { btnToggleRockstarOff = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("btnToggleRockstarOn")) { btnToggleRockstarOn = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("ttMainChangeRockstarHotkey")) { ttMainChangeRockstarHotkey = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("rtbRockstarInfo")) { rtbRockstarInfo = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("frmError")) { frmError = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("lbExceptionHeader")) { lbExceptionHeader = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("lbExceptionDescription")) { lbExceptionDescription = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("rtbExceptionDetails")) { rtbExceptionDetails = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("btnExceptionGithub")) { btnExceptionGithub = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("btnExceptionOk")) { btnExceptionOk = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("frmNewHotkey")) { frmNewHotkey = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("lbNewHotkeyHeader")) { lbNewHotkeyHeader = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("lbNewHotkeyDescription")) { lbNewHotkeyDescription = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("lbNewHotkeyModifier")) { lbNewHotkeyModifier = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("lbNewHotkeyKey")) { lbNewHotkeyKey = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("btnNewHotkeyResetToDefault")) { btnNewHotkeyResetToDefault = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("btnNewHotkeyCancel")) { btnNewHotkeyCancel = ReadLine.Split('=')[1]; continue; } else if (ReadLine.StartsWith("btnNewHotkeySave")) { btnNewHotkeySave = ReadLine.Split('=')[1]; continue; } } return(true); } catch (Exception ex) { frmException error = new frmException(); error.reportedException = ex; error.FromLanguage = true; error.ShowDialog(); return(false); } } else { return(false); } }