Fix DragDrop due to CLI updated

This commit is contained in:
fangrong 2024-08-02 10:59:39 +08:00
parent 5f426654f6
commit 2e81fd5bae
2 changed files with 32 additions and 9 deletions

View File

@ -66,6 +66,9 @@ internal class OpenOptions
[Option('f', "folder", HelpText = "Call a folder select dialog then open the selected folder.")]
public bool IsFolder { get; set; }
[Option('d', "dir", HelpText = "Open the folder directly instead of calling folder select dialog. Will be ignore if -f/--folder not passed.")]
public string DirPath { get; set; }
[Value(0, MetaName = "RomPath", HelpText = "Path of the file(s). Can be provided multiple. Will be ignore if -f/--folder passed.")]
public IEnumerable<string> Props
{
@ -100,6 +103,7 @@ namespace Tinke
public static List<string> tblRoms;
public static bool bIsFolder = false;
public static bool bOpenDefault = false;
public static string openDirPath;
/// <summary>
/// Punto de entrada principal para la aplicación.
@ -108,7 +112,7 @@ namespace Tinke
static void Main(string[] args)
{
#region Comprobación de archivos necesarios
string[] archivos = new string[] { "Ekona.dll", "DSDecmp.dll" , "Be.Windows.Forms.HexBox.dll" };
string[] archivos = new string[] { "Ekona.dll", "DSDecmp.dll" , "Be.Windows.Forms.HexBox.dll", "CommandLine.dll" };
string faltan = "";
for (int i = 0; i < archivos.Length; i++)
{
@ -190,6 +194,7 @@ namespace Tinke
else
curCommand = 3;
tblRoms = opts.Props.ToList();
openDirPath = opts.DirPath;
bIsFolder = opts.IsFolder;
}

View File

@ -139,15 +139,28 @@ namespace Tinke
}
if (Program.bIsFolder)
{
FolderBrowserDialog o = new FolderBrowserDialog();
o.ShowNewFolderButton = false;
if (o.ShowDialog() != System.Windows.Forms.DialogResult.OK)
if (string.IsNullOrWhiteSpace(Program.openDirPath))
{
Application.Exit();
return;
FolderBrowserDialog o = new FolderBrowserDialog();
o.ShowNewFolderButton = false;
if (o.ShowDialog() != System.Windows.Forms.DialogResult.OK)
{
Application.Exit();
return;
}
filesToRead[0] = o.SelectedPath;
o.Dispose();
} else {
if (Directory.Exists(Program.openDirPath))
filesToRead[0] = Program.openDirPath;
else
{
MessageBox.Show(Tools.Helper.GetTranslation("Messages", "S2E"), Tools.Helper.GetTranslation("Messages", "S01"));
this.Close();
Application.Exit();
return;
}
}
filesToRead[0] = o.SelectedPath;
o.Dispose();
}
else if (Program.tblRoms.Count() == 1)
{
@ -2706,7 +2719,12 @@ namespace Tinke
{
foreach (string item in filePaths)
{
inFile = String.Format("\"{0}\"", item);
FileAttributes attr = File.GetAttributes(item);
if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
inFile = "open -f -d";
else
inFile = "open ";
inFile += String.Format("\"{0}\"", item);
System.Diagnostics.Process.Start(Application.ExecutablePath, inFile);
}
}