- podder.zip
- Podder
- Podder.exe
- Podder.exe.config
- PodderLib.dll
- Skins
- GrantHinkson
- Infragistics.ToyBox.dll
- Infragistics3.WPF.DataPresenter.v7.2.dll
- Infragistics3.WPF.Editors.v7.2.dll
- Infragistics3.WPF.v7.2.dll
- Podder.GrantHinkson.dll
- podder_src.zip
- Podder_src
|
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Threading;
using Podder.Model;
namespace Podder.DefaultSkin.Controls
{
/// <summary>
/// A ToggleButton that knows how to both play and pause.
/// </summary>
public partial class PlayButton : ToggleButton
{
#region Constructor
public PlayButton()
{
InitializeComponent();
PodderDataSource.Instance.EpisodePlayerSettings.PropertyChanged += this.OnEpisodePlayerSettingsPropertyChanged;
this.IsChecked = PodderDataSource.Instance.EpisodePlayerSettings.IsPlaying;
}
#endregion // Constructor
#region State
private static readonly DependencyPropertyKey StatePropertyKey =
DependencyProperty.RegisterReadOnly(
"State",
typeof(PlayButtonState),
typeof(PlayButton),
new UIPropertyMetadata(PlayButtonState.Play));
public static readonly DependencyProperty StateProperty = StatePropertyKey.DependencyProperty;
public PlayButtonState State
{
get { return (PlayButtonState)GetValue(StateProperty); }
private set { SetValue(StatePropertyKey, value); }
}
#endregion // State
#region OnEpisodePlayerSettingsPropertyChanged
void OnEpisodePlayerSettingsPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "IsPlaying")
{
// Note: I tried to establish this relationship as a Binding, but in certain
// situations the property did not update correclty. If you bind the IsChecked
// property in XAML like this: IsChecked="{Binding EpisodePlayerSettings.IsPlaying, Mode=OneWay}"
// it will not update the IsChecked property when you click the Play button, deselect
// the selected item in the list of Episodes, and click the Stop button.
// This is a palatable workaround, in my opinion.
this.IsChecked = PodderDataSource.Instance.EpisodePlayerSettings.IsPlaying;
}
}
#endregion // OnEpisodePlayerSettingsPropertyChanged
#region Base Class Overrides
protected override void OnChecked(RoutedEventArgs e)
{
base.OnChecked(e);
// Delay a call which sets the State so that it
// occurs after the Click event. This allows
// the current Command to be effective until
// the entire click processing is complete.
base.Dispatcher.BeginInvoke(
DispatcherPriority.Background,
(Action)delegate
{
this.State = PlayButtonState.Pause;
});
}
protected override void OnUnchecked(RoutedEventArgs e)
{
base.OnUnchecked(e);
base.Dispatcher.BeginInvoke(
DispatcherPriority.Background,
(Action)delegate
{
this.State = PlayButtonState.Play;
});
}
#endregion // Base Class Overrides
}
public enum PlayButtonState
{
Play,
Pause
}
}
|
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.