Skip to content

Commit

Permalink
Finish 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DeadlyEmbrace committed May 19, 2016
2 parents 301be9d + c6e92a2 commit bbd493c
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 18 deletions.
Binary file added .vs/MPDN_RemoteControl/MPDN_RemoteControl.scgdat
Binary file not shown.
9 changes: 6 additions & 3 deletions MPDN_RemoteControl.sln
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 14.00
# Visual Studio 2015
VisualStudioVersion = 14.0.22823.1
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 14.0.22823.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MPDN_RemoteControl", "MPDN_RemoteControl\MPDN_RemoteControl.csproj", "{1384E75F-7293-48B8-B251-99DB02FDA9C1}"
EndProject
Expand All @@ -19,4 +19,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(CodealikeProperties) = postSolution
SolutionGuid = d27edd5c-e2b7-400f-98c2-09ad2c38e32d
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion MPDN_RemoteControl/FodyWeavers.xml
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Weavers>
<PropertyChanged />
</Weavers>
16 changes: 10 additions & 6 deletions MPDN_RemoteControl/MPDN_RemoteControl.csproj
Expand Up @@ -46,8 +46,8 @@
<Reference Include="GongSolutions.Wpf.DragDrop">
<HintPath>..\packages\gong-wpf-dragdrop.0.1.4.3\lib\net40\GongSolutions.Wpf.DragDrop.dll</HintPath>
</Reference>
<Reference Include="PropertyChanged, Version=1.50.3.0, Culture=neutral, PublicKeyToken=ee3ee20bcf148ddd, processorArchitecture=MSIL">
<HintPath>..\packages\PropertyChanged.Fody.1.50.3\lib\dotnet\PropertyChanged.dll</HintPath>
<Reference Include="PropertyChanged, Version=1.51.0.0, Culture=neutral, PublicKeyToken=ee3ee20bcf148ddd, processorArchitecture=MSIL">
<HintPath>..\packages\PropertyChanged.Fody.1.51.0\lib\dotnet\PropertyChanged.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
Expand All @@ -63,6 +63,10 @@
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="YAXLib, Version=2.14.0.0, Culture=neutral, PublicKeyToken=15c43682c986900f, processorArchitecture=MSIL">
<HintPath>..\packages\YAXLib.2.14\lib\YAXLib.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
Expand All @@ -76,6 +80,8 @@
<DependentUpon>InputDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Objects\Audio.cs" />
<Compile Include="Objects\PlaylistData.cs" />
<Compile Include="Objects\PlaylistItem.cs" />
<Compile Include="Objects\PlaylistObject.cs" />
<Compile Include="Objects\Video.cs" />
<Compile Include="Subtitles.cs" />
Expand Down Expand Up @@ -187,15 +193,13 @@
<PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
<Import Project="..\packages\Fody.1.29.3\build\dotnet\Fody.targets" Condition="Exists('..\packages\Fody.1.29.3\build\dotnet\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Fody.1.29.3\build\dotnet\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.1.29.3\build\dotnet\Fody.targets'))" />
<Error Condition="!Exists('..\packages\PropertyChanged.Fody.1.50.3\build\dotnet\PropertyChanged.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\PropertyChanged.Fody.1.50.3\build\dotnet\PropertyChanged.Fody.targets'))" />
<Error Condition="!Exists('..\packages\Fody.1.29.4\build\dotnet\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.1.29.4\build\dotnet\Fody.targets'))" />
</Target>
<Import Project="..\packages\PropertyChanged.Fody.1.50.3\build\dotnet\PropertyChanged.Fody.targets" Condition="Exists('..\packages\PropertyChanged.Fody.1.50.3\build\dotnet\PropertyChanged.Fody.targets')" />
<Import Project="..\packages\Fody.1.29.4\build\dotnet\Fody.targets" Condition="Exists('..\packages\Fody.1.29.4\build\dotnet\Fody.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">
Expand Down
96 changes: 92 additions & 4 deletions MPDN_RemoteControl/MainWindow.xaml.cs
Expand Up @@ -19,6 +19,7 @@
using Microsoft.Win32;
using MPDN_RemoteControl.Controls;
using MPDN_RemoteControl.Objects;
using YAXLib;

