got everything working on Herse.Models, split out classes into files LIKE THEY SHOULD BE

This commit is contained in:
Don Archer 2016-07-31 22:08:28 -07:00
parent 5a7b9ec43e
commit 4c60fd95d5
17 changed files with 232 additions and 104 deletions

View File

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace FirebaseKaraoke.Extensions
{
public static class StringExtension
{
public static Guid ToGUID(this string input)
{
// Create a new instance of the MD5CryptoServiceProvider object.
MD5 md5Hasher = MD5.Create();
// Convert the input string to a byte array and compute the hash.
byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input));
return new Guid(data);
}
}
}

View File

@ -1,71 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using KaraokePlayer.Enums;
using FireSharp.Interfaces;
using FireSharp.Config;
using FireSharp;
using Newtonsoft.Json;
using System.Configuration;
using Herse.Models;
namespace KaraokePlayer.Classes
{
public class Singer
{
[JsonProperty("name")]
public string Name { get; set; }
}
public class Song
{
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("artist")]
public string Artist { get; set; }
[JsonProperty("genre")]
public string Genre { get; set; }
[JsonProperty("year")]
public int Year { get; set; }
[JsonProperty("path")]
public string Path { get; set; }
[JsonIgnore]
public FileType FileType
{
get
{
switch (Path.Substring(Path.Length - 3, 3).ToLower())
{
case "cdg":
case "mp3":
return FileType.CDG;
case "mp4":
return FileType.MP4;
case "zip":
return FileType.ZIP;
default:
throw new Exception("file type not handled");
}
}
}
}
public class QueueItem
{
[JsonProperty("singer")]
public Singer Singer { get; set; }
[JsonProperty("song")]
public Song Song { get; set; }
}
public class FirebaseController
{
private IFirebaseConfig config = new FirebaseConfig

View File

@ -71,8 +71,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Enums.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="FirebaseController.cs" />
<Compile Include="PlayerDelegates.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@ -80,6 +78,12 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Herse.Models\Herse.Models.csproj">
<Project>{f02eda00-aa8f-47ef-ac7f-66dc315aa13d}</Project>
<Name>Herse.Models</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">

View File

@ -1,4 +1,4 @@
using KaraokePlayer.Enums;
using Herse.Models;
using System;
using System.Collections.Generic;
using System.Linq;

13
Herse.Models/FileType.cs Normal file
View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Herse.Models
{
public enum FileType
{
CDG, MP4, ZIP
}
}

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F02EDA00-AA8F-47EF-AC7F-66DC315AA13D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Herse.Models</RootNamespace>
<AssemblyName>Herse.Models</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FileType.cs" />
<Compile Include="PlayerState.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="QueueItem.cs" />
<Compile Include="Singer.cs" />
<Compile Include="Song.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -4,18 +4,13 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KaraokePlayer.Enums
namespace Herse.Models
{
public enum PlayerState
{
Play,
Stop,
Pause,
Pause,
Next
}
public enum FileType
{
CDG, MP4, ZIP
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 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("Herse.Models")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Herse.Models")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[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)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f02eda00-aa8f-47ef-ac7f-66dc315aa13d")]
// 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")]

18
Herse.Models/QueueItem.cs Normal file
View File

@ -0,0 +1,18 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Herse.Models
{
public class QueueItem
{
[JsonProperty("singer")]
public Singer Singer { get; set; }
[JsonProperty("song")]
public Song Song { get; set; }
}
}

16
Herse.Models/Singer.cs Normal file
View File

@ -0,0 +1,16 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Herse.Models
{
public class Singer
{
[JsonProperty("name")]
public string Name { get; set; }
}
}

48
Herse.Models/Song.cs Normal file
View File

@ -0,0 +1,48 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Herse.Models
{
public class Song
{
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("artist")]
public string Artist { get; set; }
[JsonProperty("genre")]
public string Genre { get; set; }
[JsonProperty("year")]
public int Year { get; set; }
[JsonProperty("path")]
public string Path { get; set; }
[JsonIgnore]
public FileType FileType
{
get
{
switch (Path.Substring(Path.Length - 3, 3).ToLower())
{
case "cdg":
case "mp3":
return FileType.CDG;
case "mp4":
return FileType.MP4;
case "zip":
return FileType.ZIP;
default:
throw new Exception("file type not handled");
}
}
}
}
}

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
</packages>

