mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-28 11:13:49 +02:00
Refactored FilePicker (#1045)
This commit is contained in:
@@ -12,8 +12,6 @@ namespace VRCX
|
||||
{
|
||||
public partial class AppApi
|
||||
{
|
||||
private static bool dialogOpen;
|
||||
|
||||
/// <summary>
|
||||
/// Adds metadata to a PNG screenshot file and optionally renames the file to include the specified world ID.
|
||||
/// </summary>
|
||||
@@ -39,51 +37,6 @@ namespace VRCX
|
||||
return path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens a file dialog to select a PNG screenshot file.
|
||||
/// The resulting file path is passed to <see cref="GetScreenshotMetadata(string)"/>.
|
||||
/// </summary>
|
||||
public void OpenScreenshotFileDialog()
|
||||
{
|
||||
if (dialogOpen) return;
|
||||
dialogOpen = true;
|
||||
|
||||
var thread = new Thread(() =>
|
||||
{
|
||||
using (var openFileDialog = new OpenFileDialog())
|
||||
{
|
||||
openFileDialog.DefaultExt = ".png";
|
||||
openFileDialog.Filter = "PNG Files (*.png)|*.png";
|
||||
openFileDialog.FilterIndex = 1;
|
||||
openFileDialog.RestoreDirectory = true;
|
||||
|
||||
var initialPath = GetVRChatPhotosLocation();
|
||||
if (Directory.Exists(initialPath))
|
||||
{
|
||||
openFileDialog.InitialDirectory = initialPath;
|
||||
}
|
||||
|
||||
if (openFileDialog.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
dialogOpen = false;
|
||||
return;
|
||||
}
|
||||
|
||||
dialogOpen = false;
|
||||
|
||||
var path = openFileDialog.FileName;
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return;
|
||||
|
||||
ExecuteAppFunction("screenshotMetadataResetSearch", null);
|
||||
ExecuteAppFunction("getAndDisplayScreenshot", path);
|
||||
}
|
||||
});
|
||||
|
||||
thread.SetApartmentState(ApartmentState.STA);
|
||||
thread.Start();
|
||||
}
|
||||
|
||||
public string GetExtraScreenshotData(string path, bool carouselCache)
|
||||
{
|
||||
var fileName = Path.GetFileNameWithoutExtension(path);
|
||||
@@ -131,7 +84,6 @@ namespace VRCX
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return null;
|
||||
|
||||
|
||||
var metadata = ScreenshotHelper.GetScreenshotMetadata(path);
|
||||
|
||||
if (metadata == null)
|
||||
|
||||
Reference in New Issue
Block a user