Click here to Skip to main content
15,902,299 members
Home / Discussions / C#
   

C#

 
GeneralRe: vb.net code to csharp Pin
Dave Kreskowiak21-May-07 9:42
mveDave Kreskowiak21-May-07 9:42 
QuestionCall to Graphics.DrawString thows invalid argument on call to System.Drawing.Graphics.CheckErrorStatus Pin
DoomedOne21-May-07 8:25
DoomedOne21-May-07 8:25 
AnswerRe: Call to Graphics.DrawString thows invalid argument on call to System.Drawing.Graphics.CheckErrorStatus Pin
Dave Kreskowiak21-May-07 8:29
mveDave Kreskowiak21-May-07 8:29 
GeneralRe: Call to Graphics.DrawString thows invalid argument on call to System.Drawing.Graphics.CheckErrorStatus Pin
DoomedOne21-May-07 8:46
DoomedOne21-May-07 8:46 
GeneralRe: Call to Graphics.DrawString thows invalid argument on call to System.Drawing.Graphics.CheckErrorStatus Pin
Dave Kreskowiak21-May-07 9:17
mveDave Kreskowiak21-May-07 9:17 
GeneralRe: Call to Graphics.DrawString thows invalid argument on call to System.Drawing.Graphics.CheckErrorStatus Pin
DoomedOne21-May-07 9:40
DoomedOne21-May-07 9:40 
GeneralRe: Call to Graphics.DrawString thows invalid argument on call to System.Drawing.Graphics.CheckErrorStatus Pin
Dave Kreskowiak21-May-07 10:10
mveDave Kreskowiak21-May-07 10:10 
GeneralRe: Call to Graphics.DrawString thows invalid argument on call to System.Drawing.Graphics.CheckErrorStatus Pin
DoomedOne21-May-07 10:46
DoomedOne21-May-07 10:46 
I run it in debug mode, and the frame rendering finish long beefore the second timer event.

Here is a resume of all the code, is quite large one to post completely.

