public override void Initialize(PaintEventArgs e) { base.Initialize(e); PaintHelper.SetHighQualityRender(e.Graphics); e.Graphics.SmoothingMode = SmoothingMode.Default; }
protected override void OnPaint(PaintEventArgs e) { PaintBackground(e); PaintHelper.SetHighQualityRender(e.Graphics); if (Pages == null) { BeginInvoke(new MethodInvoker(CalculatePageInfo)); } else if (Pages.Length == 0 || ExceptionPrinting) { SolidBrush brushText = new SolidBrush(ForeColor); string msg; if (this.ExceptionPrinting) { msg = Lang._("Exception Occurs"); } else { msg = Lang._("No Pages"); } e.Graphics.DrawString(msg, Font, brushText, ClientRectangle, PaintHelper.SFCenter); brushText.Dispose(); } else { PaintPages(e); } }
protected override void OnPaint(PaintEventArgs e) { //base.OnPaint(e); InvokePaintBackground(this, e); Rectangle rectTitle = ClientRectangle; rectTitle.Height = FoldingButtonRect.Height; Size sizeText = Size.Ceiling(e.Graphics.MeasureString(Text, Font)); rectTitle.Height = Math.Max(rectTitle.Height, sizeText.Height); Image image = Folded ? Properties.Resources.folding_expand : Properties.Resources.folding_collapse; PaintHelper.DrawImageInRange(e.Graphics, image, FoldingButtonRect); rectTitle.X += FoldingButtonRect.Width; rectTitle.Width -= FoldingButtonRect.Width; e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), rectTitle, PaintHelper.SFLeft); rectTitle.X += sizeText.Width; rectTitle.Width -= sizeText.Width; PaintHelper.SetHighQualityRender(e.Graphics); e.Graphics.ExcludeClip(new Rectangle(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Width - rectTitle.Width, rectTitle.Height)); Rectangle rectBorder = new Rectangle(0, rectTitle.Y + rectTitle.Height / 2, ClientSize.Width, ClientSize.Height - rectTitle.Height / 2); Pen penLine = new Pen(PaintHelper.GetDarkColor(BackColor)); if (Folded) { e.Graphics.DrawLine(penLine, rectBorder.X, rectBorder.Y, rectBorder.Right, rectBorder.Y); } else { GraphicsPath path = PaintHelper.GetRoundRectangle(rectBorder, 6); e.Graphics.DrawPath(penLine, path); path.Dispose(); } if (Focused) { ControlPaint.DrawFocusRectangle(e.Graphics, new Rectangle(0, 0, ClientSize.Width, ClientSize.Height)); } }
void ChartBox_Paint(object sender, PaintEventArgs e) { Point pt = Point.Empty; if (HorizontalScroll.Enabled) { pt.X = HorizontalScroll.Value; } if (VerticalScroll.Enabled) { pt.Y = VerticalScroll.Value; } if (Zoom != 1 && Zoom > 0) { pt.X = (int)Math.Round(pt.X / Zoom); pt.Y = (int)Math.Round(pt.Y / Zoom); } if (ChartBox.Margin.Left != 0) { pt.X -= ChartBox.Margin.Left; } if (ChartBox.Margin.Top != 0) { pt.Y -= ChartBox.Margin.Top; } if (!CustomDoubleBuffer || BmpBuffer == null) { ChartPaintEventArgs cpe; if (CustomDoubleBuffer) { BmpBuffer = new Bitmap(ChartBox.Width, ChartBox.Height); Graphics grf = Graphics.FromImage(BmpBuffer); cpe = new ChartPaintEventArgs(grf, ChartBox.ClientRectangle); } else { cpe = new ChartPaintEventArgs(e); } cpe.LogicViewPort = ChartBox.ClientRectangle; cpe.BackBrush = new SolidBrush(ChartBackColor); cpe.ForeBrush = new SolidBrush(ChartForeColor); cpe.Font = ChartBox.DefaultChartFont; if (Zoom != 1.0f) { cpe.Graphics.ScaleTransform(Zoom, Zoom); } if (HighQualityRender) { PaintHelper.SetHighQualityRender(cpe.Graphics); } if (!pt.IsEmpty) { cpe.Graphics.TranslateTransform(-pt.X, -pt.Y); Rectangle rect = cpe.LogicViewPort; rect.Offset(pt.X, pt.Y); cpe.LogicViewPort = rect; } // Draw Chart DrawChart(cpe); if (CustomDoubleBuffer) { cpe.Graphics.Dispose(); } } if (CustomDoubleBuffer && BmpBuffer != null) { e.Graphics.DrawImage(BmpBuffer, new Rectangle(0, 0, ChartBox.Width, ChartBox.Height), 0, 0, BmpBuffer.Width, BmpBuffer.Height, GraphicsUnit.Pixel); } if (CustomDoubleBuffer) { //e.Graphics.TranslateTransform(-pt.X, -pt.Y); //e.Graphics.ScaleTransform(Zoom, Zoom); PaintHelper.SetHighQualityRender(e.Graphics); } foreach (ChartLayer layer in Layers) { layer.DrawRealTime(e); } OnAfterPaint(e); }