Skip to content

Commit

Permalink
WPF: Sync window is now completed. Library Browser in Main window wor…
Browse files Browse the repository at this point in the history
…ks (missing contextual menus though).
  • Loading branch information
ycastonguay committed Oct 21, 2013
1 parent e70d0cb commit d3934d9
Show file tree
Hide file tree
Showing 20 changed files with 582 additions and 210 deletions.
6 changes: 3 additions & 3 deletions MPfm/MPfm.Library/Services/SyncListenerService.cs
Expand Up @@ -582,9 +582,9 @@ public static string GetLocalIPAddress()
foreach (var ni in NetworkInterface.GetAllNetworkInterfaces())
{
//Console.WriteLine("GetIPAddress - NetworkInterface: {0} {1}", ni.Name, ni.NetworkInterfaceType.ToString());
if(ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 ||
ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
{
if((ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 ||
ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet))
{
IPAddress ip = null;
foreach (var a in ni.GetIPProperties().UnicastAddresses)
{
Expand Down
19 changes: 18 additions & 1 deletion MPfm/MPfm.WPF/Classes/Controls/MPfmButton.cs
@@ -1,4 +1,21 @@
using System;
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand Down
67 changes: 67 additions & 0 deletions MPfm/MPfm.WPF/Classes/Controls/MPfmTreeViewItem.cs
@@ -0,0 +1,67 @@
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System.Windows;
using System.Windows.Controls;

namespace MPfm.WPF.Classes.Controls
{
/// <summary>
/// http://stackoverflow.com/questions/15640263/how-to-add-a-before-expanding-event-to-the-wpf-treeview-without-using-threads
/// </summary>
public class MPfmTreeViewItem : TreeViewItem
{
public bool IsDummyNode { get; set; }

public static readonly RoutedEvent CollapsingEvent = EventManager.RegisterRoutedEvent("Collapsing", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MPfmTreeViewItem));
public static readonly RoutedEvent ExpandingEvent = EventManager.RegisterRoutedEvent("Expanding", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MPfmTreeViewItem));

public event RoutedEventHandler Collapsing
{
add { AddHandler(CollapsingEvent, value); }
remove { RemoveHandler(CollapsingEvent, value); }
}

public event RoutedEventHandler Expanding
{
add { AddHandler(ExpandingEvent, value); }
remove { RemoveHandler(ExpandingEvent, value); }
}

protected override void OnExpanded(RoutedEventArgs e)
{
OnExpanding(new RoutedEventArgs(ExpandingEvent, this));
base.OnExpanded(e);
}

protected override void OnCollapsed(RoutedEventArgs e)
{
OnCollapsing(new RoutedEventArgs(CollapsingEvent, this));
base.OnCollapsed(e);
}

protected virtual void OnCollapsing(RoutedEventArgs e)
{
RaiseEvent(e);
}

protected virtual void OnExpanding(RoutedEventArgs e)
{
RaiseEvent(e);
}
}
}
@@ -0,0 +1,70 @@
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Windows.Data;
using MPfm.MVP.Models;

namespace MPfm.WPF.Classes.Converters
{
public class LibraryBrowserImagePathConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var entityType = (LibraryBrowserEntityType) value;
switch (entityType)
{
case LibraryBrowserEntityType.AllSongs:
return "/Resources/Images/Icons/windows.png";
break;
case LibraryBrowserEntityType.Artists:
return "/Resources/Images/Icons/user.png";
break;
case LibraryBrowserEntityType.Albums:
return "/Resources/Images/Icons/vinyl.png";
break;
case LibraryBrowserEntityType.Artist:
return "/Resources/Images/Icons/user.png";
break;
case LibraryBrowserEntityType.ArtistAlbum:
return "/Resources/Images/Icons/vinyl.png";
break;
case LibraryBrowserEntityType.Album:
return "/Resources/Images/Icons/vinyl.png";
break;
case LibraryBrowserEntityType.Song:
break;
case LibraryBrowserEntityType.Dummy:
break;
}

return null;
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return "";
}

//private string GetImageName(string text)
//{
// string name = "";
// name = text.ToLower() + ".png";
// return name;
//}
}
}
54 changes: 31 additions & 23 deletions MPfm/MPfm.WPF/Classes/Windows/MainWindow.xaml
@@ -1,14 +1,22 @@
<base:BaseWindow x:Class="MPfm.WPF.Classes.Windows.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:base="clr-namespace:MPfm.WPF.Classes.Windows.Base"
xmlns:base="clr-namespace:MPfm.WPF.Classes.Windows.Base"
xmlns:converters="clr-namespace:MPfm.WPF.Classes.Converters"
xmlns:models="clr-namespace:MPfm.MVP.Models;assembly=MPfm.MVP"
WindowStartupLocation="CenterScreen"
Title="Sessions" Height="600" Width="900" Icon="/MPfm.WPF;component/Resources/Icon.ico">
<Window.Resources>
<converters:LibraryBrowserImagePathConverter x:Key="LibraryBrowserImagePathConverter" />
<Style x:Key="TreeViewItemStyle" TargetType="TreeViewItem">
<Setter Property="Margin" Value="0,2,0,2" />
</Style>
<DataTemplate x:Key="TreeViewItemTemplate">
<StackPanel Orientation="Horizontal" Margin="4">
<Image Source="{Binding EntityType, Converter={StaticResource LibraryBrowserImagePathConverter}}" Stretch="Uniform" />
<TextBlock Text="{Binding Title}" FontSize="11" FontFamily="/Resources/Fonts/#Junction" Foreground="#333333" Margin="6,1,0,0" />
</StackPanel>
</DataTemplate>
</Window.Resources>
<Grid Background="#FF242F35">
<Grid.RowDefinitions>
Expand Down Expand Up @@ -65,38 +73,38 @@
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button Grid.Column="0" x:Name="btnPrevious" Style="{StaticResource PlayerButton}" Width="34" Height="34" ToolTip="Skips to the previous song in the playlist." Click="BtnToolbar_OnClick">
<Image Source="/Resources/Images/Toolbar/previous.png" Stretch="None" Opacity="0.95" />
<Image Source="/Resources/Images/Toolbar/previous.png" Stretch="None" />
</Button>
<Button Grid.Column="1" x:Name="btnPlayPause" Style="{StaticResource PlayerButton}" Width="40" Height="40" ToolTip="Pauses or restarts the playback." Click="BtnToolbar_OnClick">
<Image Source="/Resources/Images/Toolbar/play.png" Stretch="None" Opacity="0.95" />
<Image Source="/Resources/Images/Toolbar/play.png" Stretch="None" />
</Button>
<Button Grid.Column="2" x:Name="btnNext" Style="{StaticResource PlayerButton}" Width="34" Height="34" ToolTip="Skips to the next song in the playlist." Click="BtnToolbar_OnClick">
<Image Source="/Resources/Images/Toolbar/next.png" Stretch="None" Margin="2,0,0,0" Opacity="0.95" />
<Image Source="/Resources/Images/Toolbar/next.png" Stretch="None" Margin="2,0,0,0" />
</Button>
<Button Grid.Column="3" x:Name="btnRepeat" Style="{StaticResource PlayerButton}" Width="34" Height="34" ToolTip="Cycles through repeat types." Click="BtnToolbar_OnClick">
<Image Source="/Resources/Images/Toolbar/repeat.png" Stretch="None" Opacity="0.95" />
<Image Source="/Resources/Images/Toolbar/repeat.png" Stretch="None" />
</Button>
<Button Grid.Column="4" x:Name="btnShuffle" Style="{StaticResource PlayerButton}" Width="34" Height="34" ToolTip="Shuffles the song in the playlist." Click="BtnToolbar_OnClick">
<Image Source="/Resources/Images/Toolbar/shuffle.png" Stretch="None" Opacity="0.95" />
<Image Source="/Resources/Images/Toolbar/shuffle.png" Stretch="None" />
</Button>
<StackPanel Grid.Column="5"></StackPanel>
<Button Grid.Column="6" x:Name="btnPlaylist" Style="{StaticResource PlayerButton}" Width="34" Height="34" ToolTip="Opens the Playlist window." Click="BtnToolbar_OnClick">
<Image Source="/Resources/Images/Toolbar/playlist.png" Stretch="None" Opacity="0.95" />
<Image Source="/Resources/Images/Toolbar/playlist.png" Stretch="None" />
</Button>
<Button Grid.Column="7" x:Name="btnEffects" Style="{StaticResource PlayerButton}" Width="34" Height="34" ToolTip="Opens the Effects window." Click="BtnToolbar_OnClick">
<Image Source="/Resources/Images/Toolbar/effects.png" Stretch="None" Opacity="0.95" />
<Image Source="/Resources/Images/Toolbar/effects.png" Stretch="None" />
</Button>
<Button Grid.Column="8" x:Name="btnSync" Style="{StaticResource PlayerButton}" Width="34" Height="34" ToolTip="Opens the Sync window." Click="BtnToolbar_OnClick">
<Image Source="/Resources/Images/Toolbar/sync.png" Stretch="None" Opacity="0.95" />
<Image Source="/Resources/Images/Toolbar/sync.png" Stretch="None" />
</Button>
<Button Grid.Column="9" x:Name="btnSyncCloud" Style="{StaticResource PlayerButton}" Width="34" Height="34" ToolTip="Opens the Sync (Cloud) window." Click="BtnToolbar_OnClick">
<Image Source="/Resources/Images/Toolbar/cloud.png" Stretch="None" Opacity="0.95" />
<Image Source="/Resources/Images/Toolbar/cloud.png" Stretch="None" />
</Button>
<Button Grid.Column="10" x:Name="btnResumePlayback" Style="{StaticResource PlayerButton}" Width="34" Height="34" ToolTip="Opens the Resume Playback window." Click="BtnToolbar_OnClick">
<Image Source="/Resources/Images/Toolbar/resume.png" Stretch="None" Opacity="0.95" />
<Image Source="/Resources/Images/Toolbar/resume.png" Stretch="None" />
</Button>
<Button Grid.Column="11" x:Name="btnPreferences" Style="{StaticResource PlayerButton}" Width="34" Height="34" ToolTip="Opens the Preferences window." Click="BtnToolbar_OnClick">
<Image Source="/Resources/Images/Toolbar/preferences.png" Stretch="None" Opacity="0.95" />
<Image Source="/Resources/Images/Toolbar/preferences.png" Stretch="None" />
</Button>
</Grid>
</DockPanel>
Expand Down Expand Up @@ -135,15 +143,15 @@
<ComboBoxItem Name="WV">WV</ComboBoxItem>
</ComboBox>
</Grid>
<TreeView Grid.Row="2" x:Name="treeViewLibrary" Background="White" ItemContainerStyle="{StaticResource TreeViewItemStyle}" SelectedItemChanged="treeViewLibrary_SelectedItemChanged" Grid.ColumnSpan="2">
<TreeView.Resources>
<TreeView Grid.Row="2" x:Name="treeViewLibrary" Background="White" ItemContainerStyle="{StaticResource TreeViewItemStyle}" SelectedItemChanged="treeViewLibrary_SelectedItemChanged" TreeViewItem.Expanded="treeViewLibrary_OnExpanded" Grid.ColumnSpan="2">
<!--<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type models:LibraryBrowserEntity}" ItemsSource="{Binding SubItems}">
<StackPanel Orientation="Horizontal" Margin="4">
<Image Source="/Resources/Images/Icons/user.png" Stretch="Uniform" />
<TextBlock Text="{Binding Title}" FontSize="11" FontFamily="/Resources/Fonts/#Junction" Foreground="#333333" Margin="4,0,0,0" />
</StackPanel>
</HierarchicalDataTemplate>
</TreeView.Resources>
</TreeView.Resources>-->
</TreeView>
</Grid>
</Grid>
Expand Down Expand Up @@ -275,25 +283,25 @@
<Button Grid.Column="1" Style="{StaticResource HeaderImageButton}">
<StackPanel Orientation="Horizontal" Margin="4">
<Image Source="/Resources/Images/Buttons/play.png" Stretch="None" />
<TextBlock Margin="6,2,0,0">Play</TextBlock>
<TextBlock Margin="6,1,0,0">Play</TextBlock>
</StackPanel>
</Button>
<Button Grid.Column="2" Style="{StaticResource HeaderImageButton}">
<StackPanel Orientation="Horizontal" Margin="4">
<Image Source="/Resources/Images/Buttons/add.png" Stretch="None" />
<TextBlock Margin="6,2,0,0">Add</TextBlock>
<TextBlock Margin="6,1,0,0">Add</TextBlock>
</StackPanel>
</Button>
<Button Grid.Column="3" Style="{StaticResource HeaderImageButton}">
<StackPanel Orientation="Horizontal" Margin="4">
<Image Source="/Resources/Images/Buttons/edit.png" Stretch="None" />
<TextBlock Margin="6,2,0,0">Edit</TextBlock>
<TextBlock Margin="6,1,0,0">Edit</TextBlock>
</StackPanel>
</Button>
<Button Grid.Column="4" Style="{StaticResource HeaderImageButton}">
<StackPanel Orientation="Horizontal" Margin="4">
<Image Source="/Resources/Images/Buttons/delete.png" Stretch="None" />
<TextBlock Margin="6,2,0,0">Remove</TextBlock>
<TextBlock Margin="6,1,0,0">Remove</TextBlock>
</StackPanel>
</Button>
</Grid>
Expand All @@ -320,25 +328,25 @@
<Button Grid.Column="1" Style="{StaticResource HeaderImageButton}">
<StackPanel Orientation="Horizontal" Margin="4">
<Image Source="/Resources/Images/Buttons/goto.png" Stretch="None" />
<TextBlock Margin="6,2,0,0">Go To</TextBlock>
<TextBlock Margin="6,1,0,0">Go To</TextBlock>
</StackPanel>
</Button>
<Button Grid.Column="2" Style="{StaticResource HeaderImageButton}">
<StackPanel Orientation="Horizontal" Margin="4">
<Image Source="/Resources/Images/Buttons/add.png" Stretch="None" />
<TextBlock Margin="6,2,0,0">Add</TextBlock>
<TextBlock Margin="6,1,0,0">Add</TextBlock>
</StackPanel>
</Button>
<Button Grid.Column="3" Style="{StaticResource HeaderImageButton}">
<StackPanel Orientation="Horizontal" Margin="4">
<Image Source="/Resources/Images/Buttons/edit.png" Stretch="None" />
<TextBlock Margin="6,2,0,0">Edit</TextBlock>
<TextBlock Margin="6,1,0,0">Edit</TextBlock>
</StackPanel>
</Button>
<Button Grid.Column="4" Style="{StaticResource HeaderImageButton}">
<StackPanel Orientation="Horizontal" Margin="4">
<Image Source="/Resources/Images/Buttons/delete.png" Stretch="None" />
<TextBlock Margin="6,2,0,0">Remove</TextBlock>
<TextBlock Margin="6,1,0,0">Remove</TextBlock>
</StackPanel>
</Button>
</Grid>
Expand Down

0 comments on commit d3934d9

Please sign in to comment.