namespace MPDN_RemoteControl
{
Expand All @@ -41,6 +42,8 @@ public partial class RemoteControl : IDropTarget
private bool _muted = false;
private readonly ClientGuid _guidManager = new ClientGuid();
private readonly object _videoLock = new object();
private int ServerVersion = 3;
private readonly object PlaylistLock = new object();

#endregion

Expand Down Expand Up @@ -174,9 +177,10 @@ private void ClientConnect(IPAddress ip, int port)
try
{
var data = reader.ReadLine();
if (!String.IsNullOrEmpty(data))
var newData = data.Replace("\a", "\r\n");
if (!String.IsNullOrEmpty(newData))
{
Task.Run(() => HandleServerComms(data));
Task.Run(() => HandleServerComms(newData));
}
}
catch (Exception)
Expand Down Expand Up @@ -265,14 +269,17 @@ private void HandleServerComms(string command)
PlaylistStateChanged(cmd[1]);
break;
case "PlaylistContent":
ShowPlaylistContent(cmd[1]);
DisplayPlaylistContent(cmd[1]);
break;
case "VideoTracks":
DisplayVideoTracks(cmd[1]);
break;
case "VideoChanged":
ChangeActiveVideoTrack(cmd[1]);
break;
case "ServerVersion":
SetServerVersion(cmd[1]);
break;
}
}
else
Expand All @@ -281,7 +288,69 @@ private void HandleServerComms(string command)
}
}

private void ShowPlaylistContent(string cmd)
private void SetServerVersion(string cmd)
{
int version;
int.TryParse(cmd, out version);
ServerVersion = version == 0 ? 3 : version;
}

private void DisplayPlaylistContent(string cmd)
{
if (ServerVersion < 3)
{
ShowPlaylistContentApiV2(cmd);
}
else
{
ShowPlaylistContentApiV3(cmd);
}
}

private void ShowPlaylistContentApiV3(string cmd)
{
lock (PlaylistLock)
{
try
{
var playlistData = Deserialize<PlaylistData>(cmd);

Dispatcher.Invoke(() => PlaylistContent.Clear());
foreach (var item in playlistData.Playlist)
{
var tmpItem = new PlaylistObject
{
Filename = item.FilePath,
Playing = item.Active
};

Dispatcher.Invoke(() => PlaylistContent.Add(tmpItem));
}

Dispatcher.Invoke(() =>
{
if (PlaylistContent.Count > 1)
{
BtnPrevious.IsEnabled = true;
BtnNext.IsEnabled = true;
}
else
{
BtnPrevious.IsEnabled = false;
BtnNext.IsEnabled = false;
}
//DataGridPlaylist.ItemsSource = _playlistContent;
});
}
catch (Exception ex)
{
var pause = true;
}
}
}

private void ShowPlaylistContentApiV2(string cmd)
{
var items = Regex.Split(cmd, ">>");
Dispatcher.Invoke(() => PlaylistContent.Clear());
Expand Down Expand Up @@ -1079,5 +1148,24 @@ private void BtnUrl_Click(object sender, RoutedEventArgs e)
{
OpenUrl();
}

private static string Serialize<T>(T value)
{
return CreateSerializer(typeof(T)).Serialize(value);
}

private static T Deserialize<T>(string serializedObject)
{
var result = CreateSerializer(typeof(T)).Deserialize(serializedObject);
return (T)result;
}

private static YAXSerializer CreateSerializer(Type type)
{
return new YAXSerializer(type, YAXExceptionHandlingPolicies.ThrowWarningsAndErrors, YAXExceptionTypes.Error,
YAXSerializationOptions.ThrowUponSerializingCyclingReferences |
YAXSerializationOptions.DontSerializePropertiesWithNoSetter |
YAXSerializationOptions.SerializeNullObjects);
}
}
}
10 changes: 10 additions & 0 deletions MPDN_RemoteControl/Objects/PlaylistData.cs
@@ -0,0 +1,10 @@
using System.Collections.Generic;

