From 46d894c9c400bed6618ed379d7fa37802556359f Mon Sep 17 00:00:00 2001 From: Jeddunk Date: Wed, 13 Jan 2021 16:39:28 +0100 Subject: [PATCH] DLC copy paste implemented. --- GoldbergGUI.Core/GoldbergGUI.Core.csproj | 3 ++ GoldbergGUI.Core/ViewModels/MainViewModel.cs | 34 ++++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/GoldbergGUI.Core/GoldbergGUI.Core.csproj b/GoldbergGUI.Core/GoldbergGUI.Core.csproj index 567800d..9cc9258 100644 --- a/GoldbergGUI.Core/GoldbergGUI.Core.csproj +++ b/GoldbergGUI.Core/GoldbergGUI.Core.csproj @@ -14,6 +14,9 @@ + + ..\..\..\..\..\..\Windows\Microsoft.NET\assembly\GAC_32\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll + ..\..\..\..\..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll diff --git a/GoldbergGUI.Core/ViewModels/MainViewModel.cs b/GoldbergGUI.Core/ViewModels/MainViewModel.cs index 48d57cf..9e68dbb 100644 --- a/GoldbergGUI.Core/ViewModels/MainViewModel.cs +++ b/GoldbergGUI.Core/ViewModels/MainViewModel.cs @@ -5,7 +5,10 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; +using System.Runtime.InteropServices; +using System.Text.RegularExpressions; using System.Threading.Tasks; +using System.Windows; using GoldbergGUI.Core.Models; using GoldbergGUI.Core.Services; using Microsoft.Win32; @@ -234,7 +237,7 @@ namespace GoldbergGUI.Core.ViewModels } } - public string AboutVersionText => + public string AboutVersionText => FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion; // COMMANDS // @@ -413,10 +416,35 @@ namespace GoldbergGUI.Core.ViewModels await RaisePropertyChanged(() => SteamInterfacesTxtExists).ConfigureAwait(false); MainWindowEnabled = true; } - + 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(@"(?.*) *= *(?.*)"); + 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 //