DLC copy paste implemented.

This commit is contained in:
Jeddunk 2021-01-13 16:39:28 +01:00
parent 386daa126b
commit 46d894c9c4
2 changed files with 34 additions and 3 deletions

View File

@ -14,6 +14,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<HintPath>..\..\..\..\..\..\Windows\Microsoft.NET\assembly\GAC_32\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll</HintPath>
</Reference>
<Reference Include="PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"> <Reference Include="PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<HintPath>..\..\..\..\..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll</HintPath> <HintPath>..\..\..\..\..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll</HintPath>
</Reference> </Reference>

View File

@ -5,7 +5,10 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows;
using GoldbergGUI.Core.Models; using GoldbergGUI.Core.Models;
using GoldbergGUI.Core.Services; using GoldbergGUI.Core.Services;
using Microsoft.Win32; using Microsoft.Win32;
@ -416,7 +419,32 @@ namespace GoldbergGUI.Core.ViewModels
public IMvxCommand PasteDlcCommand => new MvxCommand(() => public IMvxCommand PasteDlcCommand => new MvxCommand(() =>
{ {
_log.Debug("Received CTRL+V"); if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return;
_log.Info("Trying to paste DLC list...");
if (!(Clipboard.ContainsText(TextDataFormat.UnicodeText) || Clipboard.ContainsText(TextDataFormat.Text)))
{
_log.Warn("Invalid DLC list!");
}
else
{
DLCs.Clear();
var result = Clipboard.GetText();
var expression = new Regex(@"(?<id>.*) *= *(?<name>.*)");
foreach (var line in result.Split(new[]
{
"\n",
"\r\n"
}, StringSplitOptions.RemoveEmptyEntries))
{
var match = expression.Match(line);
if (match.Success)
DLCs.Add(new SteamApp
{
AppId = Convert.ToInt32(match.Groups["id"].Value),
Name = match.Groups["name"].Value
});
}
}
}); });
// OTHER METHODS // // OTHER METHODS //