public ListChat(WappMessage msg, MetroFramework.MetroColorStyle style) { InitializeComponent(); this.Style = style; this.metroTile1.Style = style; this.metroTile1.BackColor = Helper.GetMetroThemeColor(style); if (msg.from_me) { this.Padding = new Padding(50, this.Padding.Top, 4, this.Padding.Bottom); } if (!String.IsNullOrEmpty(msg.author)) { Contact c = ContactStore.GetContactByJid(msg.author); if (c != null) { msg.author = c.FullName; } msg.data = String.Format("{0}\r\n{1}", msg.author, msg.data); } if (msg.type == "image") { if (!string.IsNullOrEmpty(msg.preview)) { MemoryStream ms = new MemoryStream(Convert.FromBase64String(msg.preview)); Image i = Image.FromStream(ms); this.Height += i.Height; this.Controls.Remove(this.metroTile1); PictureBox pb = new PictureBox(); pb.Width = i.Width; pb.Height = i.Height; pb.Image = i; this.Controls.Add(pb); } } else { Font f = MetroFonts.Tile(this.metroTile1.TileTextFontSize, this.metroTile1.TileTextFontWeight); int lineHeight = Int32.Parse(Math.Round((decimal)this.metroTile1.CreateGraphics().MeasureString("X", f).Height).ToString()); SizeF sf = new SizeF(); sf = this.metroTile1.CreateGraphics().MeasureString(msg.data, f, this.metroTile1.Width); this.metroTile1.Text = msg.data; int newHeight = (int)Math.Round(decimal.Parse(sf.Height.ToString())); int lines = newHeight / f.Height; //lines--; if (lines > 0) { this.Height = (lines * this.Height); } } }
protected override void OnPaint(PaintEventArgs e) { Color backColor, foreColor; backColor = MetroPaint.GetStyleColor(Style); if (useCustomBackground) { backColor = BackColor; } if (isHovered && !isPressed && Enabled) { foreColor = MetroPaint.ForeColor.Tile.Hover(Theme); } else if (isHovered && isPressed && Enabled) { foreColor = MetroPaint.ForeColor.Tile.Press(Theme); } else if (!Enabled) { foreColor = MetroPaint.ForeColor.Tile.Disabled(Theme); } else { foreColor = MetroPaint.ForeColor.Tile.Normal(Theme); } if (useCustomForeColor) { foreColor = ForeColor; } e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; if (!isPressed) { e.Graphics.Clear(backColor); } else { e.Graphics.Clear(MetroPaint.BackColor.Form(Theme)); using (SolidBrush b = new SolidBrush(backColor)) { Point[] polyPoints = new Point[] { new Point(0, 0), new Point(Width - 1, 2), new Point(Width - 1, Height - 2), new Point(0, Height) }; e.Graphics.FillPolygon(b, polyPoints); } } if (useTileImage) { if (tileImage != null) { Rectangle rect; switch (tileImageAlign) { case ContentAlignment.BottomLeft: rect = new Rectangle(new Point(0, Height - TileImage.Height), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; case ContentAlignment.BottomCenter: rect = new Rectangle(new Point(Width / 2 - TileImage.Width / 2, Height - TileImage.Height), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; case ContentAlignment.BottomRight: rect = new Rectangle(new Point(Width - TileImage.Width, Height - TileImage.Height), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; case ContentAlignment.MiddleLeft: rect = new Rectangle(new Point(0, Height / 2 - TileImage.Height / 2), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; case ContentAlignment.MiddleCenter: rect = new Rectangle(new Point(Width / 2 - TileImage.Width / 2, Height / 2 - TileImage.Height / 2), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; case ContentAlignment.MiddleRight: rect = new Rectangle(new Point(Width - TileImage.Width, Height / 2 - TileImage.Height / 2), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; case ContentAlignment.TopLeft: rect = new Rectangle(new Point(0, 0), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; case ContentAlignment.TopCenter: rect = new Rectangle(new Point(Width / 2 - TileImage.Width / 2, 0), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; case ContentAlignment.TopRight: rect = new Rectangle(new Point(Width - TileImage.Width, 0), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; default: rect = new Rectangle(new Point(0, 0), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; } e.Graphics.DrawImage(TileImage, rect); } } if (TileCount > 0 && paintTileCount) { Size countSize = TextRenderer.MeasureText(TileCount.ToString(), MetroFonts.TileCount); e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; TextRenderer.DrawText(e.Graphics, TileCount.ToString(), MetroFonts.TileCount, new Point(Width - countSize.Width, 0), foreColor); e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault; } Size textSize = TextRenderer.MeasureText(Text, MetroFonts.Tile(tileTextFontSize, tileTextFontWeight)); TextFormatFlags flags = TextFormatFlags.LeftAndRightPadding | TextFormatFlags.EndEllipsis; Rectangle clientRectangle = ClientRectangle; switch (TextAlign) { case ContentAlignment.BottomCenter: flags |= TextFormatFlags.Bottom; flags |= TextFormatFlags.HorizontalCenter; break; case ContentAlignment.BottomRight: flags |= TextFormatFlags.Bottom; flags |= TextFormatFlags.Right; break; case ContentAlignment.MiddleLeft: flags |= TextFormatFlags.VerticalCenter; flags |= TextFormatFlags.Left; break; case ContentAlignment.MiddleCenter: flags |= TextFormatFlags.VerticalCenter; flags |= TextFormatFlags.HorizontalCenter; break; case ContentAlignment.MiddleRight: flags |= TextFormatFlags.VerticalCenter; flags |= TextFormatFlags.Right; break; case ContentAlignment.TopLeft: flags |= TextFormatFlags.Top; flags |= TextFormatFlags.Left; break; case ContentAlignment.TopCenter: flags |= TextFormatFlags.Top; flags |= TextFormatFlags.HorizontalCenter; break; case ContentAlignment.TopRight: flags |= TextFormatFlags.Top; flags |= TextFormatFlags.Right; break; default: case ContentAlignment.BottomLeft: flags |= TextFormatFlags.Bottom; flags |= TextFormatFlags.Left; break; } TextRenderer.DrawText(e.Graphics, Text, MetroFonts.Tile(tileTextFontSize, tileTextFontWeight), clientRectangle, foreColor, flags); if (false && isFocused) { ControlPaint.DrawFocusRectangle(e.Graphics, ClientRectangle); } }
protected virtual void OnPaintForeground(PaintEventArgs e) { Color foreColor; if (isHovered && !isPressed && Enabled) { foreColor = MetroPaint.ForeColor.Tile.Hover(Theme); } else if (isHovered && isPressed && Enabled) { foreColor = MetroPaint.ForeColor.Tile.Press(Theme); } else if (!Enabled) { foreColor = MetroPaint.ForeColor.Tile.Disabled(Theme); } else { foreColor = MetroPaint.ForeColor.Tile.Normal(Theme); } if (useCustomForeColor) { foreColor = ForeColor; } if (isPressed) { } e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; if (useTileImage) { if (tileImage != null) { Rectangle imageRectangle; switch (tileImageAlign) { case ContentAlignment.BottomLeft: imageRectangle = new Rectangle(new Point(0, Height - TileImage.Height), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; case ContentAlignment.BottomCenter: imageRectangle = new Rectangle(new Point(Width / 2 - TileImage.Width / 2, Height - TileImage.Height), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; case ContentAlignment.BottomRight: imageRectangle = new Rectangle(new Point(Width - TileImage.Width, Height - TileImage.Height), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; case ContentAlignment.MiddleLeft: imageRectangle = new Rectangle(new Point(0, Height / 2 - TileImage.Height / 2), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; case ContentAlignment.MiddleCenter: imageRectangle = new Rectangle(new Point(Width / 2 - TileImage.Width / 2, Height / 2 - TileImage.Height / 2), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; case ContentAlignment.MiddleRight: imageRectangle = new Rectangle(new Point(Width - TileImage.Width, Height / 2 - TileImage.Height / 2), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; case ContentAlignment.TopLeft: imageRectangle = new Rectangle(new Point(0, 0), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; case ContentAlignment.TopCenter: imageRectangle = new Rectangle(new Point(Width / 2 - TileImage.Width / 2, 0), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; case ContentAlignment.TopRight: imageRectangle = new Rectangle(new Point(Width - TileImage.Width, 0), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; default: imageRectangle = new Rectangle(new Point(0, 0), new System.Drawing.Size(TileImage.Width, TileImage.Height)); break; } e.Graphics.DrawImage(TileImage, imageRectangle); } } if (TileCount > 0 && paintTileCount) { Size countSize = TextRenderer.MeasureText(TileCount.ToString(), MetroFonts.TileCount); e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; TextRenderer.DrawText(e.Graphics, TileCount.ToString(), MetroFonts.TileCount, new Point(Width - countSize.Width, 0), foreColor); e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault; } Size textSize = TextRenderer.MeasureText(Text, MetroFonts.Tile(tileTextFontSize, tileTextFontWeight)); TextFormatFlags flags = MetroPaint.GetTextFormatFlags(TextAlign) | TextFormatFlags.LeftAndRightPadding | TextFormatFlags.EndEllipsis; Rectangle textRectangle = ClientRectangle; if (isPressed) { textRectangle.Inflate(-2, -2); } TextRenderer.DrawText(e.Graphics, Text, MetroFonts.Tile(tileTextFontSize, tileTextFontWeight), textRectangle, foreColor, flags); if (false && isFocused) { ControlPaint.DrawFocusRectangle(e.Graphics, ClientRectangle); } }
protected virtual void OnPaintForeground(PaintEventArgs e) { Color foreColor; Rectangle rectangle; Color color = MetroPaint.BorderColor.Button.Normal(this.Theme); if (this.isHovered && !this.isPressed && base.Enabled) { foreColor = MetroPaint.ForeColor.Tile.Hover(this.Theme); } else if (!this.isHovered || !this.isPressed || !base.Enabled) { foreColor = (base.Enabled ? MetroPaint.ForeColor.Tile.Normal(this.Theme) : MetroPaint.ForeColor.Tile.Disabled(this.Theme)); } else { foreColor = MetroPaint.ForeColor.Tile.Press(this.Theme); } if (this.useCustomForeColor) { foreColor = this.ForeColor; } if (this.isPressed || this.isHovered || this.isFocused) { using (Pen pen = new Pen(color)) { pen.Width = 3f; Rectangle rectangle1 = new Rectangle(1, 1, base.Width - 3, base.Height - 3); e.Graphics.DrawRectangle(pen, rectangle1); } } e.Graphics.SmoothingMode = SmoothingMode.HighQuality; e.Graphics.CompositingQuality = CompositingQuality.HighQuality; if (this.useTileImage && this.tileImage != null) { ContentAlignment contentAlignment = this.tileImageAlign; if (contentAlignment <= ContentAlignment.MiddleCenter) { switch (contentAlignment) { case ContentAlignment.TopLeft: rectangle = new Rectangle(new Point(0, 0), new System.Drawing.Size(this.TileImage.Width, this.TileImage.Height)); break; case ContentAlignment.TopCenter: rectangle = new Rectangle(new Point(base.Width / 2 - this.TileImage.Width / 2, 0), new System.Drawing.Size(this.TileImage.Width, this.TileImage.Height)); break; case ContentAlignment.TopLeft | ContentAlignment.TopCenter: rectangle = new Rectangle(new Point(0, 0), new System.Drawing.Size(this.TileImage.Width, this.TileImage.Height)); break; case ContentAlignment.TopRight: rectangle = new Rectangle(new Point(base.Width - this.TileImage.Width, 0), new System.Drawing.Size(this.TileImage.Width, this.TileImage.Height)); break; default: if (contentAlignment == ContentAlignment.MiddleLeft) { rectangle = new Rectangle(new Point(0, base.Height / 2 - this.TileImage.Height / 2), new System.Drawing.Size(this.TileImage.Width, this.TileImage.Height)); break; } else if (contentAlignment == ContentAlignment.MiddleCenter) { rectangle = new Rectangle(new Point(base.Width / 2 - this.TileImage.Width / 2, base.Height / 2 - this.TileImage.Height / 2), new System.Drawing.Size(this.TileImage.Width, this.TileImage.Height)); break; } else { rectangle = new Rectangle(new Point(0, 0), new System.Drawing.Size(this.TileImage.Width, this.TileImage.Height)); } break; } } else if (contentAlignment <= ContentAlignment.BottomLeft) { if (contentAlignment == ContentAlignment.MiddleRight) { rectangle = new Rectangle(new Point(base.Width - this.TileImage.Width, base.Height / 2 - this.TileImage.Height / 2), new System.Drawing.Size(this.TileImage.Width, this.TileImage.Height)); } else { if (contentAlignment != ContentAlignment.BottomLeft) { rectangle = new Rectangle(new Point(0, 0), new System.Drawing.Size(this.TileImage.Width, this.TileImage.Height)); } else { rectangle = new Rectangle(new Point(0, base.Height - this.TileImage.Height), new System.Drawing.Size(this.TileImage.Width, this.TileImage.Height)); } } } else if (contentAlignment == ContentAlignment.BottomCenter) { rectangle = new Rectangle(new Point(base.Width / 2 - this.TileImage.Width / 2, base.Height - this.TileImage.Height), new System.Drawing.Size(this.TileImage.Width, this.TileImage.Height)); } else { if (contentAlignment != ContentAlignment.BottomRight) { rectangle = new Rectangle(new Point(0, 0), new System.Drawing.Size(this.TileImage.Width, this.TileImage.Height)); } else { rectangle = new Rectangle(new Point(base.Width - this.TileImage.Width, base.Height - this.TileImage.Height), new System.Drawing.Size(this.TileImage.Width, this.TileImage.Height)); } } e.Graphics.DrawImage(this.TileImage, rectangle); } if (this.TileCount > 0 && this.paintTileCount) { int tileCount = this.TileCount; System.Drawing.Size size = TextRenderer.MeasureText(tileCount.ToString(), MetroFonts.TileCount); e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias; Graphics graphics = e.Graphics; int num = this.TileCount; TextRenderer.DrawText(graphics, num.ToString(), MetroFonts.TileCount, new Point(base.Width - size.Width, 0), foreColor); e.Graphics.TextRenderingHint = TextRenderingHint.SystemDefault; } TextRenderer.MeasureText(this.Text, MetroFonts.Tile(this.tileTextFontSize, this.tileTextFontWeight)); TextFormatFlags textFormatFlags = MetroPaint.GetTextFormatFlags(this.TextAlign) | TextFormatFlags.LeftAndRightPadding | TextFormatFlags.EndEllipsis; Rectangle clientRectangle = base.ClientRectangle; if (!this.isPressed) { clientRectangle.Inflate(-2, -10); } else { clientRectangle.Inflate(-4, -12); } TextRenderer.DrawText(e.Graphics, this.Text, MetroFonts.Tile(this.tileTextFontSize, this.tileTextFontWeight), clientRectangle, foreColor, textFormatFlags); return; }
/// <summary> /// 自定义绘制节点 /// </summary> /// <param name="e"></param> private void DrawNodeItem(DrawTreeNodeEventArgs e) { TreeNode tn = e.Node; if (tn.Level == 0) { using (Graphics g = e.Graphics) { if (!BackColor.Equals(ChangeColor(MetroPaint.GetStyleColor(Style), -0.5f))) { BackColor = ChangeColor(MetroPaint.GetStyleColor(Style), -0.5f); } //绘制分组的背景 RenderBackgroundInternalRate( g, e.Bounds, MetroPaint.GetStyleColor(Style), false); //绘制展开按扭 g.FillEllipse(new SolidBrush(ExpandButtonColor), ExpandButtonBounds(e.Bounds)); g.DrawEllipse(new Pen(Color.LightGray), ExpandButtonBounds(e.Bounds)); Point p1; Point p2; Point p3; if (tn.IsExpanded) { p1 = new Point(ExpandButtonBounds(e.Bounds).X + 3, ExpandButtonBounds(e.Bounds).Bottom - 4); p2 = new Point(ExpandButtonBounds(e.Bounds).X + (ExpandButtonSize.Width) / 2, ExpandButtonBounds(e.Bounds).Top + 5); p3 = new Point(ExpandButtonBounds(e.Bounds).Right - 3, ExpandButtonBounds(e.Bounds).Bottom - 4); } else { p1 = new Point(ExpandButtonBounds(e.Bounds).X + 3, ExpandButtonBounds(e.Bounds).Y + 4); p2 = new Point(ExpandButtonBounds(e.Bounds).X + (ExpandButtonSize.Width) / 2, ExpandButtonBounds(e.Bounds).Bottom - 5); p3 = new Point(ExpandButtonBounds(e.Bounds).Right - 3, ExpandButtonBounds(e.Bounds).Y + 4); } GraphicsPath gp = new GraphicsPath(); gp.AddLine(p1, p2); gp.AddLine(p2, p3); g.DrawPath(new Pen(Color.FromArgb(255, 150, 0, 0), 2f), gp); //绘制分组的文本 TextRenderer.DrawText( g, e.Node.Text, MetroFonts.Tile(metroLabelSize, metroLabelWeight), GroupTitleBounds(e.Bounds), Color.White, TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis); } } else if (tn.Level == 1) { //e.DrawDefault = true; using (Graphics g = e.Graphics) { if (tn.IsSelected) { RenderBackgroundInternalRate( g, e.Bounds, ChangeColor(MetroPaint.GetStyleColor(Style), 0.3f), false ); RenderBackgroundInternalRate( g, new Rectangle { X = e.Bounds.X, Y = e.Bounds.Y, Height = e.Bounds.Height, Width = 5 }, ChangeColor(MetroPaint.GetStyleColor(Style), -0.8f), false ); TextRenderer.DrawText( g, e.Node.Text, MetroFonts.Tile(metroLabelSize, metroLabelWeight), new Rectangle { X = e.Bounds.X + 40, Y = e.Bounds.Y, Width = e.Bounds.Width, Height = e.Bounds.Height }, Color.White, TextFormatFlags.Left | TextFormatFlags.VerticalCenter); } else { TextRenderer.DrawText( g, e.Node.Text, MetroFonts.Tile(metroLabelSize, MetroTileTextWeight.Light), new Rectangle { X = e.Bounds.X + 40, Y = e.Bounds.Y, Width = e.Bounds.Width, Height = e.Bounds.Height }, Color.White, TextFormatFlags.Left | TextFormatFlags.VerticalCenter); } } } }
// Token: 0x060002F8 RID: 760 RVA: 0x0000A144 File Offset: 0x00008344 protected override void OnPaint(PaintEventArgs e) { Color color = MetroPaint.GetStyleColor(base.Style); if (this.useCustomBackground) { color = this.BackColor; } Color foreColor; if (this.isHovered && !this.isPressed && base.Enabled) { foreColor = MetroPaint.ForeColor.Tile.Hover(base.Theme); } else if (this.isHovered && this.isPressed && base.Enabled) { foreColor = MetroPaint.ForeColor.Tile.Press(base.Theme); } else if (!base.Enabled) { foreColor = MetroPaint.ForeColor.Tile.Disabled(base.Theme); } else { foreColor = MetroPaint.ForeColor.Tile.Normal(base.Theme); } if (this.useCustomForeColor) { foreColor = this.ForeColor; } e.Graphics.SmoothingMode = SmoothingMode.HighQuality; e.Graphics.CompositingQuality = CompositingQuality.HighQuality; if (!this.isPressed) { e.Graphics.Clear(color); } else { e.Graphics.Clear(MetroPaint.BackColor.Form(base.Theme)); using (SolidBrush solidBrush = new SolidBrush(color)) { Point[] points = new Point[] { new Point(0, 0), new Point(base.Width - 1, 2), new Point(base.Width - 1, base.Height - 2), new Point(0, base.Height) }; e.Graphics.FillPolygon(solidBrush, points); } } if (this.useTileImage && this.tileImage != null) { ContentAlignment contentAlignment = this.tileImageAlign; Rectangle rect; if (contentAlignment <= ContentAlignment.MiddleCenter) { switch (contentAlignment) { case ContentAlignment.TopLeft: rect = new Rectangle(new Point(0, 0), new Size(this.TileImage.Width, this.TileImage.Height)); goto IL_4A7; case ContentAlignment.TopCenter: rect = new Rectangle(new Point(base.Width / 2 - this.TileImage.Width / 2, 0), new Size(this.TileImage.Width, this.TileImage.Height)); goto IL_4A7; case (ContentAlignment)3: break; case ContentAlignment.TopRight: rect = new Rectangle(new Point(base.Width - this.TileImage.Width, 0), new Size(this.TileImage.Width, this.TileImage.Height)); goto IL_4A7; default: if (contentAlignment == ContentAlignment.MiddleLeft) { rect = new Rectangle(new Point(0, base.Height / 2 - this.TileImage.Height / 2), new Size(this.TileImage.Width, this.TileImage.Height)); goto IL_4A7; } if (contentAlignment == ContentAlignment.MiddleCenter) { rect = new Rectangle(new Point(base.Width / 2 - this.TileImage.Width / 2, base.Height / 2 - this.TileImage.Height / 2), new Size(this.TileImage.Width, this.TileImage.Height)); goto IL_4A7; } break; } } else if (contentAlignment <= ContentAlignment.BottomLeft) { if (contentAlignment == ContentAlignment.MiddleRight) { rect = new Rectangle(new Point(base.Width - this.TileImage.Width, base.Height / 2 - this.TileImage.Height / 2), new Size(this.TileImage.Width, this.TileImage.Height)); goto IL_4A7; } if (contentAlignment == ContentAlignment.BottomLeft) { rect = new Rectangle(new Point(0, base.Height - this.TileImage.Height), new Size(this.TileImage.Width, this.TileImage.Height)); goto IL_4A7; } } else { if (contentAlignment == ContentAlignment.BottomCenter) { rect = new Rectangle(new Point(base.Width / 2 - this.TileImage.Width / 2, base.Height - this.TileImage.Height), new Size(this.TileImage.Width, this.TileImage.Height)); goto IL_4A7; } if (contentAlignment == ContentAlignment.BottomRight) { rect = new Rectangle(new Point(base.Width - this.TileImage.Width, base.Height - this.TileImage.Height), new Size(this.TileImage.Width, this.TileImage.Height)); goto IL_4A7; } } rect = new Rectangle(new Point(0, 0), new Size(this.TileImage.Width, this.TileImage.Height)); IL_4A7: e.Graphics.DrawImage(this.TileImage, rect); } if (this.TileCount > 0 && this.paintTileCount) { Size size = TextRenderer.MeasureText(this.TileCount.ToString(), MetroFonts.TileCount); e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias; TextRenderer.DrawText(e.Graphics, this.TileCount.ToString(), MetroFonts.TileCount, new Point(base.Width - size.Width, 0), foreColor); e.Graphics.TextRenderingHint = TextRenderingHint.SystemDefault; } TextRenderer.MeasureText(this.Text, MetroFonts.Tile(this.tileTextFontSize, this.tileTextFontWeight)); TextFormatFlags textFormatFlags = TextFormatFlags.EndEllipsis | TextFormatFlags.LeftAndRightPadding; Rectangle clientRectangle = base.ClientRectangle; ContentAlignment textAlign = this.TextAlign; if (textAlign <= ContentAlignment.MiddleCenter) { switch (textAlign) { case ContentAlignment.TopLeft: textFormatFlags = textFormatFlags; textFormatFlags = textFormatFlags; goto IL_634; case ContentAlignment.TopCenter: textFormatFlags = textFormatFlags; textFormatFlags |= TextFormatFlags.HorizontalCenter; goto IL_634; case (ContentAlignment)3: break; case ContentAlignment.TopRight: textFormatFlags = textFormatFlags; textFormatFlags |= TextFormatFlags.Right; goto IL_634; default: if (textAlign == ContentAlignment.MiddleLeft) { textFormatFlags |= TextFormatFlags.VerticalCenter; textFormatFlags = textFormatFlags; goto IL_634; } if (textAlign == ContentAlignment.MiddleCenter) { textFormatFlags |= TextFormatFlags.VerticalCenter; textFormatFlags |= TextFormatFlags.HorizontalCenter; goto IL_634; } break; } } else if (textAlign <= ContentAlignment.BottomLeft) { if (textAlign == ContentAlignment.MiddleRight) { textFormatFlags |= TextFormatFlags.VerticalCenter; textFormatFlags |= TextFormatFlags.Right; goto IL_634; } if (textAlign != ContentAlignment.BottomLeft) { } } else { if (textAlign == ContentAlignment.BottomCenter) { textFormatFlags |= TextFormatFlags.Bottom; textFormatFlags |= TextFormatFlags.HorizontalCenter; goto IL_634; } if (textAlign == ContentAlignment.BottomRight) { textFormatFlags |= TextFormatFlags.Bottom; textFormatFlags |= TextFormatFlags.Right; goto IL_634; } } textFormatFlags |= TextFormatFlags.Bottom; textFormatFlags = textFormatFlags; IL_634: TextRenderer.DrawText(e.Graphics, this.Text, MetroFonts.Tile(this.tileTextFontSize, this.tileTextFontWeight), clientRectangle, foreColor, textFormatFlags); }