private void AddKeymapEntry(Types.KeyboardKey KeyboardKey, uint NeutralLangID, System.Windows.Forms.Keys Key) { KeymapEntry entry = new KeymapEntry(); entry.KeyboardKey = KeyboardKey; entry.Key = Key; if (DefaultKeymaps[NeutralLangID] == null) { DefaultKeymaps[NeutralLangID] = new GR.Collections.Map <System.Windows.Forms.Keys, KeymapEntry>(); } DefaultKeymaps[NeutralLangID][Key] = entry; AllKeyInfos[KeyboardKey] = entry; }
public bool ReadFromBuffer(GR.Memory.ByteBuffer SettingsData) { IgnoredWarnings.Clear(); GR.IO.BinaryReader binReader = new GR.IO.BinaryReader(SettingsData.MemoryStream()); GR.IO.FileChunk chunkData = new GR.IO.FileChunk(); while (chunkData.ReadFromStream(binReader)) { switch (chunkData.Type) { case Types.FileChunk.SETTINGS_TOOL: { ToolInfo tool = new ToolInfo(); tool.FromChunk(chunkData); // sanitize args tool.CartArguments = tool.CartArguments.Replace("$(BuildTargetFilename)", "$(RunFilename)"); tool.PRGArguments = tool.PRGArguments.Replace("$(BuildTargetFilename)", "$(RunFilename)"); tool.WorkPath = tool.WorkPath.Replace("$(FilePath)", "$(RunPath)"); if (string.IsNullOrEmpty(tool.TrueDriveOnArguments)) { tool.TrueDriveOnArguments = "-truedrive +virtualdev"; tool.TrueDriveOffArguments = "+truedrive -virtualdev"; } if (tool.PRGArguments.Contains("-truedrive ")) { tool.PRGArguments = tool.PRGArguments.Replace("-truedrive ", ""); } if (tool.PRGArguments.Contains(" -truedrive")) { tool.PRGArguments = tool.PRGArguments.Replace(" -truedrive", ""); } ToolInfos.AddLast(tool); } break; case Types.FileChunk.SETTINGS_ACCELERATOR: { AcceleratorKey key = new AcceleratorKey(); key.FromChunk(chunkData); Accelerators.Add(key.Key, key); } break; case Types.FileChunk.SETTINGS_DPS_LAYOUT: { GR.IO.IReader binIn = chunkData.MemoryReader(); uint size = binIn.ReadUInt32(); GR.Memory.ByteBuffer tempData = new GR.Memory.ByteBuffer(); binIn.ReadBlock(tempData, size); SetLayoutFromData(tempData); } break; case Types.FileChunk.SETTINGS_SOUND: { GR.IO.IReader binIn = chunkData.MemoryReader(); PlaySoundOnSuccessfulBuild = (binIn.ReadUInt8() != 0); PlaySoundOnBuildFailure = (binIn.ReadUInt8() != 0); PlaySoundOnSearchFoundNoItem = (binIn.ReadUInt8() != 0); } break; case Types.FileChunk.SETTINGS_WINDOW: { GR.IO.IReader binIn = chunkData.MemoryReader(); MainWindowPlacement = binIn.ReadString(); } break; case Types.FileChunk.SETTINGS_TABS: { GR.IO.IReader binIn = chunkData.MemoryReader(); TabSize = binIn.ReadInt32(); if ((TabSize <= 0) || (TabSize >= 100)) { TabSize = 2; } AllowTabs = (binIn.ReadUInt8() != 0); TabConvertToSpaces = (binIn.ReadUInt8() != 0); } break; case Types.FileChunk.SETTINGS_FONT: { GR.IO.IReader binIn = chunkData.MemoryReader(); SourceFontFamily = binIn.ReadString(); SourceFontSize = (float)binIn.ReadInt32(); BASICUseNonC64Font = (binIn.ReadUInt8() != 0); BASICSourceFontFamily = binIn.ReadString(); BASICSourceFontSize = (float)binIn.ReadInt32(); if (BASICSourceFontSize <= 0) { BASICSourceFontSize = 9.0f; } } break; case Types.FileChunk.SETTINGS_SYNTAX_COLORING: { GR.IO.IReader binIn = chunkData.MemoryReader(); Types.SyntaxElement element = (C64Studio.Types.SyntaxElement)binIn.ReadUInt32(); Types.SyntaxColor color = new C64Studio.Types.SyntaxColor(GR.EnumHelper.GetDescription(element)); color.FGColor = binIn.ReadUInt32(); color.BGColor = binIn.ReadUInt32(); color.BGColorAuto = (binIn.ReadUInt32() != 0); SyntaxColoring.Add(element, color); } break; case Types.FileChunk.SETTINGS_UI: { GR.IO.IReader binIn = chunkData.MemoryReader(); ToolbarActiveMain = (binIn.ReadUInt8() == 1); ToolbarActiveDebugger = (binIn.ReadUInt8() == 1); } break; case Types.FileChunk.SETTINGS_RUN_EMULATOR: { GR.IO.IReader binIn = chunkData.MemoryReader(); TrueDriveEnabled = (binIn.ReadUInt8() != 0); } break; case Types.FileChunk.SETTINGS_DEFAULTS: { GR.IO.IReader binIn = chunkData.MemoryReader(); DefaultProjectBasePath = binIn.ReadString(); } break; case Types.FileChunk.SETTINGS_FIND_REPLACE: { GR.IO.IReader binIn = chunkData.MemoryReader(); LastFindIgnoreCase = (binIn.ReadUInt8() == 1); LastFindWholeWord = (binIn.ReadUInt8() == 1); LastFindRegexp = (binIn.ReadUInt8() == 1); LastFindWrap = (binIn.ReadUInt8() == 1); LastFindTarget = binIn.ReadUInt8(); int numFindArguments = binIn.ReadInt32(); for (int i = 0; i < numFindArguments; ++i) { FindArguments.Add(binIn.ReadString()); } int numReplaceArguments = binIn.ReadInt32(); for (int i = 0; i < numReplaceArguments; ++i) { ReplaceArguments.Add(binIn.ReadString()); } } break; case Types.FileChunk.SETTINGS_IGNORED_WARNINGS: { GR.IO.IReader binIn = chunkData.MemoryReader(); int numIgnoredWarnings = binIn.ReadInt32(); for (int i = 0; i < numIgnoredWarnings; ++i) { IgnoredWarnings.Add((C64Studio.Types.ErrorCode)binIn.ReadInt32()); } } break; case Types.FileChunk.SETTINGS_PANEL_DISPLAY_DETAILS: { GR.IO.IReader binIn = chunkData.MemoryReader(); string toolName = binIn.ReadString(); if (GenericTools.ContainsKey(toolName)) { uint length = binIn.ReadUInt32(); GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer(); binIn.ReadBlock(data, length); GenericTools[toolName].ApplyDisplayDetails(data); } } break; case Types.FileChunk.SETTINGS_BASIC_KEYMAP: { GR.IO.IReader binIn = chunkData.MemoryReader(); int numEntries = binIn.ReadInt32(); uint neutralLang = (uint)(System.Globalization.CultureInfo.CurrentCulture.KeyboardLayoutId & 0xff); if ((neutralLang != 7) && (neutralLang != 9)) { neutralLang = 9; } for (int i = 0; i < numEntries; ++i) { Keys key = (Keys)binIn.ReadUInt32(); Types.KeyboardKey cmdKey = (C64Studio.Types.KeyboardKey)binIn.ReadInt32(); var keyMapEntry = new KeymapEntry(); foreach (var entry in BASICKeyMap.DefaultKeymaps[neutralLang]) { if (entry.Value.KeyboardKey == cmdKey) { BASICKeyMap.Keymap[key] = entry.Value; break; } } } } break; case Types.FileChunk.SETTINGS_ASSEMBLER_EDITOR: { GR.IO.IReader binIn = chunkData.MemoryReader(); ASMHideLineNumbers = (binIn.ReadUInt8() != 0); } break; case Types.FileChunk.SETTINGS_BASIC_PARSER: { GR.IO.IReader binIn = chunkData.MemoryReader(); BASICStripSpaces = (binIn.ReadUInt8() != 0); } break; case Types.FileChunk.SETTINGS_ENVIRONMENT: { GR.IO.IReader binIn = chunkData.MemoryReader(); AutoOpenLastSolution = (binIn.ReadUInt8() != 0); } break; } } return(true); }
private string MapString(string Text) { string result = ""; uint curNeutralLangID = (uint)(System.Windows.Forms.InputLanguage.CurrentInputLanguage.Culture.LCID & 0xff); System.Windows.Forms.KeysConverter conv = new System.Windows.Forms.KeysConverter(); //foreach ( char achar in Text ) for (int i = 0; i < Text.Length; ++i) { System.Windows.Forms.Keys keyData = ResolveKey(Text[i]); if (keyData == m_ControlKeyReplacement) { // we misuse tab as command key, avoid common processing continue; } System.Windows.Forms.Keys bareKey = keyData & ~(System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift | System.Windows.Forms.Keys.ShiftKey | System.Windows.Forms.Keys.Alt); bareKey = keyData; if ((bareKey & System.Windows.Forms.Keys.Shift) == System.Windows.Forms.Keys.Shift) { bareKey &= ~System.Windows.Forms.Keys.Shift; } if (MainForm.Settings.BASICKeyMap.KeymapEntryExists(keyData)) { KeymapEntry key = MainForm.Settings.BASICKeyMap.GetKeymapEntry(keyData); if (key.Commodore != 65535) { if ((keyData & System.Windows.Forms.Keys.Shift) == System.Windows.Forms.Keys.Shift) { result += key.Shifted; continue; } if (GR.Win32.KeyboardInfo.GetKeyState(System.Windows.Forms.Keys.Tab).IsPressed) //if ( ( keyData & m_ControlKeyReplacement ) == m_ControlKeyReplacement ) { result += key.Commodore; continue; } result += key.Normal; continue; } } else if (MainForm.Settings.BASICKeyMap.KeymapEntryExists(bareKey)) { KeymapEntry key = MainForm.Settings.BASICKeyMap.GetKeymapEntry(bareKey); if ((keyData & System.Windows.Forms.Keys.Shift) == System.Windows.Forms.Keys.Shift) { result += key.Shifted; continue; } else if (GR.Win32.KeyboardInfo.GetKeyState(System.Windows.Forms.Keys.Tab).IsPressed) //else if ( ( keyData & m_ControlKeyReplacement ) == m_ControlKeyReplacement ) { result += key.Commodore; continue; } result += key.Normal; continue; } } return(result); }