public static bool GetBool(string name) { return(MainRegistry.GetBool(name)); }
/// <summary> /// 从注册表中读取 bool 型数值。 /// </summary> /// <param name="name">键值名称。</param> /// <returns>bool 型数值。</returns> public static bool GetBool(this RegistryKey This, string name) { return(This.GetBool(name, false)); }
private async void ClassIconEditor_Load(object sender, EventArgs e) { Enabled = false; UseWaitCursor = true; EventHandler iconBtnClicked = new EventHandler(onIconBtnClicked); string studioPath = StudioBootstrapper.GetStudioPath(); showModifiedIcons = explorerRegistry.GetBool("ShowModifiedIcons"); darkTheme = explorerRegistry.GetBool("DarkTheme"); showModified.Checked = showModifiedIcons; themeSwitcher.Text = "Theme: " + (darkTheme ? "Dark" : "Light"); selectedIcon.BackColor = (darkTheme ? THEME_DARK_NORMAL : THEME_LIGHT_NORMAL); selectedIcon.Refresh(); int extraSlots = getExtraItemSlots(); Image defaultIcon = null; SuspendLayout(); var load = Task.Run(() => { Image explorerIcons = getExplorerIcons(); // Load Main Icons for (int i = 0; i < numIcons; i++) { Button iconBtn = createIconButton(iconBtnClicked); Bitmap icon = new Bitmap(iconSize, iconSize); iconLookup.Add(icon); Rectangle srcRect = new Rectangle(i * iconSize, 0, iconSize, iconSize); Rectangle iconRect = new Rectangle(0, 0, iconSize, iconSize); using (Graphics graphics = Graphics.FromImage(icon)) graphics.DrawImage(explorerIcons, iconRect, srcRect, GraphicsUnit.Pixel); if (defaultIcon == null) { defaultIcon = icon; } buttonLookup.Add(iconBtn); iconBtnIndex.Add(iconBtn, i); if (showModifiedIcons) { iconBtn.BackgroundImage = getIconForIndex(i); } else { iconBtn.BackgroundImage = icon; } AddControlAcrossThread(iconContainer, iconBtn); } // Load Extra Slots for (int i = 0; i < maxExtraIcons; i++) { int slot = numIcons + i; Button iconBtn = createIconButton(iconBtnClicked); iconBtn.Visible = (i < extraSlots); string fileName = getExplorerIconPath(slot); if (i < extraSlots && File.Exists(fileName)) { Image icon = getIconForIndex(slot); iconBtn.BackgroundImage = icon; } iconLookup.Add(defaultIcon); buttonLookup.Add(iconBtn); iconBtnIndex.Add(iconBtn, slot); AddControlAcrossThread(iconContainer, iconBtn); } explorerIcons.Dispose(); }); await load.ConfigureAwait(true); setSelectedIndex(0); ResumeLayout(); itemSlots.Value = extraSlots; header.Text = "Select Icon"; iconWatcher = new FileSystemWatcher(getExplorerIconDir()) { Filter = "*.png", EnableRaisingEvents = true }; iconWatcher.Created += safeFileEventHandler(onFileCreated); iconWatcher.Changed += safeFileEventHandler(onFileChanged); iconWatcher.Deleted += safeFileEventHandler(onFileDeleted); Enabled = true; UseWaitCursor = false; }
private async void InitializeEditor() { string localAppData = Environment.GetEnvironmentVariable("LocalAppData"); string settingsDir = Path.Combine(localAppData, "Roblox", "ClientSettings"); string settingsPath = Path.Combine(settingsDir, "StudioAppSettings.json"); string lastExecVersion = versionRegistry.GetString("LastExecutedVersion"); string versionGuid = versionRegistry.GetString("VersionGuid"); if (lastExecVersion != versionGuid) { // Reset the settings file. Directory.CreateDirectory(settingsDir); File.WriteAllText(settingsPath, ""); // Create some system events for studio so we can hide the splash screen. using (var start = new SystemEvent("FFlagExtract")) using (var show = new SystemEvent("NoSplashScreen")) { // Run Roblox Studio briefly so we can update the settings file. ProcessStartInfo studioStartInfo = new ProcessStartInfo() { FileName = StudioBootstrapper.GetStudioPath(), Arguments = $"-startEvent {start.Name} -showEvent {show.Name}" }; Process studio = Process.Start(studioStartInfo); var onStart = start.WaitForEvent(); await onStart.ConfigureAwait(true); FileInfo info = new FileInfo(settingsPath); // Wait for the settings path to be written. while (info.Length == 0) { var delay = Task.Delay(30); await delay.ConfigureAwait(true); info.Refresh(); } // Nuke studio and flag the version we updated with. versionRegistry.SetValue("LastExecutedVersion", versionGuid); studio.Kill(); } } // Initialize flag browser string[] flagNames = flagRegistry.GetSubKeyNames(); string[] flagNameStrings = Array.Empty <string>(); string settings = File.ReadAllText(settingsPath); var json = Program.ReadJsonDictionary(settings); int numFlags = json.Count; var flagSetup = new List <FVariable>(numFlags); var autoComplete = new AutoCompleteStringCollection(); foreach (string customFlag in flagNames) { if (!json.ContainsValue(customFlag)) { // skip custom flags that were recently added, this is unhandled in the prompt still RegistryKey flagKey = flagRegistry.GetSubKey(customFlag); bool isCustom = flagKey.GetBool("Custom"); if (isCustom) { string value = flagKey.GetString("Value"); FVariable flag = new FVariable(customFlag, value, true); flagSetup.Add(flag); flag.SetEditor(flagKey); } ; } } foreach (var pair in json) { string key = pair.Key, value = pair.Value; FVariable flag = new FVariable(key, value); autoComplete.Add(flag.Name); flagSetup.Add(flag); if (flagNames.Contains(flag.Name)) { // Update what the flag should be reset to if removed? RegistryKey flagKey = flagRegistry.GetSubKey(flag.Name); flagKey.SetValue("Reset", value); // Set the flag's editor. flag.SetEditor(flagKey); } } flagSearchFilter.AutoCompleteCustomSource = autoComplete; allFlags = flagSetup .OrderBy(flag => flag.Name) .ToList(); refreshFlags(); // Initialize override table. overrideTable = new DataTable(); foreach (DataGridViewColumn column in overrideDataGridView.Columns) { overrideTable.Columns.Add(column.DataPropertyName); } var overrideView = new DataView(overrideTable) { Sort = "Name" }; foreach (string flagName in flagNames) { // fetch the flag so we can check if it // 1. Has the Custom flag key, // 2. If that key is set to True RegistryKey flagKey = flagRegistry.GetSubKey(flagName); bool isCustomFlag = flagKey.GetBool("Custom"); if (flagLookup.ContainsKey(flagName)) { int index = flagLookup[flagName]; FVariable flag = flags[index]; addFlagOverride(flag, true); } else if (isCustomFlag) { // we need to make a new flag here unfortunately string flagValue = flagKey.GetString("Value"); var flag = new FVariable(flagName, flagValue); addFlagOverride(flag, true); } } overrideStatus.Visible = true; overrideDataGridView.DataSource = overrideView; }