mirror of
https://github.com/ZuneDev/ZuneShell.dll.git
synced 2026-07-27 13:11:51 -07:00
Merge pull request #4 from ZuneDev/dev/net6
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
|
||||
<ApplicationVersion>4.9.0.0</ApplicationVersion>
|
||||
<AssemblyVersion>$(ApplicationVersion)</AssemblyVersion>
|
||||
<FileVersion>$(ApplicationVersion)</FileVersion>
|
||||
<LangVersion>latest</LangVersion>
|
||||
|
||||
<TargetFrameworks>netstandard2.0;net35;net40;net6.0;net6.0-windows</TargetFrameworks>
|
||||
<Platforms>x64;x86</Platforms>
|
||||
|
||||
<SignAssembly>False</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>$(SolutionDir)\libs\MicrosoftIris\36MSApp1024.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>True</DelaySign>
|
||||
|
||||
<UseOpenZune>False</UseOpenZune>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="**\*.lg.cs" Exclude="bin\**\*.lg.cs;obj\**\*.lg.cs" />
|
||||
<Compile Remove="**\*.lg.cs" Condition="$(UseOpenZune)" />
|
||||
<Compile Include="**\*.lg.cs"
|
||||
Exclude="bin\**\*.lg.cs;obj\**\*.lg.cs"
|
||||
Condition="!$(UseOpenZune)" />
|
||||
|
||||
<None Include="**\*.oz.cs" Exclude="bin\**\*.oz.cs;obj\**\*.oz.cs" />
|
||||
<Compile Remove="**\*.oz.cs" Condition="!$(UseOpenZune)" />
|
||||
<Compile Include="**\*.oz.cs"
|
||||
Exclude="bin\**\*.oz.cs;obj\**\*.oz.cs"
|
||||
Condition="$(UseOpenZune)" />
|
||||
</ItemGroup>
|
||||
|
||||
<Choose>
|
||||
<When Condition=" $(TargetFramework.StartsWith('net6.0-windows')) ">
|
||||
<PropertyGroup>
|
||||
<UseOpenZune>True</UseOpenZune>
|
||||
|
||||
<DefineConstants Condition="$(TargetFramework.StartsWith('net6.0-windows10'))">$(DefineConstants);WINDOWS10</DefineConstants>
|
||||
<DefineConstants Condition="$(TargetFramework.StartsWith('net6.0-windows8'))">$(DefineConstants);WINDOWS8</DefineConstants>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
|
||||
<When Condition=" $(TargetFramework.StartsWith('net6.0')) ">
|
||||
<PropertyGroup>
|
||||
<UseOpenZune>True</UseOpenZune>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
|
||||
<!--
|
||||
.NET Core 3.1 is only used to target Windows 8/8.1
|
||||
-->
|
||||
<When Condition=" $(TargetFramework.StartsWith('netcoreapp')) ">
|
||||
<PropertyGroup>
|
||||
<UseOpenZune>True</UseOpenZune>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
</Choose>
|
||||
|
||||
<PropertyGroup Condition="$(UseOpenZune)">
|
||||
<ApplicationVersion>5.0.0.0</ApplicationVersion>
|
||||
<DefineConstants>$(DefineConstants);OPENZUNE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 102 KiB |
@@ -1,18 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using IrisApp = Microsoft.Iris.Application;
|
||||
|
||||
namespace ZuneHost.Wpf
|
||||
{
|
||||
@@ -21,7 +13,9 @@ namespace ZuneHost.Wpf
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private string _zuneProgramFolder;
|
||||
DirectoryInfo _zuneProgramDir;
|
||||
string decompResultDir = Path.Combine(Environment.CurrentDirectory, "DecompileResults");
|
||||
string dataMapDir = Path.Combine(Environment.CurrentDirectory, "DataMappings");
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
@@ -39,33 +33,103 @@ namespace ZuneHost.Wpf
|
||||
string strArgs = string.Join(" ", args.ToArray());
|
||||
|
||||
// Make sure that ZuneDBApi can find all the Zune native libraries
|
||||
_zuneProgramFolder = Path.Combine(
|
||||
_zuneProgramDir = new(Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
|
||||
"Zune");
|
||||
foreach (var info in new DirectoryInfo(_zuneProgramFolder).GetFileSystemInfos())
|
||||
"Zune"));
|
||||
if (_zuneProgramDir.Exists)
|
||||
{
|
||||
if (info is DirectoryInfo dirInfo)
|
||||
foreach (var info in _zuneProgramDir.GetFileSystemInfos())
|
||||
{
|
||||
CopyAll(dirInfo, new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, dirInfo.Name)));
|
||||
}
|
||||
else if (info is FileInfo fileInfo)
|
||||
{
|
||||
string fileName = fileInfo.Name;
|
||||
if (fileInfo.Extension == ".dll")
|
||||
if (info is DirectoryInfo dirInfo)
|
||||
{
|
||||
string targetPath = Path.Combine(Environment.CurrentDirectory, fileName);
|
||||
if (!File.Exists(targetPath) || fileName == "ZuneDbApi.dll")
|
||||
fileInfo.CopyTo(targetPath);
|
||||
CopyAll(dirInfo, new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, dirInfo.Name)));
|
||||
}
|
||||
}
|
||||
else if (info is FileInfo fileInfo)
|
||||
{
|
||||
string fileName = fileInfo.Name;
|
||||
if (fileInfo.Extension == ".dll")
|
||||
{
|
||||
string targetPath = Path.Combine(Environment.CurrentDirectory, fileName);
|
||||
if (!File.Exists(targetPath) || fileName == "ZuneDbApi.dll")
|
||||
fileInfo.CopyTo(targetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IrisApp.DebugSettings.UseDecompiler = false;
|
||||
if (IrisApp.DebugSettings.UseDecompiler)
|
||||
{
|
||||
if (Directory.Exists(decompResultDir))
|
||||
Directory.Delete(decompResultDir, true);
|
||||
Directory.CreateDirectory(decompResultDir);
|
||||
IrisApp.DebugSettings.DecompileResults.CollectionChanged += DecompileResults_CollectionChanged;
|
||||
#if NET6_0_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||
IrisApp.DebugSettings.Bridge.InterpreterStep += Bridge_InterpreterStep;
|
||||
#endif
|
||||
}
|
||||
|
||||
IrisApp.DebugSettings.GenerateDataMappingModels = false;
|
||||
if (IrisApp.DebugSettings.GenerateDataMappingModels)
|
||||
{
|
||||
if (Directory.Exists(dataMapDir))
|
||||
Directory.Delete(dataMapDir, true);
|
||||
Directory.CreateDirectory(dataMapDir);
|
||||
IrisApp.DebugSettings.DataMappingModels.CollectionChanged += DataMappingModels_CollectionChanged;
|
||||
}
|
||||
|
||||
// Set decompiler for marketplace track preview menu item
|
||||
IrisApp.DebugSettings.Breakpoints.Add("res://ZuneMarketplaceResources!SelectionActions.uix (121, 14)");
|
||||
|
||||
IntPtr hWnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;
|
||||
Thread zuneThread = new Thread(new ThreadStart(() =>
|
||||
Microsoft.Zune.Shell.ZuneApplication.Launch(strArgs, hWnd)));
|
||||
Thread zuneThread = new(new ThreadStart(() =>
|
||||
{
|
||||
IrisApp.Initialized += delegate
|
||||
{
|
||||
IrisApp.AddImportRedirect("res://ZuneShellResources!", "clr-res://ZuneShell!");
|
||||
};
|
||||
|
||||
Microsoft.Zune.Shell.ZuneApplication.Launch(strArgs, hWnd);
|
||||
}));
|
||||
zuneThread.Start();
|
||||
}
|
||||
|
||||
private void DecompileResults_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
foreach (var result in e.NewItems.Cast<Microsoft.Iris.Debug.DecompilationResult>())
|
||||
{
|
||||
int count = 0;
|
||||
string ctx = Path.GetFileName(result.Context.Substring(result.Context.LastIndexOf('/') + 1));
|
||||
|
||||
FileInfo file = new(Path.Combine(decompResultDir, ctx + ".uix"));
|
||||
while (file.Exists)
|
||||
file = new(Path.Combine(decompResultDir, $"{ctx}_{++count}.uix"));
|
||||
|
||||
using var stream = file.OpenWrite();
|
||||
result.Doc.Save(stream);
|
||||
stream.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
private void Bridge_InterpreterStep(object sender, Microsoft.Iris.Debug.Data.InterpreterEntry e)
|
||||
{
|
||||
Debug.WriteLine(e.ToString());
|
||||
}
|
||||
|
||||
private void DataMappingModels_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
foreach (var item in e.NewItems.Cast<Microsoft.Iris.Debug.DataMappingModel>())
|
||||
{
|
||||
FileInfo file = new(Path.Combine(dataMapDir, $"{item.Provider}_{item.Type}.cs"));
|
||||
if (file.Exists) file.Delete();
|
||||
|
||||
using var stream = file.Open(FileMode.Create);
|
||||
using var writer = new StreamWriter(stream);
|
||||
writer.Write(item.GeneratedCode);
|
||||
writer.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
public static void CopyAll(DirectoryInfo source, DirectoryInfo target)
|
||||
{
|
||||
// Check if the target directory exists
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<TargetFrameworks>net6.0-windows10.0.22000;net40</TargetFrameworks>
|
||||
<LangVersion>11.0</LangVersion>
|
||||
<UseWPF>true</UseWPF>
|
||||
<ApplicationIcon>Assets\ZuneFluentGem.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -11,7 +13,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Assets\ZuneFluentWordmark.png" />
|
||||
<Content Include="Assets\ZuneFluentGem.ico" />
|
||||
<Resource Include="Assets\ZuneFluentWordmark.png" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<startup useLegacyV2RuntimeActivationPolicy="true">
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
|
||||
</startup>
|
||||
</configuration>
|
||||
|
||||
+45
-20
@@ -1,46 +1,71 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace ZuneHost
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static string _zuneProgramFolder;
|
||||
static DirectoryInfo _zuneProgramDir;
|
||||
|
||||
[STAThread]
|
||||
static int Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Creating splash window...");
|
||||
|
||||
string strArgs = string.Join(" ", args);
|
||||
|
||||
// Make sure that ZuneDBApi can find all the Zune native libraries
|
||||
Console.WriteLine("Copying Zune files...");
|
||||
_zuneProgramFolder = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
|
||||
"Zune");
|
||||
foreach (var info in new DirectoryInfo(_zuneProgramFolder).GetFileSystemInfos())
|
||||
#if NETFRAMEWORK
|
||||
Console.WriteLine("Running legacy build on .NET Framework. If your OS supports .NET Core, please use OpenZune.");
|
||||
#endif
|
||||
|
||||
if (args.Contains("--copyFiles", StringComparer.InvariantCultureIgnoreCase))
|
||||
{
|
||||
if (info is DirectoryInfo dirInfo)
|
||||
// Make sure that ZuneDBApi can find all the Zune native libraries
|
||||
Console.WriteLine("Copying Zune files...");
|
||||
_zuneProgramDir = new(Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
|
||||
"Zune"));
|
||||
if (_zuneProgramDir.Exists)
|
||||
{
|
||||
CopyAll(dirInfo, new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, dirInfo.Name)));
|
||||
}
|
||||
else if (info is FileInfo fileInfo)
|
||||
{
|
||||
string fileName = fileInfo.Name;
|
||||
if (fileInfo.Extension == ".dll")
|
||||
foreach (var info in _zuneProgramDir.GetFileSystemInfos())
|
||||
{
|
||||
string targetPath = Path.Combine(Environment.CurrentDirectory, fileName);
|
||||
if (!File.Exists(targetPath) || fileName == "ZuneDbApi.dll")
|
||||
fileInfo.CopyTo(targetPath);
|
||||
if (info is DirectoryInfo dirInfo)
|
||||
{
|
||||
CopyAll(dirInfo, new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, dirInfo.Name)));
|
||||
}
|
||||
else if (info is FileInfo fileInfo)
|
||||
{
|
||||
string fileName = fileInfo.Name;
|
||||
if (fileInfo.Extension == ".dll")
|
||||
{
|
||||
string targetPath = Path.Combine(Environment.CurrentDirectory, fileName);
|
||||
if (!File.Exists(targetPath) || fileName == "ZuneDbApi.dll")
|
||||
fileInfo.CopyTo(targetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("Starting Zune...");
|
||||
|
||||
return Microsoft.Zune.Shell.ZuneApplication.Launch(strArgs, IntPtr.Zero);
|
||||
try
|
||||
{
|
||||
return Microsoft.Zune.Shell.ZuneApplication.Launch(strArgs, IntPtr.Zero);
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
Console.WriteLine(ex.FileName);
|
||||
throw;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debugger.Launch();
|
||||
Debugger.Break();
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static void CopyAll(DirectoryInfo source, DirectoryInfo target)
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Platforms>AnyCPU;x64;x86;ARM32</Platforms>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>net40;net6.0-windows10.0.22000;net6.0;</TargetFrameworks>
|
||||
<Platforms>AnyCPU;x64;x86;ARM32</Platforms>
|
||||
<LangVersion>11.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZuneShell\ZuneShell.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="build\**" />
|
||||
<EmbeddedResource Remove="build\**" />
|
||||
<None Remove="build\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZuneShell\ZuneShell.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
#if NETSTANDARD1_0_OR_GREATER
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
#endif
|
||||
|
||||
namespace Microsoft.Zune
|
||||
{
|
||||
internal static class Extensions
|
||||
{
|
||||
#if NETSTANDARD2_0_OR_GREATER && !NET5_0_OR_GREATER
|
||||
// FIXME: Blocking the executing thread is generally a bad idea.
|
||||
// Executing some of these methods has a chance of
|
||||
// deadlocking the app.
|
||||
|
||||
public static Stream ReadAsStream(this HttpContent content)
|
||||
{
|
||||
return content.ReadAsStreamAsync().Result;
|
||||
}
|
||||
|
||||
public static HttpResponseMessage Send(this HttpClient client, HttpRequestMessage request)
|
||||
{
|
||||
return client.SendAsync(request).Result;
|
||||
}
|
||||
|
||||
public static Task<Stream> GetStreamAsync(this HttpClient client, Uri uri, CancellationToken _)
|
||||
{
|
||||
return client.GetStreamAsync(uri);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NETSTANDARD && !NETSTANDARD2_1_OR_GREATER
|
||||
public static Task CopyToAsync(this Stream source, Stream destination, CancellationToken _)
|
||||
{
|
||||
return source.CopyToAsync(destination);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
#if OPENZUNE
|
||||
|
||||
using Microsoft.Iris;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Zune.Library
|
||||
{
|
||||
internal class LibraryVirtualList : VirtualList, ISearchableList
|
||||
{
|
||||
private StrixLibraryDataProviderQuery m_owner;
|
||||
private ZuneQueryList m_pQueryList;
|
||||
private string m_itemTypeName;
|
||||
private object m_itemTypeCookie;
|
||||
private bool m_autoRefresh;
|
||||
private bool m_useSlowDataRequests;
|
||||
private bool m_antialiasImageEdges;
|
||||
|
||||
public LibraryVirtualList(StrixLibraryDataProviderQuery owner, ZuneQueryList pQueryList,
|
||||
bool autoRefresh, bool antialiasEdges)
|
||||
: base(true)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.m_owner = owner;
|
||||
base.StoreQueryResults = true;
|
||||
this.m_pQueryList = pQueryList;
|
||||
//pQueryList.AddRef();
|
||||
//this.m_fBlockChanges = false;
|
||||
//this.m_fEndBulkArrivedDuringBlock = false;
|
||||
this.m_antialiasImageEdges = antialiasEdges;
|
||||
this.m_autoRefresh = autoRefresh;
|
||||
if (autoRefresh)
|
||||
{
|
||||
//this.m_pQueryList.Advise(this);
|
||||
}
|
||||
//base.Count = this.m_pQueryList.Count;
|
||||
|
||||
Add("Howdy there!");
|
||||
}
|
||||
catch
|
||||
{
|
||||
base.Dispose(ModelItemDisposeMode.KeepOwnerReference);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetItemTypeCookie(string itemTypeName, object itemTypeCookie)
|
||||
{
|
||||
this.m_itemTypeName = itemTypeName;
|
||||
this.m_itemTypeCookie = itemTypeCookie;
|
||||
}
|
||||
|
||||
public int SearchForString(string searchString)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
#if OPENZUNE
|
||||
|
||||
using Microsoft.Iris;
|
||||
|
||||
namespace Microsoft.Zune.Library
|
||||
{
|
||||
public static class StrixLibraryDataProvider
|
||||
{
|
||||
public static void Register()
|
||||
{
|
||||
Application.RegisterDataProvider("Library", new DataProviderQueryFactory(ConstructQuery));
|
||||
}
|
||||
|
||||
private static DataProviderQuery ConstructQuery(object queryTypeCookie)
|
||||
{
|
||||
return new StrixLibraryDataProviderQuery(queryTypeCookie);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,67 @@
|
||||
#if OPENZUNE
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Iris;
|
||||
|
||||
namespace Microsoft.Zune.Library
|
||||
{
|
||||
// Token: 0x02000271 RID: 625
|
||||
internal class StrixLibraryDataProviderQueryResult : DataProviderObject
|
||||
{
|
||||
// Token: 0x06000F6A RID: 3946 RVA: 0x000E90D0 File Offset: 0x000E84D0
|
||||
public StrixLibraryDataProviderQueryResult(StrixLibraryDataProviderQuery owner, LibraryVirtualList virtualListResultSet, object resultTypeCookie) : base(owner, resultTypeCookie)
|
||||
{
|
||||
this.m_virtualListResultSet = virtualListResultSet;
|
||||
if (virtualListResultSet != null)
|
||||
{
|
||||
foreach (DataProviderMapping dataProviderMapping in base.Mappings.Values)
|
||||
{
|
||||
if (dataProviderMapping.UnderlyingCollectionTypeCookie != null)
|
||||
{
|
||||
this.m_virtualListResultSet.SetItemTypeCookie(dataProviderMapping.UnderlyingCollectionTypeName, dataProviderMapping.UnderlyingCollectionTypeCookie);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000F6B RID: 3947 RVA: 0x000E9160 File Offset: 0x000E8560
|
||||
public override object GetProperty(string propertyName)
|
||||
{
|
||||
DataProviderMapping dataProviderMapping = null;
|
||||
if (propertyName == "IsEmpty")
|
||||
{
|
||||
return this.m_isEmpty;
|
||||
}
|
||||
if (base.Mappings.TryGetValue(propertyName, out dataProviderMapping))
|
||||
{
|
||||
return this.m_virtualListResultSet;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x06000F6C RID: 3948 RVA: 0x00101710 File Offset: 0x00100B10
|
||||
public override void SetProperty(string propertyName, object value)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
// Token: 0x06000F6D RID: 3949 RVA: 0x000E91A8 File Offset: 0x000E85A8
|
||||
public void SetIsEmpty([MarshalAs(UnmanagedType.U1)] bool isEmpty)
|
||||
{
|
||||
if (this.m_isEmpty != isEmpty)
|
||||
{
|
||||
this.m_isEmpty = isEmpty;
|
||||
base.FirePropertyChanged("IsEmpty");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000B3C RID: 2876
|
||||
protected LibraryVirtualList m_virtualListResultSet;
|
||||
|
||||
// Token: 0x04000B3D RID: 2877
|
||||
protected bool m_isEmpty;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Zune.Library
|
||||
{
|
||||
public class ZuneQueryList : IDisposable
|
||||
{
|
||||
internal ZuneQueryList(EQueryType queryType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool IsEmpty { get; protected set; }
|
||||
|
||||
public bool IsDisposed { get; protected set; }
|
||||
|
||||
public int Count { get; protected set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
IsDisposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
#if OPENZUNE
|
||||
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using NAudio.Wave;
|
||||
using StrixMusic.Sdk.MediaPlayback;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using StrixPlaybackState = StrixMusic.Sdk.MediaPlayback.PlaybackState;
|
||||
|
||||
namespace Microsoft.Zune.Playback
|
||||
{
|
||||
public class MediaFoundationAudioService : IAudioPlayerService
|
||||
{
|
||||
readonly WaveOutEvent m_audio = new();
|
||||
private PlaybackItem m_currentSource;
|
||||
|
||||
public static MediaFoundationAudioService Instance => new();
|
||||
|
||||
private MediaFoundationAudioService() { }
|
||||
|
||||
public PlaybackItem CurrentSource
|
||||
{
|
||||
get => m_currentSource;
|
||||
set
|
||||
{
|
||||
m_currentSource = value;
|
||||
CurrentSourceChanged?.Invoke(this, value);
|
||||
}
|
||||
}
|
||||
|
||||
public TimeSpan Position { get; private set; }
|
||||
|
||||
public StrixPlaybackState PlaybackState => m_audio.PlaybackState switch
|
||||
{
|
||||
NAudio.Wave.PlaybackState.Playing => StrixPlaybackState.Playing,
|
||||
|
||||
NAudio.Wave.PlaybackState.Paused or
|
||||
NAudio.Wave.PlaybackState.Stopped => StrixPlaybackState.Paused,
|
||||
|
||||
_ => StrixPlaybackState.None
|
||||
};
|
||||
|
||||
public double Volume
|
||||
{
|
||||
get => m_audio.Volume;
|
||||
private set
|
||||
{
|
||||
m_audio.Volume = (float)value;
|
||||
VolumeChanged?.Invoke(this, value);
|
||||
}
|
||||
}
|
||||
|
||||
public double PlaybackSpeed { get; private set; }
|
||||
|
||||
public event EventHandler<PlaybackItem> CurrentSourceChanged;
|
||||
public event EventHandler<float[]> QuantumProcessed;
|
||||
public event EventHandler<TimeSpan> PositionChanged;
|
||||
public event EventHandler<StrixPlaybackState> PlaybackStateChanged;
|
||||
public event EventHandler<double> VolumeChanged;
|
||||
public event EventHandler<double> PlaybackSpeedChanged;
|
||||
|
||||
public Task ChangePlaybackSpeedAsync(double speed, CancellationToken cancellationToken = default)
|
||||
{
|
||||
PlaybackSpeed = speed;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task ChangeVolumeAsync(double volume, CancellationToken cancellationToken = default)
|
||||
{
|
||||
Volume = (float)volume;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task PauseAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
m_audio.Pause();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task Play(PlaybackItem sourceConfig, CancellationToken cancellationToken = default)
|
||||
{
|
||||
WaveStream reader = null;
|
||||
var stream = sourceConfig.MediaConfig.FileStreamSource;
|
||||
var uri = sourceConfig.MediaConfig.MediaSourceUri;
|
||||
|
||||
if (stream != null)
|
||||
{
|
||||
reader = new StreamMediaFoundationReader(stream);
|
||||
}
|
||||
else if (uri.IsFile)
|
||||
{
|
||||
reader = new MediaFoundationReader(uri.ToString());
|
||||
}
|
||||
else if (uri.Scheme.StartsWith("http"))
|
||||
{
|
||||
// Use this URI for testing: https://www.newgrounds.com/audio/download/641172
|
||||
|
||||
System.Net.Http.HttpClient client = new();
|
||||
|
||||
var httpStream = await client.GetStreamAsync(uri, cancellationToken);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
// NAudio requires some fancy stuff to stream from the web. This is
|
||||
// a relatively simple workaround that downloads the entire file
|
||||
// into memory before playing.
|
||||
stream = new System.IO.MemoryStream();
|
||||
await httpStream.CopyToAsync(stream, cancellationToken);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
reader = new StreamMediaFoundationReader(stream);
|
||||
}
|
||||
|
||||
m_audio.Init(reader);
|
||||
m_audio.Play();
|
||||
}
|
||||
|
||||
public Task Preload(PlaybackItem sourceConfig, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task ResumeAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
m_audio.Play();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task SeekAsync(TimeSpan position, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,75 @@
|
||||
#if OPENZUNE
|
||||
|
||||
using MicrosoftZunePlayback;
|
||||
using StrixMusic.Sdk.MediaPlayback;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.Zune.Playback
|
||||
{
|
||||
public class PlayerInteropAudioService : IAudioPlayerService
|
||||
{
|
||||
private readonly PlayerInterop _playbackWrapper = PlayerInterop.Instance;
|
||||
|
||||
public PlaybackItem CurrentSource { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
|
||||
public TimeSpan Position => new(_playbackWrapper.Position);
|
||||
|
||||
public PlaybackState PlaybackState => throw new NotImplementedException();
|
||||
|
||||
public double Volume => _playbackWrapper.Volume / 100d;
|
||||
|
||||
public double PlaybackSpeed => 1.0d;
|
||||
|
||||
public event EventHandler<PlaybackItem> CurrentSourceChanged;
|
||||
public event EventHandler<float[]> QuantumProcessed;
|
||||
public event EventHandler<TimeSpan> PositionChanged;
|
||||
public event EventHandler<PlaybackState> PlaybackStateChanged;
|
||||
public event EventHandler<double> VolumeChanged;
|
||||
public event EventHandler<double> PlaybackSpeedChanged;
|
||||
|
||||
public Task ChangePlaybackSpeedAsync(double speed, CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task ChangeVolumeAsync(double volume, CancellationToken cancellationToken = default)
|
||||
{
|
||||
_playbackWrapper.Volume = (int)(volume * 100);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task PauseAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
_playbackWrapper.Pause();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Play(PlaybackItem sourceConfig, CancellationToken cancellationToken = default)
|
||||
{
|
||||
_playbackWrapper.Play();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Preload(PlaybackItem sourceConfig, CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task ResumeAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
_playbackWrapper.Play();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task SeekAsync(TimeSpan position, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (_playbackWrapper.CanSeek)
|
||||
_playbackWrapper.SeekToAbsolutePosition(position.Ticks);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,175 @@
|
||||
#if OPENZUNE
|
||||
|
||||
using LibVLCSharp.Shared;
|
||||
using StrixMusic.Sdk.MediaPlayback;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using StrixPlaybackState = StrixMusic.Sdk.MediaPlayback.PlaybackState;
|
||||
|
||||
namespace Microsoft.Zune.Playback
|
||||
{
|
||||
public class VlcAudioService : IAudioPlayerService
|
||||
{
|
||||
readonly LibVLC m_vlc;
|
||||
readonly MediaPlayer m_player;
|
||||
private Media m_media;
|
||||
private PlaybackItem m_currentSource;
|
||||
private TimeSpan m_position;
|
||||
|
||||
public static VlcAudioService Instance => new();
|
||||
|
||||
private VlcAudioService()
|
||||
{
|
||||
Core.Initialize(@"C:\Program Files\VideoLAN\VLC");
|
||||
|
||||
bool debug =
|
||||
#if DEBUG
|
||||
true;
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
|
||||
m_vlc = new(enableDebugLogs: debug);
|
||||
m_player = new(m_vlc);
|
||||
|
||||
m_player.TimeChanged += (sender, e) => Position = TimeSpan.FromMilliseconds(e.Time);
|
||||
}
|
||||
|
||||
public PlaybackItem CurrentSource
|
||||
{
|
||||
get => m_currentSource;
|
||||
set
|
||||
{
|
||||
m_currentSource = value;
|
||||
CurrentSourceChanged?.Invoke(this, value);
|
||||
}
|
||||
}
|
||||
|
||||
public TimeSpan Position
|
||||
{
|
||||
get => m_position;
|
||||
set
|
||||
{
|
||||
m_position = value;
|
||||
PositionChanged?.Invoke(this, value);
|
||||
}
|
||||
}
|
||||
|
||||
public StrixPlaybackState PlaybackState => m_player.State switch
|
||||
{
|
||||
VLCState.Playing => StrixPlaybackState.Playing,
|
||||
|
||||
VLCState.Paused or
|
||||
VLCState.Stopped => StrixPlaybackState.Paused,
|
||||
|
||||
VLCState.Opening or
|
||||
VLCState.Buffering => StrixPlaybackState.Loading,
|
||||
|
||||
VLCState.Error => StrixPlaybackState.Failed,
|
||||
|
||||
_ => StrixPlaybackState.None
|
||||
};
|
||||
|
||||
public double Volume
|
||||
{
|
||||
get => m_player.Volume / 100d;
|
||||
private set
|
||||
{
|
||||
m_player.Volume = (int)(value * 100);
|
||||
VolumeChanged?.Invoke(this, value);
|
||||
}
|
||||
}
|
||||
|
||||
public double PlaybackSpeed
|
||||
{
|
||||
get => m_player.Rate;
|
||||
private set
|
||||
{
|
||||
m_player.SetRate((float)value);
|
||||
VolumeChanged?.Invoke(this, value);
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<PlaybackItem> CurrentSourceChanged;
|
||||
public event EventHandler<float[]> QuantumProcessed;
|
||||
public event EventHandler<TimeSpan> PositionChanged;
|
||||
public event EventHandler<StrixPlaybackState> PlaybackStateChanged;
|
||||
public event EventHandler<double> VolumeChanged;
|
||||
public event EventHandler<double> PlaybackSpeedChanged;
|
||||
|
||||
public Task ChangePlaybackSpeedAsync(double speed, CancellationToken cancellationToken = default)
|
||||
{
|
||||
PlaybackSpeed = speed;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task ChangeVolumeAsync(double volume, CancellationToken cancellationToken = default)
|
||||
{
|
||||
Volume = (float)volume;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task PauseAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
m_player.Pause();
|
||||
|
||||
if (m_player.Media != null)
|
||||
PlaybackStateChanged?.Invoke(this, PlaybackState);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task Play(PlaybackItem sourceConfig, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (CurrentSource != sourceConfig)
|
||||
await Preload(sourceConfig, cancellationToken);
|
||||
|
||||
if (m_player.Play())
|
||||
PlaybackStateChanged?.Invoke(this, PlaybackState);
|
||||
}
|
||||
|
||||
public async Task Preload(PlaybackItem sourceConfig, CancellationToken cancellationToken = default)
|
||||
{
|
||||
PlaybackStateChanged?.Invoke(this, StrixPlaybackState.Loading);
|
||||
|
||||
CurrentSource = sourceConfig;
|
||||
var uri = sourceConfig.MediaConfig.MediaSourceUri;
|
||||
var stream = sourceConfig.MediaConfig.FileStreamSource;
|
||||
|
||||
if (uri != null)
|
||||
{
|
||||
m_media = new(m_vlc, uri);
|
||||
}
|
||||
else if (stream != null)
|
||||
{
|
||||
m_media = new(m_vlc, new StreamMediaInput(stream));
|
||||
}
|
||||
|
||||
var parseStatus = await m_media.Parse(MediaParseOptions.ParseNetwork | MediaParseOptions.ParseLocal, cancellationToken: cancellationToken);
|
||||
if (parseStatus == MediaParsedStatus.Failed || parseStatus == MediaParsedStatus.Timeout)
|
||||
PlaybackStateChanged?.Invoke(this, StrixPlaybackState.Failed);
|
||||
else if (parseStatus == MediaParsedStatus.Done || parseStatus == MediaParsedStatus.Skipped)
|
||||
PlaybackStateChanged?.Invoke(this, PlaybackState);
|
||||
|
||||
m_player.Media = m_media;
|
||||
}
|
||||
|
||||
public Task ResumeAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
m_player.Play();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task SeekAsync(TimeSpan position, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (m_player.IsSeekable)
|
||||
m_player.SeekTo(position);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Xml.Serialization;
|
||||
using Zune.Xml.Commerce;
|
||||
|
||||
namespace Microsoft.Zune.Service
|
||||
{
|
||||
internal static partial class CommunityCommerce
|
||||
{
|
||||
static readonly XmlSerializer _signInRequestSerializer = new XmlSerializer(typeof(SignInRequest));
|
||||
static readonly XmlSerializer _signInResponseSerializer = new XmlSerializer(typeof(SignInResponse));
|
||||
static SignInResponse _memberInfo;
|
||||
|
||||
public static SignInResponse MemberInfo
|
||||
{
|
||||
get => _memberInfo;
|
||||
private set
|
||||
{
|
||||
_memberInfo = value;
|
||||
|
||||
Culture = new CultureInfo(value.AccountInfo.Locale);
|
||||
}
|
||||
}
|
||||
|
||||
public static CultureInfo Culture { get; private set; } = CultureInfo.CurrentCulture;
|
||||
|
||||
public static bool IsSignedIn => Escargot.HasToken && MemberInfo != null;
|
||||
|
||||
public static void SignOut() => MemberInfo = null;
|
||||
|
||||
private static Stream GetSignInRequestBody()
|
||||
{
|
||||
var requestObj = new SignInRequest
|
||||
{
|
||||
TunerInfo = new TunerInfo
|
||||
{
|
||||
Version = Assembly.GetEntryAssembly()?.GetName()?.Version?.ToString()
|
||||
}
|
||||
};
|
||||
var contentStream = new MemoryStream();
|
||||
_signInRequestSerializer.Serialize(contentStream, requestObj);
|
||||
|
||||
contentStream.Position = 0;
|
||||
return contentStream;
|
||||
}
|
||||
|
||||
private static SignInResponse ReadSignInResponse(Stream stream)
|
||||
{
|
||||
return _signInResponseSerializer.Deserialize(stream) as SignInResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using System.Net.Http;
|
||||
using ZuneUI;
|
||||
|
||||
namespace Microsoft.Zune.Service
|
||||
{
|
||||
partial class CommunityCommerce
|
||||
{
|
||||
private static readonly HttpClient _client = Escargot._client;
|
||||
|
||||
public static HRESULT TrySignIn()
|
||||
{
|
||||
if (!Escargot.HasToken)
|
||||
return HRESULT._NS_E_SUBSCRIPTIONSERVICE_LOGIN_FAILED;
|
||||
|
||||
try
|
||||
{
|
||||
string url = Service2.Instance.GetEndPointUri(EServiceEndpointId.SEID_Commerce) + $"/account/signin";
|
||||
HttpRequestMessage request = new(HttpMethod.Post, url);
|
||||
request.Headers.UserAgent.ParseAdd(CommunityService.AppUserAgent);
|
||||
|
||||
var contentStream = GetSignInRequestBody();
|
||||
request.Content = new StreamContent(contentStream);
|
||||
request.Content.Headers.ContentType = new(Atom.Constants.ATOM_MIMETYPE);
|
||||
request.Content.Headers.ContentLength = contentStream.Length;
|
||||
|
||||
Escargot.AuthenticateRequest(request);
|
||||
|
||||
var response = _client.Send(request);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var responseObj = ReadSignInResponse(response.Content.ReadAsStream());
|
||||
|
||||
uint? errorCode = responseObj?.AccountState?.SignInErrorCode;
|
||||
if (errorCode != 0)
|
||||
return new HRESULT(unchecked((int)errorCode));
|
||||
|
||||
MemberInfo = responseObj;
|
||||
return HRESULT._S_OK;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return HRESULT._NS_E_SUBSCRIPTIONSERVICE_LOGIN_FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user