Simple form with a few drawn lines, why not working?

Hi,
I have created a simple form,drawn a few thin lines and 4 thick lines, and, even though I have single-stepped through the code and seen that it is actioned nothing shows in the emulator (PPC).

JFYI it is a Sudoku 9X9 grid.

I am NOT interested in double buffering and all that jazz as I want to see the lines drawn one by one etc.

Here is the code:-

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.IO;

namespace TestPPC
{
public partial class Form1 : Form
{
private Bitmap GridCache = null;

public Form1()
{
InitializeComponent();
GridCache = new Bitmap(240, 260);
using (Graphics g = Graphics.FromImage(GridCache))
{
//int sideX = Form1.ClientSize.Width;
//int sideX = This.ClientSize.Width;
//int sideY = Form1.ClientSize.Height;
//float cellSideX = ((float)(sideX) / 9);
//float cellSideY = ((float)(sideY) / 9);
int sideX = 240;
int sideY = 260;
float cellSideX = (240 / 9);
float cellSideY = (260 / 9);

Pen penBlack = new Pen(Color.Black);

SolidBrush brushBlack = new SolidBrush(Color.Black);

g.Clear(Color.Transparent);

g.DrawRectangle(penBlack, 0, 0, sideX - 1, 259);

for (int i = 1; i < 9; i++) g.DrawLine(penBlack, (int)(i * cellSideX), 0, (int)(i * cellSideX), sideY);//Vertical lines
for (int i = 1; i < 9; i++) g.DrawLine(penBlack, 0, (int)(i * cellSideY), sideX, (int)(i * cellSideY));//Horizontal lines

g.FillRectangle(brushBlack, 0, (int) (3 * cellSideY) - 1, sideX, 3);//First black horizontal line
g.FillRectangle(brushBlack, 0, (int) (6 * cellSideY) - 1, sideX, 3);//Second black horizontal line
g.FillRectangle(brushBlack, (int)(3 * cellSideX) - 2, 0, 4, sideY);//First black vertical line
g.FillRectangle(brushBlack, (int)(6 * cellSideX) - 2, 0, 4, sideY);//Second black vertical line

Invalidate();
}
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawImage(GridCache, 0, 0);
}
}
}

If it is easier for you to just regenerate the form please do so but please, no backbuffers etc....

TIA,

Louis
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories