Skip to content

Commit

Permalink
Merge pull request #86 from flagbug/taskbar-buttons
Browse files Browse the repository at this point in the history
Added playback control buttons to the TaskBar
  • Loading branch information
flagbug committed Jun 17, 2014
2 parents c20e6c1 + 646f728 commit fc5fe06
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Espera/Espera.View/Espera.View.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,14 @@
<Name>Espera.Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Next.png" />
<Resource Include="Images\Play.png" />
<Resource Include="Images\Previous.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Pause.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Binary file added Espera/Espera.View/Images/Next.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Espera/Espera.View/Images/Pause.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Espera/Espera.View/Images/Play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Espera/Espera.View/Images/Previous.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions Espera/Espera.View/Views/ShellView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,26 @@
</dialogs:SimpleDialog>
</ResourceDictionary>
</Window.Resources>
<Window.TaskbarItemInfo>
<TaskbarItemInfo>
<TaskbarItemInfo.ThumbButtonInfos>
<ThumbButtonInfoCollection>
<ThumbButtonInfo x:Name="PauseContinueTaskbarButton"
Command="{Binding PauseContinueCommand}"
DismissWhenClicked="False">
</ThumbButtonInfo>
<ThumbButtonInfo Command="{Binding PreviousSongCommand}"
DismissWhenClicked="False"
Description="Previous Song"
ImageSource="../Images/Previous.png" />
<ThumbButtonInfo Command="{Binding NextSongCommand}"
DismissWhenClicked="False"
Description="Next Song"
ImageSource="../Images/Next.png" />
</ThumbButtonInfoCollection>
</TaskbarItemInfo.ThumbButtonInfos>
</TaskbarItemInfo>
</Window.TaskbarItemInfo>
<Controls:MetroWindow.RightWindowCommands>
<Controls:WindowCommands>
<Button Command="{Binding Path=ShowSettingsCommand}" Content="settings" />
Expand Down
15 changes: 15 additions & 0 deletions Espera/Espera.View/Views/ShellView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using MahApps.Metro;
using MahApps.Metro.Controls.Dialogs;
using ReactiveUI;
using Splat;
using YoutubeExtractor;
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
using ListView = System.Windows.Controls.ListView;
Expand All @@ -42,6 +43,7 @@ public ShellView()
this.WirePlayer();
this.WireScreenStateUpdater();
this.WireDragAndDrop();
this.WireTaskbarButtons();
try
{
Expand Down Expand Up @@ -407,5 +409,18 @@ private void WireScreenStateUpdater()
source.AddHook(HandleWindowMove);
});
}

private void WireTaskbarButtons()
{
this.shellViewModel.WhenAnyValue(x => x.IsPlaying, x => x ? "Pause" : "Play")
.BindTo(this.PauseContinueTaskbarButton, x => x.Description);
this.shellViewModel.WhenAnyValue(x => x.IsPlaying, x => x ? "Pause" : "Play")
.Select(x => string.Format("pack://application:,,,/Espera;component/Images/{0}.png", x))
.Select(x => BitmapLoader.Current.LoadFromResource(x, null, null).ToObservable())
.Switch()
.Select(x => x.ToNative())
.ObserveOn(RxApp.MainThreadScheduler)
.BindTo(this.PauseContinueTaskbarButton, x => x.ImageSource);
}
}
}

0 comments on commit fc5fe06

Please sign in to comment.