private void _control_Load(object sender, EventArgs e) { LayoutHelper.AutoFitLabels(_labelSize); DisplayHelper.AutoFitSystemLabel(_labelOne, _labelOne.Width, int.MaxValue); DisplayHelper.AutoFitSystemButton(_previewButton, 0, int.MaxValue); if (_control.RightToLeft == RightToLeft.Yes) { _webImageUrl.Left = _previewButton.Right + (int)DisplayHelper.ScaleX(WebImageUrlPadding); _webImageUrl.Width = _pictureBorder.Right - _previewButton.Right - (int)DisplayHelper.ScaleX(WebImageUrlPadding); _fileSize.Left = _pictureBorder.Left; _fileSize.Width = _labelSize.Left - _fileSize.Left - SizeLabelPadding; } else { _webImageUrl.Left = _pictureBorder.Left; _webImageUrl.Width = _previewButton.Left - _webImageUrl.Left - (int)DisplayHelper.ScaleX(WebImageUrlPadding); _fileSize.Left = _labelSize.Right + SizeLabelPadding; _fileSize.Width = _pictureBorder.Right - _fileSize.Left; } BidiHelper.RtlLayoutFixup(_control); _webImageUrl.Select(); }
/// <summary> /// sideBarControl_SelectedIndexChanged event handler. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">An EventArgs that contains the event data.</param> private void sideBarControl_SelectedIndexChanged(object sender, EventArgs e) { // Make the selected PreferencesPanel visible. if (sideBarControl.SelectedIndex < preferencesPanelList.Count && preferencesPanelList[sideBarControl.SelectedIndex] != null) { PreferencesPanel preferencesPanel = (PreferencesPanel)preferencesPanelList[sideBarControl.SelectedIndex]; if (BidiHelper.IsRightToLeft && preferencesPanel.RightToLeft != RightToLeft.Yes) { preferencesPanel.RightToLeft = RightToLeft.Yes; } BidiHelper.RtlLayoutFixup(preferencesPanel); panelPreferences.Controls.Add(preferencesPanel); if (ShowKeyboardCues) { //fix bug 406441, if the show cues window messages have been sent to the form //resend them to force the new control to show them ControlHelper.HideAccelerators(this); ControlHelper.ShowAccelerators(this); } if (ShowFocusCues) { //fix bug 406420, if the show cues window messages have been sent to the form //resend them to force the new control to show them ControlHelper.HideFocus(this); ControlHelper.ShowFocus(this); } preferencesPanel.BringToFront(); } // Remove unselected panels. RemoveUnselectedPanels(); }
protected override void OnShown(EventArgs e) { base.OnShown(e); if (!suppressAutoRtlFixup) { BidiHelper.RtlLayoutFixup(this); } if (SystemInformation.HighContrast) { ControlHelper.Walk( delegate(Control c, object state) { LinkLabel link = c as LinkLabel; if (link != null) { if (link.LinkColor == SystemColors.HotTrack) { link.LinkColor = SystemColors.ControlText; } if (link.LinkBehavior != LinkBehavior.AlwaysUnderline) { link.LinkBehavior = LinkBehavior.AlwaysUnderline; } } }, this, null); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); int delta = -previewButton.Width + DisplayHelper.AutoFitSystemButton(previewButton, previewButton.Width, int.MaxValue); videoCode.Width -= delta; videoCode.RightToLeft = System.Windows.Forms.RightToLeft.No; if (BidiHelper.IsRightToLeft) { lblService.SizeChanged += new EventHandler(lblService_SizeChanged); videoCode.TextAlign = HorizontalAlignment.Right; } else { lblSize.SizeChanged += new EventHandler(lblSize_SizeChanged); } int oldTop = pictureBorder.Top; pictureBorder.Top = videoCode.Bottom + 6; pictureBorder.Height -= pictureBorder.Top - oldTop; BidiHelper.RtlLayoutFixup(this, true, true, Controls); }
void IRtlAware.Layout() { if (!reversed) { reversed = true; BidiHelper.RtlLayoutFixup(this, true, true, Controls); } }
/// <summary> /// Raises the CreateControl method and reverses /// the location of any child controls if running /// in a right-to-left culture. /// </summary> protected override void OnCreateControl() { base.OnCreateControl(); if (!_layedOut) { _layedOut = true; BidiHelper.RtlLayoutFixup(this); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // We do this just to reverse the anchor directions of the children BidiHelper.RtlLayoutFixup(this, true, true, Controls); UpdateQueryStatus(); }
private void DoLayout() { SuspendLayout(); _videoLoginStatusControl.Top = ContentSourceLayout.Y_MARGIN; _videoLoginStatusControl.Height = (int)DisplayHelper.ScaleY(32); _videoLoginStatusControl.Width = (Width - (ContentSourceLayout.X_MARGIN * 2)) / 2 - ContentSourceLayout.X_SPACING; _videoLoginStatusControl.TabIndex = 0; _videoLoginStatusControl.Left = ContentSourceLayout.X_MARGIN; _videoRequestComboBox.Top = _videoLoginStatusControl.Top; _videoRequestComboBox.Height = _videoLoginStatusControl.Height - ContentSourceLayout.Y_SPACING; _videoRequestComboBox.ItemHeight = _videoLoginStatusControl.Height - ContentSourceLayout.Y_SPACING; _videoRequestComboBox.IntegralHeight = true; _videoRequestComboBox.TabIndex = 10; _videoRequestComboBox.Left = _videoLoginStatusControl.Right + ContentSourceLayout.X_SPACING; _videoRequestComboBox.Width = Width - _videoRequestComboBox.Left - ContentSourceLayout.X_MARGIN; _videoPagingControl.Height = (int)DisplayHelper.ScaleY(40); _videoPagingControl.Top = Bottom - _videoPagingControl.Height + ContentSourceLayout.Y_SPACING; _videoPagingControl.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; _videoPagingControl.TabIndex = 40; _sidebarService.Top = _videoLoginStatusControl.Bottom + ContentSourceLayout.Y_SPACING; _sidebarService.Height = Height - _sidebarService.Top - _videoPagingControl.Height; _sidebarService.Width = (int)DisplayHelper.ScaleX(101); _sidebarService.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left; _sidebarService.Name = "videoProviderListBox"; _sidebarService.TabIndex = 20; _sidebarService.Left = _videoLoginStatusControl.Left + LISTBOX_PADDING; _listBoxVideos.Top = _sidebarService.Top; _listBoxVideos.Left = _sidebarService.Right + ContentSourceLayout.X_SPACING; _listBoxVideos.Height = _sidebarService.Height; _listBoxVideos.Width = _videoRequestComboBox.Right - _sidebarService.Width - 2 * MARGIN_X - LISTBOX_PADDING; _listBoxVideos.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right); _listBoxVideos.TabIndex = 30; _listBoxVideos.Name = "listBoxVideos"; _videoPagingControl.Width = _videoRequestComboBox.Width; _videoPagingControl.Left = _videoRequestComboBox.Left; _videoLoginControl.Location = _listBoxVideos.Location; _videoLoginControl.Size = _listBoxVideos.Size; _videoLoginControl.Anchor = _listBoxVideos.Anchor; _videoLoginControl.Visible = true; _videoLoginControl.TabIndex = 30; BidiHelper.RtlLayoutFixup(this, true, true, Controls); ResumeLayout(); }
/// <summary> /// Custom RTL layout is necessary to ensure that RTL fixup only happens once. /// Specifically, the "Select blog type" panel gets fixed up twice just because /// it's part of the wizard form on the form's first layout and it also gets /// reversed on the way into the form. /// /// Really we should not reverse wizard steps on the way in unless the form's /// reversal has already occurred, but this way we'll be robust to changes in /// our form reversal strategy. /// </summary> void IRtlAware.Layout() { if (!rtlApplied) { rtlApplied = true; Control[] childControls = new Control[Controls.Count]; for (int i = 0; i < childControls.Length; i++) { childControls[i] = Controls[i]; } BidiHelper.RtlLayoutFixup(this, true, true, childControls); } }
protected override void LoadEditor() { base.LoadEditor(); WarmSettings = new WarmDecorator.WarmDecoratorSettings(Settings); this.trackBarWarmth.Value = (int)(WarmSettings.WarmthPosition * 500f); trackBarWarmth.SmallChange = trackBarWarmth.Maximum / 20; trackBarWarmth.LargeChange = trackBarWarmth.Maximum / 5; BidiHelper.RtlLayoutFixup(this); label1.Top = label2.Top = trackBarWarmth.Bottom; AccessibleName = ControlHelper.ToAccessibleName(Res.Get(StringId.DecoratorColorTemp)); trackBarWarmth.AccessibleName = ControlHelper.ToAccessibleName(Res.Get(StringId.DecoratorColorTemp)); }
public WebImageForm() { InitializeComponent(); _source.Init(panelLayout.Width, panelLayout.Height); UserControl uc = _source.ImageSelectionControls; panelLayout.Controls.Add(uc); buttonInsert.Text = Res.Get(StringId.InsertImageButton); buttonCancel.Text = Res.Get(StringId.CancelButton); buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; Text = Res.Get(StringId.Plugin_WebImage_Title); Icon = ApplicationEnvironment.ProductIcon; LayoutHelper.FixupOKCancel(buttonInsert, buttonCancel); BidiHelper.RtlLayoutFixup(this); }
private void LoadCategories(bool doRtlFixup) { Controls.Clear(); int y = DockPadding.Top; List <BlogPostCategory> categories = new List <BlogPostCategory>(ctx.Categories); if (categories.Count == 0) { return; } categories.Add(new BlogPostCategoryNone()); categories.Sort(); BlogPostCategory[] selected = ctx.SelectedCategories; foreach (BlogPostCategory cat in categories) { RadioButton radio = new RadioButton(); Controls.Add(radio); radio.Text = HtmlUtils.UnEscapeEntities(cat.Name, HtmlUtils.UnEscapeMode.Default); radio.AccessibleName = cat.Name; radio.UseMnemonic = false; radio.Tag = cat; radio.AutoSize = true; radio.Location = new Point(DockPadding.Left, y); y = radio.Bottom; if (BlogPostCategoryNone.IsCategoryNone(cat)) { radio.Checked = selected.Length == 0; } else { radio.Checked = Array.IndexOf(selected, cat) >= 0; } radio.CheckedChanged += radio_CheckedChanged; } if (doRtlFixup) { BidiHelper.RtlLayoutFixup(this, true); } }
private void RearrangeControls() { if (!Visible) { return; } // This width depends on the contents of the combo, which are dynamic DisplayHelper.AutoFitSystemCombo(comboBoxPosts, 0, int.MaxValue, false); int HPADDING = GetHpadding(); int x; // a x = labelShow.Right + HPADDING; // b comboBoxPosts.Left = x; x = comboBoxPosts.Right + HPADDING; // c if (labelPosts.Visible) { labelPosts.Left = x; } else { panelType.Left = x; int x1 = 0; radioButtonPosts.Left = x1; x1 = radioButtonPosts.Right + HPADDING; radioButtonPages.Left = x1; // x1 = radioButtonPages.Right + HPADDING; panelType.Width = radioButtonPages.Right; } BidiHelper.RtlLayoutFixup(panelType); buttonDelete.Left = textBoxFilter.Right - buttonDelete.Width; }
public PanelLoginControl() { InitializeComponent(); lblEmailExample.SizeChanged += new EventHandler(lblEmailExample_SizeChanged); BackColor = SystemInformation.HighContrast ? SystemColors.Window : SystemColors.ControlLightLight; txtPassword.PasswordChar = Res.PasswordChar; btnLogin.Text = Res.Get(StringId.Plugin_Video_Soapbox_Passport_Login); pictureBoxLogo.RightToLeft = RightToLeft.No; if (BidiHelper.IsRightToLeft) { RightToLeft = RightToLeft.Yes; BidiHelper.RtlLayoutFixup(this, true, true, Controls); } if (BidiHelper.IsRightToLeft) { pictureBoxLogo.Left = txtUsername.Right - pictureBoxLogo.Width; } else { pictureBoxLogo.Left = txtUsername.Left; } lblStatus.Font = Res.GetFont(FontSize.XLarge, FontStyle.Regular); lblStatus.ForeColor = SystemColors.ControlDarkDark; linkLabelCreateMicrosoftAccountID.Text = Res.Get(StringId.CWLiveIDCreateAccount2); linkLabelCreateMicrosoftAccountID.LinkColor = ColorizedResources.Instance.SidebarLinkColor; linkLabelPrivacy.LinkColor = ColorizedResources.Instance.SidebarLinkColor; linkLabelPrivacy.Text = Res.Get(StringId.LiveIDPrivacy); lblPassword.FlatStyle = FlatStyle.System; lblEmailExample.FlatStyle = FlatStyle.System; lblUsername.FlatStyle = FlatStyle.System; linkLabelCreateMicrosoftAccountID.FlatStyle = FlatStyle.System; linkLabelCreateMicrosoftAccountID.LinkBehavior = LinkBehavior.HoverUnderline; linkLabelPrivacy.FlatStyle = FlatStyle.System; linkLabelPrivacy.LinkBehavior = LinkBehavior.HoverUnderline; }
protected override void OnCreateControl() { base.OnCreateControl(); if (!BidiHelper.IsRightToLeft || RightToLeft == RightToLeft.No) { User32.SendMessage(Handle, WM.EM_SETMARGINS, (UIntPtr)EC.RIGHTMARGIN, new IntPtr((BUTTON_WIDTH + BUTTON_RIGHT_OFFSET) << 16)); } else { if (!rtlFixedUp) { rtlFixedUp = true; int leftMargin = Margin.Left; int rightMargin = Margin.Right; BidiHelper.RtlLayoutFixup(this); Margin = new Padding(leftMargin, Padding.Top, rightMargin, Padding.Bottom); } } }
protected virtual void SetWizardBody(Control control) { wizardBody.Controls.Clear(); wizardBody.Controls.Add(control); control.Location = new Point(0, 0); control.Anchor = ((AnchorStyles)((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right))); if (!_scaledControls.Contains(control)) //only scale controls one time { DisplayHelper.Scale(control); OnAddControl(control); _scaledControls.Add(control); } control.Size = new Size(wizardBody.Width, wizardBody.Height); // This may get called multiple times per control, and that's OK, they are designed for it. BidiHelper.RtlLayoutFixup(control); }
private void LayoutControls(CategoryContext categoryContext, bool sizeForm, bool performRtlLayoutFixup) { ClearForm(); SuspendLayout(); // calculate how much room there is above me on the parent form int parentControlY = _parentControl.PointToScreen(_parentControl.Location).Y; Form parentForm = _parentControl.FindForm(); int parentFormY = parentForm.PointToScreen(parentForm.ClientRectangle.Location).Y; int maxHeight = parentControlY - parentFormY - ScaleY(_topMargin) - ScaleY(_bottomMargin); // enforce additional constraint (or not, let freedom reign!) //maxHeight = Math.Min(maxHeight, 400) ; using (PositionManager positionManager = new PositionManager(ScaleX(X_MARGIN), ScaleY(Y_MARGIN + 2), ScaleY(4), ScaleX(MinDropDownWidth), categoryContainerControl.Width, maxHeight, scale)) { // add 'none' if we're single selecting categories if (categoryContext.SelectionMode != CategoryContext.SelectionModes.MultiSelect) { AddCategoryControl(new BlogPostCategoryListItem(new BlogPostCategoryNone(), 0), positionManager); } // add the other categories BlogPostCategoryListItem[] categoryListItems = BlogPostCategoryListItem.BuildList(categoryContext.Categories, true); foreach (BlogPostCategoryListItem categoryListItem in categoryListItems) { AddCategoryControl(categoryListItem, positionManager); } if (sizeForm) { PositionAndSizeForm(positionManager); } } if (performRtlLayoutFixup) { BidiHelper.RtlLayoutFixup(categoryContainerControl); } ResumeLayout(); }
void IRtlAware.Layout() { BidiHelper.RtlLayoutFixup(this, true, true, Controls); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); RefreshParentCombo(); if (panelAddCategory.Visible) { if (comboBoxParent.Visible) { DisplayHelper.AutoFitSystemButton(buttonAdd); using (new AutoGrow(this, AnchorStyles.Bottom | AnchorStyles.Right, false)) { textBoxAddCategory.Width = buttonAdd.Right - textBoxAddCategory.Left; DisplayHelper.AutoFitSystemCombo(comboBoxParent, 0, int.MaxValue, true); comboBoxParent.Left = textBoxAddCategory.Left; comboBoxParent.Top = textBoxAddCategory.Bottom + ScaleY(3); buttonAdd.Top = comboBoxParent.Top + (comboBoxParent.Height - buttonAdd.Height) / 2; buttonAdd.Left = comboBoxParent.Right + ScaleX(3); if (buttonAdd.Right > textBoxAddCategory.Right) { int deltaX = buttonAdd.Right - textBoxAddCategory.Right; textBoxAddCategory.Width += deltaX; using (LayoutHelper.SuspendAnchoring(textBoxAddCategory, buttonAdd, comboBoxParent)) panelAddCategory.Width += deltaX; categoryContainerControl.Width += deltaX; } else { buttonAdd.Left = textBoxAddCategory.Right - buttonAdd.Width; comboBoxParent.Width = buttonAdd.Left - comboBoxParent.Left - ScaleX(3); } int deltaY = comboBoxParent.Bottom - textBoxAddCategory.Bottom; panelAddCategory.Height += deltaY; categoryContainerControl.Top += deltaY; categoryRefreshControl.Top += deltaY; } } else { using (new AutoGrow(this, AnchorStyles.Right, false)) { int deltaX = -buttonAdd.Width + DisplayHelper.AutoFitSystemButton(buttonAdd); textBoxAddCategory.Width -= deltaX; int desiredWidth = DisplayHelper.MeasureString(textBoxAddCategory, textBoxAddCategory.Text).Width + (int)DisplayHelper.ScaleX(10); deltaX += desiredWidth - textBoxAddCategory.Width; if (deltaX > 0) { panelAddCategory.Width += deltaX; categoryContainerControl.Width += deltaX; // textBoxAddCategory.Width += deltaX; // buttonAdd.Left = textBoxAddCategory.Right + ScaleX(3); // textBoxAddCategory.Width = Math.Max(desiredWidth, textBoxAddCategory.Width); // textBoxAddCategory.Width = buttonAdd.Left - textBoxAddCategory.Left - ScaleX(3); } } } /*using (LayoutHelper.SuspendAnchoring(comboBoxParent, buttonAdd, textBoxAddCategory, panelAddCategory, categoryContainerControl)) * { * if (comboBoxParent.Visible) * { * deltaW = -comboBoxParent.Width + DisplayHelper.AutoFitSystemCombo(comboBoxParent, 0, int.MaxValue, true); * buttonAdd.Left += deltaW; * } * * int oldWidth = buttonAdd.Width; * DisplayHelper.AutoFitSystemButton(buttonAdd); * buttonAdd.Width += (int)DisplayHelper.ScaleX(6); // add some more "air" in the Add button * deltaW += buttonAdd.Width - oldWidth; * * panelAddCategory.Width += deltaW; * categoryContainerControl.Width += deltaW; * Width += deltaW; * }*/ } // use design time defaults to drive dynamic layout _topMargin = categoryContainerControl.Top; _bottomMargin = Bottom - categoryContainerControl.Bottom; using (new AutoGrow(this, AnchorStyles.Right, false)) LayoutControls(_categoryContext, true, false); UpdateSelectedCategories(_categoryContext.SelectedCategories); BidiHelper.RtlLayoutFixup(this); }