Here's what I have:
private void HeroMouseEnter(object sender, MouseEventArgs e)
{
//I did things this was because it is easier to maintain code in a sense that is is a generic
//method made for all of the heroes images.
((Image)sender).Source = GetGlowingImage(((Image)sender).Name);
}
private void HeroMouseLeave(object sender, MouseEventArgs e)
{
//I did this IF conditional because I want to ask, "If the sender object
//is the hero selected, then do NOT change the image to normal.
if (SelectedHero != ((Image)sender).Name)
{
//I did things this was because it is easier to maintain code in a sense that is is a generic
//method made for all of the heroes images.
((Image)sender).Source = GetNormalImage(((Image)sender).Name);
}
}
private void HeroMouseClick(object sender, MouseEventArgs e)
{
if (!HasSelectedAHeroBefore)
{
HasSelectedAHeroBefore = true;
//Created a generic way to play the announcers voice according to where a user clicked.
string soundfile = "AnnouncerVoice/" + ((Image)sender).Name + ".mp3";
soundPlayer.Open(new Uri(soundfile, UriKind.Relative));
soundPlayer.Play();
//I call the MouseEnter event in order to have the clicked picture glow and set the Selected bool to true
//to keep it highlighted.
SelectedHero = ((Image)sender).Name;
}
else if (HasSelectedAHeroBefore)
{
//Created a generic way to play the announcers voice according to where a user clicked.
string soundfile = "AnnouncerVoice/" + ((Image)sender).Name + ".mp3";
soundPlayer.Open(new Uri(soundfile, UriKind.Relative));
soundPlayer.Play();
//I call the MouseEnter event in order to have the clicked picture glow and set the Selected bool to true
//to keep it highlighted.
SelectedHero = ((Image)sender).Name;
PreviousSelectedHero = ((Image)sender).Name;
}
}
The cliffnotes of what I want. When a user moves his mouse around my pictures, I want the pictures to Glow. I achieve this by changing the image to a photoshopped one (with glow) on MouseEnter. On MouseLeave, I switch the pic back to normal.
When a user click, I want the clicked Image to stay with the Glow one I made. All the while when the user moves his mouse I still want them to glow on MouseEnter and deglow on MouseLeave.
Finally, if a user click an image different than the selected one, the clicked picture must stay selected (glowing) like the one before.
I'm so stumped and I'm sure it's an easy fix, I'm just a bit rusty.
Thanks tremendously for the help. :D
Edit: Aplogise, I forgot to mention what isn't working. EVERYTHING words exacty how I want it to, however when I click another image, the previous one stays glowing (like selected), until I enter the mouse on it and leave it.
Edit2: I've added something that may work. But I don't know how to select a Image control by it's name. Any help?
else if (HasSelectedAHeroBefore)
{
//Created a generic way to play the announcers voice according to where a user clicked.
string soundfile = "AnnouncerVoice/" + ((Image)sender).Name + ".mp3";
soundPlayer.Open(new Uri(soundfile, UriKind.Relative));
soundPlayer.Play();
//I call the MouseEnter event in order to have the clicked picture glow and set the Selected bool to true
//to keep it highlighted.
PreviousSelectedHero = SelectedHero;
//Here I want to select the Image control by it's Name property. But it says I can't convert string to Image. ANy help?
GetNormalImage(((Image)PreviousSelectedHero).Name);
SelectedHero = ((Image)sender).Name;
}