Page 1 of 1
Custom Component
Posted: Sun Jun 18, 2006 3:23 pm
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!
Custom Component
Posted: Sun Jun 18, 2006 5:20 pm
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.
Custom Component
Posted: Mon Jun 19, 2006 1:28 am
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);
}
Custom Component
Posted: Mon Jun 19, 2006 3:25 am
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());
}
Custom Component
Posted: Mon Jun 19, 2006 4:12 am
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
Custom Component
Posted: Mon Jun 19, 2006 4:47 am
by Edward
Please contact us via LiveSupport for quick solving your problem. Thank you.
Custom Component
Posted: Mon Jun 19, 2006 2:21 pm
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());
}