diff --git a/EcomAnalysis/Form1.Designer.cs b/EcomAnalysis/Form1.Designer.cs index 73c1371..aa045e7 100644 --- a/EcomAnalysis/Form1.Designer.cs +++ b/EcomAnalysis/Form1.Designer.cs @@ -384,6 +384,7 @@ // // Form1 // + this.AllowDrop = true; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(652, 597); @@ -415,6 +416,8 @@ this.Name = "Form1"; this.Text = "Ecom Analysis"; this.Load += new System.EventHandler(this.Form1_Load); + this.DragDrop += new System.Windows.Forms.DragEventHandler(this.Form1_DragDrop); + this.DragEnter += new System.Windows.Forms.DragEventHandler(this.Form1_DragEnter); this.ResumeLayout(false); this.PerformLayout(); diff --git a/EcomAnalysis/Form1.cs b/EcomAnalysis/Form1.cs index 852d112..7adea3c 100644 --- a/EcomAnalysis/Form1.cs +++ b/EcomAnalysis/Form1.cs @@ -49,12 +49,28 @@ TxtLogFilename.Text = "not opened"; var args = Environment.GetCommandLineArgs(); if (args.Length > 1) { + ClearData(); ReadCSV(args[1]); Analyze(); } } /// + /// データ初期化 + /// + private void ClearData() { + _Data.Clear(); + _SceneTable.Clear(); + + listView1.Items.Clear(); + foreach (var ctl in this.Controls) { + if (((Control)ctl).GetType().Equals(typeof(TextBox))){ + ((Control)ctl).Text = ""; + } + } + } + + /// /// 解析 /// private void Analyze() { @@ -239,5 +255,31 @@ $"{_ScMean.Blink},{_ScMean.Pupil.R:0.00},{_ScMean.Pupil.L:0.00}"); sr.Close(); } + + /// + /// ドラッグが入ったとき + /// + /// + /// + private void Form1_DragEnter(object sender, DragEventArgs e) { + if (e.Data.GetDataPresent(DataFormats.FileDrop)) + e.Effect = DragDropEffects.Copy; + else + e.Effect = DragDropEffects.None; + } + + /// + /// ファイルがドロップされた時 + /// + /// + /// + private void Form1_DragDrop(object sender, DragEventArgs e) { + var filename = (string[])e.Data.GetData(DataFormats.FileDrop, false); + if (Path.GetExtension(filename[0]) == ".csv") { + ClearData(); + ReadCSV(filename[0]); + Analyze(); + } + } } }