Page 1 of 1
Fail at printing preview.
Posted: Thu Mar 27, 2014 3:47 pm
by 15666633
Hi, there is problem in TeeChart Print Preview dialog. there is a Margin Units box, with items percent and 1/100 inch( by default ). If youl you'll try to change it to recent and back appears exception ( "A generic error occurred in GDI+." ). It looks like a bug.
Secondary i'd like to ask is there any way to avoid Generating Preview box, that blinks everytime i try to zoom preview size|?
Re: Fail at printing preview.
Posted: Fri Mar 28, 2014 12:50 pm
by Christopher
Petr wrote:Hi, there is problem in TeeChart Print Preview dialog. there is a Margin Units box, with items percent and 1/100 inch( by default ). If youl you'll try to change it to recent and back appears exception ( "A generic error occurred in GDI+." ). It looks like a bug.
This seems to work okay here using the following code:
Code: Select all
Surface series;
private void InitializeChart()
{
series = new Surface(tChart1.Chart);
series.FillSampleValues();
series.UseColorRange = false;
series.UsePalette = true;
series.PaletteStyle = PaletteStyles.Strong;
}
private void button1_Click(object sender, EventArgs e)
{
tChart1.Printer.Preview();
}
Clicking on any of the margin comboboxes doesn't seem to produce an error.
Petr wrote:Secondary i'd like to ask is there any way to avoid Generating Preview box, that blinks everytime i try to zoom preview size|?
I'm afraid not.
Re: Fail at printing preview.
Posted: Mon Jul 07, 2014 2:33 pm
by 15666633
Hi, after quiete long time i got this problem again. I attached simple project that demonstrates it.
Re: Fail at printing preview.
Posted: Tue Jul 08, 2014 8:26 am
by Christopher
Petr,
Petr wrote:Hi, after quiete long time i got this problem again. I attached simple project that demonstrates it.
I've been able to reproduce this problem here, and I think this problem could be resolved with a code change in your code:
Code: Select all
m_PrintRect = new Rectangle( ev.MarginBounds.X, ev.MarginBounds.Y + (int)TitleSize.Height + marginFromTitle + 6 * (int)printFont.GetHeight() + 15, ev.MarginBounds.Width, (int)( ev.MarginBounds.Height * 0.3 ) );
//ev.Graphics.DrawImage( tChart1.Bitmap, ev.MarginBounds.X, ev.MarginBounds.Y + (int)TitleSize.Height + marginFromTitle + 6 * (int)printFont.GetHeight() + 15, ev.MarginBounds.Width, 300 );
//ev.Graphics.DrawImage( tChart1.Bitmap, m_PrintRect );
AdjustRectangle(ref m_PrintRect);
System.Drawing.Imaging.Metafile m = tChart1.Chart.Metafile( tChart1.Chart, m_PrintRect.Width, m_PrintRect.Height );
private void AdjustRectangle(ref Rectangle rect)
{
int top = rect.Top;
int left = rect.Left;
int width = rect.Width;
int height = rect.Height;
if (width < 0 && left + width >= 0)
{
rect.X += width;
rect.Width = Math.Abs(width);
}
if (height < 0 && top + height >= 0)
{
rect.Y += height;
rect.Height = Math.Abs(height);
}
}
does that resolve the issue?
Re: Fail at printing preview.
Posted: Tue Jul 08, 2014 12:31 pm
by 15666633
Yes, thank you, that works.