private void CreateDoubleBuffer() { memGraphics.CreateDoubleBuffer(this.CreateGraphics(), this.ClientRectangle.Width, this.ClientRectangle.Height); }
private void Corrida_Load(object sender, EventArgs e) { memGraphics.CreateDoubleBuffer(this.CreateGraphics(), this.ClientRectangle.Width, this.ClientRectangle.Height); }
private void SmoothTable_Paint(object sender, PaintEventArgs e) { m_dbgGraphics.CreateDoubleBuffer(e.Graphics, this.Width, this.Height); System.Drawing.Point ptDrawStart = new Point(0, m_iColumnHeight); System.Drawing.Point ptDrawFinish = new Point(0, 0); System.Drawing.Point ptLabelPoint = new Point(); System.Drawing.SizeF sfLabelSize; Region m_rgOrigRegion = m_dbgGraphics.g.Clip; m_dbgGraphics.g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; m_dbgGraphics.g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; m_iTotalHeight = 0; m_iTotalWidth = 0; //draw rows, but not row lines - we don't know how wide the table is yet //while drawing, keep track of total height //also draw row labels for (int i = 0; i < m_lsRowLabels.Count; i++) { //draw background gradient of row label Gradient.DrawGradient(m_dbgGraphics.g, Gradient.GradientDirection.Vertical, m_cGradientStart, m_cGradientFinish, m_iRowWidth, m_lsRowLabels[i].Height, ptDrawStart); //draw row label m_lsRowLabels[i].Region = new Rectangle(ptDrawStart.X, ptDrawStart.Y, m_iRowWidth, m_lsRowLabels[i].Height); sfLabelSize = m_dbgGraphics.g.MeasureString(m_lsRowLabels[i].Text, m_fntLabelFont); ptLabelPoint.X = ptDrawStart.X + ((m_lsRowLabels[i].Region.Width / 2) - ((int)sfLabelSize.Width / 2)); ptLabelPoint.Y = ptDrawStart.Y + ((m_lsRowLabels[i].Region.Height / 2) - ((int)sfLabelSize.Height / 2)); m_dbgGraphics.g.Clip = new Region(m_lsRowLabels[i].Region); m_dbgGraphics.g.DrawString(m_lsRowLabels[i].Text, m_fntLabelFont, m_bshLabelTextBrush, ptLabelPoint); m_dbgGraphics.g.Clip = m_rgOrigRegion; ptDrawStart.Y += m_lsRowLabels[i].Height; } //prepare start and end points m_iTotalHeight = ptDrawStart.Y; ptDrawFinish.Y = m_iTotalHeight; ptDrawStart.Y = 0; ptDrawStart.X = m_iRowWidth; //draw columns and column lines, build total width while you're at it for (int i = 0; i < m_lsColumnLabels.Count; i++) { Gradient.DrawGradient(m_dbgGraphics.g, Gradient.GradientDirection.Vertical, m_cGradientStart, m_cGradientFinish, m_lsColumnLabels[i].Width, m_iColumnHeight, ptDrawStart); //draw column label m_lsColumnLabels[i].Region = new Rectangle(ptDrawStart.X, ptDrawStart.Y, m_lsColumnLabels[i].Width, m_iColumnHeight); sfLabelSize = m_dbgGraphics.g.MeasureString(m_lsColumnLabels[i].Text, m_fntLabelFont); ptLabelPoint.X = ptDrawStart.X + ((m_lsColumnLabels[i].Region.Width / 2) - ((int)sfLabelSize.Width / 2)); ptLabelPoint.Y = ptDrawStart.Y + ((m_lsColumnLabels[i].Region.Height / 2) - ((int)sfLabelSize.Height / 2)); m_dbgGraphics.g.Clip = new Region(m_lsColumnLabels[i].Region); m_dbgGraphics.g.DrawString(m_lsColumnLabels[i].Text, m_fntLabelFont, m_bshLabelTextBrush, ptLabelPoint); m_dbgGraphics.g.Clip = m_rgOrigRegion; //draw grid line ptDrawFinish.X = ptDrawStart.X; m_dbgGraphics.g.DrawLine(m_pGridPen, ptDrawStart, ptDrawFinish); ptDrawStart.X += m_lsColumnLabels[i].Width; } //prepare start and end points. //start point will be all the way to the right of the table, //end point will be on the left m_iTotalWidth = ptDrawStart.X; ptDrawStart.Y = m_iColumnHeight; ptDrawFinish.X = 0; ptDrawFinish.Y = ptDrawStart.Y; //draw final row lines now that total width has been calculated for (int i = 0; i < m_lsRowLabels.Count; i++) { m_dbgGraphics.g.DrawLine(m_pGridPen, ptDrawStart, ptDrawFinish); ptDrawStart.Y += m_lsRowLabels[i].Height; ptDrawFinish.Y = ptDrawStart.Y; } //final border around everything m_dbgGraphics.g.DrawRectangle(m_pGridPen, 0, 0, m_iTotalWidth, m_iTotalHeight); //final resize to match size of drawn table this.SmoothTable_Resize(this, EventArgs.Empty); Fill(m_dbgGraphics.g); m_dbgGraphics.Render(e.Graphics); }
private void Form1_Load(object sender, EventArgs e) { memGraphics.CreateDoubleBuffer(this.CreateGraphics(), this.ClientRectangle.Width, this.ClientRectangle.Height); myPane = new GraphPane(new Rectangle(10, 10, 10, 10), "Wacky Widget Company\nProduction Report", "Time, Days\n(Since Plant Construction Startup)", "Widget Production\n(units/hour)"); SetSize(); double[] x = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 }; double[] y = { 20, 10, 50, 25, 35, 75, 90, 40, 33, 50 }; LineItem curve; curve = myPane.AddCurve("Larry", x, y, Color.Green, SymbolType.Circle); curve.Line.Width = 1.5F; curve.Line.Fill = new Fill(Color.White, Color.FromArgb(60, 190, 50), 90F); curve.Line.IsSmooth = true; curve.Line.SmoothTension = 0.6F; curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.Size = 10; double[] x3 = { 150, 250, 400, 520, 780, 940 }; double[] y3 = { 5.2, 49.0, 33.8, 88.57, 99.9, 36.8 }; curve = myPane.AddCurve("Moe", x3, y3, Color.FromArgb(200, 55, 135), SymbolType.Triangle); curve.Line.Width = 1.5F; //curve.Line.IsSmooth = true; curve.Symbol.Fill = new Fill(Color.White); curve.Line.Fill = new Fill(Color.White, Color.FromArgb(160, 230, 145, 205), 90F); curve.Symbol.Size = 10; double[] x4 = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 }; double[] y4 = { 30, 45, 53, 60, 75, 83, 84, 79, 71, 57 }; BarItem bar = myPane.AddBar("Wheezy", x4, y4, Color.SteelBlue); bar.Bar.Fill = new Fill(Color.RosyBrown, Color.White, Color.RosyBrown); myPane.BarSettings.ClusterScaleWidth = 100; myPane.BarSettings.Type = BarType.Stack; double[] x2 = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 }; double[] y2 = { 10, 15, 17, 20, 25, 27, 29, 26, 24, 18 }; bar = myPane.AddBar("Curly", x2, y2, Color.RoyalBlue); bar.Bar.Fill = new Fill(Color.RoyalBlue, Color.White, Color.RoyalBlue); myPane.BarSettings.ClusterScaleWidth = 100; myPane.Fill = new Fill(Color.WhiteSmoke, Color.Lavender, 0F); myPane.Chart.Fill = new Fill(Color.FromArgb(255, 255, 245), Color.FromArgb(255, 255, 190), 90F); myPane.XAxis.MajorGrid.IsVisible = true; myPane.YAxis.MajorGrid.IsVisible = true; myPane.YAxis.Scale.Max = 120; TextObj text = new TextObj("First Prod\n21-Oct-93", 175F, 80.0F); text.Location.AlignH = AlignH.Center; text.Location.AlignV = AlignV.Bottom; text.FontSpec.Fill = new Fill(Color.White, Color.PowderBlue, 45F); myPane.GraphObjList.Add(text); ArrowObj arrow = new ArrowObj(Color.Black, 12F, 175F, 77F, 100F, 45F); arrow.Location.CoordinateFrame = CoordType.AxisXYScale; myPane.GraphObjList.Add(arrow); text = new TextObj("Upgrade", 700F, 50.0F); text.FontSpec.Angle = 90; text.FontSpec.FontColor = Color.Black; text.Location.AlignH = AlignH.Right; text.Location.AlignV = AlignV.Center; text.FontSpec.Fill.IsVisible = false; text.FontSpec.Border.IsVisible = false; myPane.GraphObjList.Add(text); arrow = new ArrowObj(Color.Black, 15, 700, 53, 700, 80); arrow.Location.CoordinateFrame = CoordType.AxisXYScale; arrow.PenWidth = 2.0F; myPane.GraphObjList.Add(arrow); text = new TextObj("Confidential", 0.85F, -0.03F); text.Location.CoordinateFrame = CoordType.ChartFraction; text.FontSpec.Angle = 15.0F; text.FontSpec.FontColor = Color.Red; text.FontSpec.IsBold = true; text.FontSpec.Size = 16; text.FontSpec.Border.IsVisible = false; text.FontSpec.Border.Color = Color.Red; text.FontSpec.Fill.IsVisible = false; text.Location.AlignH = AlignH.Left; text.Location.AlignV = AlignV.Bottom; myPane.GraphObjList.Add(text); BoxObj box = new BoxObj(0, 110, 1200, 10, Color.Empty, Color.FromArgb(225, 245, 225)); box.Location.CoordinateFrame = CoordType.AxisXYScale; box.Location.AlignH = AlignH.Left; box.Location.AlignV = AlignV.Top; box.ZOrder = ZOrder.E_BehindAxis; myPane.GraphObjList.Add(box); text = new TextObj("Peak Range", 1170, 105); text.Location.CoordinateFrame = CoordType.AxisXYScale; text.Location.AlignH = AlignH.Right; text.Location.AlignV = AlignV.Center; text.FontSpec.IsItalic = true; text.FontSpec.IsBold = false; text.FontSpec.Fill.IsVisible = false; text.FontSpec.Border.IsVisible = false; myPane.GraphObjList.Add(text); myPane.AxisChange(this.CreateGraphics()); }
private void PanelChart_Resize(object sender, System.EventArgs e) { memGraphics.CreateDoubleBuffer(this.CreateGraphics(), this.ClientRectangle.Width, this.ClientRectangle.Height); Invalidate(); }