Fail at printing preview.

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Petr
Newbie
Newbie
Posts: 39
Joined: Wed Jul 24, 2013 12:00 am

Fail at printing preview.

Post by Petr » Thu Mar 27, 2014 3:47 pm

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|?

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Fail at printing preview.

Post by Christopher » Fri Mar 28, 2014 12:50 pm

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.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Petr
Newbie
Newbie
Posts: 39
Joined: Wed Jul 24, 2013 12:00 am

Re: Fail at printing preview.

Post by Petr » Mon Jul 07, 2014 2:33 pm

Hi, after quiete long time i got this problem again. I attached simple project that demonstrates it.
Attachments
PrintProblem.rar
(20.14 KiB) Downloaded 669 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Fail at printing preview.

Post by Christopher » Tue Jul 08, 2014 8:26 am

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?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Petr
Newbie
Newbie
Posts: 39
Joined: Wed Jul 24, 2013 12:00 am

Re: Fail at printing preview.

Post by Petr » Tue Jul 08, 2014 12:31 pm

Yes, thank you, that works.

Post Reply