mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 06:43:51 +02:00
feat: Copy/open image, open last image
This commit is contained in:
41
AppApi.cs
41
AppApi.cs
@@ -7,6 +7,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -796,6 +797,46 @@ namespace VRCX
|
||||
ExecuteAppFunction("displayScreenshotMetadata", metadata.ToString(Formatting.Indented));
|
||||
}
|
||||
|
||||
public void GetLastScreenshot()
|
||||
{
|
||||
// Get the last screenshot taken by VRChat
|
||||
var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "VRChat");
|
||||
if (!Directory.Exists(path))
|
||||
return;
|
||||
|
||||
var lastDirectory = Directory.GetDirectories(path).OrderByDescending(Directory.GetCreationTime).FirstOrDefault();
|
||||
if (lastDirectory == null)
|
||||
return;
|
||||
|
||||
var lastScreenshot = Directory.GetFiles(lastDirectory, "*.png").OrderByDescending(File.GetCreationTime).FirstOrDefault();
|
||||
if (lastScreenshot == null)
|
||||
return;
|
||||
|
||||
GetScreenshotMetadata(lastScreenshot);
|
||||
}
|
||||
|
||||
public void CopyImageToClipboard(string path)
|
||||
{
|
||||
// check if the file exists and is any image file type
|
||||
if (File.Exists(path) && (path.EndsWith(".png") || path.EndsWith(".jpg") || path.EndsWith(".jpeg") || path.EndsWith(".gif") || path.EndsWith(".bmp") || path.EndsWith(".webp")))
|
||||
{
|
||||
MainForm.Instance.BeginInvoke(new MethodInvoker(() =>
|
||||
{
|
||||
var image = Image.FromFile(path);
|
||||
Clipboard.SetImage(image);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenImageFolder(string path)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
return;
|
||||
|
||||
// open folder with file highlighted
|
||||
Process.Start("explorer.exe", $"/select,\"{path}\"");
|
||||
}
|
||||
|
||||
public void FlashWindow()
|
||||
{
|
||||
MainForm.Instance.BeginInvoke(new MethodInvoker(() => { WinformThemer.Flash(MainForm.Instance); }));
|
||||
|
||||
Reference in New Issue
Block a user