Skip to content

Commit

Permalink
MainForm - Focus app when draging files over it
Browse files Browse the repository at this point in the history
  • Loading branch information
NessieHax committed Aug 16, 2024
1 parent 3245609 commit 99d6fc4
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions PCK-Studio/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1236,26 +1236,30 @@ private void treeViewMain_ItemDrag(object sender, ItemDragEventArgs e)

if ((node.TryGetTagData(out PckAsset asset) && currentPCK.Contains(asset.Filename, asset.Type)) || node.Parent is TreeNode)
{
treeViewMain.DoDragDrop(node, DragDropEffects.Move);
}
}
// TODO: add (mouse) scrolling while dragging item(s)
treeViewMain.DoDragDrop(node, DragDropEffects.Scroll | DragDropEffects.Move);
}
}

private void treeViewMain_DragOver(object sender, DragEventArgs e)
private void treeViewMain_DragOver(object sender, DragEventArgs e)
{
Point dragLocation = new Point(e.X, e.Y);
TreeNode node = treeViewMain.GetNodeAt(treeViewMain.PointToClient(dragLocation));
treeViewMain.SelectedNode = node.IsTagOfType<PckAsset>() ? null : node;
}
}

private void treeViewMain_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : e.AllowedEffect;
}
BringToFront();
FocusMe();
treeViewMain.Focus();
}

private void treeViewMain_DragDrop(object sender, DragEventArgs e)
{
// Retrieve the client coordinates of the drop location.
Point dragLocation = new Point(e.X, e.Y);
// Retrieve the client coordinates of the drop location.
Point dragLocation = new Point(e.X, e.Y);
Point targetPoint = treeViewMain.PointToClient(dragLocation);

if (!treeViewMain.ClientRectangle.Contains(targetPoint))
Expand Down Expand Up @@ -1383,12 +1387,12 @@ private void ImportFiles(string baseDirectory, IEnumerable<string> files, string
if (askForAssetType)
{
using AddFilePrompt addFile = new AddFilePrompt(assetPath);
if (addFile.ShowDialog(this) != DialogResult.OK)
if (addFile.ShowDialog(this) != DialogResult.OK)
{
skippedFiles++;
skipAttempts--;
if (skipAttempts > 0)
continue;
continue;

int remainingFileCount = fileCount - addedCount - skippedFiles;
DialogResult abortFurtherImport = MessageBox.Show($"Do you wan't to abort further file imports?\n{remainingFileCount} file(s) left.", "Abort further import", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
Expand All @@ -1411,7 +1415,7 @@ private void ImportFiles(string baseDirectory, IEnumerable<string> files, string
{
DialogResult useSameTypeForRest = MessageBox.Show($"Do you want to import all remaining files as {lastSelectedAssetType}?", "Import all as", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
if (useSameTypeForRest == DialogResult.Yes)
{
{
askForAssetType = false;
}
}
Expand All @@ -1437,8 +1441,8 @@ private void ImportFiles(string baseDirectory, IEnumerable<string> files, string
if (addedCount > 0)
{
wasModified = true;
BuildMainTreeView();
}
BuildMainTreeView();
}
}

#endregion
Expand Down Expand Up @@ -1518,7 +1522,7 @@ private void skinPackToolStripMenuItem_Click(object sender, EventArgs e)
{
currentPCK = InitializePack(new Random().Next(8000, int.MaxValue), 0, namePrompt.NewText, true);
MarkTemplateFile();
LoadEditorTab();
LoadEditorTab();
}
}

Expand All @@ -1527,22 +1531,22 @@ private void texturePackToolStripMenuItem_Click(object sender, EventArgs e)
CheckSaveState();
CreateTexturePackPrompt packPrompt = new CreateTexturePackPrompt();
if (packPrompt.ShowDialog(this) == DialogResult.OK)
{
currentPCK = InitializeTexturePack(new Random().Next(8000, int.MaxValue), 0, packPrompt.PackName, packPrompt.PackRes, packPrompt.CreateSkinsPck);
{
currentPCK = InitializeTexturePack(new Random().Next(8000, int.MaxValue), 0, packPrompt.PackName, packPrompt.PackRes, packPrompt.CreateSkinsPck);
MarkTemplateFile();
LoadEditorTab();
}
}
LoadEditorTab();
}
}

private void mashUpPackToolStripMenuItem_Click(object sender, EventArgs e)
private void mashUpPackToolStripMenuItem_Click(object sender, EventArgs e)
{
CheckSaveState();
CreateTexturePackPrompt packPrompt = new CreateTexturePackPrompt();
if (packPrompt.ShowDialog(this) == DialogResult.OK)
{
currentPCK = InitializeMashUpPack(new Random().Next(8000, int.MaxValue), 0, packPrompt.PackName, packPrompt.PackRes);
MarkTemplateFile();
LoadEditorTab();
LoadEditorTab();
}
}

Expand All @@ -1551,7 +1555,7 @@ private void MarkTemplateFile()
isTemplateFile = true;
wasModified = true;
saveLocation = string.Empty;
}
}

private void quickChangeToolStripMenuItem_Click(object sender, EventArgs e)
{
Expand Down

0 comments on commit 99d6fc4

Please sign in to comment.