View File

@ -17,7 +17,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FirebaseKaraoke", "Firebase
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SongCrawler", "SongCrawler\SongCrawler.csproj", "{82F60DD0-80EC-49C8-9E7C-95A250783E68}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Herse.Models", "herse.models\Herse.Models.csproj", "{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Herse.Models", "Herse.Models\Herse.Models.csproj", "{F02EDA00-AA8F-47EF-AC7F-66DC315AA13D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -45,10 +45,10 @@ Global
{82F60DD0-80EC-49C8-9E7C-95A250783E68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82F60DD0-80EC-49C8-9E7C-95A250783E68}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82F60DD0-80EC-49C8-9E7C-95A250783E68}.Release|Any CPU.Build.0 = Release|Any CPU
{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}.Release|Any CPU.Build.0 = Release|Any CPU
{F02EDA00-AA8F-47EF-AC7F-66DC315AA13D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F02EDA00-AA8F-47EF-AC7F-66DC315AA13D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F02EDA00-AA8F-47EF-AC7F-66DC315AA13D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F02EDA00-AA8F-47EF-AC7F-66DC315AA13D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -467,6 +467,10 @@
<Project>{4fe25e6d-1beb-4902-9815-c2b421233bd7}</Project>
<Name>FirebaseKaraoke</Name>
</ProjectReference>
<ProjectReference Include="..\Herse.Models\Herse.Models.csproj">
<Project>{F02EDA00-AA8F-47EF-AC7F-66DC315AA13D}</Project>
<Name>Herse.Models</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6">

View File

@ -10,6 +10,7 @@ using System.Windows.Forms;
using KaraokePlayer.Classes;
using System.Threading.Tasks;
using System.Configuration;
using Herse.Models;
namespace KaraokePlayer
{
@ -38,15 +39,15 @@ namespace KaraokePlayer
clientId: ConfigurationManager.AppSettings["KaraokePlayer.ControllerId"],
stateChanged: (args) =>
{
if (args.State == Enums.PlayerState.Play)
if (args.State == PlayerState.Play)
{
this.Invoke(new Action(() => { play(); }));
}
else if (args.State == Enums.PlayerState.Pause)
else if (args.State == PlayerState.Pause)
{
this.Invoke(new Action(() => { pause(); }));
}
else if (args.State == Enums.PlayerState.Next)
else if (args.State == PlayerState.Next)
{
this.Invoke(new Action(() => { next(); }));
}
@ -104,7 +105,7 @@ namespace KaraokePlayer
currentPlayer.Resume();
return;
}
if (currentSong.FileType == Enums.FileType.CDG)
if (currentSong.FileType == FileType.CDG)
{
currentPlayer = karaokeCDGPlayer;
karaokeCDGPlayer.Play(new Uri(Path.ChangeExtension(currentSong.Path, ".mp3")));
@ -112,7 +113,7 @@ namespace KaraokePlayer
karaokeMP4Player.Visible = false;
karaokeMP4Player.Stop();
}
else if (currentSong.FileType == Enums.FileType.ZIP)
else if (currentSong.FileType == FileType.ZIP)
{
string playPath = null;
string extractPath = Path.Combine(Directory.GetCurrentDirectory(), "temp");

View File

@ -1,4 +1,5 @@
using KaraokePlayer.Classes;
using Herse.Models;
using KaraokePlayer.Classes;
using System;
using System.Collections.Generic;
using System.ComponentModel;

View File

@ -85,13 +85,13 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\herse.models\Herse.Models.csproj">
<Project>{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}</Project>
<Name>Herse.Models</Name>
</ProjectReference>
<Content Include="libs\taglib-sharp.dll" />
</ItemGroup>
<ItemGroup>
<Content Include="libs\taglib-sharp.dll" />
<ProjectReference Include="..\Herse.Models\Herse.Models.csproj">
<Project>{f02eda00-aa8f-47ef-ac7f-66dc315aa13d}</Project>
<Name>Herse.Models</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />