diff --git a/MPfm/MPfm.Library/Services/SyncListenerService.cs b/MPfm/MPfm.Library/Services/SyncListenerService.cs
index f7733ee6..eb9da63d 100644
--- a/MPfm/MPfm.Library/Services/SyncListenerService.cs
+++ b/MPfm/MPfm.Library/Services/SyncListenerService.cs
@@ -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)
{
diff --git a/MPfm/MPfm.WPF/Classes/Controls/MPfmButton.cs b/MPfm/MPfm.WPF/Classes/Controls/MPfmButton.cs
index 3826612a..0e8c46c2 100644
--- a/MPfm/MPfm.WPF/Classes/Controls/MPfmButton.cs
+++ b/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 .
+
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
diff --git a/MPfm/MPfm.WPF/Classes/Controls/MPfmTreeViewItem.cs b/MPfm/MPfm.WPF/Classes/Controls/MPfmTreeViewItem.cs
new file mode 100644
index 00000000..ca7c3ef7
--- /dev/null
+++ b/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 .
+
+using System.Windows;
+using System.Windows.Controls;
+
+namespace MPfm.WPF.Classes.Controls
+{
+ ///
+ /// http://stackoverflow.com/questions/15640263/how-to-add-a-before-expanding-event-to-the-wpf-treeview-without-using-threads
+ ///
+ 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);
+ }
+ }
+}
diff --git a/MPfm/MPfm.WPF/Classes/Converters/LibraryBrowserImagePathConverter.cs b/MPfm/MPfm.WPF/Classes/Converters/LibraryBrowserImagePathConverter.cs
new file mode 100644
index 00000000..d139ddac
--- /dev/null
+++ b/MPfm/MPfm.WPF/Classes/Converters/LibraryBrowserImagePathConverter.cs
@@ -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 .
+
+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;
+ //}
+ }
+}
diff --git a/MPfm/MPfm.WPF/Classes/Windows/MainWindow.xaml b/MPfm/MPfm.WPF/Classes/Windows/MainWindow.xaml
index e754e33a..d5f828a8 100644
--- a/MPfm/MPfm.WPF/Classes/Windows/MainWindow.xaml
+++ b/MPfm/MPfm.WPF/Classes/Windows/MainWindow.xaml
@@ -1,14 +1,22 @@
+
+
+
+
+
+
+
@@ -65,38 +73,38 @@
@@ -135,15 +143,15 @@
WV
-
-
+
+
@@ -275,25 +283,25 @@
@@ -320,25 +328,25 @@
diff --git a/MPfm/MPfm.WPF/Classes/Windows/MainWindow.xaml.cs b/MPfm/MPfm.WPF/Classes/Windows/MainWindow.xaml.cs
index 14a497b4..ab786878 100644
--- a/MPfm/MPfm.WPF/Classes/Windows/MainWindow.xaml.cs
+++ b/MPfm/MPfm.WPF/Classes/Windows/MainWindow.xaml.cs
@@ -20,6 +20,7 @@
using System.Linq;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Data;
using System.Windows.Threading;
using MPfm.Core;
using MPfm.MVP.Messages;
@@ -28,6 +29,7 @@
using MPfm.MVP.Views;
using MPfm.Player.Objects;
using MPfm.Sound.AudioFiles;
+using MPfm.WPF.Classes.Controls;
using MPfm.WPF.Classes.Windows.Base;
namespace MPfm.WPF.Classes.Windows
@@ -55,9 +57,7 @@ private void MenuItem_Click(object sender, RoutedEventArgs e)
dialog.Multiselect = true;
dialog.Title = "Add file(s) to library";
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
-
- }
+ OnAddFilesToLibrary(dialog.FileNames.ToList());
}
else if (sender == miFile_AddFolder)
{
@@ -65,9 +65,7 @@ private void MenuItem_Click(object sender, RoutedEventArgs e)
dialog.Description = "Please select a folder to add to the music library";
dialog.ShowNewFolderButton = false;
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
-
- }
+ OnAddFolderToLibrary(dialog.SelectedPath);
}
else if (sender == miFile_OpenAudioFiles)
{
@@ -80,6 +78,10 @@ private void MenuItem_Click(object sender, RoutedEventArgs e)
}
}
+ else if (sender == miFile_UpdateLibrary)
+ {
+ OnUpdateLibrary();
+ }
else if (sender == miWindows_Sync)
{
OnOpenSyncWindow();
@@ -96,7 +98,31 @@ private void MenuItem_Click(object sender, RoutedEventArgs e)
private void treeViewLibrary_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs
diff --git a/MPfm/MPfm.WPF/Classes/Windows/SyncMenuWindow.xaml b/MPfm/MPfm.WPF/Classes/Windows/SyncMenuWindow.xaml
index f23b098c..e6250153 100644
--- a/MPfm/MPfm.WPF/Classes/Windows/SyncMenuWindow.xaml
+++ b/MPfm/MPfm.WPF/Classes/Windows/SyncMenuWindow.xaml
@@ -4,46 +4,111 @@
xmlns:base="clr-namespace:MPfm.WPF.Classes.Windows.Base"
xmlns:controls="clr-namespace:MPfm.WPF.Classes.Controls"
WindowStartupLocation="CenterScreen" Background="#FF242F35"
- Title="Sync (Nearby Devices)" Height="426" Width="677.9" Icon="/MPfm.WPF;component/Resources/Icon.ico">
-
+ Title="Sync with" Height="426" Width="677.9" Icon="/MPfm.WPF;component/Resources/Icon.ico">
+
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/MPfm/MPfm.WPF/Classes/Windows/SyncMenuWindow.xaml.cs b/MPfm/MPfm.WPF/Classes/Windows/SyncMenuWindow.xaml.cs
index c7905e28..1483183f 100644
--- a/MPfm/MPfm.WPF/Classes/Windows/SyncMenuWindow.xaml.cs
+++ b/MPfm/MPfm.WPF/Classes/Windows/SyncMenuWindow.xaml.cs
@@ -17,6 +17,8 @@
using System;
using System.Collections.Generic;
+using System.Linq;
+using System.Security;
using System.Windows;
using System.Windows.Threading;
using MPfm.Library.Objects;
@@ -67,10 +69,28 @@ public void SyncEmptyError(Exception ex)
public void RefreshDevice(SyncDevice device)
{
+ Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
+ {
+ string title = string.Format("Sync with {0}", device.Name);
+ lblTitle.Content = title;
+ this.Title = title;
+ }));
}
public void RefreshLoading(bool isLoading, int progressPercentage)
{
+ Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
+ {
+ progressBar.Value = progressPercentage;
+ gridLoading.Visibility = isLoading ? Visibility.Visible : Visibility.Hidden;
+ progressBar.Visibility = isLoading ? Visibility.Visible : Visibility.Hidden;
+ lblLoading.Visibility = isLoading ? Visibility.Visible : Visibility.Hidden;
+
+ if (progressPercentage < 100)
+ lblLoading.Content = String.Format("Loading index ({0}%)...", progressPercentage);
+ else
+ lblLoading.Content = "Processing index...";
+ }));
}
public void RefreshSelectButton(string text)
@@ -79,6 +99,10 @@ public void RefreshSelectButton(string text)
public void RefreshItems(List items)
{
+ Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
+ {
+ treeViewItems.ItemsSource = items.ToList();
+ }));
}
public void RefreshSelection(List audioFiles)
@@ -87,6 +111,11 @@ public void RefreshSelection(List audioFiles)
public void RefreshSyncTotal(string title, string subtitle, bool enoughFreeSpace)
{
+ Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
+ {
+ lblTotal.Content = title;
+ lblFreeSpace.Content = subtitle;
+ }));
}
public void InsertItems(int index, SyncMenuItemEntity parentItem, List items, object userData)
diff --git a/MPfm/MPfm.WPF/Classes/Windows/SyncWindow.xaml b/MPfm/MPfm.WPF/Classes/Windows/SyncWindow.xaml
index fdff6966..2ea1e448 100644
--- a/MPfm/MPfm.WPF/Classes/Windows/SyncWindow.xaml
+++ b/MPfm/MPfm.WPF/Classes/Windows/SyncWindow.xaml
@@ -3,45 +3,68 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:base="clr-namespace:MPfm.WPF.Classes.Windows.Base"
xmlns:controls="clr-namespace:MPfm.WPF.Classes.Controls"
+ xmlns:models="clr-namespace:MPfm.Library.Objects;assembly=MPfm.Library"
WindowStartupLocation="CenterScreen" Background="#FF242F35"
Title="Sync (Nearby Devices)" Height="426" Width="677.9" Icon="/MPfm.WPF;component/Resources/Icon.ico">
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Searching for devices running Sessions on your local network...
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
- Refresh devices
+
+
+
+
-
-
+
+
- Connect manually to device
+
-
-
+
+
- Connect to device
+
diff --git a/MPfm/MPfm.WPF/Classes/Windows/SyncWindow.xaml.cs b/MPfm/MPfm.WPF/Classes/Windows/SyncWindow.xaml.cs
index 73372861..31ebc4bc 100644
--- a/MPfm/MPfm.WPF/Classes/Windows/SyncWindow.xaml.cs
+++ b/MPfm/MPfm.WPF/Classes/Windows/SyncWindow.xaml.cs
@@ -17,7 +17,10 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Windows;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
using System.Windows.Threading;
using MPfm.Library.Objects;
using MPfm.MVP.Messages;
@@ -32,6 +35,8 @@ namespace MPfm.WPF.Classes.Windows
{
public partial class SyncWindow : BaseWindow, ISyncView
{
+ private bool _isDiscovering;
+
public SyncWindow(Action onViewReady)
: base (onViewReady)
{
@@ -39,6 +44,42 @@ public SyncWindow(Action onViewReady)
ViewIsReady();
}
+ private void RefreshDeviceListButton()
+ {
+ if (_isDiscovering)
+ {
+ imageRefreshButton.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/Images/Buttons/cancel.png"));
+ lblRefreshButton.Content = "Cancel refresh";
+ }
+ else
+ {
+ imageRefreshButton.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/Images/Buttons/refresh.png"));
+ lblRefreshButton.Content = "Refresh devices";
+ }
+ }
+
+ private void btnRefresh_OnClick(object sender, RoutedEventArgs e)
+ {
+ if (_isDiscovering)
+ OnCancelDiscovery();
+ else
+ OnStartDiscovery();
+ }
+
+ private void btnConnect_OnClick(object sender, RoutedEventArgs e)
+ {
+ if (listView.SelectedItems.Count == 0)
+ return;
+
+ OnCancelDiscovery();
+ OnConnectDevice((SyncDevice)listView.SelectedItems[0]);
+ }
+
+ private void btnConnectManual_OnClick(object sender, RoutedEventArgs e)
+ {
+
+ }
+
#region ISyncView implementation
public Action OnConnectDevice { get; set; }
@@ -64,14 +105,34 @@ public void RefreshIPAddress(string address)
public void RefreshDiscoveryProgress(float percentageDone, string status)
{
+ Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
+ {
+ if (!_isDiscovering)
+ {
+ _isDiscovering = true;
+ progressBar.Visibility = Visibility.Visible;
+ RefreshDeviceListButton();
+ }
+ progressBar.Value = (int)percentageDone;
+ }));
}
public void RefreshDevices(IEnumerable devices)
{
+ Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
+ {
+ listView.ItemsSource = devices.ToList();
+ }));
}
public void RefreshDevicesEnded()
{
+ Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
+ {
+ _isDiscovering = false;
+ progressBar.Visibility = Visibility.Hidden;
+ RefreshDeviceListButton();
+ }));
}
public void SyncDevice(SyncDevice device)
@@ -79,5 +140,6 @@ public void SyncDevice(SyncDevice device)
}
#endregion
+
}
}
diff --git a/MPfm/MPfm.WPF/Classes/Windows/UpdateLibraryWindow.xaml b/MPfm/MPfm.WPF/Classes/Windows/UpdateLibraryWindow.xaml
index 35ac85dc..81b94e16 100644
--- a/MPfm/MPfm.WPF/Classes/Windows/UpdateLibraryWindow.xaml
+++ b/MPfm/MPfm.WPF/Classes/Windows/UpdateLibraryWindow.xaml
@@ -4,46 +4,50 @@
xmlns:base="clr-namespace:MPfm.WPF.Classes.Windows.Base"
xmlns:controls="clr-namespace:MPfm.WPF.Classes.Controls"
WindowStartupLocation="CenterScreen" Background="#FF242F35"
- Title="Update Library" Height="426" Width="677.9" Icon="/MPfm.WPF;component/Resources/Icon.ico">
+ Title="Update Library" Height="153" Width="488.9" Icon="/MPfm.WPF;component/Resources/Icon.ico">
-
-
-
-
-
-
-
-
+
-
+
-
-
-
- Refresh devices
+
+
+
+
+ OK
-
-
-
-
- Connect manually to device
+
+
+
+ Cancel
-
-
-
- Connect to device
+
+
+
+ Save Log
-
+
+
+
+
+
+
+
+
+ Loading...
+ Loading...
+
+
diff --git a/MPfm/MPfm.WPF/Classes/Windows/UpdateLibraryWindow.xaml.cs b/MPfm/MPfm.WPF/Classes/Windows/UpdateLibraryWindow.xaml.cs
index 67118c15..78f9940e 100644
--- a/MPfm/MPfm.WPF/Classes/Windows/UpdateLibraryWindow.xaml.cs
+++ b/MPfm/MPfm.WPF/Classes/Windows/UpdateLibraryWindow.xaml.cs
@@ -40,6 +40,20 @@ public UpdateLibraryWindow(Action onViewReady)
ViewIsReady();
}
+ private void btnOK_OnClick(object sender, RoutedEventArgs e)
+ {
+ Close();
+ }
+
+ private void btnCancel_OnClick(object sender, RoutedEventArgs e)
+ {
+ OnCancelUpdateLibrary();
+ }
+
+ private void btnSaveLog_OnClick(object sender, RoutedEventArgs e)
+ {
+ }
+
#region IUpdateLibraryView implementation
public Action, string> OnStartUpdateLibrary { get; set; }
@@ -48,6 +62,12 @@ public UpdateLibraryWindow(Action onViewReady)
public void RefreshStatus(UpdateLibraryEntity entity)
{
+ Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
+ {
+ lblTitle.Text = entity.Title;
+ lblSubtitle.Text = entity.Subtitle;
+ progressBar.Value = entity.PercentageDone*100;
+ }));
}
public void AddToLog(string entry)
@@ -56,8 +76,17 @@ public void AddToLog(string entry)
public void ProcessEnded(bool canceled)
{
+ Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
+ {
+ lblTitle.Text = "Update library completed successfully";
+ lblSubtitle.Text = string.Empty;
+ btnCancel.IsEnabled = false;
+ btnOK.IsEnabled = true;
+ btnSaveLog.IsEnabled = true;
+ }));
}
#endregion
+
}
}
diff --git a/MPfm/MPfm.WPF/MPfm.WPF.csproj b/MPfm/MPfm.WPF/MPfm.WPF.csproj
index 1ac8b5e8..49956b1a 100644
--- a/MPfm/MPfm.WPF/MPfm.WPF.csproj
+++ b/MPfm/MPfm.WPF/MPfm.WPF.csproj
@@ -129,6 +129,8 @@
Code
+
+
@@ -290,6 +292,12 @@
+
+
+
+
+
+