public static PSPolicy ValidatePolicies() { PSPolicy policy = new PSPolicy(); bool onePolicyApplies = false; RegistryKey psRoot = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Policies\\ProxySwitcher"); if (psRoot == null) { return(null); } int isDisabled = (int)psRoot.GetValue("IsDisabled", 0); if (isDisabled == 1) { policy.IsDisabled = true; onePolicyApplies = true; } int isNetworkSettingsLocked = (int)psRoot.GetValue("NetworkSettingsLocked", 0); if (isNetworkSettingsLocked == 1) { policy.NetworkSettingsLocked = true; onePolicyApplies = true; } int isApplicationSettingsLocked = (int)psRoot.GetValue("ApplicationSettingsLocked", 0); if (isApplicationSettingsLocked == 1) { policy.ApplicationSettingsLocked = true; onePolicyApplies = true; } if (onePolicyApplies) { policy.Message = "Some settings are managed by your system administrator."; string url = (string)psRoot.GetValue("PolicyLink", string.Empty); if (!String.IsNullOrEmpty(url)) { policy.MessageLink = url; } else { policy.MessageLink = "http://projects2.mwiedemeyer.de/ProxySwitcher/SitePages/Policy.aspx"; } } return(policy); }
public static PSPolicy ValidatePolicies() { PSPolicy policy = new PSPolicy(); bool onePolicyApplies = false; RegistryKey psRoot = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Policies\\ProxySwitcher"); if (psRoot == null) return null; int isDisabled = (int)psRoot.GetValue("IsDisabled", 0); if (isDisabled == 1) { policy.IsDisabled = true; onePolicyApplies = true; } int isNetworkSettingsLocked = (int)psRoot.GetValue("NetworkSettingsLocked", 0); if (isNetworkSettingsLocked == 1) { policy.NetworkSettingsLocked = true; onePolicyApplies = true; } int isApplicationSettingsLocked = (int)psRoot.GetValue("ApplicationSettingsLocked", 0); if (isApplicationSettingsLocked == 1) { policy.ApplicationSettingsLocked = true; onePolicyApplies = true; } if (onePolicyApplies) { policy.Message = "Some settings are managed by your system administrator."; string url = (string)psRoot.GetValue("PolicyLink", string.Empty); if (!String.IsNullOrEmpty(url)) policy.MessageLink = url; else policy.MessageLink = "http://projects2.mwiedemeyer.de/ProxySwitcher/SitePages/Policy.aspx"; } return policy; }
public MainWindowRibbon() { LocalizationManager.SetLanguage(SettingsManager.Instance.GetApplicationSetting<int>(SettingsManager.App_Language, SettingsManager.Default_Language)); InitializeComponent(); policy = PolicyManager.ValidatePolicies(); if (policy != null && policy.HasMessage) { if (policy.IsDisabled) { MessageBox.Show(LanguageResources.PolicyDisabled, this.Title, MessageBoxButton.OK, MessageBoxImage.Stop); shutdownInitiatedFromApplication = true; Application.Current.Shutdown(500); return; } SetStatus(policy.Message, policy.MessageLink); } }