protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { base.OnPaint(e); BidiGraphics g = new BidiGraphics(e.Graphics, ClientRectangle); g.DrawText(Res.Get(StringId.MapSeeInBirdseye), Font, new Rectangle(ScaleX(TEXT_INSET), 0, Width - ScaleX(TEXT_INSET + 5), Height), Color.Black, TextFormatFlags.VerticalCenter | TextFormatFlags.WordBreak); }
protected override void OnPaint(PaintEventArgs e) { BidiGraphics g = new BidiGraphics(e.Graphics, ClientRectangle); using (Brush b = new SolidBrush(ColorizedResources.Instance.BorderDarkColor)) g.FillRectangle(b, ClientRectangle); TextFormatFlags tf = TextFormatFlags.VerticalCenter; int width = g.MeasureText(Text, Font).Width; g.DrawText(Text, Font, new Rectangle(20, -1, width, ClientSize.Height), _uiTheme.TextColor, tf); }
protected override void OnPaint(PaintEventArgs e) { BidiGraphics g = new BidiGraphics(e.Graphics, ClientRectangle); StringFormat format = new StringFormat(); format.LineAlignment = StringAlignment.Center; Rectangle rectangle = ClientRectangle; // draw text g.DrawText(HeaderText, _font, rectangle, ColorizedResources.Instance.SidebarHeaderTextColor, TextFormatFlags.VerticalCenter); }
protected override void OnPaint(PaintEventArgs e) { BidiGraphics g = new BidiGraphics(e.Graphics, ClientRectangle); // draw image const int HEADER_X_INSET = 0; const int HEADER_Y_INSET = 0; g.DrawImage(false, _headerImage, HEADER_X_INSET, HEADER_Y_INSET); // draw text centered vertically const int TEXT_X_INSET = 5; Size textSize = g.MeasureText(_label, Font); int textY = (Height / 2) - (textSize.Height / 2); Color textColor = !SystemInformation.HighContrast ? Color.FromArgb(0, 77, 131) : SystemColors.WindowText; Rectangle textRect = new Rectangle(new Point(HEADER_X_INSET + _headerImage.Width + TEXT_X_INSET, textY), textSize); g.DrawText(_label, Font, textRect, textColor); }
public void Paint(BidiGraphics g, Rectangle bounds) { using (g.Container(bounds.X, bounds.Y)) { g.Graphics.CompositingMode = CompositingMode.SourceOver; g.Graphics.CompositingQuality = CompositingQuality.HighQuality; using (Font boldFont = new Font(_font, FontStyle.Bold)) { Rectangle providerNameRect = new Rectangle(_providerNameLeft, 4, _providerNameWidth, _providerNameHeight); if (_image != null) g.DrawImage(false, _image, (int)(providerNameRect.Left - _image.Width - IMAGE_PADDING_RIGHT), (int)(providerNameRect.Top - 1)); g.DrawText(_providerName, boldFont, providerNameRect, Color.White, _textFormatFlags); } g.DrawText(_blogName, _font, new Rectangle(PADDING_LEFT, 23, _blogNameWidth, _providerNameHeight), Color.White, _textFormatFlags); } // This is down here because DrawIcon has a bug (at least with .NET 1.1) where it // doesn't respect any translation transforms that have been applied to the Graphics // object in GDI+. if (_image == null && _icon != null) g.DrawIcon(false, _icon, new Rectangle(bounds.Left + _imageLeft, bounds.Top + 3, IconWidth, IconHeight)); }
protected override void OnDrawItem(DrawItemEventArgs e) { if (e.Index != -1) { ParentCategoryComboItem comboItem = Items[e.Index] as ParentCategoryComboItem; e.DrawBackground(); // don't indent for main display of category string text = comboItem != null ? comboItem.ToString() : ""; if (e.Bounds.Width < Width) text = text.Trim(); Color textColor = ((e.State & DrawItemState.Selected) == DrawItemState.Selected) ? SystemColors.HighlightText : comboItem.TextColor; BidiGraphics bg = new BidiGraphics(e.Graphics, e.Bounds); bg.DrawText(text, e.Font, e.Bounds, textColor, TextFormatFlags.NoPrefix); e.DrawFocusRectangle(); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); BidiGraphics g = new BidiGraphics(e.Graphics, ClientSize, false); ColorizedResources colRes = ColorizedResources.Instance; // draw the outer border using (Pen p = new Pen(colRes.BorderDarkColor, 1)) g.DrawRectangle(p, new Rectangle(0, 0, ClientSize.Width - 1, ClientSize.Height - 1)); // draw the caption using (Font f = Res.GetFont(FontSize.Large, FontStyle.Bold)) g.DrawText(Text, f, new Rectangle(19, 8, ClientSize.Width - 1, ClientSize.Height - 1), SystemColors.WindowText, TextFormatFlags.NoPrefix); GdiTextHelper.DrawString(this, labelPublishingTo.Font, _progressMessage, labelPublishingTo.Bounds, false, GdiTextDrawMode.EndEllipsis); }
public void Paint(BidiGraphics g) { if ( !_havePostsToDisplay ) { string noPosts = String.Format(CultureInfo.CurrentCulture, Res.Get(StringId.NoThings), _title ) ; Size size = g.MeasureText(noPosts, _font); g.DrawText(noPosts, _font, new Rectangle(Bounds.Location.X + POSTLIST_INDENT, Bounds.Location.Y + LINK_TEXT_PADDING, size.Width, size.Height), ColorizedResources.Instance.SidebarDisabledTextColor); } }
public void Paint(BidiGraphics g) { ColorizedResources colRes = ColorizedResources.Instance; g.DrawText(Caption, _captionFont, CaptionBounds, colRes.SidebarHeaderTextColor); }
/// <summary> /// Draws a menu item. /// </summary> /// <param name="drawItemState">A DrawItemEventArgs that contains the event data.</param> /// <param name="rect">A DrawItemEventArgs that contains the client rectangle.</param> private void DrawMenuItem(DrawItemState drawItemState, Rectangle rect) { // Create graphics context on the offscreen bitmap and set the bounds for painting. Graphics graphics = Graphics.FromImage(offscreenBitmap); graphics.CompositingMode = CompositingMode.SourceOver; graphics.CompositingQuality = CompositingQuality.HighQuality; BidiGraphics g = new BidiGraphics(graphics, new Rectangle(Point.Empty, offscreenBitmap.Size)); try { Rectangle bounds = new Rectangle(0, 0, offscreenBitmap.Width, offscreenBitmap.Height); // Fill the menu item with the system-defined menu color. g.FillRectangle(SystemBrushes.Menu, bounds); // Fill the bitmap area with the system-defind control color. Rectangle bitmapAreaRectangle = new Rectangle(bounds.X, bounds.Y, STANDARD_BITMAP_AREA_WIDTH, bounds.Height); // Fill the background. /* using (SolidBrush solidBrush = new SolidBrush(ApplicationManager.ApplicationStyle.MenuBitmapAreaColor)) graphics.FillRectangle(solidBrush, bitmapAreaRectangle); */ Color backgroundColor = SystemColors.Menu; // If the item is selected, draw the selection rectangle. if ((drawItemState & DrawItemState.Selected) != 0) { DrawHotlight(g, SystemColors.Highlight, bounds, true); backgroundColor = offscreenBitmap.GetPixel(2, 2); } // Obtain the bitmap to draw. If there is one, draw it centered in the bitmap area. Bitmap bitmap = MenuBitmap(drawItemState); if (bitmap != null) g.DrawImage(false, bitmap, new Point( bounds.X + Utility.CenterMinZero(bitmap.Width, bitmapAreaRectangle.Width), bounds.Y + Utility.CenterMinZero(bitmap.Height, bitmapAreaRectangle.Height))); // Obtain the menu text. If it's not "-", then this is a menu item. Otherwise, it's // a separator menu item. if (MenuText() != "-") { // Calculate the text area rectangle. This area excludes an area at the right // edge of the menu item where the system draws the cascade indicator. It would // have been better if MenuItem let us draw the indicator (we did say "OwnerDraw" // afterall), but this is just how it works. Rectangle textAreaRectangle = new Rectangle(bounds.X + STANDARD_BITMAP_AREA_WIDTH + STANDARD_TEXT_PADDING, bounds.Y, bounds.Width - (STANDARD_BITMAP_AREA_WIDTH + STANDARD_TEXT_PADDING + STANDARD_RIGHT_EDGE_PAD), bounds.Height); // Select the brush to draw the menu text with. Color color; if ((drawItemState & DrawItemState.Disabled) == 0) color = SystemColors.MenuText; else color = SystemColors.GrayText; // Determine the size of the shortcut, if it is being shown. if (!(MenuType == MenuType.Context)) { string shortcut; Size shortcutSize; if (ShowShortcut && Shortcut != Shortcut.None) { shortcut = FormatShortcutString(Shortcut); shortcutSize = MeasureShortcutMenuItemText(graphics, shortcut); } else { shortcut = null; shortcutSize = MeasureShortcutMenuItemText(graphics, FormatShortcutString(Shortcut.CtrlIns)); } // Draw the shortcut. if (shortcut != null) { Rectangle shortcutTextRect = textAreaRectangle; TextFormatFlags textFormatTemp = shortcutStringFormat; //DisplayHelper.FixupGdiPlusLineCentering(graphics, menuFont, shortcut, ref stringFormatTemp, ref shortcutTextRect); // Draw the shortcut text. g.DrawText(shortcut, menuFont, shortcutTextRect, color, backgroundColor, textFormatTemp); } // Reduce the width of the text area rectangle to account for the shortcut and // the padding before it. textAreaRectangle.Width -= shortcutSize.Width + STANDARD_TEXT_PADDING; } // Determine which StringFormat to use when drawing the menu item text. TextFormatFlags textFormat; if ((drawItemState & DrawItemState.NoAccelerator) != 0) textFormat = menuItemTextNoHotKeyStringFormat; else textFormat = menuItemTextHotKeyStringFormat; //DisplayHelper.FixupGdiPlusLineCentering(graphics, menuFont, MenuText(), ref stringFormat, ref textAreaRectangle); // Draw the text. g.DrawText(MenuText(), menuFont, textAreaRectangle, color, backgroundColor, textFormat); } else { // Calculate the separator line rectangle. This area excludes an area at the right // edge of the menu item where the system draws the cascade indicator. It would // have been better if MenuItem let us draw the indicator (we did say "OwnerDraw" // after all), but this is just how it works. Rectangle separatorLineRectangle = new Rectangle(bounds.X + STANDARD_SEPARATOR_PADDING, bounds.Y + Utility.CenterMinZero(1, bounds.Height), bounds.Width - STANDARD_SEPARATOR_PADDING, 1); // Fill the separator line rectangle. g.FillRectangle(SystemBrushes.ControlDark, separatorLineRectangle); } } finally { // We're finished with the double buffered painting. Dispose of the graphics context // and draw the offscreen image. Cache the offscreen bitmap, though. graphics.Dispose(); } }
protected override void OnDrawItem(DrawItemEventArgs e) { // screen invalid drawing states if (DesignMode || e.Index == -1) return; // get post-source we are rendering IPostEditorPostSource postSource = (Items[e.Index] as PostSourceItem).PostSource; // determine image and text to use Image postSourceImage; if (e.Index == _draftsIndex) postSourceImage = _showLargeIcons ? _draftsImageLarge : _draftsImage; else if (e.Index == _recentPostsIndex) postSourceImage = _showLargeIcons ? _recentPostsImageLarge : _recentPostsImage; else postSourceImage = _showLargeIcons ? _weblogImageLarge : _weblogImage; // determine state bool selected = (e.State & DrawItemState.Selected) > 0; // calculate colors Color backColor, textColor; if (selected) { if (Focused) { backColor = _theme.backColorSelectedFocused; textColor = _theme.textColorSelectedFocused; } else { backColor = _theme.backColorSelected; textColor = _theme.textColorSelected; } } else { backColor = _theme.backColor; textColor = _theme.textColor; } BidiGraphics g = new BidiGraphics(e.Graphics, e.Bounds); // draw background using (SolidBrush solidBrush = new SolidBrush(backColor)) g.FillRectangle(solidBrush, e.Bounds); if (_showLargeIcons) { // center the image within the list box int imageLeft = e.Bounds.Left + ((e.Bounds.Width / 2) - (ScaleX(postSourceImage.Width) / 2)); int imageTop = e.Bounds.Top + ScaleY(LARGE_TOP_INSET); g.DrawImage(false, postSourceImage, new Rectangle(imageLeft, imageTop, ScaleX(postSourceImage.Width), ScaleY(postSourceImage.Height))); // setup string format TextFormatFlags stringFormat = TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl | TextFormatFlags.ExpandTabs | TextFormatFlags.WordEllipsis | TextFormatFlags.HorizontalCenter; // calculate standard text drawing metrics int leftMargin = ScaleX(ELEMENT_PADDING); int topMargin = imageTop + ScaleY(postSourceImage.Height) + ScaleY(ELEMENT_PADDING); int fontHeight = g.MeasureText(postSource.Name, e.Font).Height; // caption // calculate layout rectangle Rectangle layoutRectangle = new Rectangle( leftMargin, topMargin, e.Bounds.Width - (2 * ScaleX(ELEMENT_PADDING)), fontHeight * TITLE_LINES); // draw caption g.DrawText(postSource.Name, e.Font, layoutRectangle, textColor, stringFormat); } else { // draw post icon g.DrawImage(false, postSourceImage, new Rectangle(e.Bounds.Left + ScaleX(ELEMENT_PADDING), e.Bounds.Top + ScaleY(SMALL_TOP_INSET), ScaleX(postSourceImage.Width), ScaleY(postSourceImage.Height))); // setup string format TextFormatFlags stringFormat = TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl | TextFormatFlags.ExpandTabs | TextFormatFlags.WordEllipsis; // calculate standard text drawing metrics int leftMargin = ScaleX(ELEMENT_PADDING) + ScaleX(postSourceImage.Width) + ScaleX(ELEMENT_PADDING); int topMargin = e.Bounds.Top + ScaleY(SMALL_TOP_INSET); int fontHeight = g.MeasureText(postSource.Name, e.Font).Height; // caption // calculate layout rectangle Rectangle layoutRectangle = new Rectangle( leftMargin, topMargin, e.Bounds.Width - leftMargin - ScaleX(ELEMENT_PADDING), fontHeight * TITLE_LINES); // draw caption g.DrawText(postSource.Name, e.Font, layoutRectangle, textColor, stringFormat); } // draw focus rectange if necessary e.DrawFocusRectangle(); }
protected override void OnDrawItem(DrawItemEventArgs e) { // screen invalid drawing states if (DesignMode || e.Index == -1) return; // get post we are rendering PostInfo postInfo = (Items[e.Index] as PostInfoItem).PostInfo; // determine state bool selected = (e.State & DrawItemState.Selected) > 0; // calculate colors Color backColor, textColor; if (selected) { if (Focused) { backColor = _theme.backColorSelectedFocused; textColor = _theme.textColorSelectedFocused; } else { backColor = _theme.backColorSelected; textColor = _theme.textColorSelected; } } else { backColor = _theme.backColor; textColor = _theme.textColor; } BidiGraphics g = new BidiGraphics(e.Graphics, e.Bounds); // setup standard string format TextFormatFlags ellipsesStringFormat = TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl | TextFormatFlags.ExpandTabs | TextFormatFlags.WordEllipsis | TextFormatFlags.NoPrefix; // draw background using (SolidBrush solidBrush = new SolidBrush(backColor)) g.FillRectangle(solidBrush, e.Bounds); // draw top-line if necessary //if ( !selected ) { using (Pen pen = new Pen(_theme.topLineColor)) g.DrawLine(pen, e.Bounds.Left, e.Bounds.Bottom - 1, e.Bounds.Right, e.Bounds.Bottom - ScaleY(1)); } // draw post icon g.DrawImage(false, _blogPostImage, new Rectangle( e.Bounds.Left + ScaleX(HORIZONTAL_INSET), e.Bounds.Top + ScaleY(TITLE_INSET), ScaleX(_blogPostImage.Width), ScaleY(_blogPostImage.Height))); // calculate standard text drawing metrics int leftMargin = ScaleX(HORIZONTAL_INSET) + ScaleX(_blogPostImage.Width) + ScaleX(HORIZONTAL_INSET); int topMargin = e.Bounds.Top + ScaleY(TITLE_INSET); // draw title line // post date string dateText = postInfo.PrettyDateDisplay; Size dateSize = g.MeasureText(dateText, e.Font); Rectangle dateRectangle = new Rectangle( e.Bounds.Right - ScaleX(HORIZONTAL_INSET) - dateSize.Width, topMargin, dateSize.Width, dateSize.Height); g.DrawText(dateText, e.Font, dateRectangle, textColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.NoPrefix); // post title int titleWidth = dateRectangle.Left - leftMargin - ScaleX(DATE_PADDING); string titleString = String.Format(CultureInfo.CurrentCulture, "{0}", postInfo.Title); int fontHeight = g.MeasureText(titleString, e.Font).Height; Rectangle titleRectangle = new Rectangle(leftMargin, topMargin, titleWidth, fontHeight); g.DrawText( titleString, e.Font, titleRectangle, textColor, ellipsesStringFormat); // draw post preview // calculate layout rectangle Rectangle layoutRectangle = new Rectangle( leftMargin, topMargin + fontHeight + ScaleY(PREVIEW_INSET), e.Bounds.Width - leftMargin - ScaleX(HORIZONTAL_INSET), fontHeight * PREVIEW_LINES); // draw post preview string postPreview = postInfo.PlainTextContents; if (PostSource.HasMultipleWeblogs && (postInfo.BlogName != String.Empty)) postPreview = String.Format(CultureInfo.CurrentCulture, "{0} - {1}", postInfo.BlogName, postPreview); g.DrawText( postPreview, e.Font, layoutRectangle, textColor, ellipsesStringFormat); // focus rectange if necessary e.DrawFocusRectangle(); }
protected override void OnPaint(PaintEventArgs args) { base.OnPaint(args); BidiGraphics g = new BidiGraphics(args.Graphics, ClientRectangle); g.DrawText(Text, Font, ClientRectangle, SystemColors.ControlText, TextFormatFlags); }
/// <summary> /// Draw the image and the text overlay /// </summary> public override void Draw(BidiGraphics g, Font font, Rectangle thumbnailRect) { // draw the image base.Draw(g, font, thumbnailRect); // calculate the rectangle for the text then draw it Rectangle textRect = new Rectangle(thumbnailRect.X + (int)(thumbnailRect.Width * 0.1F), thumbnailRect.Y, (int)(thumbnailRect.Width * 0.8F), thumbnailRect.Height); g.DrawText(_textOverlay, font, textRect, Color.Gray, TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter | TextFormatFlags.WordBreak); }
private void DrawTabContents(BidiGraphics g, Color textColor) { Rectangle logicalClientRect = ClientRectangle; if (!Selected) logicalClientRect.Height -= 2; // Make up for the top "border" being just off the top of the control logicalClientRect.Y -= 1; logicalClientRect.Height += 1; if (clipLeftBorder) { logicalClientRect.X -= 1; logicalClientRect.Width += 1; } if (clipRightBorder) logicalClientRect.Width += 1; g.DrawText(Text, Font, logicalClientRect, textColor, Color.Transparent, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); // if (Focused) // { // Rectangle rect = logicalClientRect; // rect.Inflate(-2, -2); // g.DrawFocusRectangle(rect); // } }
protected override void OnPaint(PaintEventArgs e) { BidiGraphics g = new BidiGraphics(e.Graphics, ClientRectangle); if (m_pressed) { SystemButtonHelper.DrawSystemButtonFacePushed(g, false, ClientRectangle, false); } else if (m_hover) { SystemButtonHelper.DrawSystemButtonFace(g, false, false, ClientRectangle, false); } Rectangle colorRect = new Rectangle(PADDING, PADDING, COLOR_SIZE, COLOR_SIZE); Rectangle dropDownArrowRect = new Rectangle(Width - PADDING - m_dropDownArrow.Width, PADDING, m_dropDownArrow.Width, colorRect.Height); Rectangle textRect = new Rectangle(PADDING + GUTTER_SIZE + colorRect.Width, PADDING, Width - (PADDING + GUTTER_SIZE + colorRect.Width) - (PADDING + GUTTER_SIZE + dropDownArrowRect.Width), colorRect.Height); using (Brush b = new SolidBrush(EffectiveColor)) g.FillRectangle(b, colorRect); using (Pen p = new Pen(SystemColors.Highlight, 1)) g.DrawRectangle(p, colorRect); g.DrawText(Text, Font, textRect, SystemColors.ControlText, ShowKeyboardCues ? TextFormatFlags.Default : TextFormatFlags.NoPrefix); g.DrawImage(false, m_dropDownArrow, RectangleHelper.Center(m_dropDownArrow.Size, dropDownArrowRect, false), 0, 0, m_dropDownArrow.Width, m_dropDownArrow.Height, GraphicsUnit.Pixel); }
/// <summary> /// Raises the Paint event. /// </summary> /// <param name="e">A PaintEventArgs that contains the event data.</param> protected override void OnPaint(PaintEventArgs args) { // Call the base class's method so that registered delegates receive the event. base.OnPaint(args); // Fix bug 602576: The 'Remove Effects' button is truncated in right-to-left builds if (BidiHelper.IsRightToLeft) args.Graphics.ResetClip(); // Take int account vertical padding Rectangle rect = new Rectangle(VirtualClientRectangle.X, VirtualClientRectangle.Y + VerticalPadding, VirtualClientRectangle.Width, VirtualClientRectangle.Height); BidiGraphics g = new BidiGraphics(args.Graphics, rect); // No painting required if there is no parent or no command. if (Parent == null || Command == null) return; // Determine the draw state of the button. DrawState drawState; if (!Command.Enabled) drawState = DrawState.Disabled; else if (Command.Latched || (ButtonPushed && MouseInside) || (ContextMenuUserInterface && ContextMenuShowing)) drawState = DrawState.Pushed; else if (MouseInside || (DropDownContextMenuUserInterface && ContextMenuShowing)) drawState = DrawState.Selected; else drawState = DrawState.Enabled; // Draw the button. if (Command.CommandBarButtonStyle == CommandBarButtonStyle.System) { Size imageSize = ImageSize; // is this a large button? bool isLargeButton = false; if (imageSize.Height > SystemButtonHelper.SMALL_BUTTON_IMAGE_SIZE) isLargeButton = true; if (Command is ICustomButtonBitmapPaint) { switch (drawState) { case DrawState.Selected: SystemButtonHelper.DrawSystemButtonFace(g, DropDownContextMenuUserInterface, contextMenuShowing, VirtualClientRectangle, isLargeButton); break; case DrawState.Pushed: SystemButtonHelper.DrawSystemButtonFacePushed(g, DropDownContextMenuUserInterface, VirtualClientRectangle, isLargeButton); break; } ((ICustomButtonBitmapPaint)Command).Paint(g, rImage, drawState); } else { Bitmap buttonBitmap = null; switch (drawState) { case DrawState.Disabled: buttonBitmap = Command.CommandBarButtonBitmapDisabled; break; case DrawState.Enabled: buttonBitmap = Command.CommandBarButtonBitmapEnabled; break; case DrawState.Selected: SystemButtonHelper.DrawSystemButtonFace(g, DropDownContextMenuUserInterface, contextMenuShowing, VirtualClientRectangle, isLargeButton); buttonBitmap = Command.CommandBarButtonBitmapSelected; break; case DrawState.Pushed: SystemButtonHelper.DrawSystemButtonFacePushed(g, DropDownContextMenuUserInterface, VirtualClientRectangle, isLargeButton); buttonBitmap = Command.CommandBarButtonBitmapSelected; break; } // Draw the button bitmap. if (buttonBitmap != null && !Command.SuppressCommandBarBitmap) { if (!SystemInformation.HighContrast) g.DrawImage(false, buttonBitmap, rImage); else { //apply a high contrast image matrix ImageAttributes ia = new ImageAttributes(); ia.SetColorMatrix(HighContrastColorMatrix); ColorMap cm = new ColorMap(); cm.OldColor = Color.White; cm.NewColor = SystemColors.Control; ia.SetRemapTable(new ColorMap[] { cm }); g.DrawImage(false, buttonBitmap, rImage, 0, 0, buttonBitmap.Width, buttonBitmap.Height, GraphicsUnit.Pixel, ia); } } } // Draw the text. if (Command.CommandBarButtonText != null && Command.CommandBarButtonText.Length != 0) { Color textColor; if (drawState == DrawState.Disabled) textColor = commandBarLightweightControl.DisabledTextColor; else textColor = commandBarLightweightControl.TextColor; g.DrawText( Command.CommandBarButtonText, ApplicationManager.ApplicationStyle.NormalApplicationFont, rText, textColor, TextFormatFlags.PreserveGraphicsTranslateTransform | TextFormatFlags.NoPadding | TextFormatFlags.NoClipping); } // Draw the context menu arrow, if needed. if (DropDownContextMenuUserInterface || ContextMenuUserInterface) { Bitmap contextMenuArrowBitmapToDraw; if (drawState == DrawState.Disabled) contextMenuArrowBitmapToDraw = contextMenuArrowBitmapDisabled; else contextMenuArrowBitmapToDraw = contextMenuArrowBitmap; int height = isLargeButton ? SystemButtonHelper.LARGE_BUTTON_TOTAL_SIZE : VirtualHeight; g.DrawImage(false, contextMenuArrowBitmapToDraw, rArrow); } } else if (Command.CommandBarButtonStyle == CommandBarButtonStyle.Bitmap) { switch (drawState) { case DrawState.Disabled: g.DrawImage(true, Command.CommandBarButtonBitmapDisabled, HorizontalMargin, TOP_MARGIN); break; case DrawState.Enabled: g.DrawImage(true, Command.CommandBarButtonBitmapEnabled, HorizontalMargin, TOP_MARGIN); break; case DrawState.Selected: g.DrawImage(true, Command.CommandBarButtonBitmapSelected, HorizontalMargin, TOP_MARGIN); break; case DrawState.Pushed: g.DrawImage(true, Command.CommandBarButtonBitmapPushed, HorizontalMargin, TOP_MARGIN); break; } } else if (Command.CommandBarButtonStyle == CommandBarButtonStyle.Provider) { DrawProviderButtonFace(g, drawState); DrawProviderButton(g, drawState); } if (Focused) g.DrawFocusRectangle(new Rectangle(0, 0, VirtualWidth, VirtualHeight), Parent.ForeColor, Parent.BackColor); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); BidiGraphics g = new BidiGraphics(e.Graphics, summaryTextRect); //paint the background over the last text paint using (Brush backBrush = new SolidBrush(BackColor)) { g.FillRectangle(backBrush, summaryTextRect); } Color textColor = Color.DarkGray; Size sizeTextSize; if (linkToSizeText != null) sizeTextSize = g.MeasureText(linkToSizeText, Font, summaryTextRect.Size, imageFileSizeFormat); else sizeTextSize = Size.Empty; Size summaryTextSize = g.MeasureText(linkToSummaryText, Font, new Size(summaryTextRect.Size.Width - sizeTextSize.Width - ScaleX(summarySizeSpacing), sizeTextSize.Height), imageFileSummaryFormat); Rectangle summaryTextLayoutRect = new Rectangle(new Point(summaryTextRect.X, summaryTextRect.Y), summaryTextSize); Rectangle sizeTextLayoutRect = new Rectangle(new Point(summaryTextLayoutRect.Right + summarySizeSpacing, summaryTextRect.Y), sizeTextSize); Rectangle imageViewerTextLayoutRect = new Rectangle(summaryTextRect.X, sizeTextLayoutRect.Bottom + ScaleY(3), ClientRectangle.Width, (int)Math.Ceiling(Font.GetHeight(e.Graphics))); g.DrawText(linkToSummaryText, this.Font, summaryTextLayoutRect, textColor, imageFileSummaryFormat); g.DrawText(linkToSizeText, this.Font, sizeTextLayoutRect, textColor, imageFileSummaryFormat); if (linkToImageViewer != "") g.DrawText(linkToImageViewer, this.Font, imageViewerTextLayoutRect, textColor, imageFileSummaryFormat); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); e.Graphics.ResetClip(); BidiGraphics g = new BidiGraphics(e.Graphics, Bounds, false); using (Brush brush = new SolidBrush(SystemColors.ActiveCaption)) { g.FillRectangle(brush, new Rectangle(0, 0, Width - 1, SystemInformation.ToolWindowCaptionHeight)); } using (Pen borderPen = new Pen(Color.FromArgb(127, 157, 185))) { g.DrawRectangle(borderPen, new Rectangle(0, 0, Width - 1, Height - 1)); g.DrawLine(borderPen, 0, SystemInformation.ToolWindowCaptionHeight, Width - 1, SystemInformation.ToolWindowCaptionHeight); } using (Font boldFont = new Font(Font, FontStyle.Bold)) g.DrawText(Text, boldFont, new Rectangle(4, 2, Width - 2, SystemInformation.ToolWindowCaptionHeight - 1), SystemColors.ActiveCaptionText); }
/// <summary> /// Raises the Paint event. /// </summary> /// <param name="e">A PaintEventArgs that contains the event data.</param> protected override void OnPaint(PaintEventArgs e) { // Call the base class's method so that registered delegates receive the event. base.OnPaint(e); BidiGraphics g = new BidiGraphics(e.Graphics, ClientRectangle); // Determine the draw state of the button. DrawState drawState; if (!Enabled) drawState = DrawState.Disabled; else if (Latched) drawState = DrawState.Latched; else if (Pushed && MouseInside) drawState = DrawState.Pushed; else if (MouseInside) drawState = DrawState.Selected; else drawState = DrawState.Enabled; // Draw the button face, as needed, and select the button bitmap to draw below. Bitmap buttonBitmap = null; switch (drawState) { case DrawState.Disabled: buttonBitmap = BitmapDisabled; break; case DrawState.Enabled: if (Focused) { if (ButtonStyle == ButtonStyle.Standard) DrawStandardButtonFace(e.Graphics); else if (ButtonStyle == ButtonStyle.Flat) DrawFlatButtonFace(e.Graphics); } buttonBitmap = BitmapEnabled; break; case DrawState.Selected: if (ButtonStyle == ButtonStyle.Standard) DrawStandardButtonFace(e.Graphics); else if (ButtonStyle == ButtonStyle.Flat) DrawFlatButtonFace(e.Graphics); buttonBitmap = BitmapSelected; break; case DrawState.Latched: case DrawState.Pushed: if (ButtonStyle == ButtonStyle.Standard) { DrawStandardButtonFacePushed(e.Graphics); buttonBitmap = BitmapSelected; } else if (ButtonStyle == ButtonStyle.Flat) { DrawFlatButtonFacePushed(e.Graphics); buttonBitmap = BitmapSelected; } else if (ButtonStyle == ButtonStyle.Bitmap) buttonBitmap = BitmapPushed; break; } // Draw the button bitmap, if there is one. if (buttonBitmap != null) { // Set the rectangle into which we'll draw the bitmap. Rectangle drawBitmapRectangle = bitmapRectangle; // if (ButtonStyle != ButtonStyle.Bitmap && drawState == DrawState.Pushed) // drawBitmapRectangle.Offset(ScaleX(PUSHED_OFFSET), ScaleY(PUSHED_OFFSET)); // Draw the bitmap. g.DrawImage(AllowMirroring, buttonBitmap, new Rectangle(ScaleX(drawBitmapRectangle.X), ScaleY(drawBitmapRectangle.Y), ScaleX(buttonBitmap.Width), ScaleY(buttonBitmap.Height))); } // If focus is being shown, and we're focused, draw the focus rectangle. if (ShowFocusCues && Focused) { Rectangle rectangle = ClientRectangle; if (ButtonStyle == ButtonStyle.Flat) { //offset the focus a bit to ensure it draws directly over the flat border rectangle = new Rectangle(rectangle.Location, new Size(ScaleX(rectangle.Width - 1), ScaleY(rectangle.Height - 1))); //clear the background of the rectangle so it contrasts well with the flat selection using (Pen p = new Pen(BackColor)) g.DrawRectangle(p, rectangle); } ControlPaint.DrawFocusRectangle(e.Graphics, rectangle); } // Draw the button text, if there is some. if (ButtonStyle != ButtonStyle.Bitmap && buttonText != null) { // Set the rectangle into which we'll draw the text. Rectangle drawTextRectangle = textRectangle; drawTextRectangle.Offset(HORIZONTAL_TEXT_PAD, VERTICAL_TEXT_PAD); if (drawState == DrawState.Pushed) drawTextRectangle.Offset(ScaleX(PUSHED_OFFSET), ScaleY(PUSHED_OFFSET)); TextFormatFlags textFormat; if (ShowKeyboardCues) textFormat = TextFormatFlags.VerticalCenter | TextFormatFlags.NoPadding | TextFormatFlags.WordBreak | TextFormatFlags.ExpandTabs | TextFormatFlags.EndEllipsis; else textFormat = TextFormatFlags.VerticalCenter | TextFormatFlags.NoPadding | TextFormatFlags.WordBreak | TextFormatFlags.ExpandTabs | TextFormatFlags.EndEllipsis | TextFormatFlags.HidePrefix; // Set the text color. Color textColor = ForeColor; if (!Enabled) textColor = Color.FromArgb(GraphicsHelper.Opacity(50), textColor); // Draw the text. g.DrawText(buttonText, Font, drawTextRectangle, textColor, textFormat); } }
protected override void OnPaint(PaintEventArgs e) { BidiGraphics g = new BidiGraphics(e.Graphics, _controlRectangle); Color backgroundColor = ColorizedResources.Instance.SidebarGradientBottomColor; using (Brush brush = new SolidBrush(backgroundColor)) g.FillRectangle(brush, _controlRectangle); if (!(_image == null && (Text == null || Text == string.Empty))) { // draw the border using (Pen pen = new Pen(ColorizedResources.Instance.BorderLightColor)) { g.DrawLine(pen, _controlRectangle.Left, _controlRectangle.Top, _controlRectangle.Width, _controlRectangle.Top); g.DrawLine(pen, _controlRectangle.Left, _controlRectangle.Bottom, _controlRectangle.Width, _controlRectangle.Bottom); } // draw the image if (_image != null) g.DrawImage(true, _image, new Rectangle(_imageRectangle.Left, _imageRectangle.Top, _image.Width, _image.Height)); // draw the text g.DrawText(Text, ApplicationManager.ApplicationStyle.NormalApplicationFont, new Rectangle(_textRectangle.X, _textRectangle.Y, _textRectangle.Width, _textRectangle.Height), ApplicationManager.ApplicationStyle.PrimaryWorkspaceCommandBarTextColor, _stringFormat); } }
private Size Render(BidiGraphics g, int width, int height) { int maxWidth = 0; // Start at the top left after padding Point origin = new Point(HORIZONTAL_PADDING, VERTICAL_PADDING); // Draw the green arrow Image arrow; if (IsHovered) arrow = ResourceHelper.LoadAssemblyResourceBitmap("Images.arrow_hover.png"); else arrow = ResourceHelper.LoadAssemblyResourceBitmap("Images.arrow.png"); if (g != null) g.DrawImage(true, arrow, origin.X, origin.Y + 3); origin.Offset(arrow.Width + HORIZONTAL_PADDING, 0); TextFormatFlags textFormatFlags = TextFormatFlags.NoPadding | TextFormatFlags.WordBreak; // Draw the Heading Size headingMaxSize = new Size(width - origin.X - HORIZONTAL_PADDING - 1, height - origin.Y - VERTICAL_PADDING); if (g == null) { headingSize = TextRenderer.MeasureText(Heading, Res.GetFont(FontSize.XLarge, FontStyle.Regular), headingMaxSize, textFormatFlags); } else { g.DrawText(Heading, Res.GetFont(FontSize.XLarge, FontStyle.Regular), new Rectangle(new Point(origin.X - 1, origin.Y), headingMaxSize), ChoiceDialog.BlueText, textFormatFlags); } origin.Offset(0, headingSize.Height + INSIDE_VERTICAL_PADDING); maxWidth = headingSize.Width; // Draw the subheading if (!string.IsNullOrEmpty(SubHeading)) { if (g == null) { subHeadingSize = TextRenderer.MeasureText(SubHeading, Res.DefaultFont, new Size(width - origin.X - HORIZONTAL_PADDING, height - origin.Y), textFormatFlags | TextFormatFlags.NoPrefix); } else { g.DrawText(SubHeading, Res.DefaultFont, new Rectangle(origin.X, origin.Y, width - origin.X - HORIZONTAL_PADDING, height - origin.Y), ChoiceDialog.BlueText, textFormatFlags | TextFormatFlags.NoPrefix); } maxWidth = Math.Max(subHeadingSize.Width, maxWidth); origin.Offset(0, subHeadingSize.Height + INSIDE_VERTICAL_PADDING); } // Draw the image if (OptionImage != null) { if (g != null) { g.DrawImage(false, OptionImage, origin); } origin.Offset(0, OptionImage.Height); maxWidth = Math.Max(OptionImage.Width, maxWidth); } origin.Offset(maxWidth + HORIZONTAL_PADDING, VERTICAL_PADDING); return new Size(origin); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); BidiGraphics g = new BidiGraphics(e.Graphics, VirtualClientRectangle); Rectangle tabRectangle = VirtualClientRectangle; if (selected) ColorizedResources.Instance.ViewSwitchingTabSelected.DrawBorder(e.Graphics, tabRectangle); else ColorizedResources.Instance.ViewSwitchingTabUnselected.DrawBorder(e.Graphics, tabRectangle); if (ColorizedResources.UseSystemColors) { if (BorderColor.HasValue) { using (Pen pen = new Pen(BorderColor.Value)) { if (!selected) g.DrawLine(pen, tabRectangle.Left, tabRectangle.Top, tabRectangle.Right, tabRectangle.Top); g.DrawLine(pen, tabRectangle.Left, tabRectangle.Top, tabRectangle.Left, tabRectangle.Bottom); g.DrawLine(pen, tabRectangle.Right - 1, tabRectangle.Top, tabRectangle.Right - 1, tabRectangle.Bottom); g.DrawLine(pen, tabRectangle.Left, tabRectangle.Bottom - 1, tabRectangle.Right, tabRectangle.Bottom - 1); } } } /* if (!selected && !SystemInformation.HighContrast) { using (Pen p = new Pen(borderColor, 1.0f)) g.DrawLine(p, 0, 0, VirtualWidth, 0); using (Pen p = new Pen(Color.FromArgb(192, borderColor), 1.0f)) g.DrawLine(p, 0, 1, VirtualWidth - 1, 1); using (Pen p = new Pen(Color.FromArgb(128, borderColor), 1.0f)) g.DrawLine(p, 0, 2, VirtualWidth - 2, 2); using (Pen p = new Pen(Color.FromArgb(64, borderColor), 1.0f)) g.DrawLine(p, 0, 3, VirtualWidth - 2, 3); } * */ Rectangle textBounds = tabRectangle; if (!selected) textBounds.Y += (int)DisplayHelper.ScaleX(3); else textBounds.Y += (int)DisplayHelper.ScaleX(3); Color textColor = ColorizedResources.Instance.MainMenuTextColor; if (selected) textColor = Parent.ForeColor; g.DrawText(Text, selected ? ctx.Font : ctx.Font, textBounds, SystemInformation.HighContrast ? SystemColors.ControlText : textColor, TextFormatFlags.Top | TextFormatFlags.HorizontalCenter | TextFormatFlags.PreserveGraphicsTranslateTransform | TextFormatFlags.PreserveGraphicsClipping); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); BidiGraphics g = new BidiGraphics(e.Graphics, ClientRectangle); int textX = 0; if (ShowIcon) { g.DrawImage(false, _tipIcon, new Point(0, (Height / 2) - (_tipIcon.Height / 2))); textX = _tipIcon.Width + 2; } if (TipText != null) { TextFormatFlags flags = TextFormatFlags.WordBreak | TextFormatFlags.EndEllipsis; // setup text rect Rectangle textRectangle = new Rectangle(textX, 0, Width - textX - 3, Height); // draw string g.DrawText(TipText, Font, textRectangle, Color.FromArgb(GraphicsHelper.Opacity(TextOpacityPct), ForeColor), flags); } }
protected override void OnDrawItem(DrawItemEventArgs e) { // screen invalid drawing states if (DesignMode || e.Index == -1) return; // get video we are rendering IVideo video = Items[e.Index] as IVideo; // determine state bool selected = ((e.State & DrawItemState.Selected) > 0) && !_preventSelectionPainting; // calculate colors Color textColor; if (selected) { if (Focused) { textColor = SystemColors.HighlightText; } else { textColor = SystemColors.ControlText; } } else { textColor = SystemColors.ControlText; } Color previewColor = Color.FromArgb(200, textColor); BidiGraphics g = new BidiGraphics(e.Graphics, e.Bounds); // setup standard string format TextFormatFlags ellipsesStringFormat = TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl | TextFormatFlags.ExpandTabs | TextFormatFlags.WordEllipsis; // draw background e.DrawBackground(); //using (SolidBrush solidBrush = new SolidBrush(backColor)) // g.FillRectangle(solidBrush, e.Bounds); // draw the thumbnail image Rectangle thumbnailRect = new Rectangle(e.Bounds.Left + ScaleX(HORIZONTAL_INSET), e.Bounds.Top + ScaleY(VERTICAL_INSET), THUMBNAIL_IMAGE_WIDTH, THUMBNAIL_IMAGE_HEIGHT); VideoThumbnail thumbnail = _thumbnailManager.GetThumbnail(video); thumbnail.Draw(g, e.Font, thumbnailRect); // calculate standard text drawing metrics int leftMargin = ScaleX(HORIZONTAL_INSET) + THUMBNAIL_IMAGE_WIDTH + ScaleX(HORIZONTAL_INSET); int topMargin = e.Bounds.Top + ScaleY(VERTICAL_INSET); int fontHeight = g.MeasureText(video.Title, e.Font).Height; // draw title and duration int titleWidth; Rectangle durationRectangle; using (Font hyperlinkFont = new Font(e.Font, FontStyle.Underline)) { titleWidth = e.Bounds.Right - ScaleX(HORIZONTAL_INSET) - leftMargin; Rectangle titleRectangle = new Rectangle(leftMargin, topMargin, titleWidth, fontHeight); string title = video.Title ?? ""; g.DrawText(title, hyperlinkFont, titleRectangle, selected ? textColor : SystemColors.HotTrack, ellipsesStringFormat); } using (Font durationFont = new Font(e.Font, FontStyle.Regular)) // was bold { durationRectangle = new Rectangle(leftMargin, topMargin + fontHeight + 3, titleWidth, fontHeight); string duration = String.Format(CultureInfo.InvariantCulture, "{0:00}:{1:00}", video.LengthSeconds / 60, video.LengthSeconds % 60); g.DrawText( duration, durationFont, durationRectangle, textColor, ellipsesStringFormat); } // draw description // calculate layout rectangle Rectangle layoutRectangle = new Rectangle( leftMargin, durationRectangle.Bottom + ScaleY(VERTICAL_INSET), e.Bounds.Width - leftMargin - ScaleX(HORIZONTAL_INSET), e.Bounds.Bottom - ScaleY(VERTICAL_INSET) - durationRectangle.Bottom - ScaleY(VERTICAL_INSET)); // draw description g.DrawText( video.Description, e.Font, layoutRectangle, previewColor, ellipsesStringFormat); // draw bottom-line if necessary if (!selected) { using (Pen pen = new Pen(SystemColors.ControlLight)) g.DrawLine(pen, e.Bounds.Left, e.Bounds.Bottom - ScaleY(1), e.Bounds.Right, e.Bounds.Bottom - ScaleY(1)); } // focus rectange if necessary e.DrawFocusRectangle(); }
protected override void OnDrawItem(DrawItemEventArgs e) { // screen invalid drawing states if (DesignMode || e.Index == -1) return; Rectangle area = e.Bounds; e.Graphics.ResetClip(); BidiGraphics g = new BidiGraphics(e.Graphics, area); Image borderImage = null; string borderText = ""; object item = Items[e.Index]; if (item != null) borderText = item.ToString(); if (item is IComboImageItem) { IComboImageItem comboItem = (IComboImageItem)item; borderImage = comboItem.Image; } // determine state bool selected = (e.State & DrawItemState.Selected) > 0; // calculate colors Color backColor = SystemColors.Window; Color textColor = SystemColors.ControlText; // setup standard string format TextFormatFlags ellipsesStringFormat = TextFormatFlags.VerticalCenter | TextFormatFlags.WordBreak | TextFormatFlags.ExpandTabs | TextFormatFlags.WordEllipsis; // draw background using (SolidBrush solidBrush = new SolidBrush(backColor)) g.FillRectangle(solidBrush, area); if (selected && Focused && dropDownShowing) { //draw the focus highlight rectangle Rectangle focusRect = new Rectangle(area.X, area.Y, area.Width - 1, area.Height - 1); using (SolidBrush solidBrush = new SolidBrush(Color.FromArgb(50, SystemColors.Highlight))) g.FillRectangle(solidBrush, focusRect); using (Pen focusPen = new Pen(SystemColors.Highlight, 1)) g.DrawRectangle(focusPen, focusRect); } // draw border icon if (borderImage != null) { Rectangle imageRect = new Rectangle(area.Left + HORIZONTAL_INSET, area.Top + TOP_INSET, borderImage.Width, borderImage.Height); g.DrawImage(false, borderImage, imageRect); //g.DrawRectangle(Pens.Blue, e.Bounds); } // calculate standard text drawing metrics int leftMargin = HORIZONTAL_INSET + MAX_IMAGE_WIDTH + HORIZONTAL_INSET; // draw title line // post title int titleWidth = e.Bounds.Width - leftMargin - 1; Rectangle titleRectangle = new Rectangle(area.Left + leftMargin, area.Top, titleWidth, area.Height - 1); //g.DrawRectangle(Pens.Red,titleRectangle); g.DrawText( borderText, e.Font, titleRectangle, textColor, ellipsesStringFormat); // focus rectange if necessary e.DrawFocusRectangle(); }
public void Paint(BidiGraphics g) { // draw icon if ( Image != null ) g.DrawImage(false, Image, Bounds.X, Bounds.Y) ; else if ( Icon != null ) g.DrawIcon(false, Icon, Bounds.X, Bounds.Y); // draw text g.DrawText(Caption, _captionFont, new Rectangle(CaptionBounds.X, CaptionBounds.Y, CaptionBounds.Width, CaptionBounds.Height), SystemColors.ControlText, TextFormatFlags.WordEllipsis ); }
/// <summary> /// Raises the Paint event. /// </summary> /// <param name="e">A PaintEventArgs that contains the event data.</param> protected override void OnPaint(PaintEventArgs e) { BidiGraphics g = new BidiGraphics(e.Graphics, ClientRectangle); // Paint. g.DrawText(Text, Font, ClientRectangle, Color.FromArgb(GraphicsHelper.Opacity(Enabled ? 100.0 : 50.0), ForeColor), stringFormat); Size size = new Size(ClientSize.Width, ClientSize.Height); measuredTextSize = g.MeasureText(Text, Font, size, stringFormat); }
public void Paint(BidiGraphics g) { Rectangle rectangle = CaptionBounds; g.DrawText(Caption, _font, rectangle, SystemColors.ControlText, TextFormatFlags.VerticalCenter); }
// replace standard painting behavior protected override void OnDrawItem(DrawItemEventArgs evt) { BidiGraphics g = new BidiGraphics(evt.Graphics, ClientRectangle); // determine the text color based on whether we have categories bool hasCategories = _categoryContext.SelectedCategories.Length > 0; Color textColor = hasCategories ? SystemColors.ControlText : SystemColors.GrayText; //Color.FromArgb(200, SystemColors.ControlText) ; // margins const int HORIZONTAL_MARGIN = 1; // draw the icon (if we have one) const int ICON_MARGIN = 4; int textMargin = 0; if (_icon != null) { g.DrawImage(true, _icon, new Rectangle(ScaleX(ICON_MARGIN), ScaleY(2), ScaleX(_icon.Width), ScaleY(_icon.Height))); textMargin += ScaleX(ICON_MARGIN + _icon.Width); } // draw the text int leftMargin = textMargin; int rightMargin = ScaleX(HORIZONTAL_MARGIN); Rectangle textRegion = new Rectangle(new Point(leftMargin, -1), new Size(Width - leftMargin - rightMargin, Height)); TextFormatFlags tempFormat = DisplayFormat; Rectangle tempRectangle = textRegion; g.DrawText( _categoryContext.Text, Font, tempRectangle, textColor, tempFormat); // draw focus rectangle (only if necessary) evt.DrawFocusRectangle(); }