forked from Alxandr/SpotiFire
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
2,425 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<Application x:Class="SpotiFire.SpotiClient.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<Application.Resources> | ||
|
||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.ServiceModel; | ||
using System.Windows; | ||
using SpotiFire.SpotiClient.ServiceReference; | ||
|
||
namespace SpotiFire.SpotiClient | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application, ServiceReference.SpotifyCallback | ||
{ | ||
private ServiceReference.SpotifyClient client; | ||
|
||
public App() | ||
: base() | ||
{ | ||
client = new ServiceReference.SpotifyClient(new InstanceContext(this)); | ||
bool ok = false; | ||
try { ok = client.Authenticate("tester"); } | ||
catch { throw; } | ||
if (!ok) | ||
Shutdown(); | ||
else | ||
MainWindow = new MainWindow(this); | ||
} | ||
|
||
public void LoginComplete() | ||
{ | ||
Dispatcher.BeginInvoke(new Action(() => | ||
{ | ||
MainWindow.Show(); | ||
})); | ||
} | ||
|
||
public void LoginFailed() | ||
{ | ||
RequireLogin(); | ||
} | ||
|
||
public void RequireLogin() | ||
{ | ||
Dispatcher.BeginInvoke(new Action(() => | ||
{ | ||
SpotifyLogin login = new SpotifyLogin(); | ||
login.ShowDialog(); | ||
string username = login.Username.Text; | ||
if (!string.IsNullOrWhiteSpace(username)) | ||
client.Login(login.Username.Text, login.Password.Password); | ||
})); | ||
} | ||
|
||
public void Ping() | ||
{ | ||
client.Pong(); | ||
} | ||
|
||
public PlaylistTreeItem[] GetPlaylists() | ||
{ | ||
return MakePlaylistTree(client.GetPlaylists()).ToArray(); | ||
} | ||
|
||
private IEnumerable<PlaylistTreeItem> MakePlaylistTree(Playlist[] playlists) | ||
{ | ||
for (int i = 0; i < playlists.Length; i++) | ||
{ | ||
if (playlists[i].Type == PlaylistType.Playlist) | ||
yield return new PlaylistTreeItem(playlists[i]); | ||
|
||
else if (playlists[i].Type == PlaylistType.FolderStart) | ||
{ | ||
Playlist p = playlists[i]; | ||
int depth = 1; | ||
IList<Playlist> intermedium = new List<Playlist>(); | ||
for (i++; i < playlists.Length; i++) | ||
{ | ||
if (playlists[i].Type == PlaylistType.Playlist) | ||
intermedium.Add(playlists[i]); | ||
else if (playlists[i].Type == PlaylistType.FolderStart) | ||
{ | ||
intermedium.Add(playlists[i]); | ||
depth++; | ||
} | ||
else if (playlists[i].Type == PlaylistType.FolderEnd) | ||
{ | ||
if (--depth == 0) | ||
{ | ||
yield return new PlaylistTreeItem(p, MakePlaylistTree(intermedium.ToArray()).ToArray()); | ||
break; | ||
} | ||
else | ||
{ | ||
intermedium.Add(playlists[i]); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
yield break; | ||
} | ||
|
||
public Track[] GetPlaylistTracks(Guid guid) | ||
{ | ||
return client.GetPlaylistTracks(guid); | ||
} | ||
|
||
public void PlayPlaylistTrack(Guid guid, int index) | ||
{ | ||
client.PlayPlaylistTrack(guid, index); | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<Window x:Class="SpotiFire.SpotiClient.MainWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
Title="MainWindow" Height="500" Width="800" Loaded="Window_Loaded"> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="200" /> | ||
<ColumnDefinition /> | ||
</Grid.ColumnDefinitions> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="20" /> | ||
<RowDefinition /> | ||
<RowDefinition Height="50" /> | ||
</Grid.RowDefinitions> | ||
|
||
<Menu Grid.ColumnSpan="2"> | ||
<MenuItem Header="_File"> | ||
<MenuItem Header="_New Playlist"></MenuItem> | ||
<MenuItem Header="New _Playlist Folder"></MenuItem> | ||
<Separator /> | ||
<MenuItem Header="_Log Out"></MenuItem> | ||
<Separator /> | ||
<MenuItem Header="_Exit"></MenuItem> | ||
</MenuItem> | ||
<MenuItem Header="_Edit"></MenuItem> | ||
<MenuItem Header="_View"></MenuItem> | ||
<MenuItem Header="_Playback"></MenuItem> | ||
<MenuItem Header="_Help"></MenuItem> | ||
</Menu> | ||
|
||
<StackPanel Grid.ColumnSpan="2" Grid.Row="1" Orientation="Horizontal"> | ||
<Button Content="Back"></Button> | ||
<Button Content="Forward"></Button> | ||
<TextBox Width="200" Margin="10,0,0,0"></TextBox> | ||
<Button Content="Search"></Button> | ||
</StackPanel> | ||
|
||
<Grid Grid.Row="2"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition /> | ||
<ColumnDefinition Width="20" /> | ||
</Grid.ColumnDefinitions> | ||
</Grid> | ||
|
||
<TreeView Grid.Row="3" BorderThickness="0" x:Name="SpotifyTree" SelectedItemChanged="SpotifyTree_SelectedItemChanged"> | ||
<TreeView.ItemTemplate> | ||
<HierarchicalDataTemplate ItemsSource="{Binding Path=Children}"> | ||
<TextBlock Text="{Binding Path=Name}" /> | ||
</HierarchicalDataTemplate> | ||
</TreeView.ItemTemplate> | ||
</TreeView> | ||
|
||
<DataGrid Grid.Row="3" Grid.Column="1" x:Name="SpotifySongs" MouseDoubleClick="SpotifySongs_MouseDoubleClick" AreRowDetailsFrozen="True" IsReadOnly="True" SelectionMode="Single"> | ||
</DataGrid> | ||
</Grid> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System.Windows; | ||
using SpotiFire.SpotiClient.ServiceReference; | ||
|
||
namespace SpotiFire.SpotiClient | ||
{ | ||
/// <summary> | ||
/// Interaction logic for MainWindow.xaml | ||
/// </summary> | ||
public partial class MainWindow : Window | ||
{ | ||
App app; | ||
Playlist playlist = null; | ||
public MainWindow(App app) | ||
{ | ||
this.app = app; | ||
InitializeComponent(); | ||
} | ||
|
||
private void Window_Loaded(object sender, RoutedEventArgs e) | ||
{ | ||
PlaylistTreeItem[] playlists = app.GetPlaylists(); | ||
SpotifyTree.ItemsSource = playlists; | ||
} | ||
|
||
private void SpotifyTree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e) | ||
{ | ||
PlaylistTreeItem playlist = e.NewValue as PlaylistTreeItem; | ||
if (playlist.Type == ServiceReference.PlaylistType.Playlist) | ||
{ | ||
Track[] tracks = app.GetPlaylistTracks(playlist.Id); | ||
this.playlist = playlist; | ||
|
||
SpotifySongs.ItemsSource = tracks; | ||
} | ||
} | ||
|
||
private void SpotifySongs_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) | ||
{ | ||
int index = SpotifySongs.SelectedIndex; | ||
app.PlayPlaylistTrack(playlist.Id, index); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using SpotiFire.SpotiClient.ServiceReference; | ||
|
||
namespace SpotiFire.SpotiClient | ||
{ | ||
public class PlaylistTreeItem : Playlist | ||
{ | ||
public PlaylistTreeItem(Playlist playlist, PlaylistTreeItem[] children = null) | ||
{ | ||
if (children == null) | ||
children = new PlaylistTreeItem[0]; | ||
Children = children; | ||
|
||
this.Description = playlist.Description; | ||
this.ExtensionData = playlist.ExtensionData; | ||
this.Id = playlist.Id; | ||
this.ImageId = playlist.ImageId; | ||
this.IsColaberativ = playlist.IsColaberativ; | ||
this.Name = playlist.Name; | ||
this.Type = playlist.Type; | ||
} | ||
public PlaylistTreeItem[] Children { get; private set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Reflection; | ||
using System.Resources; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using System.Windows; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("SpotiFire.Client")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("Microsoft")] | ||
[assembly: AssemblyProduct("SpotiFire.Client")] | ||
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
//In order to begin building localizable applications, set | ||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file | ||
//inside a <PropertyGroup>. For example, if you are using US english | ||
//in your source files, set the <UICulture> to en-US. Then uncomment | ||
//the NeutralResourceLanguage attribute below. Update the "en-US" in | ||
//the line below to match the UICulture setting in the project file. | ||
|
||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] | ||
|
||
|
||
[assembly: ThemeInfo( | ||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||
//(used if a resource is not found in the page, | ||
// or application resource dictionaries) | ||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||
//(used if a resource is not found in the page, | ||
// app, or any theme specific resource dictionaries) | ||
)] | ||
|
||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.