Skip to content

Commit

Permalink
Fix DragDrop due to CLI updated
Browse files Browse the repository at this point in the history
  • Loading branch information
R-YaTian committed Aug 2, 2024
1 parent 5f42665 commit 2e81fd5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
7 changes: 6 additions & 1 deletion Tinke/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -100,6 +103,7 @@ static class Program
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.
Expand All @@ -108,7 +112,7 @@ static class Program
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++)
{
Expand Down Expand Up @@ -190,6 +194,7 @@ private static void RunOpen(OpenOptions opts)
else
curCommand = 3;
tblRoms = opts.Props.ToList();
openDirPath = opts.DirPath;
bIsFolder = opts.IsFolder;
}

Expand Down
34 changes: 26 additions & 8 deletions Tinke/Sistema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,28 @@ void Sistema_Load(object sender, EventArgs e)
}
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)
{
Expand Down Expand Up @@ -2706,7 +2719,12 @@ private void Sistema_DragDrop(object sender, DragEventArgs e)
{
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);
}
}
Expand Down

0 comments on commit 2e81fd5

Please sign in to comment.