diff --git a/MemoScope/MemoScopeForm.Designer.cs b/MemoScope/MemoScopeForm.Designer.cs index 566c33f..1efbb64 100644 --- a/MemoScope/MemoScopeForm.Designer.cs +++ b/MemoScope/MemoScopeForm.Designer.cs @@ -31,15 +31,18 @@ private void InitializeComponent() System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MemoScopeForm)); this.SuspendLayout(); // - // MemoScope + // MemoScopeForm // + this.AllowDrop = true; this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(925, 744); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Name = "MemoScope"; + this.Name = "MemoScopeForm"; this.Text = "Form1"; this.Load += new System.EventHandler(this.MemoScope_Load); + this.DragDrop += new System.Windows.Forms.DragEventHandler(this.MemoScopeForm_DragDrop); + this.DragEnter += new System.Windows.Forms.DragEventHandler(this.MemoScopeForm_DragEnter); this.ResumeLayout(false); } diff --git a/MemoScope/MemoScopeForm.cs b/MemoScope/MemoScopeForm.cs index ee9376a..1924175 100644 --- a/MemoScope/MemoScopeForm.cs +++ b/MemoScope/MemoScopeForm.cs @@ -8,6 +8,7 @@ using WinFwk.UIModules; using WinFwk.UIServices; using MemoScope.Modules.Workplace; +using System.Linq; namespace MemoScope { @@ -47,5 +48,32 @@ public void HandleMessage(ClrDumpLoadedMessage message) var dump = message.ClrDump; UIModuleFactory.CreateModule( 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(module => { module.SetUp(directory); }, module => DockModule(module, DockState.DockLeft)); + } + else + { + MessageBox.Show("Dropped files must have a .dmp extension !"); + } + } } } \ No newline at end of file diff --git a/MemoScope/Modules/Explorer/ExplorerModule.cs b/MemoScope/Modules/Explorer/ExplorerModule.cs index e189f8b..eb3fa67 100644 --- a/MemoScope/Modules/Explorer/ExplorerModule.cs +++ b/MemoScope/Modules/Explorer/ExplorerModule.cs @@ -102,6 +102,12 @@ private void OpenFilesFromData(IEnumerable 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().Where(data => data.FileInfo != null).Select(data => data.FileInfo).ToList();