In my continuing effort to bring over apps I used all the time on my wn 8.1 machine I ran into this problem.
I'm trying to reproduce in C#/winforms an app I wrote long ago in Delphi. It wasn't hard back then, but I have problems getting it to work properly a windows form under .Net.
The problem is that The image simply does not appear about 15% of the time. Any attempt to draw the same image at the same place gets the same result. Here is the basic method:
In Form_Load I have: g = CreateGraphics();
If I draw on the form or on a PictureBox, the result is the same. If I draw on command from a menu choice or in an OnPaint event handler, the result is the same.
How can I get the images (cards) to draw visibly reliably?
Thanks - Jon
I'm trying to reproduce in C#/winforms an app I wrote long ago in Delphi. It wasn't hard back then, but I have problems getting it to work properly a windows form under .Net.
The problem is that The image simply does not appear about 15% of the time. Any attempt to draw the same image at the same place gets the same result. Here is the basic method:
C#:
private void DrawCard(string cardno, int x, int y)
{
string pattern = "card_" + cardno + "_*.bmp";
string[] files = Directory.GetFiles(pth, pattern);
if (files.Length < 1) return;//exactly 1 file fits the pattern
string FQFN = files[0];
Point p = new Point(x, y);
Bitmap bmp = (Bitmap)Bitmap.FromFile(FQFN);
int h = bmp.Height;
int w = bmp.Width;
int h2 = h / 2;
int w2 = w / 2;
Rectangle r = new Rectangle(x, y, w2, h2);
g.DrawImage(bmp, r);
}
In Form_Load I have: g = CreateGraphics();
If I draw on the form or on a PictureBox, the result is the same. If I draw on command from a menu choice or in an OnPaint event handler, the result is the same.
How can I get the images (cards) to draw visibly reliably?
Thanks - Jon