/// <summary> /// Draws preview on the charts tab /// </summary> private void DrawChartsPreview() { Rectangle rect = pctCharts.ClientRectangle; Bitmap bmp = new Bitmap(rect.Width, rect.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); if (_shapefile.Charts.Count > 0 && _shapefile.Charts.NumFields > 0) { Graphics g = Graphics.FromImage(bmp); IntPtr ptr = g.GetHdc(); int width = rect.Width; int height = rect.Height; MapWinGIS.Charts charts = _shapefile.Charts; if (charts.ChartType == MapWinGIS.tkChartType.chtPieChart) { charts.DrawChart(ptr.ToInt32(), (width - charts.IconWidth) / 2, (height - charts.IconHeight) / 2, false, Colors.ColorToUInteger(Color.White)); } else { charts.DrawChart(ptr.ToInt32(), (width - charts.IconWidth) / 2, (height - charts.IconHeight) / 2, false, Colors.ColorToUInteger(Color.White)); } g.ReleaseHdc(ptr); } pctCharts.Image = bmp; }
/// <summary> /// Performs drawing /// </summary> private void Draw() { int width = pictureBox1.ClientRectangle.Width; int height = pictureBox1.ClientRectangle.Height; Bitmap bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(bmp); IntPtr hdc = g.GetHdc(); uint backColor = Colors.ColorToUInteger(this.BackColor); if (_charts.Visible) { if (_charts.ChartType == MapWinGIS.tkChartType.chtPieChart) { _charts.DrawChart(hdc, (width - _charts.IconWidth) / 2, (height - _charts.IconHeight) / 2, false, backColor); } else { _charts.DrawChart(hdc, (width - _charts.IconWidth) / 2, (height - _charts.IconHeight) / 2, false, backColor); } } g.ReleaseHdc(); pictureBox1.Image = bmp; }