- soccerlight.zip
- Soccerlight.Controls
- Soccerlight.Core
- Soccerlight.sln
- Soccerlight.Web
- Soccerlight
- App.xaml
- App.xaml.cs
- BasePage.cs
- Images
- ALG.png
- ARG.png
- AUS.png
- BRA.png
- CHI.png
- CIV.png
- CMR.png
- DEN.png
- ENG.png
- ESP.png
- FRA.png
- GER.png
- GHA.png
- goalnet.png
- Grass.png
- GRE.png
- HON.png
- ITA.png
- Jabulani.png
- JPN.png
- KOR.png
- mask.png
- MEX.png
- NED.png
- NGA.png
- NZL.png
- PAR.png
- PlayerPointer.PNG
- POR.png
- PRK.png
- RSA.png
- ScoreMask.png
- Soccerlight.png
- Soccerlight_bkp.png
- SouthAfrica.png
- SRB.png
- SUI.png
- SVK.png
- SVN.png
- Thumbs.db
- URU.png
- USA.png
- Properties
- Soccerlight.csproj
- Soccerlight.csproj.user
- Sounds
- Shot01.wav
- View
|
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace Soccerlight.Controls
{
[TemplateVisualState(Name = "Normal", GroupName = "ViewStates")]
[TemplateVisualState(Name = "Highlighted", GroupName = "ViewStates")]
public class GreenButton : Button
{
public static readonly DependencyProperty ImageContentProperty =
DependencyProperty.Register("ImageContent", typeof(object),
typeof(GreenButton), null);
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string),
typeof(GreenButton), null);
public static readonly DependencyProperty IsHighlightedProperty =
DependencyProperty.Register("IsHighlighted", typeof(bool), typeof(GreenButton), null);
public GreenButton()
{
DefaultStyleKey = typeof(GreenButton);
this.IsEnabledChanged += new DependencyPropertyChangedEventHandler(GreenButton_IsEnabledChanged);
}
void GreenButton_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (!(bool)e.NewValue)
{
this.IsHighlighted = false;
ChangeVisualState(true);
this.Opacity = 0.35;
}
else
{
this.Opacity = 1.00;
VisualStateManager.GoToState(this, "Normal", true);
}
}
public object ImageContent
{
get
{
return base.GetValue(ImageContentProperty);
}
set
{
base.SetValue(ImageContentProperty, value);
}
}
public object Text
{
get
{
return base.GetValue(TextProperty);
}
set
{
base.SetValue(TextProperty, value);
}
}
public bool IsHighlighted
{
get
{
return (bool)base.GetValue(IsHighlightedProperty);
}
set
{
base.SetValue(IsHighlightedProperty, value);
ChangeVisualState(true);
}
}
private void ChangeVisualState(bool useTransitions)
{
if (IsHighlighted)
{
VisualStateManager.GoToState(this, "Highlighted", useTransitions);
}
else
{
VisualStateManager.GoToState(this, "Normal", useTransitions);
}
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
this.MouseEnter += new MouseEventHandler(GreenButton_MouseEnter);
this.MouseLeave += new MouseEventHandler(GreenButton_MouseLeave);
this.MouseMove += new MouseEventHandler(GreenButton_MouseMove);
this.HorizontalContentAlignment = HorizontalAlignment.Center;
this.ChangeVisualState(false);
}
void GreenButton_MouseMove(object sender, MouseEventArgs e)
{
this.IsHighlighted = true;
ChangeVisualState(true);
}
void GreenButton_MouseEnter(object sender, MouseEventArgs e)
{
this.IsHighlighted = true;
ChangeVisualState(true);
}
void GreenButton_MouseLeave(object sender, MouseEventArgs e)
{
this.IsHighlighted = false;
ChangeVisualState(true);
}
private void NormalButton_Click(object sender, RoutedEventArgs e)
{
this.IsHighlighted = !this.IsHighlighted;
ChangeVisualState(true);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.