Skip to content

Commit

Permalink
Drag-and-drop
Browse files Browse the repository at this point in the history
  • Loading branch information
philstopford committed Jul 13, 2020
1 parent b998bb2 commit eab4b7e
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Common/Variance/UI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,11 @@ void UI(VarianceContextGUI _varianceContext)
do2DLayerUI_exp(0, updateUI: true);
addAllUIHandlers();
commonVars.setHashes();

tabControl_main.DragEnter += dragEvent;
tabControl_main.DragOver += dragEvent;

tabControl_main.DragDrop += dragAndDrop;
}

enum layerLookUpOrder { ICV, OCV, SCDU, TCDU, XOL, YOL, HTPV, HTNV, VTPV, VTNV, WOB, LWR, LWR2 }
Expand Down
49 changes: 49 additions & 0 deletions Common/Variance/UI/UIHandlers_file.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,55 @@ void saveEnabler()
});
}

void dragEvent(object sender, DragEventArgs e)
{
if (e.Data.ContainsUris)
{
// Check that we have a valid file somewhere in the dropped resources
for (int i = 0; i < e.Data.Uris.Length; i++)
{
string[] tokens = e.Data.Uris[i].LocalPath.Split(new char[] { '.' });
if ((tokens[tokens.Length - 1].ToUpper() == "VARIANCE") || (tokens[tokens.Length - 1].ToUpper() == "XML"))
{
e.Effects = DragEffects.Copy;
break;
}
}
}
}

void dragAndDrop(object sender, DragEventArgs e)
{
// Only allow a single selection; pick the first.
DataObject d = e.Data;
int length = d.Uris.Length;
if (length < 1)
{
return;
}

// Find our first file object.
int index = -1;
for (int i = 0; i < length; i++)
{
if (d.Uris[i].IsFile)
{
// Actually a supported file?
string[] tokens = d.Uris[i].LocalPath.Split(new char[] { '.' });
if ((tokens[tokens.Length - 1].ToUpper() == "VARIANCE") || (tokens[tokens.Length - 1].ToUpper() == "XML"))
{
index = i;
break;
}
}
}

if (index != -1)
{
doLoad(d.Uris[index].LocalPath);
}
}

void openHandler(object sender, EventArgs e)
{
// Need to request input file location and name.
Expand Down
3 changes: 2 additions & 1 deletion Documentation/releases.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,12 @@ <h1 class="western">Variance Release History</h1>

<blockquote>
<a name="releases_426"></a>
<h2 class="western">New to 4.2.6 (Jul 10 2020)</h2>
<h2 class="western">New to 4.2.6 (Jul 15 2020)</h2>
<blockquote>
<ul>
<li>Viewport enhancements.</li>
<li>Bug fix to update DOE settings on loading project.</li>
<li>Drag-and-drop support for project loading.</li>
</ul>
</blockquote>
</blockquote>
Expand Down
1 change: 1 addition & 0 deletions Series 4.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog for Variance

- Viewport enhancements.
- Bug fix to update DOE configuration with project load.
- Drag-and-drop support for project loading.

4.2.5

Expand Down

0 comments on commit eab4b7e

Please sign in to comment.