public MpontuoTabControl() { this._HeaderWidth = 100; this._HeaderHeight = 32; this._HeaderAlignment = ContentAlignment.MiddleLeft; this._HeaderPadding = new Padding(3); this._BackColor = Color.FromArgb(40, 40, 40); this._HeaderBorderColor = Color.FromArgb(40, 40, 40); this._HeaderFont = this.Font; this._HeaderForeColor = Color.FromArgb(66, 130, 181); this._HeaderBackColor = Color.FromArgb(50, 50, 50); this._HeaderSelectedBackColor = Color.FromArgb(65, 65, 65); this._HeaderSelectedForeColor = Color.FromArgb(66, 130, 181); this.DrawMode = TabDrawMode.OwnerDrawFixed; this.SizeMode = TabSizeMode.Fixed; this.Alignment = TabAlignment.Left; this.ItemSize = new Size(this.HeaderHeight, this.HeaderWidth); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); foreach (TabPage tp in this.TabPages) { tp.BackColor = Color.Transparent; tp.CreateGraphics().DrawRectangle(new Pen(Color.FromArgb(65, 65, 65)), new Rectangle(0, 0, tp.Width - 1, tp.Height - 1)); } SubscribeToEvents(); }
protected override void OnOwnerDraw(Graphics g) { RadioButton radioButton = base.HostControl as RadioButton; RadioButtonState state = radioButton.Focused ? RadioButtonState.UncheckedHot : RadioButtonState.UncheckedNormal; System.Drawing.ContentAlignment checkAlign = radioButton.CheckAlign; Size glyphSize = RadioButtonRenderer.GetGlyphSize(g, state); Rectangle rectangle = base.CalculateCheckBounds(checkAlign, glyphSize); if (base["Checked"] == 3) { int num = LayoutHelper.IsRightToLeft(base.HostControl) ? 12 : 8; Rectangle targetRect = new Rectangle(rectangle.Left + rectangle.Width - num, rectangle.Top, 8, 8); Color color = radioButton.Enabled ? radioButton.BackColor : SystemColors.Control; using (new SolidBrush(color)) { g.DrawIcon(Icons.LockIcon, targetRect); } radioButton.Enabled = false; return; } if (Application.RenderWithVisualStyles) { RadioButtonRenderer.DrawRadioButton(g, rectangle.Location, state); return; } rectangle.X--; ControlPaint.DrawRadioButton(g, rectangle, ButtonState.Normal); }
public WaterMark(string Copyright, System.Drawing.ContentAlignment CopyrightPos, System.Drawing.Font CopyrightFont) { m_Copyright = Copyright; m_CopyrightPosition = CopyrightPos; m_CopyrightFont = CopyrightFont; m_ImgWatermark = null; }
/// <summary> /// Calculate the location of rectangle of the given size, /// so that it's indicated corner would be at the given point. /// </summary> /// <param name="pt">The point</param> /// <param name="size"></param> /// <param name="corner">Which corner will be positioned at the reference point</param> /// <returns></returns> /// <example>CalculateAlignedPosition(new Point(50, 100), new Size(10, 20), System.Drawing.ContentAlignment.TopLeft) -> Point(50, 100)</example> /// <example>CalculateAlignedPosition(new Point(50, 100), new Size(10, 20), System.Drawing.ContentAlignment.MiddleCenter) -> Point(45, 90)</example> /// <example>CalculateAlignedPosition(new Point(50, 100), new Size(10, 20), System.Drawing.ContentAlignment.BottomRight) -> Point(40, 80)</example> public Point CalculateAlignedPosition(Point pt, Size size, System.Drawing.ContentAlignment corner) { switch (corner) { case System.Drawing.ContentAlignment.TopLeft: return(pt); case System.Drawing.ContentAlignment.TopCenter: return(new Point(pt.X - (size.Width / 2), pt.Y)); case System.Drawing.ContentAlignment.TopRight: return(new Point(pt.X - size.Width, pt.Y)); case System.Drawing.ContentAlignment.MiddleLeft: return(new Point(pt.X, pt.Y - (size.Height / 2))); case System.Drawing.ContentAlignment.MiddleCenter: return(new Point(pt.X - (size.Width / 2), pt.Y - (size.Height / 2))); case System.Drawing.ContentAlignment.MiddleRight: return(new Point(pt.X - size.Width, pt.Y - (size.Height / 2))); case System.Drawing.ContentAlignment.BottomLeft: return(new Point(pt.X, pt.Y - size.Height)); case System.Drawing.ContentAlignment.BottomCenter: return(new Point(pt.X - (size.Width / 2), pt.Y - size.Height)); case System.Drawing.ContentAlignment.BottomRight: return(new Point(pt.X - size.Width, pt.Y - size.Height)); } // Should never reach here return(pt); }
private static Rectangle OverlayObjectRect(ref Rectangle container, ref Size sizeOfObject, ContentAlignment alignment) { int x, y; switch (alignment) { case ContentAlignment.TopLeft: x = 4; y = 4; break; case ContentAlignment.TopCenter: x = (container.Width - sizeOfObject.Width) / 2; y = 4; break; case ContentAlignment.TopRight: x = container.Width - sizeOfObject.Width - 4; y = 4; break; case ContentAlignment.MiddleLeft: x = 4; y = (container.Height - sizeOfObject.Height) / 2; break; case ContentAlignment.MiddleCenter: x = (container.Width - sizeOfObject.Width) / 2; y = (container.Height - sizeOfObject.Height) / 2; break; case ContentAlignment.MiddleRight: x = container.Width - sizeOfObject.Width - 4; y = (container.Height - sizeOfObject.Height) / 2; break; case ContentAlignment.BottomLeft: x = 4; y = container.Height - sizeOfObject.Height - 4; break; case ContentAlignment.BottomCenter: x = (container.Width - sizeOfObject.Width) / 2; y = container.Height - sizeOfObject.Height - 4; break; case ContentAlignment.BottomRight: x = container.Width - sizeOfObject.Width - 4; y = container.Height - sizeOfObject.Height - 4; break; default: x = 4; y = 4; break; } return(new Rectangle(x, y, sizeOfObject.Width, sizeOfObject.Height)); }
/// <summary> /// Return the point at the indicated corner of the given rectangle (it doesn't /// have to be a corner, but a named location) /// </summary> /// <param name="bounds">The reference rectangle</param> /// <param name="location">Which point of the rectangle should be returned?</param> /// <returns>A point</returns> /// <example>CalculateReferenceLocation(new Rectangle(0, 0, 50, 100), System.Drawing.ContentAlignment.TopLeft) -> Point(0, 0)</example> /// <example>CalculateReferenceLocation(new Rectangle(0, 0, 50, 100), System.Drawing.ContentAlignment.MiddleCenter) -> Point(25, 50)</example> /// <example>CalculateReferenceLocation(new Rectangle(0, 0, 50, 100), System.Drawing.ContentAlignment.BottomRight) -> Point(50, 100)</example> public Point CalculateCorner(Rectangle r, System.Drawing.ContentAlignment corner) { switch (corner) { case System.Drawing.ContentAlignment.TopLeft: return(new Point(r.Left, r.Top)); case System.Drawing.ContentAlignment.TopCenter: return(new Point(r.X + (r.Width / 2), r.Top)); case System.Drawing.ContentAlignment.TopRight: return(new Point(r.Right, r.Top)); case System.Drawing.ContentAlignment.MiddleLeft: return(new Point(r.Left, r.Top + (r.Height / 2))); case System.Drawing.ContentAlignment.MiddleCenter: return(new Point(r.X + (r.Width / 2), r.Top + (r.Height / 2))); case System.Drawing.ContentAlignment.MiddleRight: return(new Point(r.Right, r.Top + (r.Height / 2))); case System.Drawing.ContentAlignment.BottomLeft: return(new Point(r.Left, r.Bottom)); case System.Drawing.ContentAlignment.BottomCenter: return(new Point(r.X + (r.Width / 2), r.Bottom)); case System.Drawing.ContentAlignment.BottomRight: return(new Point(r.Right, r.Bottom)); } // Should never reach here return(r.Location); }
internal static Rectangle AlignInRectangle(Rectangle outer, Size inner, System.Drawing.ContentAlignment align) { int x = 0; int y = 0; if (align == System.Drawing.ContentAlignment.BottomLeft || align == System.Drawing.ContentAlignment.MiddleLeft || align == System.Drawing.ContentAlignment.TopLeft) { x = outer.X; } else if (align == System.Drawing.ContentAlignment.BottomCenter || align == System.Drawing.ContentAlignment.MiddleCenter || align == System.Drawing.ContentAlignment.TopCenter) { x = Math.Max(outer.X + ((outer.Width - inner.Width) / 2), outer.Left); } else if (align == System.Drawing.ContentAlignment.BottomRight || align == System.Drawing.ContentAlignment.MiddleRight || align == System.Drawing.ContentAlignment.TopRight) { x = outer.Right - inner.Width; } if (align == System.Drawing.ContentAlignment.TopCenter || align == System.Drawing.ContentAlignment.TopLeft || align == System.Drawing.ContentAlignment.TopRight) { y = outer.Y; } else if (align == System.Drawing.ContentAlignment.MiddleCenter || align == System.Drawing.ContentAlignment.MiddleLeft || align == System.Drawing.ContentAlignment.MiddleRight) { y = outer.Y + (outer.Height - inner.Height) / 2; } else if (align == System.Drawing.ContentAlignment.BottomCenter || align == System.Drawing.ContentAlignment.BottomRight || align == System.Drawing.ContentAlignment.BottomLeft) { y = outer.Bottom - inner.Height; } return(new Rectangle(x, y, Math.Min(inner.Width, outer.Width), Math.Min(inner.Height, outer.Height))); }
/// <summary> /// /// </summary> /// <param name="control"></param> /// <param name="HorAligment"></param> /// <returns></returns> internal static ContentAlignment GetContentAligmentForSetHorAligment(Control control, AlignmentTypeHori HorAligment) { //get the current content alignment of the control ContentAlignment CurrContentAlignment = GetContentAlignment(control); return(GetContentAligmentForSetHorAligment(CurrContentAlignment, HorAligment)); }
protected override void OnOwnerDraw(Graphics g) { CheckBox checkBox = base.HostControl as CheckBox; System.Drawing.ContentAlignment checkAlign = checkBox.CheckAlign; CheckBoxState state = checkBox.Focused ? CheckBoxState.MixedHot : CheckBoxState.MixedNormal; Size glyphSize = CheckBoxRenderer.GetGlyphSize(g, state); Rectangle rectangle = base.CalculateCheckBounds(checkAlign, glyphSize); if (LayoutHelper.IsRightToLeft(base.HostControl)) { rectangle.Offset(-1, 0); } if (base["Checked"] == 3) { int num = LayoutHelper.IsRightToLeft(base.HostControl) ? 12 : 8; Rectangle targetRect = new Rectangle(rectangle.Left + rectangle.Width - num, rectangle.Top, 8, 8); Color color = checkBox.Enabled ? checkBox.BackColor : SystemColors.Control; using (new SolidBrush(color)) { g.DrawIcon(Icons.LockIcon, targetRect); } checkBox.Enabled = false; return; } if (Application.RenderWithVisualStyles) { CheckBoxRenderer.DrawCheckBox(g, rectangle.Location, state); return; } ControlPaint.DrawMixedCheckBox(g, rectangle, ButtonState.Checked); }
internal static TextFormatFlags CreateTextFormatFlags( Control ctl, System.Drawing.ContentAlignment textAlign, bool showEllipsis, bool useMnemonic, bool showKeyboardCues) { textAlign = RtlTranslateContent(textAlign, ctl.RightToLeft); TextFormatFlags textFormatFlags = WindowFormsUtils.TextFormatFlagsForAlignmentGDI(textAlign) | TextFormatFlags.TextBoxControl | TextFormatFlags.WordBreak; if (showEllipsis) { textFormatFlags |= TextFormatFlags.EndEllipsis; } if (ctl.RightToLeft == RightToLeft.Yes) { textFormatFlags |= TextFormatFlags.RightToLeft; } if (!useMnemonic) { textFormatFlags |= TextFormatFlags.NoPrefix; } else if (!showKeyboardCues) { textFormatFlags |= TextFormatFlags.HidePrefix; } return(textFormatFlags); }
public WaterMark(string Copyright, System.Drawing.ContentAlignment CopyrightPos, System.Drawing.Font CopyrightFont, Image ImgWatermark, System.Drawing.ContentAlignment WaterMarkImagePos) { m_Copyright = Copyright; m_CopyrightPosition = CopyrightPos; m_CopyrightFont = CopyrightFont; m_ImgWatermark = ImgWatermark; m_ImagePosition = WaterMarkImagePos; }
/// <summary> /// Strings the format for alignment. /// </summary> /// <param name="align">The align.</param> /// <returns>StringFormat.</returns> public static StringFormat StringFormatForAlignment(System.Drawing.ContentAlignment align) { return(new StringFormat { Alignment = TranslateAlignment(align), LineAlignment = TranslateLineAlignment(align) }); }
public WaterMark(string Copyright,System.Drawing.ContentAlignment CopyrightPos, System.Drawing.Font CopyrightFont, Image ImgWatermark,System.Drawing.ContentAlignment WaterMarkImagePos) { m_Copyright = Copyright; m_CopyrightPosition = CopyrightPos; m_CopyrightFont = CopyrightFont; m_ImgWatermark = ImgWatermark; m_ImagePosition = WaterMarkImagePos; }
/// <summary> /// Strings the format for alignment. /// </summary> /// <param name="align">The align.</param> /// <returns>StringFormat.</returns> public static StringFormat StringFormatForAlignment(System.Drawing.ContentAlignment align) { return new StringFormat { Alignment = ControlPaintWrapper.TranslateAlignment(align), LineAlignment = ControlPaintWrapper.TranslateLineAlignment(align) }; }
/// <summary> /// Create a rectangle of the given size which is positioned so that /// its indicated corner is at the indicated corner of the reference rect. /// </summary> /// <param name="reference"></param> /// <param name="sz"></param> /// <param name="reference"></param> /// <param name="alignment"></param> /// <param name="offset"></param> /// <returns></returns> /// <remarks> /// <para>Creates a rectangle so that its bottom left is at the centre of the reference: /// corner=BottomLeft, referenceCorner=MiddleCenter</para> /// <para>This is a powerful concept that takes some getting used to, but is /// very neat once you understand it.</para> /// </remarks> public Rectangle CreateAlignedRectangle(Rectangle r, Size sz, System.Drawing.ContentAlignment corner, System.Drawing.ContentAlignment referenceCorner, Size offset) { Point referencePt = this.CalculateCorner(r, referenceCorner); Point topLeft = this.CalculateAlignedPosition(referencePt, sz, corner); return(new Rectangle(topLeft + offset, sz)); }
/// <summary> Sets horizontal alignment of the control. </summary> /// <param name="control"></param> /// <param name="verticalAlignment"></param> public static void SetHorizontalAlignment(Control control, AlignmentTypeHori horizontalAlignment) { if (control is MgLinkLabel || control is MgButtonBase || control is Label || control is MgRadioPanel || control is MgCheckBox || control is MgTextBox || control is MgShape) { ContentAlignment contentAlignment = GetContentAligmentForSetHorAligment(control, horizontalAlignment); SetContentAlignment(control, contentAlignment); } }
private LinkLabel CreateLinkLabel(int id, System.Drawing.ContentAlignment align) { LinkLabel label = new LinkLabel(); label.Name = String.Format("LinkLabel{0}", id); label.Size = new Size(label_width, label_height); label.TabIndex = id; label.BackColor = Color.Silver; label.TabStop = true; label.TextAlign = align; label.LinkBehavior = LinkBehavior.HoverUnderline; label.LinkClicked += new LinkLabelLinkClickedEventHandler(LinkLabelClicked); label.Font = new Font(label.Font.FontFamily, label.Font.Size + 1, label.Font.Style); label.Text = "Mono provides the necessary software to develop and run .NET client and server " + "applications on Linux, Solaris, Mac OS X, Windows, and Unix. Sponsored by Novell, " + "the Mono open source project has an active and enthusiastic contributing community " + "and is positioned to become the leading choice for development of Linux applications."; string [,] links = { { "develop and run .NET client and server", "none" }, { "active and enthusiastic contributing community and is positioned", "none" }, { "Novell", "http://www.novell.com" }, { "Mono", "http://www.mono-project.com" }, { "Linux", "http://www.linux.org/" }, { "Mac OS X", "http://www.apple.com/br/macosx/" } }; for (int i = 0; i < (links.Length / 2); i++) { LinkLabel.Link link = label.Links.Add(label.Text.IndexOf(links[i, 0]), links[i, 0].Length, links[i, 1]); if (i == 0) { link.Enabled = false; } if (i == 1) { link.Visited = false; } } int magic = (id + 2); label.Location = new System.Drawing.Point( 5 + ((magic % 3) * (label.Size.Width + 3)), 5 + (((magic / 3) - 1) * (label.Size.Height + 3))); this.Controls.Add(label); return(label); }
public PGroupBox() { InitializeComponent(); _radius = 35; _borderColor = Color.Gray; _bgColor = Color.Transparent; title_lbl.Text = "Title Here"; _textAlignment = ContentAlignment.TopLeft; }
/// <summary> /// Returns a Rectangle that specifies the size and location of the buttons Image /// </summary> /// <param name="image">The buttons image</param> /// <param name="imageAlignment">The alignment of the image</param> /// <returns>A Rectangle that specifies the size and location of the buttons Image</returns> protected Rectangle CalcImageRect(Image image, System.Drawing.ContentAlignment imageAlignment) { Rectangle imageRect = new Rectangle(this.ClientRectangle.X, this.ClientRectangle.Y, image.Width, image.Height); switch (imageAlignment) { case System.Drawing.ContentAlignment.TopCenter: case System.Drawing.ContentAlignment.MiddleCenter: case System.Drawing.ContentAlignment.BottomCenter: { imageRect.X += (this.ClientRectangle.Width - image.Width) / 2; break; } case System.Drawing.ContentAlignment.TopRight: case System.Drawing.ContentAlignment.MiddleRight: case System.Drawing.ContentAlignment.BottomRight: { imageRect.X = this.ClientRectangle.Right - image.Width; break; } } switch (imageAlignment) { case System.Drawing.ContentAlignment.TopLeft: case System.Drawing.ContentAlignment.TopCenter: case System.Drawing.ContentAlignment.TopRight: { imageRect.Y += 2; break; } case System.Drawing.ContentAlignment.MiddleLeft: case System.Drawing.ContentAlignment.MiddleCenter: case System.Drawing.ContentAlignment.MiddleRight: { imageRect.Y += (this.ClientRectangle.Height - image.Height) / 2; break; } case System.Drawing.ContentAlignment.BottomLeft: case System.Drawing.ContentAlignment.BottomCenter: case System.Drawing.ContentAlignment.BottomRight: { imageRect.Y = this.ClientRectangle.Bottom - image.Height - 2; break; } } return(imageRect); }
public HLabelStyles(Point pt, Size sz, Color foreColor, Color backColor, Single szFont, System.Drawing.ContentAlignment align) { m_pt = pt; m_sz = sz; m_foreColor = foreColor; m_backColor = backColor; m_szFont = szFont; m_align = align; }
/// <summary>Set the CheckAlign according to the TextAlignment of the control</summary> /// <param name="CurrContentAlignment"></param> /// <param name="HorAligment"></param> /// <returns></returns> internal static void SetCheckAlign(Control control) { ContentAlignment checkContentAlignment = ContentAlignment.MiddleLeft; ContentAlignment TextAlign = ContentAlignment.MiddleLeft; if (control is MgCheckBox) { TextAlign = ((MgCheckBox)control).TextAlign; } else if (control is MgRadioButton) { TextAlign = ((MgRadioButton)control).TextAlign; } else { Debug.Assert(false); } switch (TextAlign) { case ContentAlignment.BottomCenter: case ContentAlignment.BottomLeft: case ContentAlignment.BottomRight: checkContentAlignment = ContentAlignment.BottomLeft; break; case ContentAlignment.MiddleCenter: case ContentAlignment.MiddleLeft: case ContentAlignment.MiddleRight: checkContentAlignment = ContentAlignment.MiddleLeft; break; case ContentAlignment.TopCenter: case ContentAlignment.TopLeft: case ContentAlignment.TopRight: checkContentAlignment = ContentAlignment.TopLeft; break; default: break; } if (control is MgCheckBox) { ((MgCheckBox)control).CheckAlign = checkContentAlignment; } else if (control is MgRadioButton) { ((MgRadioButton)control).CheckAlign = checkContentAlignment; } else { Debug.Assert(false); } }
/* * OnPaint */ /// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.Paint"></see> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"></see> that contains the event data.</param> protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; using (SolidBrush sb = new SolidBrush(this.BackColor)) { g.FillRectangle(sb, this.ClientRectangle); } Rectangle closeButtonBounds = this.CloseButton.Visible ? this.CloseButton.Bounds : Rectangle.Empty; Rectangle bounds = this.LayoutManager.GetContentRectangle(this.ClientRectangle, closeButtonBounds); Image image = this.Image; System.Drawing.ContentAlignment imageAlign = System.Drawing.ContentAlignment.MiddleLeft; Rectangle imageBounds = this.LayoutManager.GetImageBounds(new NuGenImageBoundsParams(bounds, image, imageAlign)); Rectangle textBounds = this.LayoutManager.GetTextBounds(new NuGenTextBoundsParams(bounds, imageBounds, imageAlign)); NuGenTabButtonPaintParams tabItemParams = new NuGenTabButtonPaintParams(g, this.ClientRectangle); tabItemParams.Font = this.Font; tabItemParams.Image = this.Image; tabItemParams.ImageBounds = imageBounds; tabItemParams.IsRightToLeft = this.RightToLeft == RightToLeft.Yes; tabItemParams.Text = this.Text; if (this.Text != null) { tabItemParams.TextBounds = textBounds; } if (!this.Enabled) { tabItemParams.State = TabItemState.Disabled; } else { switch (this.TabStateTracker.GetControlState()) { case NuGenControlState.Hot: { tabItemParams.State = TabItemState.Hot; break; } case NuGenControlState.Pressed: { tabItemParams.State = TabItemState.Selected; break; } } } Debug.Assert(this.TabRenderer != null, "this.TabRenderer != null"); this.TabRenderer.DrawTabButton(tabItemParams); }
// Token: 0x06002AE6 RID: 10982 RVA: 0x000A6C5C File Offset: 0x000A4E5C private static HorizontalAlignment smethod_1(System.Drawing.ContentAlignment align) { if (align <= System.Drawing.ContentAlignment.MiddleCenter) { switch (align) { case System.Drawing.ContentAlignment.TopLeft: break; case System.Drawing.ContentAlignment.TopCenter: return(HorizontalAlignment.Center); case (System.Drawing.ContentAlignment) 3: return(HorizontalAlignment.Left); case System.Drawing.ContentAlignment.TopRight: return(HorizontalAlignment.Right); default: if (align != System.Drawing.ContentAlignment.MiddleLeft) { if (align != System.Drawing.ContentAlignment.MiddleCenter) { return(HorizontalAlignment.Left); } return(HorizontalAlignment.Center); } break; } } else if (align <= System.Drawing.ContentAlignment.BottomLeft) { if (align == System.Drawing.ContentAlignment.MiddleRight) { return(HorizontalAlignment.Right); } if (align != System.Drawing.ContentAlignment.BottomLeft) { return(HorizontalAlignment.Left); } } else { if (align == System.Drawing.ContentAlignment.BottomCenter) { return(HorizontalAlignment.Center); } if (align != System.Drawing.ContentAlignment.BottomRight) { return(HorizontalAlignment.Left); } return(HorizontalAlignment.Right); } return(HorizontalAlignment.Left); }
/// <summary> /// calculates the left/top edge for content. /// </summary> /// <param name="Alignment">the alignment of the content</param> /// <param name="rect">rectagular region to place content</param> /// <param name="nWidth">with of content</param> /// <param name="nHeight">height of content</param> /// <returns>returns the left/top edge to place content</returns> private System.Drawing.Point Calculate_LeftEdgeTopEdge(System.Drawing.ContentAlignment Alignment, System.Drawing.Rectangle rect, int nWidth, int nHeight) { System.Drawing.Point pt = new System.Drawing.Point(0, 0); switch (Alignment) { case System.Drawing.ContentAlignment.BottomCenter: pt.X = (rect.Width - nWidth) / 2; pt.Y = rect.Height - nHeight; break; case System.Drawing.ContentAlignment.BottomLeft: pt.X = 0; pt.Y = rect.Height - nHeight; break; case System.Drawing.ContentAlignment.BottomRight: pt.X = rect.Width - nWidth; pt.Y = rect.Height - nHeight; break; case System.Drawing.ContentAlignment.MiddleCenter: pt.X = (rect.Width - nWidth) / 2; pt.Y = (rect.Height - nHeight) / 2; break; case System.Drawing.ContentAlignment.MiddleLeft: pt.X = 0; pt.Y = (rect.Height - nHeight) / 2; break; case System.Drawing.ContentAlignment.MiddleRight: pt.X = rect.Width - nWidth; pt.Y = (rect.Height - nHeight) / 2; break; case System.Drawing.ContentAlignment.TopCenter: pt.X = (rect.Width - nWidth) / 2; pt.Y = 0; break; case System.Drawing.ContentAlignment.TopLeft: pt.X = 0; pt.Y = 0; break; case System.Drawing.ContentAlignment.TopRight: pt.X = rect.Width - nWidth; pt.Y = 0; break; } pt.X += rect.Left; pt.Y += rect.Top; return(pt); }
/// <summary>Sets the text alignment of control</summary> /// <param name="label"></param> /// <param name="contentAlignment"></param> public static void SetContentAlignment(Control control, ContentAlignment contentAlignment) { if (control is IContentAlignmentProperty) { ((IContentAlignmentProperty)control).TextAlign = contentAlignment; } else { Debug.Assert(false); } }
private Label CreateLBL(Control c, System.Drawing.ContentAlignment Aligment = System.Drawing.ContentAlignment.MiddleRight) { Label lbl = new Label(); lbl.Name = FuncGeneral.GetControlName(lbl); lbl.AutoSize = false; lbl.Text = lbl.Name; lbl.TextAlign = Aligment; c.Controls.Add(lbl); return(lbl); }
/// <summary> /// in WebInfo.cpp we send the HorAligement property revers, because the control displays the text according to the RTL Property /// the printText() displays the text according to the send aligment so we need to reverse the org horisontal aligment /// </summary> /// <param name="rightToLeft"></param> /// <param name="AlignmentInfo"></param> /// <param name="TextAlign"></param> /// <returns></returns> public static ContentAlignment GetOrgContentAligment(RightToLeft rightToLeft, ContentAlignment TextAlign) { AlignmentInfo alignmentInfo = GetAlignmentInfo(TextAlign); ContentAlignment NewTextAli = TextAlign; if (rightToLeft == RightToLeft.Yes && alignmentInfo.HorAlign != AlignmentTypeHori.Center) { AlignmentTypeHori newTypeHor = (alignmentInfo.HorAlign == AlignmentTypeHori.Right ? AlignmentTypeHori.Left : AlignmentTypeHori.Right); NewTextAli = GetContentAligmentForHorAligmentAndVerAligment(newTypeHor, alignmentInfo.VerAlign); } return(NewTextAli); }
private static Rectangle VAlign(Size alignThis, Rectangle withinThis, System.Drawing.ContentAlignment align) { if ((align & (System.Drawing.ContentAlignment.BottomRight | System.Drawing.ContentAlignment.BottomCenter | System.Drawing.ContentAlignment.BottomLeft)) != ((System.Drawing.ContentAlignment) 0x0)) { withinThis.Y += withinThis.Height - alignThis.Height; } else if ((align & (System.Drawing.ContentAlignment.MiddleRight | System.Drawing.ContentAlignment.MiddleCenter | System.Drawing.ContentAlignment.MiddleLeft)) != ((System.Drawing.ContentAlignment) 0x0)) { withinThis.Y += (withinThis.Height - alignThis.Height) / 0x2; } withinThis.Height = alignThis.Height; return(withinThis); }
// Token: 0x06002AE8 RID: 10984 RVA: 0x000A6D2C File Offset: 0x000A4F2C public static Rectangle smethod_3(Rectangle outer, Size inner, System.Drawing.ContentAlignment align) { int x = 0; int y = 0; if (align != System.Drawing.ContentAlignment.BottomLeft && align != System.Drawing.ContentAlignment.MiddleLeft) { if (align != System.Drawing.ContentAlignment.TopLeft) { if (align != System.Drawing.ContentAlignment.BottomCenter && align != System.Drawing.ContentAlignment.MiddleCenter) { if (align != System.Drawing.ContentAlignment.TopCenter) { if (align == System.Drawing.ContentAlignment.BottomRight || align == System.Drawing.ContentAlignment.MiddleRight || align == System.Drawing.ContentAlignment.TopRight) { x = outer.Right - inner.Width; goto IL_7D; } goto IL_7D; } } x = Math.Max(outer.X + (outer.Width - inner.Width) / 2, outer.Left); goto IL_7D; } } x = outer.X; IL_7D: if (align != System.Drawing.ContentAlignment.TopCenter && align != System.Drawing.ContentAlignment.TopLeft) { if (align != System.Drawing.ContentAlignment.TopRight) { if (align != System.Drawing.ContentAlignment.MiddleCenter && align != System.Drawing.ContentAlignment.MiddleLeft) { if (align != System.Drawing.ContentAlignment.MiddleRight) { if (align == System.Drawing.ContentAlignment.BottomCenter || align == System.Drawing.ContentAlignment.BottomRight || align == System.Drawing.ContentAlignment.BottomLeft) { y = outer.Bottom - inner.Height; goto IL_EA; } goto IL_EA; } } y = outer.Y + (outer.Height - inner.Height) / 2; goto IL_EA; } } y = outer.Y; IL_EA: return(new Rectangle(x, y, Math.Min(inner.Width, outer.Width), Math.Min(inner.Height, outer.Height))); }
/// <summary> /// /// </summary> /// <param name="contentAlignment"></param> /// <param name="HorAligment"></param> /// <returns></returns> public static ContentAlignment GetContentAligmentForSetHorAligment(ContentAlignment contentAlignment, AlignmentTypeHori HorAligment) { ContentAlignment RetContentAlignment; //get the Current Content alignment info from the ContentAlignmentTable AlignmentInfo aligmentInfo = _contentAlignmentTable[contentAlignment]; //get the current Vertical alignment AlignmentTypeVert CurrVerAligment = aligmentInfo.VerAlign; //get the new Contant alignment from the HorVerConversion; RetContentAlignment = _horVerTranslation[(int)(CurrVerAligment - 1), (int)(HorAligment - 1)]; return(RetContentAlignment); }
/* * OnPaint */ /// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.Paint"></see> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"></see> that contains the event data.</param> protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; using (SolidBrush sb = new SolidBrush(this.BackColor)) { g.FillRectangle(sb, this.ClientRectangle); } Rectangle closeButtonBounds = this.CloseButton.Visible ? this.CloseButton.Bounds : Rectangle.Empty; Rectangle bounds = this.LayoutManager.GetContentRectangle(this.ClientRectangle, closeButtonBounds); Image image = this.Image; System.Drawing.ContentAlignment imageAlign = System.Drawing.ContentAlignment.MiddleLeft; Rectangle imageBounds = Rectangle.Empty; if (image != null) { imageBounds = this.LayoutManager.GetImageBounds( new NuGenBoundsParams( bounds , imageAlign , new Rectangle(Point.Empty, image.Size) , this.RightToLeft ) ); } Rectangle textBounds = this.LayoutManager.GetTextBounds( new NuGenBoundsParams(bounds, imageAlign, imageBounds, this.RightToLeft) ); NuGenTabButtonPaintParams tabItemParams = new NuGenTabButtonPaintParams(g); tabItemParams.Bounds = this.ClientRectangle; tabItemParams.Font = this.Font; tabItemParams.Image = this.Image; tabItemParams.ImageBounds = imageBounds; tabItemParams.Text = this.Text; if (this.Text != null) { tabItemParams.TextBounds = textBounds; } tabItemParams.State = NuGenTabItemStateTranslator.FromControlState(this.TabStateTracker.GetControlState()); Debug.Assert(this.TabRenderer != null, "this.TabRenderer != null"); this.TabRenderer.DrawTabButton(tabItemParams); }
private static HorizontalAlignment GetHorizontalAlignment(ContentAlignment align) { switch (align) { case ContentAlignment.BottomLeft: case ContentAlignment.MiddleLeft: case ContentAlignment.TopLeft: return HorizontalAlignment.Left; case ContentAlignment.BottomCenter: case ContentAlignment.MiddleCenter: case ContentAlignment.TopCenter: return HorizontalAlignment.Center; case ContentAlignment.BottomRight: case ContentAlignment.MiddleRight: case ContentAlignment.TopRight: return HorizontalAlignment.Right; } return HorizontalAlignment.Left; }
/// <summary> /// This procedure sets the appearance of this control according to the data contained. /// </summary> /// <returns>void</returns> public void AppearanceSetup(TListTableEnum AListTable) { System.Single mFontSize; System.Drawing.Font mFont; // TLogging.Log('ButtonTextAlign: ' + Enum.GetName(typeof(System.Drawing.ContentAlignment), this.FButtonTextAlign)); switch (AListTable) { case TListTableEnum.OccupationList : #region TListTableEnum.OccupationList // Settings for the button this.FDefaultButtonText = Catalog.GetString("&Occupation..."); this.FDefaultButtonTextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.FDefaultButtonWidth = 108; // Setting the TextBox this.FDefaultTextBoxWidth = 170; // Layout this.txtAutoPopulated.AdjustButtonWidth = false; this.txtAutoPopulated.SeparatorWidth = 2; this.txtAutoPopulated.LabelSeparatorWidth = 6; #endregion break; case TListTableEnum.PartnerKey : #region TListTableEnum.PartnerKey // Settings for the button this.FDefaultButtonText = String.Format(Catalog.GetString("&{0}"), ApplWideResourcestrings.StrPartnerKey); this.FDefaultButtonTextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.FDefaultButtonWidth = 108; this.FDefaultTextBoxWidth = 80; this.txtAutoPopulated.AdjustButtonWidth = false; mFontSize = this.txtAutoPopulated.txtTextBox.Font.Size; mFont = new System.Drawing.Font("Courier New", mFontSize, System.Drawing.FontStyle.Bold); this.txtAutoPopulated.txtTextBox.Font = mFont; this.FLookUpColumnIndex = -1; this.txtAutoPopulated.txtTextBox.Text = "0000000000"; this.txtAutoPopulated.Size = this.Size; if (ShowLabel) { this.txtAutoPopulated.SetLabel += new TDelegateSetLabel(this.TxtAutoPopulated_SetLabel); } AddCustomContextMenuStrip(); #endregion break; case TListTableEnum.Extract: #region TListTableEnum.Extract // Settings for the button this.FDefaultButtonText = Catalog.GetString("&Extract"); this.FDefaultButtonTextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.FDefaultButtonWidth = 108; this.FDefaultTextBoxWidth = 80; this.txtAutoPopulated.AdjustButtonWidth = false; mFontSize = this.txtAutoPopulated.txtTextBox.Font.Size; mFont = new System.Drawing.Font("Courier New", mFontSize, System.Drawing.FontStyle.Bold); this.txtAutoPopulated.txtTextBox.Font = mFont; this.FLookUpColumnIndex = -1; this.txtAutoPopulated.txtTextBox.Text = ""; this.txtAutoPopulated.Size = this.Size; if (ShowLabel) { this.txtAutoPopulated.SetLabel += new TDelegateSetLabel(this.TxtAutoPopulated_SetLabel); } #endregion break; case TListTableEnum.Conference: #region TListTableEnum.Conference /* Settings for the button */ this.FDefaultButtonText = Catalog.GetString("&Conference"); this.FDefaultButtonTextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.FDefaultButtonWidth = 108; this.FDefaultTextBoxWidth = 80; this.txtAutoPopulated.AdjustButtonWidth = false; mFontSize = this.txtAutoPopulated.txtTextBox.Font.Size; mFont = new System.Drawing.Font("Courier New", mFontSize, System.Drawing.FontStyle.Bold); this.txtAutoPopulated.txtTextBox.Font = mFont; this.FLookUpColumnIndex = -1; this.txtAutoPopulated.txtTextBox.Text = "0000000000"; this.txtAutoPopulated.Size = this.Size; this.txtAutoPopulated.SetLabel += new TDelegateSetLabel(this.TxtAutoPopulated_SetLabel); AddCustomContextMenuStrip(); #endregion break; case TListTableEnum.Event: #region TListTableEnum.Event /* Settings for the button */ this.FDefaultButtonText = Catalog.GetString("&Event"); this.FDefaultButtonTextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.FDefaultButtonWidth = 108; this.FDefaultTextBoxWidth = 80; this.txtAutoPopulated.AdjustButtonWidth = false; mFontSize = this.txtAutoPopulated.txtTextBox.Font.Size; mFont = new System.Drawing.Font("Courier New", mFontSize, System.Drawing.FontStyle.Bold); this.txtAutoPopulated.txtTextBox.Font = mFont; this.FLookUpColumnIndex = -1; this.txtAutoPopulated.txtTextBox.Text = "0000000000"; this.txtAutoPopulated.Size = this.Size; this.txtAutoPopulated.SetLabel += new TDelegateSetLabel(this.TxtAutoPopulated_SetLabel); AddCustomContextMenuStrip(); #endregion break; case TListTableEnum.Bank: #region TListTableEnum.Event /* Settings for the button */ this.FDefaultButtonText = Catalog.GetString("&Bank"); this.FDefaultButtonTextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.FDefaultButtonWidth = 108; this.FDefaultTextBoxWidth = 80; this.txtAutoPopulated.AdjustButtonWidth = false; mFontSize = this.txtAutoPopulated.txtTextBox.Font.Size; mFont = new System.Drawing.Font("Courier New", mFontSize, System.Drawing.FontStyle.Bold); this.txtAutoPopulated.txtTextBox.Font = mFont; this.FLookUpColumnIndex = -1; this.txtAutoPopulated.txtTextBox.Text = "0000000000"; this.txtAutoPopulated.Size = this.Size; if (ShowLabel) { this.txtAutoPopulated.SetLabel += new TDelegateSetLabel(this.TxtAutoPopulated_SetLabel); } AddCustomContextMenuStrip(); #endregion break; } if (this.FASpecialSetting == true) { #region Special Settings apply // TLogging.Log('this.FASpecialSetting = true START'); // ButtonText if (this.ButtonText == "") { this.ButtonText = this.FDefaultButtonText; } this.txtAutoPopulated.ButtonText = this.ButtonText; // ButtonTextAlign // TLogging.Log('FASpecialSettingButtonTextAlign: ' + Enum.GetName(typeof(System.Drawing.ContentAlignment), this.FButtonTextAlign)); this.txtAutoPopulated.ButtonTextAlign = this.ButtonTextAlign; // ButtonWidth if (this.ButtonWidth < 0) { this.ButtonWidth = this.FDefaultButtonWidth; } this.txtAutoPopulated.ButtonWidth = this.ButtonWidth; // TextBoxWidth if (this.TextBoxWidth <= 0) { this.TextBoxWidth = this.FDefaultTextBoxWidth; } this.txtAutoPopulated.TextBoxWidth = this.TextBoxWidth; #endregion // TLogging.Log('this.FASpecialSetting = true END'); } else { // TLogging.Log('this.FASpecialSetting <> true START'); #region Default Settings apply // ButtonText this.ButtonText = this.FDefaultButtonText; // TLogging.Log(' this.FDefaultButtonText: >' + this.FDefaultButtonText + '<'); // TLogging.Log(' this.ButtonText: >' + this.FDefaultButtonText + '<'); this.txtAutoPopulated.ButtonText = this.ButtonText; // TLogging.Log(' this.txtAutoPopulated.ButtonText: >' + this.FDefaultButtonText + '<'); // ButtonTextAlign this.ButtonTextAlign = this.FDefaultButtonTextAlign; this.txtAutoPopulated.ButtonTextAlign = this.ButtonTextAlign; // ButtonWidth this.ButtonWidth = this.FDefaultButtonWidth; this.txtAutoPopulated.ButtonWidth = this.ButtonWidth; // TextBoxWidth this.TextBoxWidth = this.FDefaultTextBoxWidth; this.txtAutoPopulated.TextBoxWidth = this.TextBoxWidth; #endregion // TLogging.Log('this.FASpecialSetting <> true END'); } }
/// <summary> /// Raises the PaintCell event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> public override void OnPaintCell(PaintCellEventArgs e) { if (e.Table.ColumnModel.Columns[e.Column] is ButtonColumn) { ButtonColumn buttonCol = ((ButtonColumn)e.Table.ColumnModel.Columns[e.Column]); this.ImageAlignment = buttonCol.ImageAlignment; this.FlatStyle = buttonCol.FlatStyle; } else { this.ImageAlignment = System.Drawing.ContentAlignment.MiddleLeft; } base.OnPaintCell(e); }
private static Rectangle OverlayObjectRect(ref Rectangle container, ref Size sizeOfObject, ContentAlignment alignment) { int x, y; switch (alignment) { case ContentAlignment.TopLeft: x = 4; y = 4; break; case ContentAlignment.TopCenter: x = (container.Width - sizeOfObject.Width)/2; y = 4; break; case ContentAlignment.TopRight: x = container.Width - sizeOfObject.Width - 4; y = 4; break; case ContentAlignment.MiddleLeft: x = 4; y = (container.Height - sizeOfObject.Height)/2; break; case ContentAlignment.MiddleCenter: x = (container.Width - sizeOfObject.Width)/2; y = (container.Height - sizeOfObject.Height)/2; break; case ContentAlignment.MiddleRight: x = container.Width - sizeOfObject.Width - 4; y = (container.Height - sizeOfObject.Height)/2; break; case ContentAlignment.BottomLeft: x = 4; y = container.Height - sizeOfObject.Height - 4; break; case ContentAlignment.BottomCenter: x = (container.Width - sizeOfObject.Width)/2; y = container.Height - sizeOfObject.Height - 4; break; case ContentAlignment.BottomRight: x = container.Width - sizeOfObject.Width - 4; y = container.Height - sizeOfObject.Height - 4; break; default: x = 4; y = 4; break; } return new Rectangle(x, y, sizeOfObject.Width, sizeOfObject.Height); }
private static VerticalAlignment GetVerticalAlignment(ContentAlignment align) { switch (align) { case ContentAlignment.TopLeft: case ContentAlignment.TopCenter: case ContentAlignment.TopRight: return VerticalAlignment.Top; case ContentAlignment.MiddleLeft: case ContentAlignment.MiddleCenter: case ContentAlignment.MiddleRight: return VerticalAlignment.Center; case ContentAlignment.BottomLeft: case ContentAlignment.BottomCenter: case ContentAlignment.BottomRight: return VerticalAlignment.Bottom; } return VerticalAlignment.Top; }
internal static Rectangle AlignInRectangle(Rectangle outer, Size inner, ContentAlignment align) { int x = 0; int y = 0; if (align == ContentAlignment.BottomLeft || align == ContentAlignment.MiddleLeft || align == ContentAlignment.TopLeft) x = outer.X; else if (align == ContentAlignment.BottomCenter || align == ContentAlignment.MiddleCenter || align == ContentAlignment.TopCenter) x = Math.Max(outer.X + ((outer.Width - inner.Width)/2), outer.Left); else if (align == ContentAlignment.BottomRight || align == ContentAlignment.MiddleRight || align == ContentAlignment.TopRight) x = outer.Right - inner.Width; if (align == ContentAlignment.TopCenter || align == ContentAlignment.TopLeft || align == ContentAlignment.TopRight) y = outer.Y; else if (align == ContentAlignment.MiddleCenter || align == ContentAlignment.MiddleLeft || align == ContentAlignment.MiddleRight) y = outer.Y + (outer.Height - inner.Height)/2; else if (align == ContentAlignment.BottomCenter || align == ContentAlignment.BottomRight || align == ContentAlignment.BottomLeft) y = outer.Bottom - inner.Height; return new Rectangle(x, y, Math.Min(inner.Width, outer.Width), Math.Min(inner.Height, outer.Height)); }
/// <summary> /// Initializes a new instance of the ButtonCellRenderer class with /// default settings /// </summary> public ButtonCellRenderer() : base() { this.imageAlignment = System.Drawing.ContentAlignment.MiddleCenter; }
private static Rectangle AlignInRectangle(Rectangle outer, Size inner, ContentAlignment align) { int x = 0; int y = 0; switch (align) { case ContentAlignment.TopLeft: case ContentAlignment.MiddleLeft: case ContentAlignment.BottomLeft: x = outer.X; break; case ContentAlignment.TopCenter: case ContentAlignment.MiddleCenter: case ContentAlignment.BottomCenter: x = Math.Max(outer.X + ((outer.Width - inner.Width) / 2), outer.Left); break; case ContentAlignment.TopRight: case ContentAlignment.MiddleRight: case ContentAlignment.BottomRight: x = outer.Right - inner.Width; break; } switch (align) { case ContentAlignment.TopRight: case ContentAlignment.TopLeft: case ContentAlignment.TopCenter: y = outer.Y; break; case ContentAlignment.MiddleRight: case ContentAlignment.MiddleLeft: case ContentAlignment.MiddleCenter: y = outer.Y + (outer.Height - inner.Height) / 2; break; case ContentAlignment.BottomLeft: case ContentAlignment.BottomRight: case ContentAlignment.BottomCenter: y = outer.Bottom - inner.Height; break; } return new Rectangle(x, y, Math.Min(inner.Width, outer.Width), Math.Min(inner.Height, outer.Height)); }