J
John Salerno
Ok, I'm having this problem again. The first I was able to use the
debugger to see that it was being called twice, so I fixed that. This
time, though, the debugger does not show it (MessageBox.Show) being
called twice, and sometimes it *doesn't* get called twice! So I don't
know why it's happening. Here's the code. I hope it looks ok, if not
I'll post it a different way.
namespace CharacterManager
{
public partial class frmCharacterManager : Form
{
private string incompatibleSelection = "Incompatible Selection";
#region Class validators
public bool IsBarbarian()
{
if (rdoBarbarian.Checked == true)
return true;
return false;
}
public bool IsBard()
{
if (rdoBard.Checked == true)
return true;
return false;
}
public bool IsCleric()
{
if (rdoCleric.Checked == true)
return true;
return false;
}
public bool IsDruid()
{
if (rdoDruid.Checked == true)
return true;
return false;
}
public bool IsFighter()
{
if (rdoFemale.Checked == true)
return true;
return false;
}
public bool IsMonk()
{
if (rdoMonk.Checked == true)
return true;
return false;
}
public bool IsPaladin()
{
if (rdoPaladin.Checked == true)
return true;
return false;
}
public bool IsRanger()
{
if (rdoRanger.Checked == true)
return true;
return false;
}
public bool IsRogue()
{
if (rdoRogue.Checked == true)
return true;
return false;
}
public bool IsSorcerer()
{
if (rdoSorcerer.Checked == true)
return true;
return false;
}
public bool IsWizard()
{
if (rdoWizard.Checked == true)
return true;
return false;
}
#endregion
#region Alignment validators
public bool IsLawful()
{
if (rdoLawfulGood.Checked == true || rdoLawfulNeutral.Checked == true
|| rdoLawfulEvil.Checked == true)
return true;
return false;
}
public bool IsChaotic()
{
if (rdoChaoticGood.Checked == true || rdoChaoticNeutral.Checked ==
true || rdoChaoticEvil.Checked == true)
return true;
return false;
}
public bool IsGood()
{
if (rdoLawfulGood.Checked == true || rdoNeutralGood.Checked == true
|| rdoChaoticGood.Checked == true)
return true;
return false;
}
public bool IsNeutral()
{
if (rdoLawfulNeutral.Checked == true || rdoNeutralGood.Checked ==
true || rdoTrueNeutral.Checked == true || rdoNeutralEvil.Checked == true
|| rdoChaoticNeutral.Checked == true)
return true;
return false;
}
public bool IsEvil()
{
if (rdoLawfulEvil.Checked == true || rdoNeutralEvil.Checked == true
|| rdoChaoticEvil.Checked == true)
return true;
return false;
}
#endregion
#region Race event handlers
private void rdoHuman_CheckedChanged(object sender, EventArgs e)
{
SuggestClass();
}
private void rdoElf_CheckedChanged(object sender, EventArgs e)
{
SuggestClass();
}
private void rdoDwarf_CheckedChanged(object sender, EventArgs e)
{
SuggestClass();
}
private void rdoHalfElf_CheckedChanged(object sender, EventArgs e)
{
SuggestClass();
}
private void rdoGnome_CheckedChanged(object sender, EventArgs e)
{
SuggestClass();
}
private void rdoHalfling_CheckedChanged(object sender, EventArgs e)
{
SuggestClass();
}
private void rdoHalfOrc_CheckedChanged(object sender, EventArgs e)
{
SuggestClass();
}
#endregion
private void btnReorganizeAlignments_Click(object sender, EventArgs e)
{
Point p1;
Point p2;
p1 = rdoLawfulNeutral.Location;
p2 = rdoNeutralGood.Location;
rdoLawfulNeutral.Location = p2;
rdoNeutralGood.Location = p1;
p1 = rdoLawfulEvil.Location;
p2 = rdoChaoticGood.Location;
rdoLawfulEvil.Location = p2;
rdoChaoticGood.Location = p1;
p1 = rdoNeutralEvil.Location;
p2 = rdoChaoticNeutral.Location;
rdoNeutralEvil.Location = p2;
rdoChaoticNeutral.Location = p1;
}
public void SuggestClass()
{
if (chkSuggestedClass.Checked == true)
{
string noClass = "No Recommended Class";
if (rdoHuman.Checked == true)
{
string noHumanClass = "There is no suggested class for Humans.";
stsStatusLabel.Text = noHumanClass;
MessageBox.Show(noHumanClass, noClass);
}
if (rdoElf.Checked == true)
rdoWizard.Checked = true;
if (rdoDwarf.Checked == true)
rdoFighter.Checked = true;
if (rdoHalfElf.Checked == true)
{
string noHalfElfClass = "There is no recommended class for
Half-Elves.";
stsStatusLabel.Text = noHalfElfClass;
MessageBox.Show(noHalfElfClass, noClass);
}
if (rdoGnome.Checked == true)
rdoWizard.Checked = true;
if (rdoHalfling.Checked == true)
rdoRogue.Checked = true;
if (rdoHalfOrc.Checked == true)
rdoBarbarian.Checked = true;
}
}
}
}
debugger to see that it was being called twice, so I fixed that. This
time, though, the debugger does not show it (MessageBox.Show) being
called twice, and sometimes it *doesn't* get called twice! So I don't
know why it's happening. Here's the code. I hope it looks ok, if not
I'll post it a different way.
namespace CharacterManager
{
public partial class frmCharacterManager : Form
{
private string incompatibleSelection = "Incompatible Selection";
#region Class validators
public bool IsBarbarian()
{
if (rdoBarbarian.Checked == true)
return true;
return false;
}
public bool IsBard()
{
if (rdoBard.Checked == true)
return true;
return false;
}
public bool IsCleric()
{
if (rdoCleric.Checked == true)
return true;
return false;
}
public bool IsDruid()
{
if (rdoDruid.Checked == true)
return true;
return false;
}
public bool IsFighter()
{
if (rdoFemale.Checked == true)
return true;
return false;
}
public bool IsMonk()
{
if (rdoMonk.Checked == true)
return true;
return false;
}
public bool IsPaladin()
{
if (rdoPaladin.Checked == true)
return true;
return false;
}
public bool IsRanger()
{
if (rdoRanger.Checked == true)
return true;
return false;
}
public bool IsRogue()
{
if (rdoRogue.Checked == true)
return true;
return false;
}
public bool IsSorcerer()
{
if (rdoSorcerer.Checked == true)
return true;
return false;
}
public bool IsWizard()
{
if (rdoWizard.Checked == true)
return true;
return false;
}
#endregion
#region Alignment validators
public bool IsLawful()
{
if (rdoLawfulGood.Checked == true || rdoLawfulNeutral.Checked == true
|| rdoLawfulEvil.Checked == true)
return true;
return false;
}
public bool IsChaotic()
{
if (rdoChaoticGood.Checked == true || rdoChaoticNeutral.Checked ==
true || rdoChaoticEvil.Checked == true)
return true;
return false;
}
public bool IsGood()
{
if (rdoLawfulGood.Checked == true || rdoNeutralGood.Checked == true
|| rdoChaoticGood.Checked == true)
return true;
return false;
}
public bool IsNeutral()
{
if (rdoLawfulNeutral.Checked == true || rdoNeutralGood.Checked ==
true || rdoTrueNeutral.Checked == true || rdoNeutralEvil.Checked == true
|| rdoChaoticNeutral.Checked == true)
return true;
return false;
}
public bool IsEvil()
{
if (rdoLawfulEvil.Checked == true || rdoNeutralEvil.Checked == true
|| rdoChaoticEvil.Checked == true)
return true;
return false;
}
#endregion
#region Race event handlers
private void rdoHuman_CheckedChanged(object sender, EventArgs e)
{
SuggestClass();
}
private void rdoElf_CheckedChanged(object sender, EventArgs e)
{
SuggestClass();
}
private void rdoDwarf_CheckedChanged(object sender, EventArgs e)
{
SuggestClass();
}
private void rdoHalfElf_CheckedChanged(object sender, EventArgs e)
{
SuggestClass();
}
private void rdoGnome_CheckedChanged(object sender, EventArgs e)
{
SuggestClass();
}
private void rdoHalfling_CheckedChanged(object sender, EventArgs e)
{
SuggestClass();
}
private void rdoHalfOrc_CheckedChanged(object sender, EventArgs e)
{
SuggestClass();
}
#endregion
private void btnReorganizeAlignments_Click(object sender, EventArgs e)
{
Point p1;
Point p2;
p1 = rdoLawfulNeutral.Location;
p2 = rdoNeutralGood.Location;
rdoLawfulNeutral.Location = p2;
rdoNeutralGood.Location = p1;
p1 = rdoLawfulEvil.Location;
p2 = rdoChaoticGood.Location;
rdoLawfulEvil.Location = p2;
rdoChaoticGood.Location = p1;
p1 = rdoNeutralEvil.Location;
p2 = rdoChaoticNeutral.Location;
rdoNeutralEvil.Location = p2;
rdoChaoticNeutral.Location = p1;
}
public void SuggestClass()
{
if (chkSuggestedClass.Checked == true)
{
string noClass = "No Recommended Class";
if (rdoHuman.Checked == true)
{
string noHumanClass = "There is no suggested class for Humans.";
stsStatusLabel.Text = noHumanClass;
MessageBox.Show(noHumanClass, noClass);
}
if (rdoElf.Checked == true)
rdoWizard.Checked = true;
if (rdoDwarf.Checked == true)
rdoFighter.Checked = true;
if (rdoHalfElf.Checked == true)
{
string noHalfElfClass = "There is no recommended class for
Half-Elves.";
stsStatusLabel.Text = noHalfElfClass;
MessageBox.Show(noHalfElfClass, noClass);
}
if (rdoGnome.Checked == true)
rdoWizard.Checked = true;
if (rdoHalfling.Checked == true)
rdoRogue.Checked = true;
if (rdoHalfOrc.Checked == true)
rdoBarbarian.Checked = true;
}
}
}
}