Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ycastonguay/MPfm
Browse files Browse the repository at this point in the history
  • Loading branch information
ycastonguay committed Feb 13, 2013
2 parents 174e164 + 2834acc commit 0b4d95b
Show file tree
Hide file tree
Showing 19 changed files with 139 additions and 153 deletions.
10 changes: 0 additions & 10 deletions MPfm/MPfm.GTK/Bass.Net.dll.config

This file was deleted.

Expand Up @@ -19,7 +19,7 @@
using System.Drawing;
using System.Drawing.Drawing2D;

namespace MPfm.GTK
namespace MPfm.GTK.Helpers
{
/// <summary>
/// The ImageManipulation class contains static functions for manipulating images.
Expand Down
4 changes: 3 additions & 1 deletion MPfm/MPfm.GTK/Main.cs → MPfm/MPfm.GTK/Classes/Main.cs
Expand Up @@ -22,7 +22,9 @@
using MPfm.MVP;
using MPfm.MVP.Views;
using MPfm.MVP.Navigation;
using MPfm.MVP.Bootstrapper;
using MPfm.MVP.Bootstrap;
using MPfm.GTK.Navigation;
using MPfm.GTK.Windows;

namespace MPfm.GTK
{
Expand Down
Expand Up @@ -21,7 +21,7 @@
using MPfm.MVP.Navigation;
using MPfm.MVP.Views;

namespace MPfm.GTK
namespace MPfm.GTK.Navigation
{
/// <summary>
/// Navigation manager for Gtk.
Expand Down
44 changes: 21 additions & 23 deletions MPfm/MPfm.GTK/MPfm.GTK.csproj
Expand Up @@ -11,36 +11,36 @@
<AssemblyName>mpfm</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>False</Optimize>
<Optimize>false</Optimize>
<OutputPath>..\Output\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>False</Optimize>
<Optimize>false</Optimize>
<OutputPath>..\Output</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug_Linux|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>False</Optimize>
<Optimize>false</Optimize>
<OutputPath>..\Output\Debug_Linux</OutputPath>
<DefineConstants>DEBUG;TRACE;LINUX</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug_MacOSX|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>False</Optimize>
<Optimize>false</Optimize>
<OutputPath>..\Output\Debug_Mac_GTK</OutputPath>
<DefineConstants>DEBUG;TRACE;MACOSX</DefineConstants>
<WarningLevel>4</WarningLevel>
Expand Down Expand Up @@ -81,23 +81,23 @@
</ItemGroup>
<ItemGroup>
<Compile Include="gtk-gui\generated.cs" />
<Compile Include="Main.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="gtk-gui\MPfm.GTK.MainWindow.cs" />
<Compile Include="gtk-gui\MPfm.GTK.PlaylistWindow.cs" />
<Compile Include="gtk-gui\MPfm.GTK.EffectsWindow.cs" />
<Compile Include="Windows\MainWindow.cs" />
<Compile Include="Windows\PlaylistWindow.cs" />
<Compile Include="Windows\EffectsWindow.cs" />
<Compile Include="Windows\UpdateLibraryWindow.cs" />
<Compile Include="gtk-gui\MPfm.GTK.UpdateLibraryWindow.cs" />
<Compile Include="Windows\PreferencesWindow.cs" />
<Compile Include="gtk-gui\MPfm.GTK.PreferencesWindow.cs" />
<Compile Include="gtk-gui\MPfm.GTK.SplashWindow.cs" />
<Compile Include="Windows\SplashWindow.cs" />
<Compile Include="Windows\BaseWindow.cs" />
<Compile Include="Classes\GtkNavigationManager.cs" />
<Compile Include="Classes\ImageManipulation.cs" />
<Compile Include="Classes\Navigation\GtkNavigationManager.cs" />
<Compile Include="Classes\Helpers\ImageManipulation.cs" />
<Compile Include="gtk-gui\MPfm.GTK.Windows.EffectsWindow.cs" />
<Compile Include="gtk-gui\MPfm.GTK.Windows.MainWindow.cs" />
<Compile Include="gtk-gui\MPfm.GTK.Windows.PlaylistWindow.cs" />
<Compile Include="gtk-gui\MPfm.GTK.Windows.PreferencesWindow.cs" />
<Compile Include="gtk-gui\MPfm.GTK.Windows.SplashWindow.cs" />
<Compile Include="gtk-gui\MPfm.GTK.Windows.UpdateLibraryWindow.cs" />
<Compile Include="Classes\Main.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
Expand Down Expand Up @@ -149,10 +149,6 @@
<None Include="Lib\x86\libbass_mpc.so" />
<None Include="Lib\x86\libbass_tta.so" />
<None Include="Lib\x86\libbasswv.so" />
<None Include="Bass.Net.dll.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Lib\Ninject.dll" />
<None Include="black.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand All @@ -163,10 +159,12 @@
<Folder Include="Lib\x64\" />
<Folder Include="Windows\" />
<Folder Include="Classes\" />
<Folder Include="Classes\Navigation\" />
<Folder Include="Classes\Helpers\" />
</ItemGroup>
<ItemGroup>
<Content Include="icon48.png">
<DeployService-UseProjectRelativePath>True</DeployService-UseProjectRelativePath>
<DeployService-UseProjectRelativePath>true</DeployService-UseProjectRelativePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Splash.png">
Expand Down
2 changes: 1 addition & 1 deletion MPfm/MPfm.GTK/Windows/BaseWindow.cs
Expand Up @@ -21,7 +21,7 @@
using MPfm.MVP;
using MPfm.MVP.Views;

namespace MPfm.GTK
namespace MPfm.GTK.Windows
{
/// <summary>
/// Base window for GTK.
Expand Down
2 changes: 1 addition & 1 deletion MPfm/MPfm.GTK/Windows/EffectsWindow.cs
Expand Up @@ -21,7 +21,7 @@
using MPfm.MVP;
using MPfm.MVP.Views;

namespace MPfm.GTK
namespace MPfm.GTK.Windows
{
/// <summary>
/// Effects window.
Expand Down
156 changes: 76 additions & 80 deletions MPfm/MPfm.GTK/Windows/MainWindow.cs
Expand Up @@ -16,30 +16,23 @@
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Timers;
using Gtk;
using Gdk;
using Pango;
using Mono.Posix;
using Mono.Unix;
using MPfm.Core;
using MPfm.Library;
using MPfm.Player;
using MPfm.Sound;
using MPfm.MVP;
using System.Drawing.Imaging;
using System.Text;
using MPfm.MVP.Views;
using MPfm.Sound.AudioFiles;
using MPfm.MVP.Models;
using MPfm.Library.UpdateLibrary;
using MPfm.GTK.Helpers;

namespace MPfm.GTK
namespace MPfm.GTK.Windows
{
/// <summary>
/// Main window.
Expand Down Expand Up @@ -108,7 +101,7 @@ public MainWindow(Action<IBaseView> onViewReady): base (Gtk.WindowType.Toplevel,

// Refresh other stuff
RefreshRepeatButton();
RefreshSongInformation(new SongInformationEntity());
RefreshSongInformation(null);

// Fill sound format combo box
storeAudioFileFormat = new ListStore(typeof(string));
Expand Down Expand Up @@ -789,94 +782,97 @@ public void RefreshPlayerPosition(PlayerPositionEntity entity)
});
}

public void RefreshSongInformation(SongInformationEntity entity)
public void RefreshSongInformation(AudioFile audioFile)
{
Gtk.Application.Invoke(delegate{
// Refresh labels
Console.WriteLine("MainWindow - RefreshSongInformation");
lblArtistName.Text = entity.ArtistName;
lblAlbumTitle.Text = entity.AlbumTitle;
lblSongTitle.Text = entity.Title;
lblSongFilePath.Text = entity.FilePath;
lblCurrentPosition.Text = entity.Position;
lblCurrentLength.Text = entity.Length;

lblCurrentFileType.Text = entity.FileTypeString;
lblCurrentBitrate.Text = entity.BitrateString;
lblCurrentSampleRate.Text = entity.SampleRateString;
lblCurrentBitsPerSample.Text = entity.BitsPerSampleString;

//Pixbuf stuff = new Pixbuf("icon48.png");
//stuff = stuff.ScaleSimple(150, 150, InterpType.Bilinear);
//this.imageAlbumCover.Pixbuf = stuff;

System.Drawing.Image drawingImage = AudioFile.ExtractImageForAudioFile(entity.FilePath);

if(drawingImage != null)
if(audioFile != null)
{
// Resize image
drawingImage = ImageManipulation.ResizeImage(drawingImage, 150, 150);
// Refresh labels
Console.WriteLine("MainWindow - RefreshSongInformation");
lblArtistName.Text = audioFile.ArtistName;
lblAlbumTitle.Text = audioFile.AlbumTitle;
lblSongTitle.Text = audioFile.Title;
lblSongFilePath.Text = audioFile.FilePath;
//lblCurrentPosition.Text = audioFile.Position;
lblCurrentLength.Text = audioFile.Length;

lblCurrentFileType.Text = audioFile.FileType.ToString();
lblCurrentBitrate.Text = audioFile.Bitrate.ToString();
lblCurrentSampleRate.Text = audioFile.SampleRate.ToString();
lblCurrentBitsPerSample.Text = audioFile.BitsPerSample.ToString();

//Pixbuf stuff = new Pixbuf("icon48.png");
//stuff = stuff.ScaleSimple(150, 150, InterpType.Bilinear);
//this.imageAlbumCover.Pixbuf = stuff;

// Set album cover
imageAlbumCover.Pixbuf = ImageToPixbuf(drawingImage);
}
else
{
// Get Unix-style directory information (i.e. case sensitive file names)
if(!String.IsNullOrEmpty(entity.FilePath))
System.Drawing.Image drawingImage = AudioFile.ExtractImageForAudioFile(audioFile.FilePath);

if(drawingImage != null)
{
try
// Resize image
drawingImage = ImageManipulation.ResizeImage(drawingImage, 150, 150);

// Set album cover
imageAlbumCover.Pixbuf = ImageToPixbuf(drawingImage);
}
else
{
// Get Unix-style directory information (i.e. case sensitive file names)
if(!String.IsNullOrEmpty(audioFile.FilePath))
{
bool imageFound = false;
string folderPath = System.IO.Path.GetDirectoryName(entity.FilePath);
UnixDirectoryInfo rootDirectoryInfo = new UnixDirectoryInfo(folderPath);

// For each directory, search for new directories
UnixFileSystemInfo[] infos = rootDirectoryInfo.GetFileSystemEntries();
foreach (UnixFileSystemInfo fileInfo in rootDirectoryInfo.GetFileSystemEntries())
{
// Check if the file matches
string fileName = fileInfo.Name.ToUpper();
if((fileName.EndsWith(".JPG") ||
fileName.EndsWith(".JPEG") ||
fileName.EndsWith(".PNG") ||
fileName.EndsWith(".GIF")) &&
(fileName.StartsWith("FOLDER") ||
fileName.StartsWith("COVER")))
try
{
bool imageFound = false;
string folderPath = System.IO.Path.GetDirectoryName(audioFile.FilePath);
UnixDirectoryInfo rootDirectoryInfo = new UnixDirectoryInfo(folderPath);

// For each directory, search for new directories
UnixFileSystemInfo[] infos = rootDirectoryInfo.GetFileSystemEntries();
foreach (UnixFileSystemInfo fileInfo in rootDirectoryInfo.GetFileSystemEntries())
{
// Check if the file matches
string fileName = fileInfo.Name.ToUpper();
if((fileName.EndsWith(".JPG") ||
fileName.EndsWith(".JPEG") ||
fileName.EndsWith(".PNG") ||
fileName.EndsWith(".GIF")) &&
(fileName.StartsWith("FOLDER") ||
fileName.StartsWith("COVER")))
{
// Get image from file
imageFound = true;
Pixbuf imageCover = new Pixbuf(fileInfo.FullName);
imageCover = imageCover.ScaleSimple(150, 150, InterpType.Bilinear);
this.imageAlbumCover.Pixbuf = imageCover;
}
}

// Set empty image if not cover not found
if(!imageFound)
{
// Get image from file
imageFound = true;
Pixbuf imageCover = new Pixbuf(fileInfo.FullName);
imageCover = imageCover.ScaleSimple(150, 150, InterpType.Bilinear);
this.imageAlbumCover.Pixbuf = imageCover;
this.imageAlbumCover.Pixbuf = null;
}
}

// Set empty image if not cover not found
if(!imageFound)
catch
{
this.imageAlbumCover.Pixbuf = null;
}
}
catch
else
{
this.imageAlbumCover.Pixbuf = null;
// Set empty album cover
imageAlbumCover.Pixbuf = null;
}
}
else
{
// Set empty album cover
imageAlbumCover.Pixbuf = null;

// Check if image cover is still empty
if(imageAlbumCover.Pixbuf == null)
{
Pixbuf imageCover = new Pixbuf("black.png");
imageCover = imageCover.ScaleSimple(150, 150, InterpType.Bilinear);
this.imageAlbumCover.Pixbuf = imageCover;
}
}

// Check if image cover is still empty
if(imageAlbumCover.Pixbuf == null)
{
Pixbuf imageCover = new Pixbuf("black.png");
imageCover = imageCover.ScaleSimple(150, 150, InterpType.Bilinear);
this.imageAlbumCover.Pixbuf = imageCover;
}
});
}

Expand Down
2 changes: 1 addition & 1 deletion MPfm/MPfm.GTK/Windows/PlaylistWindow.cs
Expand Up @@ -19,7 +19,7 @@
using MPfm.MVP;
using MPfm.MVP.Views;

namespace MPfm.GTK
namespace MPfm.GTK.Windows
{
/// <summary>
/// Playlist window.
Expand Down
2 changes: 1 addition & 1 deletion MPfm/MPfm.GTK/Windows/PreferencesWindow.cs
Expand Up @@ -19,7 +19,7 @@
using MPfm.MVP;
using MPfm.MVP.Views;

namespace MPfm.GTK
namespace MPfm.GTK.Windows
{
/// <summary>
/// Settings window.
Expand Down
2 changes: 1 addition & 1 deletion MPfm/MPfm.GTK/Windows/SplashWindow.cs
Expand Up @@ -20,7 +20,7 @@
using MPfm.MVP;
using MPfm.MVP.Views;

namespace MPfm.GTK
namespace MPfm.GTK.Windows
{
public partial class SplashWindow : BaseWindow, ISplashView
{
Expand Down

0 comments on commit 0b4d95b

Please sign in to comment.