/// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                    components.Dispose();

                SystemEvents.UserPreferenceChanged -= new UserPreferenceChangedEventHandler(OnOperatingSystemSettingsChanged);

                if (this.designerPreview != null)
                {
                    this.designerPreview.Dispose();
                    this.designerPreview = null;
                }

                if (this.bufferedTheme != null)
                {
                    ((IDisposable)this.bufferedTheme).Dispose();
                    this.bufferedTheme = null;
                }
            }
            base.Dispose(disposing);
        }
        private void InitializeControls()
        {
            HelpButtonClicked += new CancelEventHandler(OnHelpClicked);

            this.themeNameTextBox.Text = this.bufferedTheme.Name;
            this.themeLocationTextBox.Text = this.bufferedTheme.FilePath;

            this.propertiesGrid.PropertySort = PropertySort.Categorized;

            //Make sure that size and location are changed after adding the control to the parent
            //this will autoscale the control correctly
            this.designerPreview = new DesignerPreview(this);
            this.dummyPreviewPanel.Parent.Controls.Add(this.designerPreview);
            this.designerPreview.TabStop = false;
            this.designerPreview.Location = this.dummyPreviewPanel.Location;
            this.designerPreview.Size = this.dummyPreviewPanel.Size;
            this.dummyPreviewPanel.Visible = false;
            this.designerPreview.Parent.Controls.Remove(this.dummyPreviewPanel);

            this.designerTreeView.ShowLines = false;
            this.designerTreeView.ShowPlusMinus = false;
            this.designerTreeView.ShowRootLines = false;
            this.designerTreeView.ShowNodeToolTips = true;
            this.designerTreeView.HideSelection = false;
            this.designerTreeView.ItemHeight = Math.Max(this.designerTreeView.ItemHeight, 18);
            ThemeConfigHelpers.PopulateActivities(this.serviceProvider, this.designerTreeView);

            this.themeConfigPanel.Controls.Remove(this.designerTreeView);
            this.themeConfigPanel.Controls.Remove(this.propertiesGrid);
            this.designerTreeView.Dock = DockStyle.Left;
            this.splitter = new Splitter();
            this.splitter.Dock = DockStyle.Left;
            this.propertiesGrid.Dock = DockStyle.Fill;
            this.themeConfigPanel.Controls.AddRange(new Control[] { this.propertiesGrid, this.splitter, this.designerTreeView });

            this.themePanel.Paint += new PaintEventHandler(OnThemePanelPaint);
            this.previewButton.Click += new EventHandler(OnPreviewClicked);
            this.designerTreeView.AfterSelect += new TreeViewEventHandler(OnDesignerSelectionChanged);
            this.themeLocationButton.Click += new EventHandler(OnThemeLocationClicked);
            this.okButton.Click += new EventHandler(OnOk);
            this.propertiesGrid.PropertyValueChanged += new PropertyValueChangedEventHandler(OnThemePropertyChanged);
            this.themeNameTextBox.TextChanged += new EventHandler(OnThemeChanged);
            this.themeLocationTextBox.TextChanged += new EventHandler(OnThemeChanged);

            this.designerTreeView.SelectedNode = (this.designerTreeView.Nodes.Count > 0) ? this.designerTreeView.Nodes[0] : null;
            this.designerTreeView.SelectedNode.EnsureVisible();

            ShowPreview = true;
        }