Skip to content

Commit 9998c74

Browse files
author
Evan Comtesse
committed
feat: added working-directory on default-output for drop zones
1 parent 718bdcf commit 9998c74

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/RayGUI.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,21 +214,26 @@ internal static DropZone ImportFiles(DropZone c)
214214
// Copy file to output directory of the container
215215
if (!c.Contains(c.OutputFilePath + "\\" +fileName))
216216
{
217-
if (pathArray.Last() == c.ExtensionFile)
217+
if (c.Extensions.Contains(pathArray.Last()) || c.Extensions.Length == 0)
218218
{
219219
try
220220
{
221221
File.Copy(path, c.OutputFilePath + "\\" + fileName, true);
222222
c.AddFile(c.OutputFilePath + "\\" + fileName);
223223
// Add file path to the container
224-
Debugger.Send($"File {fileName} received successfully");
224+
Debugger.Send($"File {fileName} received successfully", ConsoleColor.Green);
225225
}
226226
catch
227227
{
228-
Debugger.Send($"File could not be received, incorrect path: \nSource: {path}\nDestination: {c.OutputFilePath}", ConsoleColor.Red);
228+
Debugger.Send($"File could not be received, either wrong destination ({c.OutputFilePath}) or unsuitable source file ({path}))", ConsoleColor.Yellow);
229229
}
230230
}
231-
else Debugger.Send($"File could not be received, required extension: .{c.ExtensionFile}", ConsoleColor.Yellow);
231+
else
232+
{
233+
string err = "File could not be received, required extension(s):";
234+
for (int i = 0; i < c.Extensions.Length; i++) err += $" .{c.Extensions[i]}";
235+
Debugger.Send(err, ConsoleColor.Yellow);
236+
}
232237
}
233238
UnloadDroppedFiles(filePathList);
234239

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ public class DropZone : Component
66
/// <summary>The abosulte file path for the output directory.</summary>
77
public string OutputFilePath;
88

9-
/// <summary>Acceptable file type when file is dropped.</summary>
10-
public string ExtensionFile;
9+
/// <summary>Acceptable file types when file is dropped.</summary>
10+
public string[] Extensions;
1111

1212
/// <summary>Last dropped file.</summary>
1313
public string LastFile;
@@ -22,9 +22,9 @@ public class DropZone : Component
2222
/// <param name="height">Height of the container</param>
2323
public DropZone(int x, int y, int width, int height) : base(x, y, width, height)
2424
{
25-
ExtensionFile = "";
25+
Extensions = []; // Accept any file by default
2626
Files = new List<string>() { "" };
27-
OutputFilePath = "";
27+
OutputFilePath = Directory.GetCurrentDirectory(); // Working directory by default
2828
LastFile = "";
2929
}
3030

0 commit comments

Comments
 (0)