public static void DetectRegions() { // Get configured region using (RegistryKey SettingsKey = POL.OpenPOLUtilsConfigKey(true)) { if (SettingsKey != null) { string UserRegion = SettingsKey.GetValue("Region", "None") as string; try { POL.SelectedRegion_ = (Region)Enum.Parse(typeof(Region), UserRegion, true); } catch { POL.SelectedRegion_ = Region.None; } } } // Check for installed POL software foreach (Region R in Enum.GetValues(typeof(Region))) { using (RegistryKey POLKey = POL.OpenRegistryKey(R, "InstallFolder")) { if (POLKey != null) { POL.AvailableRegions_ |= R; } } } // If user's choice is not available, clear that selection if ((POL.AvailableRegions_ & POL.SelectedRegion_) != POL.SelectedRegion_) { POL.SelectedRegion_ = Region.None; } // Select a region based on what's available if (POL.SelectedRegion_ == Region.None) { if ((POL.AvailableRegions_ & Region.NorthAmerica) != 0) { POL.SelectedRegion_ = Region.NorthAmerica; } else if ((POL.AvailableRegions_ & Region.Europe) != 0) { POL.SelectedRegion_ = Region.Europe; } else if ((POL.AvailableRegions_ & Region.Japan) != 0) { POL.SelectedRegion_ = Region.Japan; } } }
public static void ChooseRegion(Form Parent) { POL.DetectRegions(); if (POL.MultipleRegionsAvailable) { using (ChooseRegionDialog CRD = new ChooseRegionDialog()) CRD.ShowDialog(Parent); } else // No multiple regions installed? No choice to be made then! { POL.SelectedRegion_ = POL.AvailableRegions_; } using (RegistryKey POLKey = POL.OpenPOLUtilsConfigKey()) { if (POLKey != null) { POLKey.SetValue("Region", POL.SelectedRegion_.ToString()); } } }
public static RegistryKey OpenPOLUtilsConfigKey(bool MachineWide) { return(POL.OpenPOLUtilsConfigKey(null, MachineWide)); }
public static RegistryKey OpenPOLUtilsConfigKey(string SubKey) { return(POL.OpenPOLUtilsConfigKey(SubKey, false)); }
public static RegistryKey OpenPOLUtilsConfigKey() { return(POL.OpenPOLUtilsConfigKey(null, false)); }