/// <include file='doc\ComponentEditorForm.uex' path='docs/doc[@for="ComponentEditorForm.ComponentEditorPageSite.ComponentEditorPageSite"]/*' /> /// <devdoc> /// Creates the page site. /// </devdoc> /// <internalonly/> internal ComponentEditorPageSite(Control parent, Type pageClass, IComponent component, ComponentEditorForm form) { this.component = component; this.parent = parent; this.isActive = false; this.isDirty = false; if (form == null) { throw new ArgumentNullException(nameof(form)); } this.form = form; try { pageControl = (ComponentEditorPage)Activator.CreateInstance(pageClass); } catch (TargetInvocationException e) { Debug.Fail(e.ToString()); throw new TargetInvocationException(string.Format(SR.ExceptionCreatingCompEditorControl, e.ToString()), e.InnerException); } pageControl.SetSite(this); pageControl.SetComponent(component); }
/// <include file='doc\ComponentEditorForm.uex' path='docs/doc[@for="ComponentEditorForm.OnNewObjects"]/*' /> /// <devdoc> /// Called to initialize this form with the new component. /// </devdoc> /// <internalonly/> private void OnNewObjects() { pageSites = null; maxSize = new Size(3 * (BUTTON_WIDTH + BUTTON_PAD), 24 * pageTypes.Length); pageSites = new ComponentEditorPageSite[pageTypes.Length]; // create sites for them // for (int n = 0; n < pageTypes.Length; n++) { pageSites[n] = new ComponentEditorPageSite(pageHost, pageTypes[n], component, this); ComponentEditorPage page = pageSites[n].GetPageControl(); Size pageSize = page.Size; if (pageSize.Width > maxSize.Width) { maxSize.Width = pageSize.Width; } if (pageSize.Height > maxSize.Height) { maxSize.Height = pageSize.Height; } } // and set them all to an ideal size // for (int n = 0; n < pageSites.Length; n++) { pageSites[n].GetPageControl().Size = maxSize; } }
internal ComponentEditorPageSite(Control parent, System.Type pageClass, IComponent component, ComponentEditorForm form) { this.component = component; this.parent = parent; this.isActive = false; this.isDirty = false; if (form == null) { throw new ArgumentNullException("form"); } this.form = form; try { this.pageControl = (ComponentEditorPage)System.Windows.Forms.SecurityUtils.SecureCreateInstance(pageClass); } catch (TargetInvocationException exception) { throw new TargetInvocationException(System.Windows.Forms.SR.GetString("ExceptionCreatingCompEditorControl", new object[] { exception.ToString() }), exception.InnerException); } this.pageControl.SetSite(this); this.pageControl.SetComponent(component); }
/// <summary> /// Creates the page site. /// </summary> internal ComponentEditorPageSite(Control parent, Type pageClass, IComponent component, ComponentEditorForm form) { _component = component; _parent = parent; _isActive = false; _isDirty = false; _form = form.OrThrowIfNull(); try { _pageControl = (ComponentEditorPage)Activator.CreateInstance(pageClass) !; } catch (TargetInvocationException e) { Debug.Fail(e.ToString()); throw new TargetInvocationException(string.Format(SR.ExceptionCreatingCompEditorControl, e.ToString()), e.InnerException); } _pageControl.SetSite(this); _pageControl.SetComponent(component); }
/// <include file='doc\ComponentEditorForm.uex' path='docs/doc[@for="ComponentEditorForm.OnConfigureUI"]/*' /> /// <devdoc> /// Lays out the UI of the form. /// </devdoc> /// <internalonly/> private void OnConfigureUI() { Font uiFont = Control.DefaultFont; if (component.Site != null) { IUIService uiService = (IUIService)component.Site.GetService(typeof(IUIService)); if (uiService != null) { uiFont = (Font)uiService.Styles["DialogFont"]; } } this.Font = uiFont; okButton = new Button(); cancelButton = new Button(); applyButton = new Button(); helpButton = new Button(); selectorImageList = new ImageList(); selectorImageList.ImageSize = new Size(16, 16); selector = new PageSelector(); selector.ImageList = selectorImageList; selector.AfterSelect += new TreeViewEventHandler(this.OnSelChangeSelector); Label grayStrip = new Label(); grayStrip.BackColor = SystemColors.ControlDark; int selectorWidth = MIN_SELECTOR_WIDTH; if (pageSites != null) { // Add the nodes corresponding to the pages for (int n = 0; n < pageSites.Length; n++) { ComponentEditorPage page = pageSites[n].GetPageControl(); string title = page.Title; Graphics graphics = CreateGraphicsInternal(); int titleWidth = (int)graphics.MeasureString(title, Font).Width; graphics.Dispose(); selectorImageList.Images.Add(page.Icon.ToBitmap()); selector.Nodes.Add(new TreeNode(title, n, n)); if (titleWidth > selectorWidth) { selectorWidth = titleWidth; } } } selectorWidth += SELECTOR_PADDING; string caption = string.Empty; ISite site = component.Site; if (site != null) { caption = string.Format(SR.ComponentEditorFormProperties, site.Name); } else { caption = SR.ComponentEditorFormPropertiesNoName; } this.Text = caption; Rectangle pageHostBounds = new Rectangle(2 * BUTTON_PAD + selectorWidth, 2 * BUTTON_PAD + STRIP_HEIGHT, maxSize.Width, maxSize.Height); pageHost.Bounds = pageHostBounds; grayStrip.Bounds = new Rectangle(pageHostBounds.X, BUTTON_PAD, pageHostBounds.Width, STRIP_HEIGHT); if (pageSites != null) { Rectangle pageBounds = new Rectangle(0, 0, pageHostBounds.Width, pageHostBounds.Height); for (int n = 0; n < pageSites.Length; n++) { ComponentEditorPage page = pageSites[n].GetPageControl(); page.GetControl().Bounds = pageBounds; } } int xFrame = SystemInformation.FixedFrameBorderSize.Width; Rectangle bounds = pageHostBounds; Size size = new Size(bounds.Width + 3 * (BUTTON_PAD + xFrame) + selectorWidth, bounds.Height + STRIP_HEIGHT + 4 * BUTTON_PAD + BUTTON_HEIGHT + 2 * xFrame + SystemInformation.CaptionHeight); this.Size = size; selector.Bounds = new Rectangle(BUTTON_PAD, BUTTON_PAD, selectorWidth, bounds.Height + STRIP_HEIGHT + 2 * BUTTON_PAD + BUTTON_HEIGHT); bounds.X = bounds.Width + bounds.X - BUTTON_WIDTH; bounds.Y = bounds.Height + bounds.Y + BUTTON_PAD; bounds.Width = BUTTON_WIDTH; bounds.Height = BUTTON_HEIGHT; helpButton.Bounds = bounds; helpButton.Text = SR.HelpCaption; helpButton.Click += new EventHandler(this.OnButtonClick); helpButton.Enabled = false; helpButton.FlatStyle = FlatStyle.System; bounds.X -= (BUTTON_WIDTH + BUTTON_PAD); applyButton.Bounds = bounds; applyButton.Text = SR.ApplyCaption; applyButton.Click += new EventHandler(this.OnButtonClick); applyButton.Enabled = false; applyButton.FlatStyle = FlatStyle.System; bounds.X -= (BUTTON_WIDTH + BUTTON_PAD); cancelButton.Bounds = bounds; cancelButton.Text = SR.CancelCaption; cancelButton.Click += new EventHandler(this.OnButtonClick); cancelButton.FlatStyle = FlatStyle.System; this.CancelButton = cancelButton; bounds.X -= (BUTTON_WIDTH + BUTTON_PAD); okButton.Bounds = bounds; okButton.Text = SR.OKCaption; okButton.Click += new EventHandler(this.OnButtonClick); okButton.FlatStyle = FlatStyle.System; this.AcceptButton = okButton; this.Controls.Clear(); this.Controls.AddRange(new Control[] { selector, grayStrip, pageHost, okButton, cancelButton, applyButton, helpButton }); #pragma warning disable 618 // continuing with the old autoscale base size stuff, it works, // and is currently set to a non-standard height AutoScaleBaseSize = new Size(5, 14); ApplyAutoScaling(); #pragma warning restore 618 }
internal ComponentEditorPageSite(Control parent, System.Type pageClass, IComponent component, ComponentEditorForm form) { this.component = component; this.parent = parent; this.isActive = false; this.isDirty = false; if (form == null) { throw new ArgumentNullException("form"); } this.form = form; try { this.pageControl = (ComponentEditorPage) System.Windows.Forms.SecurityUtils.SecureCreateInstance(pageClass); } catch (TargetInvocationException exception) { throw new TargetInvocationException(System.Windows.Forms.SR.GetString("ExceptionCreatingCompEditorControl", new object[] { exception.ToString() }), exception.InnerException); } this.pageControl.SetSite(this); this.pageControl.SetComponent(component); }
/// <include file='doc\ComponentEditorForm.uex' path='docs/doc[@for="ComponentEditorForm.ComponentEditorPageSite.ComponentEditorPageSite"]/*' /> /// <devdoc> /// Creates the page site. /// </devdoc> /// <internalonly/> internal ComponentEditorPageSite(Control parent, Type pageClass, IComponent component, ComponentEditorForm form) { this.component = component; this.parent = parent; this.isActive = false; this.isDirty = false; if (form == null) throw new ArgumentNullException("form"); this.form = form; try { pageControl = (ComponentEditorPage)SecurityUtils.SecureCreateInstance(pageClass); } catch (TargetInvocationException e) { Debug.Fail(e.ToString()); throw new TargetInvocationException(SR.GetString(SR.ExceptionCreatingCompEditorControl, e.ToString()), e.InnerException); } pageControl.SetSite(this); pageControl.SetComponent(component); }
private void OnConfigureUI() { Font defaultFont = Control.DefaultFont; if (this.component.Site != null) { IUIService service = (IUIService)this.component.Site.GetService(typeof(IUIService)); if (service != null) { defaultFont = (Font)service.Styles["DialogFont"]; } } this.Font = defaultFont; this.okButton = new Button(); this.cancelButton = new Button(); this.applyButton = new Button(); this.helpButton = new Button(); this.selectorImageList = new ImageList(); this.selectorImageList.ImageSize = new Size(0x10, 0x10); this.selector = new PageSelector(); this.selector.ImageList = this.selectorImageList; this.selector.AfterSelect += new TreeViewEventHandler(this.OnSelChangeSelector); Label label = new Label { BackColor = SystemColors.ControlDark }; int width = 90; if (this.pageSites != null) { for (int i = 0; i < this.pageSites.Length; i++) { ComponentEditorPage pageControl = this.pageSites[i].GetPageControl(); string title = pageControl.Title; Graphics graphics = base.CreateGraphicsInternal(); int num3 = (int)graphics.MeasureString(title, this.Font).Width; graphics.Dispose(); this.selectorImageList.Images.Add(pageControl.Icon.ToBitmap()); this.selector.Nodes.Add(new TreeNode(title, i, i)); if (num3 > width) { width = num3; } } } width += 10; string str2 = string.Empty; ISite site = this.component.Site; if (site != null) { str2 = System.Windows.Forms.SR.GetString("ComponentEditorFormProperties", new object[] { site.Name }); } else { str2 = System.Windows.Forms.SR.GetString("ComponentEditorFormPropertiesNoName"); } this.Text = str2; Rectangle rectangle = new Rectangle(12 + width, 0x10, this.maxSize.Width, this.maxSize.Height); this.pageHost.Bounds = rectangle; label.Bounds = new Rectangle(rectangle.X, 6, rectangle.Width, 4); if (this.pageSites != null) { Rectangle rectangle2 = new Rectangle(0, 0, rectangle.Width, rectangle.Height); for (int j = 0; j < this.pageSites.Length; j++) { this.pageSites[j].GetPageControl().GetControl().Bounds = rectangle2; } } int num5 = SystemInformation.FixedFrameBorderSize.Width; Rectangle rectangle3 = rectangle; Size size = new Size((rectangle3.Width + (3 * (6 + num5))) + width, ((((rectangle3.Height + 4) + 0x18) + 0x17) + (2 * num5)) + SystemInformation.CaptionHeight); base.Size = size; this.selector.Bounds = new Rectangle(6, 6, width, ((rectangle3.Height + 4) + 12) + 0x17); rectangle3.X = (rectangle3.Width + rectangle3.X) - 80; rectangle3.Y = (rectangle3.Height + rectangle3.Y) + 6; rectangle3.Width = 80; rectangle3.Height = 0x17; this.helpButton.Bounds = rectangle3; this.helpButton.Text = System.Windows.Forms.SR.GetString("HelpCaption"); this.helpButton.Click += new EventHandler(this.OnButtonClick); this.helpButton.Enabled = false; this.helpButton.FlatStyle = FlatStyle.System; rectangle3.X -= 0x56; this.applyButton.Bounds = rectangle3; this.applyButton.Text = System.Windows.Forms.SR.GetString("ApplyCaption"); this.applyButton.Click += new EventHandler(this.OnButtonClick); this.applyButton.Enabled = false; this.applyButton.FlatStyle = FlatStyle.System; rectangle3.X -= 0x56; this.cancelButton.Bounds = rectangle3; this.cancelButton.Text = System.Windows.Forms.SR.GetString("CancelCaption"); this.cancelButton.Click += new EventHandler(this.OnButtonClick); this.cancelButton.FlatStyle = FlatStyle.System; base.CancelButton = this.cancelButton; rectangle3.X -= 0x56; this.okButton.Bounds = rectangle3; this.okButton.Text = System.Windows.Forms.SR.GetString("OKCaption"); this.okButton.Click += new EventHandler(this.OnButtonClick); this.okButton.FlatStyle = FlatStyle.System; base.AcceptButton = this.okButton; base.Controls.Clear(); base.Controls.AddRange(new Control[] { this.selector, label, this.pageHost, this.okButton, this.cancelButton, this.applyButton, this.helpButton }); this.AutoScaleBaseSize = new Size(5, 14); base.ApplyAutoScaling(); }