mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-25 01:33: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;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -796,6 +797,46 @@ namespace VRCX
|
|||||||
ExecuteAppFunction("displayScreenshotMetadata", metadata.ToString(Formatting.Indented));
|
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()
|
public void FlashWindow()
|
||||||
{
|
{
|
||||||
MainForm.Instance.BeginInvoke(new MethodInvoker(() => { WinformThemer.Flash(MainForm.Instance); }));
|
MainForm.Instance.BeginInvoke(new MethodInvoker(() => { WinformThemer.Flash(MainForm.Instance); }));
|
||||||
|
|||||||
@@ -89,8 +89,11 @@ speechSynthesis.getVoices();
|
|||||||
$app.refreshCustomCss();
|
$app.refreshCustomCss();
|
||||||
}
|
}
|
||||||
|
|
||||||
let carouselNavigation = { 'ArrowLeft': 0, 'ArrowRight': 2 }[e.key]
|
let carouselNavigation = {ArrowLeft: 0, ArrowRight: 2}[e.key];
|
||||||
if (carouselNavigation !== undefined && $app.screenshotMetadataDialog?.visible) {
|
if (
|
||||||
|
typeof carouselNavigation !== 'undefined' &&
|
||||||
|
$app.screenshotMetadataDialog?.visible
|
||||||
|
) {
|
||||||
$app.screenshotMetadataCarouselChange(carouselNavigation);
|
$app.screenshotMetadataCarouselChange(carouselNavigation);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -20636,7 +20639,7 @@ speechSynthesis.getVoices();
|
|||||||
D.metadata.dateTime = Date.parse(json.creationDate);
|
D.metadata.dateTime = Date.parse(json.creationDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showScreenshotMetadataDialog();
|
this.openScreenshotMetadataDialog();
|
||||||
};
|
};
|
||||||
|
|
||||||
$app.data.screenshotMetadataDialog = {
|
$app.data.screenshotMetadataDialog = {
|
||||||
@@ -20645,7 +20648,7 @@ speechSynthesis.getVoices();
|
|||||||
isUploading: false
|
isUploading: false
|
||||||
};
|
};
|
||||||
|
|
||||||
$app.methods.showScreenshotMetadataDialog = function () {
|
$app.methods.openScreenshotMetadataDialog = function () {
|
||||||
this.$nextTick(() =>
|
this.$nextTick(() =>
|
||||||
adjustDialogZ(this.$refs.screenshotMetadataDialog.$el)
|
adjustDialogZ(this.$refs.screenshotMetadataDialog.$el)
|
||||||
);
|
);
|
||||||
@@ -20653,6 +20656,14 @@ speechSynthesis.getVoices();
|
|||||||
D.visible = true;
|
D.visible = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$app.methods.showScreenshotMetadataDialog = function () {
|
||||||
|
var D = this.screenshotMetadataDialog;
|
||||||
|
if (!D.metadata.filePath) {
|
||||||
|
AppApi.GetLastScreenshot();
|
||||||
|
}
|
||||||
|
this.openScreenshotMetadataDialog();
|
||||||
|
};
|
||||||
|
|
||||||
$app.methods.screenshotMetadataCarouselChange = function (index) {
|
$app.methods.screenshotMetadataCarouselChange = function (index) {
|
||||||
var D = this.screenshotMetadataDialog;
|
var D = this.screenshotMetadataDialog;
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
@@ -20712,16 +20723,36 @@ speechSynthesis.getVoices();
|
|||||||
* This function is called by .NET(CefCustomDragHandler#CefCustomDragHandler) when a file is dragged over a drop zone in the app window.
|
* This function is called by .NET(CefCustomDragHandler#CefCustomDragHandler) when a file is dragged over a drop zone in the app window.
|
||||||
* @param {string} filePath - The full path to the file being dragged into the window
|
* @param {string} filePath - The full path to the file being dragged into the window
|
||||||
*/
|
*/
|
||||||
$app.methods.dragEnterCef = function(filePath) {
|
$app.methods.dragEnterCef = function (filePath) {
|
||||||
this.currentlyDroppingFile = filePath
|
this.currentlyDroppingFile = filePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
$app.methods.handleDrop = function(event) {
|
$app.methods.handleDrop = function (event) {
|
||||||
if (this.currentlyDroppingFile == null) return
|
if (this.currentlyDroppingFile === null) {
|
||||||
console.log("Dropped file into window: ", this.currentlyDroppingFile)
|
return;
|
||||||
|
}
|
||||||
|
console.log('Dropped file into window: ', this.currentlyDroppingFile);
|
||||||
AppApi.GetScreenshotMetadata(this.currentlyDroppingFile);
|
AppApi.GetScreenshotMetadata(this.currentlyDroppingFile);
|
||||||
|
|
||||||
event.preventDefault()
|
event.preventDefault();
|
||||||
|
};
|
||||||
|
|
||||||
|
$app.methods.copyImageToClipboard = function (path) {
|
||||||
|
AppApi.CopyImageToClipboard(path).then(() => {
|
||||||
|
this.$message({
|
||||||
|
message: 'Image copied to clipboard',
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$app.methods.openImageFolder = function (path) {
|
||||||
|
AppApi.OpenImageFolder(path).then(() => {
|
||||||
|
this.$message({
|
||||||
|
message: 'Opened image folder',
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// YouTube API
|
// YouTube API
|
||||||
|
|||||||
@@ -3846,9 +3846,16 @@ html
|
|||||||
//- dialog: screenshot metadata
|
//- dialog: screenshot metadata
|
||||||
el-dialog.x-dialog(:before-close="beforeDialogClose" @mousedown.native="dialogMouseDown" @mouseup.native="dialogMouseUp" ref="screenshotMetadataDialog" :visible.sync="screenshotMetadataDialog.visible" :title="$t('dialog.screenshot_metadata.header')" width="1050px")
|
el-dialog.x-dialog(:before-close="beforeDialogClose" @mousedown.native="dialogMouseDown" @mouseup.native="dialogMouseUp" ref="screenshotMetadataDialog" :visible.sync="screenshotMetadataDialog.visible" :title="$t('dialog.screenshot_metadata.header')" width="1050px")
|
||||||
div(v-if="screenshotMetadataDialog.visible" @dragover.prevent @dragenter.prevent @drop="handleDrop" style="-webkit-app-region: drag")
|
div(v-if="screenshotMetadataDialog.visible" @dragover.prevent @dragenter.prevent @drop="handleDrop" style="-webkit-app-region: drag")
|
||||||
|
span(style="margin-left:5px;color:#909399;font-family:monospace") {{ $t('dialog.screenshot_metadata.drag') }}
|
||||||
|
br
|
||||||
el-button(size="small" icon="el-icon-folder-opened" @click="AppApi.OpenScreenshotFileDialog()") {{ $t('dialog.screenshot_metadata.browse') }}
|
el-button(size="small" icon="el-icon-folder-opened" @click="AppApi.OpenScreenshotFileDialog()") {{ $t('dialog.screenshot_metadata.browse') }}
|
||||||
|
el-button(size="small" icon="el-icon-picture-outline" @click="AppApi.GetLastScreenshot()") {{ $t('dialog.screenshot_metadata.last_screenshot') }}
|
||||||
|
el-button(size="small" icon="el-icon-copy-document" @click="copyImageToClipboard(screenshotMetadataDialog.metadata.filePath)") {{ $t('dialog.screenshot_metadata.copy_image') }}
|
||||||
|
el-button(size="small" icon="el-icon-folder" @click="openImageFolder(screenshotMetadataDialog.metadata.filePath)") {{ $t('dialog.screenshot_metadata.open_folder') }}
|
||||||
el-button(v-if="API.currentUser.$isVRCPlus && screenshotMetadataDialog.metadata.filePath" size="small" icon="el-icon-upload2" @click="uploadScreenshotToGallery") {{ $t('dialog.screenshot_metadata.upload') }}
|
el-button(v-if="API.currentUser.$isVRCPlus && screenshotMetadataDialog.metadata.filePath" size="small" icon="el-icon-upload2" @click="uploadScreenshotToGallery") {{ $t('dialog.screenshot_metadata.upload') }}
|
||||||
span(v-text="screenshotMetadataDialog.metadata.fileName" style="margin-left:5px")
|
br
|
||||||
|
br
|
||||||
|
span(v-text="screenshotMetadataDialog.metadata.fileName")
|
||||||
br
|
br
|
||||||
span(v-if="screenshotMetadataDialog.metadata.dateTime") {{ screenshotMetadataDialog.metadata.dateTime | formatDate('long') }}
|
span(v-if="screenshotMetadataDialog.metadata.dateTime") {{ screenshotMetadataDialog.metadata.dateTime | formatDate('long') }}
|
||||||
span(v-if="screenshotMetadataDialog.metadata.fileResolution" v-text="screenshotMetadataDialog.metadata.fileResolution" style="margin-left:5px")
|
span(v-if="screenshotMetadataDialog.metadata.fileResolution" v-text="screenshotMetadataDialog.metadata.fileResolution" style="margin-left:5px")
|
||||||
|
|||||||
@@ -1095,7 +1095,11 @@
|
|||||||
},
|
},
|
||||||
"screenshot_metadata": {
|
"screenshot_metadata": {
|
||||||
"header": "Screenshot Metadata",
|
"header": "Screenshot Metadata",
|
||||||
|
"drag": "Drag and drop a screenshot here",
|
||||||
"browse": "Browse",
|
"browse": "Browse",
|
||||||
|
"last_screenshot": "Last Screenshot",
|
||||||
|
"copy_image": "Copy Image",
|
||||||
|
"open_folder": "Open Folder",
|
||||||
"upload": "Upload"
|
"upload": "Upload"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user