Custom Component

Stimulsoft Reports.NET discussion
Post Reply
EDV Gradl
Posts: 228
Joined: Sat Jun 17, 2006 9:50 am
Location: Germany

Custom Component

Post by EDV Gradl »

Hi Team from Stimulsoft,

I am using a third party component to creat a custom component im the Report Deisner, like in the custom compnent example.

I am writing to a graphics object and set the object to e.Graphics in the Pain event (like in the example)

In the the designer and in the Preview it works fine (I can see my component),

but when printing to the printer my component is not printed. I can set bord to all and the border is printed. Is there anything else I must consider?

Thanks a lot!
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Custom Component

Post by Vital »

EDV wrote:Hi Team from Stimulsoft,

I am using a third party component to creat a custom component im the Report Deisner, like in the custom compnent example.

I am writing to a graphics object and set the object to e.Graphics in the Pain event (like in the example)

In the the designer and in the Preview it works fine (I can see my component),

but when printing to the printer my component is not printed. I can set bord to all and the border is printed. Is there anything else I must consider?

Thanks a lot!
Please show source code of method Paint(StiPaintEventArgs e) of your component.

EDV Gradl
Posts: 228
Joined: Sat Jun 17, 2006 9:50 am
Location: Germany

Custom Component

Post by EDV Gradl »

Very easy. I just modified the code from the example:

Code: Select all

	public override void Paint(StiPaintEventArgs e)
		{
			InvokePainting(this, e);
			
			if (!e.Cancel)
			{			
				Graphics g = e.Graphics;

				RectangleD rect = GetPaintRectangle();
				if (rect.Width > 0 && rect.Height > 0 && (e.ClipRectangle.IsEmpty || rect.IntersectsWith(e.ClipRectangle)))
				{
					#region Fill rectangle
				/*	if (this.Brush is StiSolidBrush && 
						((StiSolidBrush)this.Brush).Color == Color.Transparent && 
						Report.Info.FillComponent &&
						IsDesigning)
					{
						Color color = Color.FromArgb(150, Color.Green);

						StiDrawing.FillRectangle(g, color, rect.Left, rect.Top, rect.Width, rect.Height);
					}
					else StiDrawing.FillRectangle(g, Brush, rect);*/
					#endregion
                    GraphicsState state = g.Save();
                    g.SmoothingMode = SmoothingMode.AntiAlias;

                    g.SetClip(rect.ToRectangleF());                                        
                    
                    Barcodes.DataMatrix.DataMatrixControl MyBarcode = new Barcodes.DataMatrix.DataMatrixControl();
                    MyBarcode.DrawMatrixToSize(rect.Left, rect.Top, rect.Width, rect.Height,
                        Barcodes.DataMatrix.Dimensions.dmPixels, g);

                    Debug.WriteLine("Left:" + rect.Left.ToString());
                    Debug.WriteLine("Top: " + rect.Top.ToString());
                    Debug.WriteLine("Width: " + rect.Width.ToString());
                    Debug.WriteLine("Height: " + rect.Height.ToString());

                    g.Restore(state);

					//******************
					//Draw control
					//******************

					#region Markers
					PaintMarkers(g, rect);
					#endregion

					#region Border
					if (this.HighlightState == StiHighlightState.Hide)
						Border.Draw(g, rect, Page.Zoom);
					#endregion

					PaintEvents(e.Graphics, rect);
				}
			}
			e.Cancel = false;
			InvokePainted(this, e);

		}
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Custom Component

Post by Vital »


Try to change this code:

Code: Select all

Barcodes.DataMatrix.DataMatrixControl MyBarcode = new Barcodes.DataMatrix.DataMatrixControl();
MyBarcode.DrawMatrixToSize(rect.Left, rect.Top, rect.Width, rect.Height,  Barcodes.DataMatrix.Dimensions.dmPixels, g);
to this code:

Code: Select all

using (Bitmap bmp = new Bitmap((int)rect.Width, (int)rect.Height))
using (Graphics gr = Graphics.FromImage(bmp))
{
	gr.PageUnit = GraphicsUnit.Pixel;
	gr.Clear(Color.White);
                                    
          Barcodes.DataMatrix.DataMatrixControl MyBarcode = new Barcodes.DataMatrix.DataMatrixControl();
          MyBarcode.DrawMatrixToSize(0, 0, rect.Width, rect.Height, Barcodes.DataMatrix.Dimensions.dmPixels, gr);
                                   
          gr.DrawImage(bmp, rect.ToRectangleF());
}
EDV Gradl
Posts: 228
Joined: Sat Jun 17, 2006 9:50 am
Location: Germany

Custom Component

Post by EDV Gradl »

Sadly, it doen't work.

Now I can't see the component any more. Not in designer, not in preview, not when printing.

Do you have any other ideas?

Thank you very much
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Custom Component

Post by Edward »

Please contact us via LiveSupport for quick solving your problem. Thank you.
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Custom Component

Post by Vital »


Problem solved. Corrected code:

Code: Select all

using (Bitmap bmp = new Bitmap((int)rect.Width, (int)rect.Height))
using (Graphics gr = Graphics.FromImage(bmp))
{
     Barcodes.DataMatrix.DataMatrixControl MyBarcode = new Barcodes.DataMatrix.DataMatrixControl();
     MyBarcode.DrawMatrixToSize(0, 0, rect.Width, rect.Height, Barcodes.DataMatrix.Dimensions.dmPixels, gr);
     g.DrawImage(bmp, rect.ToRectangleF());
}

Post Reply