I am really not sure if it is an issue with my inexperience with C#, VS 2010, debug, .net, or events in general, so please be bear with me. I have a project drawing an Alphabet Aquarium. Adding letters in different colors to a panel and then animate them. It is a simple windows form project that includes two classes, Fishtank and Fish. A paint event is uses to draw the colored letters and it is our task to animate them. In order to understand how the paint event is using the classes with initial load and controls, I set a breakpoint. With the breakpoint, I cannot step through or over the paint event. Without the breakpoint, the program loads?? Is it an issue with my ineperience, the code, the debugging or what??
private void fishTankPanel_Paint(object sender, PaintEventArgs e)
{
// Loop through each fish in our fish tank, and draw them.
for (int i = 0; i < _fishTank.CountFish(); i++)
{
Fish fish = _fishTank.GetFish(i);
e.Graphics.DrawString(fish.FishLetter, new Font("Arial", 10),
new SolidBrush(fish.FishColor), new Point(fish.XPosition, fish.YPosition));
}
fishCountLabel.Text = _fishTank.CountFish().ToString();
}
class Fish
{
private Color _fishColor;
public Color FishColor
{
get { return _fishColor; }
set { _fishColor = value; }
}
private int _xPosition;
public int XPosition
{
get { return _xPosition; }
set { _xPosition = value; }
}
private int _yPosition;
public int YPosition
{
get { return _yPosition; }
set { _yPosition = value; }
}
private string _fishLetter;
public string FishLetter
{
get { return _fishLetter; }
set { _fishLetter = value; }
}
private string _direction;
public string Direction
{
get { return _direction; }
set { _direction = value; }
}
public Fish(string fishLetter, int xPosition, int yPosition, Color fishColor, string fishDirection)
{
// If no letter specified, use "X."
if (fishLetter.Length == 0)
fishLetter = "X";
_fishLetter = fishLetter;
// Ensure the position is >= 0.
if (xPosition < 0)
xPosition = 0;
_xPosition = xPosition;
if (yPosition < 0)
yPosition = 0;
_yPosition = yPosition;
// Set the fish color.
_fishColor = fishColor;
// Set fish direction
}
}class FishTank
{
// Use a List collection to hold the fish.
private List<Fish> _fishTank = new List<Fish>();
public int CountFish()
{
return _fishTank.Count;
}
public Fish GetFish(int position)
{
return _fishTank[position];
}
public void AddFish(Fish fish)
{
_fishTank.Add(fish);
}
public void ClearFish()
{
_fishTank.Clear();
}
}
Feedback would be appreciated and thanks in advance.