Skip to content

Commit

Permalink
he lost it (#4)
Browse files Browse the repository at this point in the history
* yes

* nanabooboo. kanna no like wrapping

* Add drag-and-drop functionality for Modpack.json files

The ability to drag-and-drop Modpack.json files into the application has been introduced. Appropriate event handlers for DragEnter and DragDrop are now added to the DataGridView control. Upon a successful drop of a json file, a new configuration instance is created and existing mod details are replaced with those from the dropped file.

* what

* override

* no i didnt

---------

Co-authored-by: Kanna <[email protected]>
  • Loading branch information
zrodevkaan and MistressPlague committed Dec 24, 2023
1 parent 1431ea6 commit 5ac8af7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions .idea/.idea.Easy Minecraft Modpacks/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Easy Minecraft Modpacks/MainUI.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions Easy Minecraft Modpacks/MainUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class ModInfo
public static ConfigLib<Configuration> Config;

private static WebClient client = new WebClient();
private readonly string FileExt = "Modpack.json";

public MainUI()
{
Expand Down Expand Up @@ -282,6 +283,39 @@ private void MainUI_FormClosing(object sender, FormClosingEventArgs e)
}
}
}

private void dataGridView1_DragEnter(object sender, DragEventArgs e)
{
if (!DoUnsavedChangesCheck())
{
return;
}

if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (!files[0].EndsWith(FileExt)) return;
e.Effect = DragDropEffects.Copy;
}
}

private void dataGridView1_DragDrop(object sender, DragEventArgs e)
{
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files != null && files.Length > 0)
{
var file = files[0];
if (file.EndsWith(FileExt))
{
Config = new ConfigLib<Configuration>(file);
dataGridView1.Rows.Clear();
foreach (var mod in Config.InternalConfig.Mods)
{
dataGridView1.Rows.Add(mod.Name, mod.DownloadLink);
}
}
}
}

private void UpdateRows()
{
Expand Down

0 comments on commit 5ac8af7

Please sign in to comment.