/// <summary> /// Constructor /// </summary> public Setting() { Title = Properties_Resources.EditTitle; ResizeMode = ResizeMode.NoResize; Height = 370; Width = 660; Icon = UIHelpers.GetImageSource("app", "ico"); ElementHost.EnableModelessKeyboardInterop(this); WindowStartupLocation = WindowStartupLocation.CenterScreen; Closing += delegate(object sender, CancelEventArgs args) { Controller.HideWindow(); args.Cancel = true; }; LoadSetting(); Controller.ShowWindowEvent += delegate { Dispatcher.BeginInvoke((Action) delegate { RefreshSetting(); Show(); Activate(); BringIntoView(); }); }; Controller.HideWindowEvent += delegate { Dispatcher.BeginInvoke((Action) delegate { Hide(); }); }; FinishButton.Click += delegate { ProxySettings proxy = new ProxySettings(); if (ProxyNone.IsChecked.GetValueOrDefault()) { proxy.Selection = ProxySelection.NOPROXY; } else if (ProxySystem.IsChecked.GetValueOrDefault()) { proxy.Selection = ProxySelection.SYSTEM; } else { proxy.Selection = ProxySelection.CUSTOM; } proxy.LoginRequired = LoginCheck.IsChecked.GetValueOrDefault(); string server = Controller.GetServer(AddressText.Text); if (server != null) { proxy.Server = new Uri(server); } else { proxy.Server = ConfigManager.CurrentConfig.Proxy.Server; } proxy.Username = UserText.Text; proxy.ObfuscatedPassword = Crypto.Obfuscate(PasswordText.Password); ConfigManager.CurrentConfig.Proxy = proxy; ConfigManager.CurrentConfig.Notifications = NotificationsCheck.IsChecked.GetValueOrDefault(); ConfigManager.CurrentConfig.Save(); Controller.HideWindow(); }; CancelButton.Click += delegate { Controller.HideWindow(); }; }