private void mainSheet_DragDrop(object sender, DragEventArgs e) { try { int rowidx; { Point pt = this.mainSheet.PointToClient(new Point(e.X, e.Y)); DataGridView.HitTestInfo hit = this.mainSheet.HitTest(pt.X, pt.Y); rowidx = hit.RowIndex; } string[] files = (string[])e.Data.GetData(DataFormats.FileDrop, false); files = droppedFilesFltr(files); if (rowidx == -1) { rowidx = this.mainSheet.RowCount; } this.mainSheet.Rows.Insert(rowidx, files.Length); foreach (string file in files) { mainSheetSetRow(rowidx++, MediaInfo.create(file)); } Utils.adjustColumnsWidth(this.mainSheet); } catch { } }
private void ファイルから読み込みRToolStripMenuItem_Click(object sender, EventArgs e) { this.mtEnabled = false; try { string initDir = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string initLFile = "きららプレイリスト.krrpl"; if (Gnd.i.lastPlayListFile != "") { initDir = Path.GetDirectoryName(Gnd.i.lastPlayListFile); initLFile = Path.GetFileName(Gnd.i.lastPlayListFile); } string plFile = SaveLoadDialogs.LoadFile("開くプレイリスト・ファイルを選択してください", "きららプレイリスト:krrpl", initDir, initLFile); if (plFile != null) { plFile = FileTools.toFullPath(plFile); Gnd.i.lastPlayListFile = plFile; List <MediaInfo> mis = new List <MediaInfo>(); foreach (string file in FileTools.readAllLines(plFile, Encoding.UTF8)) { if ( file != "" && file[0] != ';' ) { mis.Add(MediaInfo.create(file)); } } int startPos = plSheet.RowCount; plSheet.RowCount += mis.Count; for (int index = 0; index < mis.Count; index++) { plSheetSetRow(startPos + index, mis[index]); } } } catch (Exception ex) { FailedOperation.caught(ex); } finally { this.mtEnabled = true; } }
private void plSheet_DragDrop(object sender, DragEventArgs e) { try { int droppedRowIndex; { Point pt = this.plSheet.PointToClient(new Point(e.X, e.Y)); DataGridView.HitTestInfo hit = this.plSheet.HitTest(pt.X, pt.Y); droppedRowIndex = hit.RowIndex; } string[] files = (string[])e.Data.GetData(DataFormats.FileDrop, false); if (Gnd.i.plCountMax < files.Length) { throw new Exception("入力ファイル大杉.1"); } files = Utils.droppedFilesFilter(files); if (Gnd.i.plCountMax < files.Length) { throw new Exception("入力ファイル大杉.2"); } if (files.Length == 0) { throw new Exception("入力ファイル無し"); } List <MediaInfo> mis = new List <MediaInfo>(); foreach (string file in files) { mis.Add(MediaInfo.create(file)); } Gnd.i.oc.add(delegate { if (droppedRowIndex < 0 || plSheet.RowCount < droppedRowIndex) { droppedRowIndex = plSheet.RowCount; } plSheet.RowCount += mis.Count; for (int rowidx = plSheet.RowCount - 1; ; rowidx--) { int rRowidx = rowidx - mis.Count; if (rRowidx < droppedRowIndex) { break; } plSheetSetRow(rowidx, plSheetGetRow(rRowidx)); } for (int index = 0; index < mis.Count; index++) { plSheetSetRow(droppedRowIndex + index, mis[index]); } Utils.adjustColumnsWidth(plSheet); }); } catch (Exception ex) { Gnd.i.logger.writeLine("plSheet-dd-error: " + ex); } }