namespace MPDN_RemoteControl.Objects
{
public class PlaylistData
{
public string PlaylistName { get; set; }
public List<PlaylistItem> Playlist { get; set; }
}
}
85 changes: 85 additions & 0 deletions MPDN_RemoteControl/Objects/PlaylistItem.cs
@@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.IO;

namespace MPDN_RemoteControl.Objects
{
public class PlaylistItem
{
public string FilePath { get; set; }
public bool Active { get; set; }
public bool HasChapter { get; set; }
public List<int> SkipChapters { get; set; }
public int EndChapter { get; set; }
public string Duration { get; set; }
public int PlayCount { get; set; }
public Guid Guid { get; set; }

public PlaylistItem()
{
}

public PlaylistItem(string filePath, bool isActive)
{
if (string.IsNullOrWhiteSpace(filePath)) throw new ArgumentNullException("filePath");

FilePath = filePath;
Active = isActive;
PlayCount = 0;
Guid = Guid.NewGuid();
}

public PlaylistItem(string filePath, List<int> skipChapter, int endChapter, bool isActive)
{
if (string.IsNullOrWhiteSpace(filePath)) throw new ArgumentNullException("filePath");

FilePath = filePath;
Active = isActive;
SkipChapters = skipChapter;
EndChapter = endChapter;
HasChapter = true;
PlayCount = 0;
Guid = Guid.NewGuid();
}

public PlaylistItem(string filePath, List<int> skipChapter, int endChapter, bool isActive, string duration)
{
if (string.IsNullOrWhiteSpace(filePath)) throw new ArgumentNullException("filePath");

FilePath = filePath;
Active = isActive;
SkipChapters = skipChapter;
EndChapter = endChapter;
HasChapter = true;
Duration = duration;
PlayCount = 0;
Guid = Guid.NewGuid();
}

public PlaylistItem(string filePath, List<int> skipChapter, int endChapter, bool isActive, string duration,
int playCount)
{
if (string.IsNullOrWhiteSpace(filePath)) throw new ArgumentNullException("filePath");

FilePath = filePath;
Active = isActive;
SkipChapters = skipChapter;
EndChapter = endChapter;
HasChapter = true;
Duration = duration;
PlayCount = playCount;
Guid = Guid.NewGuid();
}

public override string ToString()
{
if (HasChapter)
{
return Path.GetFileName(FilePath) + " | SkipChapter: " + string.Join(",", SkipChapters) +
" | EndChapter: " + EndChapter;
}

return Path.GetFileName(FilePath) ?? "???";
}
}
}
4 changes: 2 additions & 2 deletions MPDN_RemoteControl/Properties/AssemblyInfo.cs
Expand Up @@ -51,5 +51,5 @@
// 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.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]
5 changes: 3 additions & 2 deletions MPDN_RemoteControl/packages.config
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Fody" version="1.29.3" targetFramework="net45" developmentDependency="true" />
<package id="Fody" version="1.29.4" targetFramework="net45" developmentDependency="true" />
<package id="gong-wpf-dragdrop" version="0.1.4.3" targetFramework="net45" />
<package id="PropertyChanged.Fody" version="1.50.3" targetFramework="net45" developmentDependency="true" />
<package id="PropertyChanged.Fody" version="1.51.0" targetFramework="net45" developmentDependency="true" />
<package id="YAXLib" version="2.14" targetFramework="net45" />
</packages>

0 comments on commit bbd493c

Please sign in to comment.