private class Principal:Form
{
//.... declarations , constructor, Othes Methods, etc.

//waht is important for the case

private Bitmap offScreenBmp;
private Graphics offScreenDC;
private Bitmap FondoLimpioBmp;
private bool DrawingToBuffer;

private viod BackImg() //this is been called once at form_load (for now).
{
DrawingToBuffer = true;
FondoLimpioBmp = new Bitmap(BackIngPath);
//BackIngPath is string containing path and file name of backgound image.
FondoLimpioBmp = new Bitmap(BackIngPath);
Graphics FondoLimpioDC = Graphics.FromImage(FondoLimpioBmp );
//Draw Some Gradients here to FondoLimpioDC, no problems here

//PicBack is a PicuteBox in the form.
offScreenBmp = new Bitmap(PicBack.Width, PicBack.Height);
offScreenDC = Graphics.FromImage(offScreenBmp);
offScreenDC.Clear(Color.Transparent);
offScreenDC.DrawImage(this.BackgroundImage,new Point(0,0));
offScreenDC.SmoothingMode = SmoothingMode.AntiAlias;
offScreenDC.DrawImage(FondoLimpioBmp , 0, 0);

FondoLimpioDC.dispose();
offScreenDC.Dispose(); //Add this after yuor comment.
DrawingToBuffer = false;
}


private void Paginar() /// this is called from Timer_Tick event
{

if (!DrawingToBuffer){ //flag para prevenir 2 instancias al mismo tiempo
// Here gos code to read data from database....

DrawingToBuffer = true;
offScreenDC = Graphics.FromImage(offScreenBmp);
offScreenDC.Clear(Color.Transparent);
offScreenDC.DrawImage(FondoLimpioBmp, 0, 0);
offScreenDC.SmoothingMode = SmoothingMode.AntiAlias;

StringFormat sf = new StringFormat();
Brush tBrush = Brushes.Black;

sf.LineAlignment = StringAlignment.Center;
Font tFont = new Font("Arial", 17F, FontStyle.Bold);
string itemToShow;
int Y1, Y2, Y3, Y4;
RectangleF txtRect;
for(int i = 0; i < 10; i++)
{
Y1 = (sepHeigth * i) + (rowHeigth * i);
Y2 = (sepHeigth * (i + 1)) + (rowHeigth * i);
Y3 = Y2;
Y4 = (sepHeigth * (i + 1)) + (rowHeigth * (i + 1));
sf.Alignment = StringAlignment.Center;
txtRect = new RectangleF(TitleSrv.Left, Y3, TitleSrv.Width, rowHeigth);
itemToShow = LSRVLbl[i].Text;
sf.FormatFlags = StringFormatFlags.NoClip;

//*************************************************************//
//This is the line where error is thrown
offScreenDC.DrawString(itemToShow, tFont, tBrush, txtRect, sf);

//*************************************************************

txtRect = new RectangleF(TitleInt.Left, Y3, TitleInt.Width, rowHeigth);
itemToShow = LINTLbl[i].Text;
offScreenDC.DrawString(itemToShow, tFont, tBrush, txtRect, sf);

sf.Alignment = StringAlignment.Near;
txtRect = new RectangleF(TitleOrDes.Left, Y3, TitleOrDes.Width, rowHeigth);
itemToShow = LORDESLbl[i].Text;
offScreenDC.DrawString(itemToShow, tFont17, tBrush, txtRect, sf);
}

sf.Dispose();
tFont.Dispose();
tBrush.Dispose();
offScreenDC.Dispose();
offScreenDC = null;
DrawingToBuffer = false;

PicBox.Invalidate();
}


private void PicBack_Paint(object sender, PaintEventArgs e)
{
if(!DrawingToBuffer)
{
e.Graphics.Clear(Color.Transparent);
e.Graphics.DrawImageUnscaled(offScreenBmp, 0, 0);
}
}

}
GeneralRe: Call to Graphics.DrawString thows invalid argument on call to System.Drawing.Graphics.CheckErrorStatus Pin
Luc Pattyn21-May-07 12:40
sitebuilderLuc Pattyn21-May-07 12:40 
GeneralRe: Call to Graphics.DrawString thows invalid argument on call to System.Drawing.Graphics.CheckErrorStatus Pin
DoomedOne22-May-07 3:05
DoomedOne22-May-07 3:05 
AnswerRe: Call to Graphics.DrawString thows invalid argument on call to System.Drawing.Graphics.CheckErrorStatus Pin
DoomedOne22-May-07 7:22
DoomedOne22-May-07 7:22 
QuestionHow to validate decimal value Pin
indiaone21-May-07 7:21
indiaone21-May-07 7:21 
AnswerRe: How to validate decimal value Pin
Sven Cipido21-May-07 7:34
Sven Cipido21-May-07 7:34 
AnswerRe: How to validate decimal value Pin
Are Jay21-May-07 8:00
Are Jay21-May-07 8:00 
QuestionDerived class constructors Pin
~~~Johnny~~~21-May-07 7:08
~~~Johnny~~~21-May-07 7:08 
AnswerRe: Derived class constructors Pin
Not Active21-May-07 7:15
mentorNot Active21-May-07 7:15 
AnswerRe: Derived class constructors Pin
Dave Kreskowiak21-May-07 7:24
mveDave Kreskowiak21-May-07 7:24 
GeneralRe: Derived class constructors Pin
~~~Johnny~~~21-May-07 7:36
~~~Johnny~~~21-May-07 7:36 
GeneralRe: Derived class constructors Pin
Dave Kreskowiak21-May-07 8:24
mveDave Kreskowiak21-May-07 8:24 
AnswerRe: Derived class constructors Pin
Dave Herren21-May-07 7:41
Dave Herren21-May-07 7:41 
GeneralRe: Derived class constructors Pin
~~~Johnny~~~21-May-07 8:12
~~~Johnny~~~21-May-07 8:12 
GeneralRe: Derived class constructors Pin
Dave Herren21-May-07 9:48
Dave Herren21-May-07 9:48 
GeneralRe: Derived class constructors Pin
~~~Johnny~~~21-May-07 10:37
~~~Johnny~~~21-May-07 10:37 
Question.net test question bank creator Pin
rajantawate1(http//www.tawateventures.com21-May-07 7:02
rajantawate1(http//www.tawateventures.com21-May-07 7:02 
AnswerRe: .net test question bank creator Pin
Not Active21-May-07 7:09
mentorNot Active21-May-07 7:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.