Custom Component
Custom Component
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!
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
Please show source code of method Paint(StiPaintEventArgs e) of your component.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!
Custom Component
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
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);
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
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
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
Please contact us via LiveSupport for quick solving your problem. Thank you.
Custom Component
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());
}