protected virtual System.Drawing.Rectangle OnNCCalcSize(System.Drawing.Rectangle windowRect) { windowRect.Inflate(-TIPMARGIN, -TIPMARGIN); switch (this.Quadrant) { case BallonQuadrant.TopLeft: case BallonQuadrant.TopRight: windowRect.set_Y((int) (windowRect.get_Y() + TIPTAIL)); windowRect.set_Height((int) (windowRect.get_Height() - TIPTAIL)); return windowRect; case BallonQuadrant.BottomLeft: case BallonQuadrant.BottomRight: windowRect.set_Height((int) (windowRect.get_Height() - TIPTAIL)); return windowRect; } return windowRect; }
public void DrawDiscoverContentPane(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds, System.Windows.Forms.DrawItemState state, DiscoverPane pane, System.Drawing.Font font, bool rtl) { int num1 = 5; bounds.Inflate(-7, 0); Rectangle imgRect = Rectangle.Empty; Rectangle rectangle2 = bounds; if (rtl) { if (pane.LargeImage != null) { imgRect = new Rectangle(bounds.Right - pane.LargeImage.Width, (bounds.Top + (bounds.Height / 2)) - (pane.LargeImage.Height / 2), pane.LargeImage.Width, pane.LargeImage.Height); rectangle2.Width -= (pane.LargeImage.Width + num1); } } else if (pane.LargeImage != null) { imgRect = new Rectangle(bounds.Left, (bounds.Top + (bounds.Height / 2)) - (pane.LargeImage.Height / 2), pane.LargeImage.Width, pane.LargeImage.Height); rectangle2.X += (pane.LargeImage.Width + num1); rectangle2.Width -= (pane.LargeImage.Width + num1); } if (imgRect != Rectangle.Empty) { Image image1 = pane.LargeImage; if ((state & DrawItemState.Disabled) == DrawItemState.Disabled) { graphics.DrawImage(image1, imgRect, 0, 0, image1.Width, image1.Height, GraphicsUnit.Pixel, new System.Drawing.Imaging.ImageAttributes()); //TODO:ImageAttributes } else { graphics.DrawImage(image1, imgRect); } } using (StringFormat strFormat = new StringFormat(StringFormat.GenericTypographic)) { strFormat.Trimming = StringTrimming.EllipsisCharacter; strFormat.FormatFlags |= StringFormatFlags.NoWrap; strFormat.LineAlignment = StringAlignment.Center; strFormat.HotkeyPrefix = HotkeyPrefix.Show; if (rtl) { strFormat.FormatFlags |= StringFormatFlags.DirectionRightToLeft; } if ((state & DrawItemState.Disabled) == DrawItemState.Disabled) { graphics.DrawString(pane.Text, font, SystemBrushes.ControlDark, (RectangleF)rectangle2, strFormat); } else { using (SolidBrush stringBrush = new SolidBrush(((state & DrawItemState.Selected) == DrawItemState.Selected) ? this.BorderColor : pane.ForeColor)) //TODO:this.BorderColor { graphics.DrawString(pane.Text, font, stringBrush, (RectangleF)rectangle2, strFormat); } } } }
public RectangleF PaintSymbol(System.Drawing.Graphics g, System.Drawing.RectangleF bounds) { if (Shape != XYPlotScatterStyles.Shape.NoSymbol) { GraphicsState gs = g.Save(); g.TranslateTransform(bounds.X + 0.5f * bounds.Width, bounds.Y + 0.5f * bounds.Height); Paint(g); g.Restore(gs); if (this.SymbolSize > bounds.Height) bounds.Inflate(0, this.SymbolSize - bounds.Height); } return bounds; }
public override void DrawRect (System.Drawing.RectangleF dirtyRect) { dirtyRect.Inflate (-1, -1); if (selected) { var color = NSColor.SelectedControl; color.Set (); NSGraphics.RectFill (dirtyRect); } }
public override void DrawAppointment(System.Drawing.Graphics g, System.Drawing.Rectangle rect, Calendar.Appointment appointment, bool isSelected, System.Drawing.Rectangle gripRect) { if (appointment == null) throw new ArgumentNullException("appointment"); if (g == null) throw new ArgumentNullException("g"); /* * Logic for drawing the appointment: * 1) Do something messy with the colours * * 2) Determine background pattern * 2.1) App is locked -> HatchBrush * 2.2) Normal app -> Nothing * * 3) Draw the background of appointment * * 4) Draw the edges of appointment * 4.1) If app is selected -> just draw the selection rectangle * 4.2) If not -> draw the gripper, border (if required) and shadows */ if (rect.Width != 0 && rect.Height != 0) { rect.Width--; using (StringFormat format = new StringFormat()) { format.Alignment = StringAlignment.Near; format.LineAlignment = StringAlignment.Near; // Draw the background of the appointment if (isSelected) { g.FillRectangle(System.Drawing.Brushes.White, rect); ExplorerSelection.DrawBackground(g, rect); ExplorerSelection.DrawBackground(g, rect); } else { using (SolidBrush brush = new SolidBrush(appointment.FillColor)) g.FillRectangle(brush, rect); } // Draw gripper bar gripRect = rect; gripRect.Inflate(-2, -2); gripRect.Width = 5; gripRect.Height--; using (SolidBrush brush = new SolidBrush(appointment.BarColor)) g.FillRectangle(brush, gripRect); // Draw gripper border using (Pen m_Pen = new Pen(TDLColor.DarkerDrawing(appointment.BarColor, 0.5f), 1)) g.DrawRectangle(m_Pen, gripRect); // Draw appointment border if needed if (!isSelected && appointment.DrawBorder) { using (Pen pen = new Pen(appointment.BorderColor, 1)) g.DrawRectangle(pen, rect.Left, rect.Top, rect.Width - 1, rect.Height - 1); } // draw appointment text rect.X = gripRect.Right/* + 2*/; rect.Y++; g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; Color textColor = (isSelected ? TDLColor.DarkerDrawing(appointment.TextColor, 0.5f) : appointment.TextColor); using (SolidBrush brush = new SolidBrush(textColor)) g.DrawString(appointment.Title, this.BaseFont, brush, rect, format); g.TextRenderingHint = TextRenderingHint.SystemDefault; } } }
public RectangleF PaintSymbol(System.Drawing.Graphics g, System.Drawing.RectangleF bounds) { if (_scatterSymbol is NoSymbol) return bounds; var cachedPathData = new CachedPathData(); var cachedBrushData = new CachedBrushData(); var scatterSymbol = CalculateOverriddenScatterSymbol(); CalculatePaths(scatterSymbol, _symbolSize, ref cachedPathData); CalculateBrushes(scatterSymbol, _color, cachedPathData, ref cachedBrushData); GraphicsState gs = g.Save(); g.TranslateTransform(bounds.X + 0.5f * bounds.Width, bounds.Y + 0.5f * bounds.Height); if (null != cachedPathData.InsetPath) g.FillPath(cachedBrushData.InsetBrush, cachedPathData.InsetPath); if (null != cachedPathData.FillPath) g.FillPath(cachedBrushData.FillBrush, cachedPathData.FillPath); if (null != cachedPathData.FramePath) g.FillPath(cachedBrushData.FrameBrush, cachedPathData.FramePath); cachedBrushData.Clear(); cachedPathData.Clear(); g.Restore(gs); if (this.SymbolSize > bounds.Height) bounds.Inflate(0, (float)(this.SymbolSize - bounds.Height)); return bounds; }
public System.Drawing.RectangleF MeasureItem(System.Drawing.Graphics g, System.Drawing.RectangleF innerArea) { innerArea.Inflate(3.0f*_shadowLength/2, 3.0f*_shadowLength/2); return innerArea; }
public void Draw(System.Drawing.Graphics g, System.Drawing.RectangleF innerArea) { innerArea.Inflate(_shadowLength / 2, _shadowLength / 2); // Padding RectangleF outerArea = innerArea; outerArea.Inflate(_shadowLength, _shadowLength); _brush.Rectangle = outerArea; g.FillRectangle(_brush, outerArea); SolidBrush twhite = new SolidBrush(Color.FromArgb(128, 255, 255, 255)); g.FillPolygon(twhite, new PointF[] { new PointF(outerArea.Left,outerArea.Top), // upper left point new PointF(outerArea.Right,outerArea.Top), // go to the right new PointF(innerArea.Right,innerArea.Top), // go 45 deg left down in the upper right corner new PointF(innerArea.Left,innerArea.Top), // upper left corner of the inner rectangle new PointF(innerArea.Left,innerArea.Bottom), // lower left corner of the inner rectangle new PointF(outerArea.Left,outerArea.Bottom) // lower left corner }); SolidBrush tblack = new SolidBrush(Color.FromArgb(128, 0, 0, 0)); g.FillPolygon(tblack, new PointF[] { new PointF(outerArea.Right,outerArea.Bottom), new PointF(outerArea.Right,outerArea.Top), new PointF(innerArea.Right,innerArea.Top), new PointF(innerArea.Right,innerArea.Bottom), // upper left corner of the inner rectangle new PointF(innerArea.Left,innerArea.Bottom), // lower left corner of the inner rectangle new PointF(outerArea.Left,outerArea.Bottom) // lower left corner }); }
TryGetLayoutRectangleMinusMargin ( out System.Drawing.Rectangle oLayoutRectangleMinusMargin ) { AssertValid(); // Note that between this class, LayoutBase, and GraphDrawingContext, // there is some duplication of margin-subtracting code. That's // because layout-related code uses System.Drawing rectangles to avoid // WPF dependencies, while drawing code uses WPF rectangles. Int32 iMargin = m_oLayout.Margin; oLayoutRectangleMinusMargin = m_oLastLayoutContext.GraphRectangle; oLayoutRectangleMinusMargin.Inflate(-iMargin, -iMargin); return (oLayoutRectangleMinusMargin.Width > 0 && oLayoutRectangleMinusMargin.Height > 0); }
internal static void DrawDropShadow(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds, int radius, System.Drawing.Color color) { graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; using (System.Drawing.Brush brush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(color.A / 4, color.R, color.G, color.B))) { for (int i = 0; i < 4; i++) { bounds.Inflate(-1, -1); using (System.Drawing.Drawing2D.GraphicsPath graphicsPath = Skybound.VisualTips.Rendering.VisualTipRenderer.CreateRoundRectPath(bounds, radius, Skybound.VisualTips.Rendering.VisualTipRenderer.BorderCorners.All)) { graphics.FillPath(brush, graphicsPath); } } } graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default; }
public static void DrawMenuCheckBox(ItemPaintArgs pa, System.Drawing.Rectangle r, eDotNetBarStyle style, bool MouseOver) { System.Drawing.Graphics g = pa.Graphics; Color clr; if (style != eDotNetBarStyle.Office2000) { if (MouseOver) { //clr=g.GetNearestColor(Color.FromArgb(45,SystemColors.Highlight)); //SolidBrush objBrush=new SolidBrush(clr); //g.FillRectangle(objBrush,r); //objBrush.Dispose(); } else { //clr=g.GetNearestColor(Color.FromArgb(96,ColorFunctions.HoverBackColor())); clr = pa.Colors.ItemCheckedBackground; //ColorFunctions.CheckBoxBackColor(g); SolidBrush objBrush = new SolidBrush(clr); g.FillRectangle(objBrush, r); objBrush.Dispose(); } //clr=g.GetNearestColor(Color.FromArgb(200,SystemColors.Highlight)); clr = pa.Colors.ItemCheckedBorder; // SystemColors.Highlight; Pen objPen = new Pen(clr, 1); // TODO: Beta 2 fix --> g.DrawRectangle(objPen,r); NativeFunctions.DrawRectangle(g, objPen, r); objPen.Dispose(); // Draw checker... Point[] pt = new Point[3]; pt[0].X = r.Left + (r.Width - 5) / 2 - 1; pt[0].Y = r.Top + (r.Height - 6) / 2 + 3; pt[1].X = pt[0].X + 2; pt[1].Y = pt[0].Y + 2; pt[2].X = pt[1].X + 4; pt[2].Y = pt[1].Y - 4; objPen = new Pen(pa.Colors.ItemCheckedText); g.DrawLines(objPen, pt); pt[0].X++; pt[1].X++; pt[2].X++; g.DrawLines(objPen, pt); objPen.Dispose(); } else if (style == eDotNetBarStyle.Office2000) { // Draw checked box System.Windows.Forms.ControlPaint.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.SunkenOuter, System.Windows.Forms.Border3DSide.All); if (!MouseOver) { r.Inflate(-1, -1); g.FillRectangle(ColorFunctions.GetPushedBrush(), r); } // Draw checker... Point[] pt = new Point[3]; pt[0].X = r.Left + (r.Width - 6) / 2; pt[0].Y = r.Top + (r.Height - 6) / 2 + 3; pt[1].X = pt[0].X + 2; pt[1].Y = pt[0].Y + 2; pt[2].X = pt[1].X + 4; pt[2].Y = pt[1].Y - 4; g.DrawLines(SystemPens.ControlText, pt); pt[0].X++; pt[1].X++; pt[2].X++; g.DrawLines(SystemPens.ControlText, pt); } }
public override void DrawCell(System.Drawing.Graphics g, System.Drawing.Rectangle rect, CellInfo ci) { StringFormat m_fTitle = new StringFormat(); m_fTitle.Alignment = StringAlignment.Center; m_fTitle.FormatFlags = StringFormatFlags.FitBlackBox; m_fTitle.LineAlignment = StringAlignment.Center; StringFormat m_fTip = new StringFormat(); m_fTip.Alignment = StringAlignment.Near; g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; Color bg = MonthColorMap[ci.date.Month]; if (ci.bCurMonth) { bg = MonthColorMap[0]; } using (SolidBrush backBrush = new SolidBrush(bg)) g.FillRectangle(backBrush, rect); using (Pen vLineClr = new Pen(VerticalLineColor)) { g.DrawLine(vLineClr, rect.Left, rect.Top, rect.Left, rect.Bottom); } using (Pen hLineClr = new Pen(HorisontalLineColor)) { g.DrawLine(hLineClr, rect.Left, rect.Bottom, rect.Right, rect.Bottom); } Rectangle rTitle = rect; rTitle.Offset(2, 1); Rectangle rText = rect; rText.Offset(2, 1); Size textSize = g.MeasureString(ci.sTitle, CellDataBoldFont, rTitle.Width).ToSize(); rTitle.Height = textSize.Height; rText.Height -= textSize.Height; rText.Y += textSize.Height; rect.Inflate(1, 1); rect.Offset(1, 0); Brush bText = SystemBrushes.WindowText; if (ci.bSelected) { using (SolidBrush backBrush = new SolidBrush(SelectionColor)) g.FillRectangle(backBrush, rect); using (Pen borderPen = new Pen(SelectionBorderColor)) g.DrawRectangle(borderPen, rect); bText = SystemBrushes.HighlightText; } g.DrawString(ci.sTitle, CellDataBoldFont, bText, rTitle, m_fTitle); g.DrawString(ci.sTip, CellDataFont, bText, rText, m_fTip); g.TextRenderingHint = TextRenderingHint.SystemDefault; }
public void Draw(System.Drawing.Graphics g, System.Drawing.RectangleF innerArea) { if (null == _cachedShadowBrush) SetCachedBrushes(); innerArea.Inflate(_shadowLength / 2,_shadowLength/2); // please note: m_Bounds is already extended to the shadow // first the shadow _cachedShadowBrush.Rectangle = innerArea; g.TranslateTransform(_shadowLength, _shadowLength); g.FillRectangle(_cachedShadowBrush, innerArea); g.TranslateTransform(-_shadowLength, -_shadowLength); _brush.Rectangle = innerArea; g.FillRectangle(_brush, innerArea); g.DrawRectangle(Pens.Black, innerArea.Left, innerArea.Top, innerArea.Width , innerArea.Height ); }
public System.Drawing.RectangleF MeasureItem(System.Drawing.Graphics g, System.Drawing.RectangleF innerArea) { innerArea.Inflate(_shadowLength/2,_shadowLength/2); innerArea.Width += _shadowLength; innerArea.Height += _shadowLength; return innerArea; }
/// <summary> /// 渲染控件边框 /// </summary> /// <param name="g">绘图画面</param> /// <param name="TabArea">绘制的区域</param> public virtual void RenderTabPanelBorder(System.Drawing.Graphics g, System.Drawing.Rectangle TabArea) { Pen border1 = new Pen(Color.FromArgb(19, 28, 37)); //Pen border1 = new Pen(Color.FromArgb(0,255,0)); g.DrawRectangle(border1, TabArea); border1.Dispose(); //内边框 Pen border2 = new Pen(Color.FromArgb(91, 125, 170)); //Pen border2 = new Pen(Color.FromArgb(255,0,0)); TabArea.Inflate(-1, -1); g.DrawRectangle(border2, TabArea); //g.DrawRectangle(border2,tabArea.X+1,tabArea.Y+1,tabArea.Width-3,tabArea.Height-3); border2.Dispose(); }