protected override Rectangle GetTextRectangle(ButtonItem button, ItemPaintArgs pa, eTextFormat stringFormat, CompositeImage image) { Rectangle r = base.GetTextRectangle(button, pa, stringFormat, image); r.Offset(0, 12); //r.Height -= 18; return r; }
private void PaintManyInternal(ItemPaintArgs itemPaintArgs) { CurrentRectangle = new Rectangle(); for (int i = 0; i < items.Length; i++) { GridStringItem item = items[i]; Point locStr = itemPaintArgs.Rectangle.Location; locStr.Y += (itemPaintArgs.Rectangle.Height * i) / items.Length; item.OnPaint( new ItemPaintArgs(itemPaintArgs.Graphics, new Rectangle(locStr, new Size(itemPaintArgs.Rectangle.Width, itemPaintArgs.Rectangle.Height / items.Length)), itemPaintArgs.State)); if (item.DataSize.Width > DataSize.Width) { DataSize.Width = item.DataSize.Width; } DataSize.Height += item.DataSize.Height; if (item.CurrentRectangle.Width > CurrentRectangle.Width) { CurrentRectangle.Width = item.CurrentRectangle.Width; } CurrentRectangle.Height += item.CurrentRectangle.Height; } }
public override void PaintButtonText(ButtonItem button, ItemPaintArgs pa, Color textColor, CompositeImage image) { Rectangle r = button.DisplayRectangle; r.Inflate(-1, -1); r.Width--; Office2007ButtonItemColorTable colorTable = GetColorTable(button, eButtonContainer.RibbonStrip); Color shadowColor = Color.FromArgb(32, Color.Black); if (colorTable.Default != null && colorTable.Default.OuterBorder != null && !colorTable.Default.OuterBorder.IsEmpty) shadowColor = colorTable.Default.OuterBorder.Start; if (pa.GlassEnabled) { ThemeTextFormat textFormat = ThemeTextFormat.Center | ThemeTextFormat.VCenter | ThemeTextFormat.HidePrefix | ThemeTextFormat.SingleLine; Office2007RibbonControlPainter.PaintShadowTextOnGlass(pa.Graphics, button.Text, pa.Font, r, textFormat,textColor, shadowColor , true); } else { eTextFormat format = eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter | eTextFormat.HidePrefix; // Shadow r.Offset(1, 1); TextDrawing.DrawString(pa.Graphics, button.Text, pa.Font, shadowColor, r, format); r.Offset(-1, -1); TextDrawing.DrawString(pa.Graphics, button.Text, pa.Font, textColor, r, format); } }
public override void OnPaint(ItemPaintArgs itemPaintArgs) { Image im = image == null ? imageDelegate() : image; if (im == null) return; Point loc = itemPaintArgs.Rectangle.Location; if (hAlign == HorizontalAlignment.Center) { loc.X += ((itemPaintArgs.Rectangle.Width / 2) - (im.Width / 2)); } else if (hAlign == HorizontalAlignment.Right) { loc.X += (itemPaintArgs.Rectangle.Width - im.Width); } if (vAlign == VerticalAlignment.Middle) { loc.Y += ((itemPaintArgs.Rectangle.Height / 2) - (im.Height / 2)); } if(im.Width <= itemPaintArgs.Rectangle.Width) itemPaintArgs.Graphics.DrawImage(im, loc.X, loc.Y, im.Width, im.Height); else itemPaintArgs.Graphics.DrawImage(im, new Rectangle(itemPaintArgs.Rectangle.Left, loc.Y, itemPaintArgs.Rectangle.Width, im.Height), new Rectangle(0, 0, itemPaintArgs.Rectangle.Width, im.Height), GraphicsUnit.Pixel); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Override the paint to make this item very distict from other menu items. /// </summary> /// <param name="p"></param> /// ------------------------------------------------------------------------------------ public override void Paint(ItemPaintArgs p) { // It turns out the only rectangle we're given to work with is the // p.Graphics.ClipBounds but that is the rectangle of the entire menu, not just // this menu item. To only get the rectangle for this item, use it's size and // assume this item is the first item in the menu. Rectangle rc = new Rectangle(1, 1, Size.Width, Size.Height); p.Graphics.FillRectangle(SystemBrushes.Control, rc); p.Graphics.DrawLine(SystemPens.ControlText, 0, rc.Bottom - 1, rc.Right, rc.Bottom - 1); using (Font fnt = new Font(SystemInformation.MenuFont, SystemInformation.MenuFont.FontFamily.IsStyleAvailable(FontStyle.Bold) ? FontStyle.Bold : FontStyle.Regular)) { using (StringFormat sf = new StringFormat(StringFormat.GenericTypographic)) { sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; p.Graphics.DrawString(Text, fnt, SystemBrushes.ControlText, rc, sf); } } }
public override void OnPaint(ItemPaintArgs itemPaintArgs) { if (!string.IsNullOrEmpty(sortdata.ToString())) { PaintManyInternal(itemPaintArgs); base.DrawGlyphs(itemPaintArgs); } }
/// <summary> /// Draws the item border /// </summary> /// <param name="e">ItemPaintArgs</param> private void DrawBorder(ItemPaintArgs e) { Graphics g = e.Graphics; using (GraphicsPath path = GetItemPath(g, 0)) { g.DrawPath(Pens.Black, path); } }
public override void PaintButtonImage(ButtonItem button, ItemPaintArgs pa, CompositeImage image, Rectangle imagebounds) { if (!string.IsNullOrEmpty(button.Text)) return; Rectangle r = button.DisplayRectangle; r.X = r.X + (r.Width - imagebounds.Width) / 2; r.Y = r.Y + (r.Height - imagebounds.Height) / 2; r.Width = imagebounds.Width; r.Height = imagebounds.Height; base.PaintButtonImage(button, pa, image, r); }
/// <summary> /// Draws the item border /// </summary> /// <param name="e"></param> /// <param name="scheme"></param> private void DrawBorder(ItemPaintArgs e, int scheme) { Graphics g = e.Graphics; using (GraphicsPath path = GetItemPath(g, 0)) { g.FillPath(_MyColors[scheme].BackBrush, path); g.DrawPath(Pens.Black, path); } }
protected override IShapeDescriptor GetButtonShape(ButtonItem button, ItemPaintArgs pa) { IShapeDescriptor shape = MetroButtonItemPainter.GetButtonShape(button); if (pa.ContainerControl is ButtonX) shape = ((ButtonX)pa.ContainerControl).GetButtonShape(); else if (pa.ContainerControl is NavigationBar) shape = ((NavigationBar)pa.ContainerControl).ButtonShape; return shape; }
public override void PaintButtonBackground(ButtonItem button, ItemPaintArgs pa, CompositeImage image) { Office2007ButtonItemColorTable colors = GetColorTable(button, eButtonContainer.RibbonStrip); Office2007ButtonItemStateColorTable stateColors = colors.Default; if (button.IsMouseDown) stateColors = colors.Pressed; else if (button.IsMouseOver) stateColors = colors.MouseOver; Rectangle bounds = button.DisplayRectangle; bounds.Width--; Graphics g = pa.Graphics; using (GraphicsPath borderPath = DisplayHelp.GetRoundedRectanglePath(bounds, 2, 2, 0, 0)) { DisplayHelp.FillPath(g, borderPath, stateColors.Background); if (stateColors.BottomBackgroundHighlight != null && !stateColors.BottomBackgroundHighlight.IsEmpty) { Rectangle ellipse = new Rectangle(bounds.X - 12, bounds.Y + bounds.Height / 2 - 4, bounds.Width + 24, bounds.Height + 4); using (GraphicsPath path = new GraphicsPath()) { path.AddEllipse(ellipse); using (PathGradientBrush brush = new PathGradientBrush(path)) { brush.CenterColor = stateColors.BottomBackgroundHighlight.Start; brush.SurroundColors = new Color[] { stateColors.BottomBackgroundHighlight.End }; brush.CenterPoint = new PointF(ellipse.X + ellipse.Width / 2, bounds.Bottom - 1); g.FillRectangle(brush, bounds); } } } if (stateColors.InnerBorder != null && !stateColors.InnerBorder.IsEmpty) { Rectangle innerBorder = bounds; innerBorder.Y += 1; innerBorder.Width -= 1; innerBorder.X++; DisplayHelp.DrawGradientRectangle(g, innerBorder, stateColors.InnerBorder, 1); //using (GraphicsPath innerBorderPath = DisplayHelp.GetRoundedRectanglePath(innerBorder, 1, 1, 0, 0)) //{ // DisplayHelp.DrawGradientPathBorder(g, innerBorderPath, stateColors.InnerBorder, 1); //} using (Pen pen = new Pen(ColorScheme.GetColor(10, 0xffffff))) { g.DrawLine(pen, innerBorder.X + 1, innerBorder.Y + 1, innerBorder.X + 1, innerBorder.Bottom - 1); g.DrawLine(pen, innerBorder.Right - 2, innerBorder.Y + 1, innerBorder.Right - 2, innerBorder.Bottom - 1); } } DisplayHelp.DrawGradientPathBorder(g, borderPath, stateColors.OuterBorder, 1); } }
public override void PaintButtonBackground(ButtonItem button, ItemPaintArgs pa, CompositeImage image) { Office2007ButtonItemColorTable colors = GetColorTable(button, eButtonContainer.RibbonStrip); Office2007ButtonItemStateColorTable stateColors = colors.Default; if (button.IsMouseDown) stateColors = colors.Pressed; else if (button.IsMouseOver) stateColors = colors.MouseOver; Rectangle bounds = button.DisplayRectangle; bounds.Width--; //bounds.Height--; Graphics g = pa.Graphics; if (pa.ContainerControl.FindForm() is RibbonForm) bounds.Width -= RibbonFormWidthOffset; //using (GraphicsPath borderPath = DisplayHelp.GetRoundedRectanglePath(bounds, 0, 2, 2, 0)) { //DisplayHelp.FillPath(g, borderPath, stateColors.Background); DisplayHelp.FillRectangle(g, bounds, stateColors.Background); if (stateColors.BottomBackgroundHighlight != null && !stateColors.BottomBackgroundHighlight.IsEmpty) { Rectangle ellipse = new Rectangle(bounds.X - 12, bounds.Y + bounds.Height / 2 - 4, bounds.Width + 24, bounds.Height + 4); using (GraphicsPath path = new GraphicsPath()) { path.AddEllipse(ellipse); using (PathGradientBrush brush = new PathGradientBrush(path)) { brush.CenterColor = stateColors.BottomBackgroundHighlight.Start; brush.SurroundColors = new Color[] { stateColors.BottomBackgroundHighlight.End }; brush.CenterPoint = new PointF(ellipse.X + ellipse.Width / 2, bounds.Bottom - 1); g.FillRectangle(brush, bounds); } } } if (stateColors.InnerBorder != null && !stateColors.InnerBorder.IsEmpty) { Rectangle innerBorder = bounds; innerBorder.Inflate(-1, -1); using (GraphicsPath innerBorderPath = new GraphicsPath()) { innerBorderPath.AddRectangle(innerBorder); DisplayHelp.DrawGradientPath(g, innerBorderPath, innerBorder, stateColors.InnerBorder, 1); } } if (stateColors.OuterBorder != null && !stateColors.OuterBorder.IsEmpty) DisplayHelp.DrawRectangle(g, stateColors.OuterBorder.Start, bounds); //DisplayHelp.DrawGradientPathBorder(g, borderPath, stateColors.OuterBorder, 1); } }
public override Rectangle GetImageRectangle(ButtonItem button, ItemPaintArgs pa, CompositeImage image) { Rectangle imageRect = Rectangle.Empty; bool isOnMenu = IsOnMenu(button, pa); // Calculate image position if (image != null) { imageRect.Width = image.Width + 16; imageRect.Height = image.Height + 16; imageRect.X = button.DisplayRectangle.X + (button.DisplayRectangle.Width - imageRect.Width) / 2; imageRect.Y = button.DisplayRectangle.Y + 3; } return imageRect; }
/// <summary> /// /// </summary> /// <param name="p"></param> public override void Paint(ItemPaintArgs p) { base.Paint(p); //如果要显示的话 if (this.ShowUACIcon) { //Text的显示位置 Rectangle rect = this.TextDrawRect; //判断下显示模式 if (this.ImagePosition == eImagePosition.Top) { //判断下按钮类型和文件 if (this.ItemType == ButtonItemType.Plugin || win32.IsElevationRequired(this._FullName)) { //uisng及时释放资源 //大图标的时候,只采用16x16像素 using (Icon icon = new System.Drawing.Icon(Properties.Resources.uac, new Size(16, 16))) { //获取显示的位置 Point location = new Point(rect.Left + DisplayRectangle.Location.X + rect.Width - 40, DisplayRectangle.Bottom - rect.Height - 16); //开始画图标 p.Graphics.DrawIcon(icon, location.X, location.Y); } } } else { //判断下按钮类型和文件 if (this.ItemType == ButtonItemType.Plugin || win32.IsElevationRequired(this._FullName)) { //uisng及时释放资源 //小图标的时候,只采用8x8 using (Icon icon = new System.Drawing.Icon(Properties.Resources.uac, new Size(8, 8))) { //获取显示的位置 Point location = new Point(rect.Left + DisplayRectangle.Location.X - 8, DisplayRectangle.Bottom - 12); //开始画图标 p.Graphics.DrawIcon(icon, location.X, location.Y); } } } } }
/// <summary> /// Initiates the Painting of the item /// </summary> /// <param name="e"></param> public override void Paint(ItemPaintArgs e) { Graphics g = e.Graphics; // Lets have it draw as best it can CompositingQuality comp = g.CompositingQuality; g.CompositingQuality = CompositingQuality.HighQuality; DrawBorder(e); DrawContent(e); // Set our CompostingQuality back g.CompositingQuality = comp; }
public override void PaintButtonImage(ButtonItem button, ItemPaintArgs pa, CompositeImage image, Rectangle imagebounds) { if (imagebounds.Width <= 0 || imagebounds.Height <= 0) return; // Paint image background RibbonOverflowButtonItem overflow = button as RibbonOverflowButtonItem; if (overflow == null || overflow.RibbonBar==null) { base.PaintButtonImage(button, pa, image, imagebounds); return; } ElementStyle backStyle = overflow.RibbonBar.GetPaintBackgroundStyle(); ElementStyle titleStyle = overflow.RibbonBar.TitleStyle; int cornerSize = 3; if (backStyle.BackColorBlend.Count > 0) DisplayHelp.FillRoundedRectangle(pa.Graphics, imagebounds, cornerSize, backStyle.BackColorBlend[0].Color, backStyle.BackColorBlend[backStyle.BackColorBlend.Count-1].Color, overflow.RibbonBar.BackgroundStyle.BackColorGradientAngle); else DisplayHelp.FillRoundedRectangle(pa.Graphics, imagebounds, cornerSize, backStyle.BackColor, backStyle.BackColor2, backStyle.BackColorGradientAngle); if(!button.Expanded) DisplayHelp.FillRectangle(pa.Graphics, new Rectangle(imagebounds.X+1, imagebounds.Bottom - 8, imagebounds.Width-2, 7), titleStyle.BackColor, titleStyle.BackColor2, titleStyle.BackColorGradientAngle); if (!backStyle.BorderColor.IsEmpty) { using (GraphicsPath path = new GraphicsPath()) { path.AddLine(imagebounds.X, imagebounds.Bottom - 8, imagebounds.Right, imagebounds.Bottom - 8); ElementStyleDisplay.AddCornerArc(path, imagebounds, cornerSize, eCornerArc.BottomRight); ElementStyleDisplay.AddCornerArc(path, imagebounds, cornerSize, eCornerArc.BottomLeft); path.CloseAllFigures(); using (SolidBrush brush = new SolidBrush(Color.FromArgb(192, backStyle.BorderColor))) pa.Graphics.FillPath(brush, path); } } DisplayHelp.DrawRoundGradientRectangle(pa.Graphics, imagebounds, backStyle.BorderColor, backStyle.BorderColor2, backStyle.BorderGradientAngle, 1, cornerSize); imagebounds.X += (imagebounds.Width - image.Width) / 2; imagebounds.Y += 4; imagebounds.Width = image.Width; imagebounds.Height = image.Height; image.DrawImage(pa.Graphics, imagebounds); }
/// <summary> /// Draws the content area of the item /// </summary> /// <param name="g"></param> /// <param name="scheme"></param> private void DrawContent(ItemPaintArgs e) { Graphics g = e.Graphics; // Grab a path slightly inset from the border using (GraphicsPath gPath = GetItemPath(g, -1)) { // Set up a new clip region for the item Region rgnSave = g.Clip; using (Region rgn = new Region(rgnSave.GetRegionData())) { rgn.Intersect(gPath); g.Clip = rgn; // Now let all our added SubItems draw themselves for (int i = 0; i < this.SubItems.Count; i++) { if (SubItems[i].Displayed == true) { SubItems[i].Paint(e); } } } // Restore our original clip region g.Clip = rgnSave; // Draw a contrast border around the item g.DrawPath(Pens.White, gPath); } }
/// <summary> /// Initiates the Painting of the item /// </summary> /// <param name="e"></param> public override void Paint(ItemPaintArgs e) { Graphics g = e.Graphics; // Lets have it draw as best it can CompositingQuality comp = g.CompositingQuality; g.CompositingQuality = CompositingQuality.HighQuality; // The color scheme used is based on whether // the CheckBox is checked or not int scheme = _CheckBox.Checked ? 0 : 1; // Draw the border and content area DrawBorder(e, scheme); DrawContent(e, scheme); // Set our CompostingQuality back g.CompositingQuality = comp; }
public override void Paint(ItemPaintArgs p) { MetroRender.Paint(this, p); }
/// <summary> /// Draws the content text /// </summary> /// <param name="e"></param> /// <param name="r"></param> private void DrawContentText(ItemPaintArgs e, Rectangle r) { Graphics g = e.Graphics; if (DisplayTemplateText(e, r) == false) { string s = Appointment.Subject; eTextFormat tf = eTextFormat.NoPadding | eTextFormat.NoPrefix; if (Appointment.IsMultiDayOrAllDayEvent == false) { s += "\n" + Appointment.Description; r.Y += 3; r.Height -= 3; tf |= eTextFormat.WordBreak; } else { tf |= eTextFormat.VerticalCenter; } Font font = Font ?? e.Font; if (r.Width > 4) TextDrawing.DrawString(g, s, font, TextColor, r, tf); Size size = TextDrawing.MeasureString(g, s, font, r.Width, tf); IsTextClipped = (r.Width < size.Width || r.Height < size.Height); } }
/// <summary> /// Draws TimeLine appointments /// </summary> /// <param name="e"></param> private void DrawAppointments(ItemPaintArgs e) { List<CalendarItem> items = CalendarItems; if (items.Count > 0) { // Loop through each CalendarItem in the week int selItem = -1; for (int i = 0; i < items.Count; i++) { // If we can display the item, then initiate the paint if (items[i].Displayed == true) { if (e.ClipRectangle.IsEmpty || e.ClipRectangle.IntersectsWith(items[i].DisplayRectangle)) { if (items[i].IsSelected == true) selItem = i; else items[i].Paint(e); } } } if (selItem >= 0) items[selItem].Paint(e); } }
/// <summary> /// Calculates the range of columns needed to be drawn /// to satisfy the specified paint request /// </summary> /// <param name="e">ItemPaintArgs</param> /// <param name="colStart">[out] Column start index</param> /// <param name="colEnd">[out] Column end index</param> /// <returns>Column range count (end - start)</returns> private int GetColRange(ItemPaintArgs e, out int colStart, out int colEnd) { // Calc our starting index int start = -_HScrollPos / ColumnWidth; int x = ClientRect.X + start * ColumnWidth + _HScrollPos; while (start < TimeLineColumnCount) { if (x + ColumnWidth > e.ClipRectangle.X) break; x += ColumnWidth; start++; } // Calc our ending index int end = start; while (end < TimeLineColumnCount) { if (x >= e.ClipRectangle.Right) break; x += ColumnWidth; end++; } end++; // Set the user supplied 'out' values, and // return the range count to the caller if (end - start == 0) { colStart = 0; colEnd = 0; return (0); } colStart = start; colEnd = end; return (end - start); }
public override void OnPaint(ItemPaintArgs itemPaintArgs) { lastPaintRectangle = itemPaintArgs.Rectangle; if (items.Length == 0) return; Rectangle rect = itemPaintArgs.Rectangle; int ind = indent * IndentDistance; if (rect.Width - ind < MinimumWidth) // not enough room to indent fully: do as much as we can ind = Math.Max(rect.Width - MinimumWidth, 0); rect.X += ind; rect.Width -= ind; for (int i = 0; i < items.Length; ++i) { items[i].OnPaint(new ItemPaintArgs(itemPaintArgs.Graphics, rect, itemPaintArgs.State)); if (i < items.Length - 1) { ind = widths[i] + Padding; rect.X += ind; rect.Width -= ind; } } }
/// <summary> /// Paint processing /// </summary> /// <param name="e">ItemPaintArgs</param> public override void Paint(ItemPaintArgs e) { Graphics g = e.Graphics; // Set our current color table _ViewColor.SetColorTable(); // calculate our Column count and range int colStart, colEnd; if (GetColRange(e, out colStart, out colEnd) > 0) { Region rgnSave = g.Clip; g.SetClip(ClientRect, CombineMode.Intersect); // Draw the TimeLine DrawTimeLine(g, colStart, colEnd); if (Connector != null && ShowCondensed == true) DrawCondensedLine(g); // If we have a model connection then // draw our appointments if (Connector != null && Connector.IsConnected) { Rectangle r = ClientRect; r.X += 1; if (ShowCondensed == true) { Rectangle r2 = GetCondensedRect(); if (r.Bottom > r2.Top) r.Height -= (r.Bottom - r2.Top); } g.SetClip(r, CombineMode.Intersect); DrawAppointments(e); } g.Clip = rgnSave; // Update our pos window UpdatePosWin(ClientRect); } // Let the base painting take place base.Paint(e); }
public override void OnPaint(ItemPaintArgs itemPaintArgs) { if (items.Length == 0) return; Rectangle rect = itemPaintArgs.Rectangle; // Padding at top, bottom and between each item. // If this changes, CurrentItem() needs to change. rect.Y += Padding; if (RegularSpacing) rect.Height = ItemHeight; else { rect.Height -= Padding * items.Length; rect.Height /= items.Length; } foreach (GridItemBase item in items) { item.OnPaint(new ItemPaintArgs(itemPaintArgs.Graphics, rect, itemPaintArgs.State)); rect.Y += rect.Height + Padding; } }
/// <summary> /// Draws the content area of the item /// </summary> /// <param name="e"></param> /// <param name="scheme"></param> private void DrawContent(ItemPaintArgs e, int scheme) { Graphics g = e.Graphics; // Grab a path slightly inset from the border using (GraphicsPath gPath = GetItemPath(g, -1)) { // Set up a new clip region for the item Region rgnSave = g.Clip; using (Region rgn = new Region(rgnSave.GetRegionData())) { rgn.Intersect(gPath); g.Clip = rgn; // Draw the top half of the item Rectangle r = Bounds; r.Height = r.Height / 2; using (LinearGradientBrush lbr = new LinearGradientBrush(r, Color.LightGray, _MyColors[scheme].BackColor, 90f)) { r.Height -= 1; g.FillRectangle(lbr, r); } // Draw the bottom back-lit area r.Y = r.Bottom; r.Height = Bounds.Height; using (GraphicsPath path = new GraphicsPath()) { path.AddEllipse(r); using (PathGradientBrush pbr = new PathGradientBrush(path)) { pbr.CenterPoint = new PointF(r.X + r.Width / 2, r.Y + r.Height / 2); // If it is selected, make it a little more lit pbr.CenterColor = (IsSelected ? _MyColors[scheme].BackLitColor1 : _MyColors[scheme].BackLitColor2); pbr.SurroundColors = new Color[] { _MyColors[scheme].BackColor }; g.FillEllipse(pbr, r); } } // Now let all our added SubItems draw themselves for (int i = 0; i < this.SubItems.Count; i++) { if (SubItems[i].Displayed == true) { SubItems[i].Paint(e); } } } // Restore our original clip region g.Clip = rgnSave; // Draw a contrast border around the item g.DrawPath(Pens.White, gPath); } }
protected override Color GetTextColor(ButtonItem button, ItemPaintArgs pa) { return base.GetTextColor(button, pa, GetColorTable(button, eButtonContainer.RibbonStrip)); }
/// <summary> /// Paint processing /// </summary> /// <param name="e">ItemPaintArgs</param> public override void Paint(ItemPaintArgs e) { // Set our current color table _ViewColor.SetColorTable(); // Only draw something if we have something to draw if (_NumberOfMonths > 0) { // Calculate our drawing ranges int colStart, colEnd; int rowStart, rowEnd; int colCount = GetColRange(e, out colStart, out colEnd); int rowCount = GetRowRange(e, out rowStart, out rowEnd); // Draw our calendar parts if (colCount > 0 && rowCount > 0) DrawContent(e, rowStart, rowEnd, colStart, colEnd); } // Let the base painting take place base.Paint(e); }
/// <summary> /// Calculates the range of columns needed to be drawn /// to satisfy the specified paint request /// </summary> /// <param name="e">ItemPaintArgs</param> /// <param name="colStart">[out] Col start index</param> /// <param name="colEnd">[out] COl end index</param> /// <returns>Col range count (end - start)</returns> private int GetColRange(ItemPaintArgs e, out int colStart, out int colEnd) { // Calc our starting index int nCols = Math.Min(_NumberOfMonths, _NumberOfCols); int start = 0; while (start < nCols) { Rectangle dr1 = _YearMonths[start].Bounds; if (dr1.Right > e.ClipRectangle.X) break; start++; } // Calc our ending index int end = start; while (end < nCols) { Rectangle dr2 = _YearMonths[end].Bounds; if (dr2.X >= e.ClipRectangle.Right) break; end++; } // Set the user supplied 'out' values, and // return the range count to the caller if (end - start == 0) { colStart = 0; colEnd = 0; return (0); } colStart = start; colEnd = end - 1; return (end - start); }
public override void Paint(ItemPaintArgs p) { }
/// <summary> /// Draws the resize handles for the view /// </summary> /// <param name="e"></param> /// <param name="r">View rectangle</param> private void DrawResizeHandles(ItemPaintArgs e, Rectangle r) { if (r.Width > 6) { Graphics g = e.Graphics; Rectangle r2 = new Rectangle(r.X + (r.Width / 2) - 2, r.Y - 3, 5, 5); // Top handle g.FillRectangle(Brushes.White, r2); g.DrawRectangle(Pens.Black, r2); // Bottom handle r2.Y = r.Bottom - 2; g.FillRectangle(Brushes.White, r2); g.DrawRectangle(Pens.Black, r2); } }
/// <summary> /// Paint processing /// </summary> /// <param name="e">ItemPaintArgs</param> public override void Paint(ItemPaintArgs e) { AppointmentColor.SetColorTable(); Rectangle r = GetViewRect(); if (r.Width > 1 && r.Height > 0) { if (EffectiveStyle == eDotNetBarStyle.Office2010 || EffectiveStyle == eDotNetBarStyle.Metro) DrawMetroAppointment(e, r); else DrawDefaultAppointment(e, r); if (IsMutable == true) DrawResizeHandles(e, r); } }
private void DrawDefaultAppointment(ItemPaintArgs e, Rectangle r) { Graphics g = e.Graphics; int n = Math.Min(5, r.Height / 2); n = Math.Min(n, r.Width / 2); using (GraphicsPath path = DisplayHelp.GetRoundedRectanglePath(r, n, n, n, n)) { using (Brush br = BackBrush(r)) g.FillPath(br, path); if (BaseView.CalendarView.DoAppointmentViewPreRender(this, g, r, path) == false) { DrawContent(e, r); BaseView.CalendarView.DoAppointmentViewPostRender(this, g, r, path); } DrawDefaultBorder(g, n, r, path); } }
internal void OnMenuPaint(ItemPaintArgs pa) { if (!_ThumbTucked) return; Graphics g = pa.Graphics; MetroTabStrip rs = this.ContainerControl as MetroTabStrip; if (rs != null) { if (this.Parent is MetroTabItemContainer) { if (pa.RightToLeft) g.TranslateTransform(-(this.LeftInternal - pa.ContainerControl.Width + this.WidthInternal), -(this.TopInternal)); else { if (this.EffectiveStyle == eDotNetBarStyle.Windows7) g.TranslateTransform(-this.LeftInternal, -(this.TopInternal - 1)); else g.TranslateTransform(-this.LeftInternal, -(this.TopInternal)); } } else { if (pa.RightToLeft) g.TranslateTransform(-(this.LeftInternal - pa.ContainerControl.Width + this.WidthInternal), -(rs.GetItemContainerBounds().Y - 1)); else g.TranslateTransform(-this.LeftInternal, -(rs.GetItemContainerBounds().Y - 1)); } g.ResetClip(); Control c = pa.ContainerControl; pa.ContainerControl = rs; pa.IsOnMenu = false; this.IgnoreAlpha = true; bool oldGlassEnabled = pa.GlassEnabled; pa.GlassEnabled = rs.IsGlassEnabled; this.Paint(pa); pa.GlassEnabled = oldGlassEnabled; this.IgnoreAlpha = false; pa.ContainerControl = c; pa.IsOnMenu = true; g.ResetTransform(); } }
private void DrawMetroAppointment(ItemPaintArgs e, Rectangle r) { Graphics g = e.Graphics; using (Brush br = BackBrush(r)) g.FillRectangle(br, r); if (BaseView.CalendarView.DoAppointmentViewPreRender(this, g, r, null) == false) { DrawContent(e, r); BaseView.CalendarView.DoAppointmentViewPostRender(this, g, r, null); } DrawMetroBorder(g, r); }
/// <summary> /// Draws YearMonth header and content /// </summary> /// <param name="e">ItemPaintArgs</param> /// <param name="rowStart">Row start index</param> /// <param name="rowEnd">Row end index</param> /// <param name="colStart">Col start index</param> /// <param name="colEnd">Col end index</param> private void DrawContent(ItemPaintArgs e, int rowStart, int rowEnd, int colStart, int colEnd) { Graphics g = e.Graphics; // Set our clipping region Rectangle r = ClientRect; r.X = ClientRect.X; r.Width = ClientRect.Width; Region regSave = g.Clip; g.SetClip(r, CombineMode.Intersect); // Loop through each day in each week, displaying // the associated day content and header DateTime date = DateTime.Now; int nowMonth = -1; for (int i = rowStart; i <= rowEnd; i++) { for (int j = colStart; j <= colEnd; j++) { int n = (i * _NumberOfCols) + j; if (n < _NumberOfMonths) { YearMonth ym = _YearMonths[n]; bool now = CalendarView.HighlightCurrentDay == true && ym.StartDate.Month == date.Month && ym.StartDate.Year == date.Year; if (now == true) nowMonth = n; else ym.Paint(e, false); } } } if (nowMonth >= 0) _YearMonths[nowMonth].Paint(e, true); // Restore our original clip region g.Clip = regSave; }
/// <summary> /// DrawContent /// </summary> /// <param name="e"></param> /// <param name="r"></param> private void DrawContent(ItemPaintArgs e, Rectangle r) { Image image = Image; Rectangle rText = r; rText.X += 4; rText.Width -= 6; if (Appointment.TimeMarkedAs != null) { rText.X += 4; rText.Width -= 4; } Rectangle rImage = GetItemBounds(rText, ref rText, image); DrawContentImage(e, r, rImage, image); DrawContentText(e, rText); }
/// <summary> /// Calculates the range of rows needed to be drawn /// to satisfy the specified paint request /// </summary> /// <param name="e">ItemPaintArgs</param> /// <param name="rowStart">[out] Row start index</param> /// <param name="rowEnd">[out] Row end index</param> /// <returns>Row range count (end - start)</returns> private int GetRowRange(ItemPaintArgs e, out int rowStart, out int rowEnd) { // Calc our starting index int start = 0; while (start < _NumberOfRows) { if (_YearMonths[start * _NumberOfCols].Bounds.Bottom > e.ClipRectangle.Y) break; start++; } // Calc our ending index int end = start; while (end < _NumberOfRows) { if (_YearMonths[end * _NumberOfCols].Bounds.Y >= e.ClipRectangle.Bottom) break; end++; } // Set the user supplied 'out' values, and // return the range count to the caller if (end - start == 0) { rowStart = 0; rowEnd = 0; return (0); } rowStart = start; rowEnd = end - 1; return (end - start); }
public override void OnPaint(ItemPaintArgs itemPaintArgs) { }