Commit e667a1b1 authored by Axelander's avatar Axelander

Replaced further method bindings with x:Bind (issue #32)

parent afafbf7f
This diff is collapsed.
using Windows.UI.Xaml.Controls;
using SonicStreamer.Common.System;
using SonicStreamer.ViewModels;
namespace SonicStreamer.Controls
{
public sealed partial class ArtistInfoView : UserControl
{
public TrackListingViewModel TrackListingVm;
public ArtistInfoView()
{
InitializeComponent();
if (ResourceLoader.Current.GetResource(ref TrackListingVm, Constants.ViewModelTrackListing) == false)
TrackListingVm = new TrackListingViewModel();
}
}
}
\ No newline at end of file
......@@ -2,15 +2,12 @@
x:Class="SonicStreamer.Controls.MobilePlaybackView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SonicStreamer.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400"
DataContext="{StaticResource PlaybackVM}">
DataContext="{StaticResource PlaybackVM}"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary>
......@@ -35,13 +32,18 @@
</Grid.RowDefinitions>
<Grid Margin="0,0,0,5">
<Image Source="ms-appx:///Assets/cover.png" />
<Image Source="{Binding CurrentTrack.Cover.Uri}" Canvas.ZIndex="1" />
<Image Canvas.ZIndex="1" Source="{Binding CurrentTrack.Cover.Uri}" />
</Grid>
<StackPanel Grid.Row="1">
<TextBlock Text="{Binding CurrentTrack.Name}" Style="{StaticResource OrangeTitleTextBlockStyle}"
FontWeight="SemiBold" TextAlignment="Center" />
<TextBlock Text="{Binding CurrentTrack.Artist}" Style="{StaticResource OrangeSubtitleTextBlockStyle}"
TextAlignment="Center" />
<TextBlock
FontWeight="SemiBold"
Style="{StaticResource OrangeTitleTextBlockStyle}"
Text="{Binding CurrentTrack.Name}"
TextAlignment="Center" />
<TextBlock
Style="{StaticResource OrangeSubtitleTextBlockStyle}"
Text="{Binding CurrentTrack.Artist}"
TextAlignment="Center" />
</StackPanel>
</Grid>
<Grid Grid.Row="1" VerticalAlignment="Center">
......@@ -55,80 +57,63 @@
</Grid.RowDefinitions>
<Slider
Grid.ColumnSpan="2"
IsEnabled="{Binding PlaybackEnabled}"
Maximum="{Binding CurrentTrackDuration}"
Value="{Binding CurrentTrackPosition, Mode=TwoWay}"
IsThumbToolTipEnabled="False"
Style="{StaticResource OrangeSliderStyle}">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="PointerCaptureLost">
<Core:CallMethodAction TargetObject="{Binding Mode=OneWay}"
MethodName="PlaybackSlider_PointerCaptureLost" />
</Core:EventTriggerBehavior>
<Core:EventTriggerBehavior EventName="PointerEntered">
<Core:CallMethodAction TargetObject="{Binding Mode=OneWay}"
MethodName="PlaybackSlider_PointerEntered" />
</Core:EventTriggerBehavior>
<Core:EventTriggerBehavior EventName="PointerExited">
<Core:CallMethodAction TargetObject="{Binding Mode=OneWay}"
MethodName="PlaybackSlider_PointerExited" />
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</Slider>
<TextBlock Grid.Row="1" Text="{Binding PlayedDuration}"
Style="{StaticResource OrangeCaptionTextBlockStyle}" />
<TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding RemainingDuration}"
Style="{StaticResource OrangeCaptionTextBlockStyle}" HorizontalAlignment="Right" />
Maximum="{Binding CurrentTrackDuration}"
PointerCaptureLost="{x:Bind PlaybackVm.PlaybackSlider_PointerCaptureLost}"
PointerEntered="{x:Bind PlaybackVm.PlaybackSlider_PointerEntered}"
PointerExited="{x:Bind PlaybackVm.PlaybackSlider_PointerExited}"
Style="{StaticResource OrangeSliderStyle}"
Value="{Binding CurrentTrackPosition, Mode=TwoWay}" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
Style="{StaticResource OrangeCaptionTextBlockStyle}"
Text="{Binding PlayedDuration}" />
<TextBlock
Grid.Row="1"
Grid.Column="1"
HorizontalAlignment="Right"
Style="{StaticResource OrangeCaptionTextBlockStyle}"
Text="{Binding RemainingDuration}" />
</Grid>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="5">
<ToggleButton Background="Transparent" Style="{StaticResource PlaybackToggleButtonStyle}"
IsChecked="{Binding IsRepeating, Mode=TwoWay}">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Checked">
<Core:CallMethodAction TargetObject="{Binding Mode=OneWay}" MethodName="SwitchOnRepeatingMode" />
</Core:EventTriggerBehavior>
<Core:EventTriggerBehavior EventName="Unchecked">
<Core:CallMethodAction TargetObject="{Binding Mode=OneWay}" MethodName="SwitchOffRepeatingMode" />
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
<StackPanel
Grid.Row="2"
Margin="5"
HorizontalAlignment="Center"
Orientation="Horizontal">
<ToggleButton
Checked="{x:Bind PlaybackVm.SwitchOnRepeatingMode}"
IsChecked="{Binding IsRepeating, Mode=TwoWay}"
Style="{StaticResource PlaybackToggleButtonStyle}"
Unchecked="{x:Bind PlaybackVm.SwitchOffRepeatingMode}">
<SymbolIcon Symbol="RepeatAll" />
</ToggleButton>
<Line Y1="40" Stroke="Orange" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0" />
<Button IsEnabled="{Binding PlaybackEnabled}" Style="{StaticResource PlaybackButtonStyle}">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Click">
<Core:CallMethodAction TargetObject="{Binding Mode=OneWay}" MethodName="PlayPrevious" />
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
<Line
Margin="5,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stroke="Orange"
Y1="40" />
<Button Click="{x:Bind PlaybackVm.PlayPrevious}" Style="{StaticResource PlaybackButtonStyle}">
<SymbolIcon Symbol="Previous" />
</Button>
<Button IsEnabled="{Binding PlaybackEnabled}" Style="{StaticResource PlaybackButtonStyle}">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Click">
<Core:CallMethodAction TargetObject="{Binding Mode=OneWay}" MethodName="Play" />
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
<Button Click="{x:Bind PlaybackVm.Play}" Style="{StaticResource PlaybackButtonStyle}">
<SymbolIcon Symbol="{Binding PlayButtonIcon}" />
</Button>
<Button IsEnabled="{Binding PlaybackEnabled}" Style="{StaticResource PlaybackButtonStyle}">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Click">
<Core:CallMethodAction TargetObject="{Binding Mode=OneWay}" MethodName="PlayNext" />
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
<Button Click="{x:Bind PlaybackVm.PlayNext}" Style="{StaticResource PlaybackButtonStyle}">
<SymbolIcon Symbol="Next" />
</Button>
<Line Y1="40" Stroke="Orange" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0" />
<ToggleButton Background="Transparent" Style="{StaticResource PlaybackToggleButtonStyle}"
IsChecked="{Binding IsShuffling, Mode=TwoWay}">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Checked">
<Core:CallMethodAction TargetObject="{Binding Mode=OneWay}" MethodName="SwitchOnShuffleMode" />
</Core:EventTriggerBehavior>
<Core:EventTriggerBehavior EventName="Unchecked">
<Core:CallMethodAction TargetObject="{Binding Mode=OneWay}" MethodName="SwitchOffShuffleMode" />
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
<Line
Margin="5,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stroke="Orange"
Y1="40" />
<ToggleButton
Checked="{x:Bind PlaybackVm.SwitchOnShuffleMode}"
IsChecked="{Binding IsShuffling, Mode=TwoWay}"
Style="{StaticResource PlaybackToggleButtonStyle}"
Unchecked="{x:Bind PlaybackVm.SwitchOffShuffleMode}">
<SymbolIcon Symbol="Shuffle" />
</ToggleButton>
</StackPanel>
......
using Windows.UI.Xaml.Controls;
using SonicStreamer.Common.System;
using SonicStreamer.ViewModels;
namespace SonicStreamer.Controls
{
public sealed partial class MobilePlaybackView : UserControl
{
public PlaybackViewModel PlaybackVm;
public MobilePlaybackView()
{
InitializeComponent();
if (ResourceLoader.Current.GetResource(ref PlaybackVm, Constants.ViewModelPlayback) == false)
PlaybackVm = new PlaybackViewModel();
}
}
}
\ No newline at end of file
......@@ -2,17 +2,12 @@
x:Class="SonicStreamer.Controls.SimilarArtistsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SonicStreamer.Controls"
xmlns:common="using:SonicStreamer.Common"
xmlns:controls="using:SonicStreamer.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
mc:Ignorable="d"
d:DataContext="{StaticResource TrackListingVM}"
d:DesignHeight="600"
d:DesignWidth="1020"
d:DataContext="{StaticResource TrackListingVM}">
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary>
......@@ -22,12 +17,13 @@
<ResourceDictionary Source="ms-appx:///Styles/ListingItemStyles.xaml" />
<ResourceDictionary Source="ms-appx:///Styles/ButtonStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
<common:BooleanToVisibilityConverter x:Key="BoolToVis" />
<Style x:Key="SectionGridStyle" TargetType="Grid">
<Setter Property="Margin" Value="0,10,20,0" />
</Style>
<Style x:Key="InfoSectionHeaderTextBlockStyle" TargetType="TextBlock"
BasedOn="{StaticResource OrangeSubtitleTextBlockStyle}">
<Style
x:Key="InfoSectionHeaderTextBlockStyle"
BasedOn="{StaticResource OrangeSubtitleTextBlockStyle}"
TargetType="TextBlock">
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="FontStyle" Value="Italic" />
<Setter Property="Margin" Value="0,10" />
......@@ -35,24 +31,24 @@
</ResourceDictionary>
</UserControl.Resources>
<ScrollViewer HorizontalScrollMode="Disabled" HorizontalSnapPointsType="None" IsHorizontalRailEnabled="False"
IsHorizontalScrollChainingEnabled="False">
<ScrollViewer
HorizontalScrollMode="Disabled"
HorizontalSnapPointsType="None"
IsHorizontalRailEnabled="False"
IsHorizontalScrollChainingEnabled="False">
<StackPanel d:DataContext="{Binding ArtistInfo}" Orientation="Vertical">
<!--Subsonic-->
<!-- Subsonic -->
<Grid Style="{StaticResource SectionGridStyle}">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="Available on server" Style="{StaticResource InfoSectionHeaderTextBlockStyle}" />
<TextBlock Style="{StaticResource InfoSectionHeaderTextBlockStyle}" Text="Available on server" />
<ListView
Grid.Row="1"
ItemClick="SubsonicSimilarArtist_ItemClick"
ItemsSource="{Binding SubsonicSimilarArtists}"
ItemTemplate="{StaticResource ListingItemTemplate}"
Style="{StaticResource ListingListViewStyle}"
IsItemClickEnabled="True"
SelectionMode="None"
ItemClick="SubsonicSimilarArtist_ItemClick">
Style="{StaticResource ListingListViewStyle}">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid Orientation="Horizontal" />
......@@ -60,35 +56,34 @@
</ListView.ItemsPanel>
</ListView>
</Grid>
<!--last.fm-->
<!-- last.fm -->
<Grid Style="{StaticResource SectionGridStyle}">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="Suggestions from last.fm" Style="{StaticResource InfoSectionHeaderTextBlockStyle}" />
<TextBlock Style="{StaticResource InfoSectionHeaderTextBlockStyle}" Text="Suggestions from last.fm" />
<ListView
Grid.Row="1"
HorizontalAlignment="Center"
IsItemClickEnabled="True"
SelectionMode="None"
ItemsSource="{Binding LastFmSimilarArtists}">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="ItemClick">
<Core:CallMethodAction TargetObject="{Binding Mode=OneWay}" MethodName="SimilarArtistClick" />
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
ItemClick="{x:Bind TrackListingVm.ArtistInfo.SimilarArtistClick}"
ItemsSource="{Binding LastFmSimilarArtists}"
SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock
Text="{Binding Name}"
Style="{StaticResource OrangeBaseTextBlockStyle}"
Margin="0,0,0,10"
FontSize="25"
FontWeight="SemiBold"
TextWrapping="Wrap"
Margin="0,0,0,10" />
<Image Source="{Binding Cover.Uri}" Stretch="UniformToFill" MaxHeight="200" />
Style="{StaticResource OrangeBaseTextBlockStyle}"
Text="{Binding Name}"
TextWrapping="Wrap" />
<Image
MaxHeight="200"
Source="{Binding Cover.Uri}"
Stretch="UniformToFill" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
......
using SonicStreamer.Pages;
using Windows.UI.Xaml.Controls;
using SonicStreamer.Common.System;
using SonicStreamer.ViewModels;
namespace SonicStreamer.Controls
{
public sealed partial class SimilarArtistsView : UserControl
{
public TrackListingViewModel TrackListingVm;
public SimilarArtistsView()
{
InitializeComponent();
if (ResourceLoader.Current.GetResource(ref TrackListingVm, Constants.ViewModelTrackListing) == false)
TrackListingVm = new TrackListingViewModel();
}
private void SubsonicSimilarArtist_ItemClick(object sender, ItemClickEventArgs e)
......
......@@ -3,9 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:SonicStreamer.Controls"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
DataContext="{StaticResource FolderVM}"
mc:Ignorable="d">
......@@ -38,31 +36,22 @@
<CommandBar.Resources>
<Style BasedOn="{StaticResource OrangeAppBarButtonStyle}" TargetType="AppBarButton" />
</CommandBar.Resources>
<AppBarButton Icon="Play" Label="Play Selection">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Click">
<core:CallMethodAction MethodName="PlayClick" TargetObject="{Binding Mode=OneWay}" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</AppBarButton>
<AppBarButton Icon="Add" Label="Add to Playback">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Click">
<core:CallMethodAction MethodName="AddClick" TargetObject="{Binding Mode=OneWay}" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</AppBarButton>
<AppBarButton
Click="{x:Bind FolderVm.PlayClick}"
Icon="Play"
Label="Play Selection" />
<AppBarButton
Click="{x:Bind FolderVm.AddClick}"
Icon="Add"
Label="Add to Playback" />
<AppBarButton
Click="AddToPlaylist_Click"
Icon="Favorite"
Label="Add to Playlist" />
<AppBarButton Icon="Download" Label="Download">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Click">
<core:CallMethodAction MethodName="DownloadTracksClick" TargetObject="{Binding Mode=OneWay}" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</AppBarButton>
<AppBarButton
Click="{x:Bind FolderVm.DownloadTracksClick}"
Icon="Download"
Label="Download" />
</CommandBar>
</Page.BottomAppBar>
......
......@@ -3,9 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:SonicStreamer.Controls"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="playbackPage"
DataContext="{StaticResource PlaybackVM}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment