internal void PaintImage(ItemPaintArgs p, Image image, eLabelPartAlignment imageAlign) { if (image == null) return; Graphics g = p.Graphics; Rectangle imageRect = GetAlignedRect(this.DisplayRectangle, image.Size, imageAlign); CompositeImage ci = new CompositeImage(image, false); ci.DrawImage(g, imageRect); ci.Dispose(); _ImageRenderBounds = imageRect; }
private Rectangle GetAlignedRect(Rectangle bounds, Size innerSize, eLabelPartAlignment partAlign) { Rectangle innerRect = new Rectangle(bounds.Right - innerSize.Width, bounds.Y, innerSize.Width, innerSize.Height); if (partAlign == eLabelPartAlignment.BottomCenter) innerRect.Location = new Point(bounds.X + (bounds.Width - innerSize.Width) / 2, bounds.Bottom - innerSize.Height); else if (partAlign == eLabelPartAlignment.BottomLeft) innerRect.Location = new Point(bounds.X, bounds.Bottom - innerSize.Height); else if (partAlign == eLabelPartAlignment.BottomRight) innerRect.Location = new Point(bounds.Right - innerSize.Width, bounds.Bottom - innerSize.Height); else if (partAlign == eLabelPartAlignment.MiddleCenter) innerRect.Location = new Point(bounds.X + (bounds.Width - innerSize.Width) / 2, bounds.Y + (bounds.Height - innerSize.Height) / 2); else if (partAlign == eLabelPartAlignment.MiddleLeft) innerRect.Location = new Point(bounds.X, bounds.Y + (bounds.Height - innerSize.Height) / 2); else if (partAlign == eLabelPartAlignment.MiddleRight) innerRect.Location = new Point(bounds.Right - innerSize.Width, bounds.Y + (bounds.Height - innerSize.Height) / 2); else if (partAlign == eLabelPartAlignment.TopCenter) innerRect.Location = new Point(bounds.X + (bounds.Width - innerSize.Width) / 2, bounds.Y); else if (partAlign == eLabelPartAlignment.TopLeft) innerRect.Location = new Point(bounds.X, bounds.Y); return innerRect; }
/// <summary> /// Renders items image. /// </summary> public void PaintImage(eLabelPartAlignment imageAlign) { _Item.PaintImage(_ItemPaintArgs, _Item.Image, imageAlign); }
internal void PaintText(ItemPaintArgs p, Font textFont, Color textColor, eLabelPartAlignment textAlign) { Graphics g = p.Graphics; string text = this.Text; if (_Date != DateTime.MinValue) text = _Date.Day.ToString(); bool isBold = _IsBold; if (textColor.IsEmpty) { if (!_TextColor.IsEmpty) textColor = _TextColor; else if (!this.Enabled) { textColor = p.Colors.ItemDisabledText; } else { textColor = _IsTrailing ? p.Colors.ItemDisabledText : p.Colors.ItemText; SingleMonthCalendar month = this.Parent as SingleMonthCalendar; MonthCalendarColors colors = null; if (month != null) colors = month.GetColors(); if (colors != null) { if (_Date != DateTime.MinValue) { if (_IsSelected && colors.Selection.IsCustomized) { if (!colors.Selection.TextColor.IsEmpty) textColor = colors.Selection.TextColor; if (colors.Selection.IsBold) isBold = colors.Selection.IsBold; } else { if (_IsTrailing) { if (!colors.TrailingDay.TextColor.IsEmpty) textColor = colors.TrailingDay.TextColor; if (colors.TrailingDay.IsBold) isBold = colors.TrailingDay.IsBold; } else if (colors.Day.IsCustomized) { if (!colors.Day.TextColor.IsEmpty) textColor = colors.Day.TextColor; if (colors.Day.IsBold) isBold = colors.Day.IsBold; } if (IsWeekend(_Date)) { if (_IsTrailing) { if (!colors.TrailingWeekend.TextColor.IsEmpty) textColor = colors.TrailingWeekend.TextColor; if (colors.TrailingWeekend.IsBold) isBold = colors.TrailingWeekend.IsBold; } else { if (!colors.Weekend.TextColor.IsEmpty) textColor = colors.Weekend.TextColor; if (colors.Weekend.IsBold) isBold = colors.TrailingWeekend.IsBold; } } } } else if (IsWeekOfYear) { if (colors.WeekOfYear.IsCustomized) { if (!colors.WeekOfYear.TextColor.IsEmpty) textColor = colors.WeekOfYear.TextColor; if (colors.WeekOfYear.IsBold) isBold = colors.WeekOfYear.IsBold; } } else if (IsDayLabel) { if (!colors.DayLabel.TextColor.IsEmpty) textColor = colors.DayLabel.TextColor; if (colors.DayLabel.IsBold) isBold = colors.DayLabel.IsBold; } } } } if (_IsMouseOver && TrackMouse && EffectiveStyle == eDotNetBarStyle.Metro) { textColor = p.Colors.ItemHotText; } bool disposeFont = false; if (textFont == null) { if (isBold) { textFont = new Font(p.Font, FontStyle.Bold); disposeFont = true; } else textFont = p.Font; } if (_Date != DateTime.MinValue) { Size size = TextDrawing.MeasureString(g, "32", textFont); Rectangle r = GetAlignedRect(this.DisplayRectangle, size, textAlign); eTextFormat format = eTextFormat.Right | eTextFormat.VerticalCenter; TextDrawing.DrawString(g, text, textFont, textColor, r, format); } else { eTextFormat format = eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter; if (textAlign == eLabelPartAlignment.BottomCenter) format = eTextFormat.Bottom | eTextFormat.HorizontalCenter; else if (textAlign == eLabelPartAlignment.BottomLeft) format = eTextFormat.Left | eTextFormat.Bottom; else if (textAlign == eLabelPartAlignment.BottomRight) format = eTextFormat.Bottom | eTextFormat.Right; else if (textAlign == eLabelPartAlignment.MiddleLeft) format = eTextFormat.Left | eTextFormat.VerticalCenter; else if (textAlign == eLabelPartAlignment.MiddleRight) format = eTextFormat.Right | eTextFormat.VerticalCenter; else if (textAlign == eLabelPartAlignment.TopCenter) format = eTextFormat.Top | eTextFormat.VerticalCenter; else if (textAlign == eLabelPartAlignment.TopLeft) format = eTextFormat.Top | eTextFormat.Left; else if (textAlign == eLabelPartAlignment.TopRight) format = eTextFormat.Top | eTextFormat.Right; TextDrawing.DrawString(g, text, textFont, textColor, this.Bounds, format); } if (disposeFont) textFont.Dispose(); }
/// <summary> /// Renders the item text. /// </summary> public void PaintText(Color textColor, Font textFont, eLabelPartAlignment textAlign) { _Item.PaintText(_ItemPaintArgs, textFont, textColor, textAlign); }