Skip to content

Commit

Permalink
Explorer: drag/drop dump files
Browse files Browse the repository at this point in the history
Closes #59
  • Loading branch information
fremag committed Mar 13, 2016
1 parent acbc237 commit 30ae61d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
7 changes: 5 additions & 2 deletions MemoScope/MemoScopeForm.Designer.cs

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

28 changes: 28 additions & 0 deletions MemoScope/MemoScopeForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using WinFwk.UIModules;
using WinFwk.UIServices;
using MemoScope.Modules.Workplace;
using System.Linq;

namespace MemoScope
{
Expand Down Expand Up @@ -47,5 +48,32 @@ public void HandleMessage(ClrDumpLoadedMessage message)
var dump = message.ClrDump;
UIModuleFactory.CreateModule<TypeStatModule>( tsm => tsm.Setup(dump), tsm => DockModule(tsm));
}

private void MemoScopeForm_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.Copy;
}
}

private void MemoScopeForm_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
var fileInfos = files.Select(f => new FileInfo(f));
var filteredFileInfos = fileInfos.Where(
fi => fi.Extension.Equals(".dmp", System.StringComparison.InvariantCultureIgnoreCase)
);
if (filteredFileInfos.Any())
{
msgBus.SendMessage(new OpenDumpRequest(filteredFileInfos));
var directory = filteredFileInfos.First().DirectoryName;
UIModuleFactory.CreateModule<ExplorerModule>(module => { module.SetUp(directory); }, module => DockModule(module, DockState.DockLeft));
}
else
{
MessageBox.Show("Dropped files must have a .dmp extension !");
}
}
}
}
6 changes: 6 additions & 0 deletions MemoScope/Modules/Explorer/ExplorerModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ private void OpenFilesFromData(IEnumerable<AbstractDumpExplorerData> datas)
MessageBus.SendMessage(new OpenDumpRequest(fileInfos));
}

internal void SetUp(string directory)
{
tbRootDir.Text = directory;
RefreshRootDir();
}

private void btnLoad_Click(object sender, System.EventArgs e)
{
var fileInfos = dtlvExplorer.CheckedObjects.OfType<AbstractDumpExplorerData>().Where(data => data.FileInfo != null).Select(data => data.FileInfo).ToList();
Expand Down

0 comments on commit 30ae61d

Please sign in to comment.