private void UpdatePageFor(IssueRepositoryConnector connector) { configPagePanel.Controls.Clear(); bool needsCurrentSettings = false; _configPage = GetConfigurationPageFor(connector, ref needsCurrentSettings); if (_connectorPageControlMap == null) { _connectorPageControlMap = new Dictionary<string, Control>(); } Control newControl = null; if (!_connectorPageControlMap.TryGetValue(connector.Name, out newControl)) { newControl = GetControlFor(_configPage); newControl.Dock = DockStyle.Fill; _connectorPageControlMap.Add(connector.Name, newControl); } // setup config page if (_configPage != null) { _configPage.OnPageEvent += new EventHandler<ConfigPageEventArgs>(_configPage_OnPageEvent); } configPagePanel.Controls.Add(newControl); if (_configPage != null && needsCurrentSettings) { BeginInvoke((DoSomething)delegate() { IssueRepositorySettings currentSettings = CurrentSolutionSettings; if (currentSettings != null && string.Equals(currentSettings.ConnectorName, connector.Name)) { _configPage.Settings = currentSettings; } }); } }
private static Control GetControlFor(IssueRepositoryConfigurationPage configPage) { Control result = null; if (configPage != null) { IWin32Window window = configPage.Window; if (window != null) { IntPtr handle = window.Handle; if (handle != null && handle != IntPtr.Zero) { result = Control.FromHandle(window.Handle); } } } if (result == null) { result = new Label(); result.Text = "Don't associate current solution with an issue repository."; } return result; }