private void InitializeOpenFileList() { var column_configs = new [] { new { id = OpenFileListViewColumnId.FilePath, text = "Path", width = 400, }, new { id = OpenFileListViewColumnId.FormatType, text = "Format Type", width = 200, }, new { id = OpenFileListViewColumnId.FormatOption, text = "Format Option", width = -2, }, }; LView_OpenFileList.BeginUpdate(); { LView_OpenFileList.Clear(); foreach (var config in column_configs) { LView_OpenFileList.Columns.Add(new ColumnHeader() { Tag = config.id, Text = config.text, Width = config.width, }); } } LView_OpenFileList.EndUpdate(); }
private void LView_OpenFileList_DragDrop(object sender, DragEventArgs e) { DebugManager.MessageOut("DragDrop"); var target_indices = (int[])e.Data.GetData(typeof(int[])); var target_files = new List <FileControlParam>(); foreach (var target_index in target_indices) { if (LView_OpenFileList.Items[target_index].Tag is FileControlParam file) { target_files.Add(file); } } var insert_index = GetOpenFileInsertIndex(LView_OpenFileList.PointToClient(new Point(e.X, e.Y))); files_.InsertRange(insert_index, target_files); foreach (var remove_index in target_indices.Reverse()) { if (remove_index > insert_index) { files_.RemoveAt(remove_index + target_files.Count); } } LView_OpenFileList.InsertionMark.Index = -1; }
/* 見た目のみを更新する */ private void RedrawOpenFileList() { LView_OpenFileList.BeginUpdate(); { foreach (ListViewItem item in LView_OpenFileList.Items) { UpdateOpenFileListItem(item); } } LView_OpenFileList.EndUpdate(); }
private void LView_OpenFileList_ItemDrag(object sender, ItemDragEventArgs e) { DebugManager.MessageOut("ItemDrag"); /* D&D対象ファイルを取得 */ if (LView_OpenFileList.SelectedIndices.Count > 0) { var select_files = new int[LView_OpenFileList.SelectedIndices.Count]; LView_OpenFileList.SelectedIndices.CopyTo(select_files, 0); LView_OpenFileList.DoDragDrop(select_files, DragDropEffects.Move); } }
private int GetOpenFileInsertIndex(Point pos) { var insert_index = LView_OpenFileList.InsertionMark.NearestIndex(pos); if (LView_OpenFileList.Items.Count > 0) { var last_item_rect = LView_OpenFileList.GetItemRect(LView_OpenFileList.Items.Count - 1); if (pos.Y > last_item_rect.Bottom) { insert_index = LView_OpenFileList.Items.Count; } } return(insert_index); }
private void LView_OpenFileList_DragOver(object sender, DragEventArgs e) { DebugManager.MessageOut("DragOver"); // e.Effect = DragDropEffects.Move; var insert_index = GetOpenFileInsertIndex(LView_OpenFileList.PointToClient(new Point(e.X, e.Y))); if (insert_index >= LView_OpenFileList.Items.Count) { LView_OpenFileList.InsertionMark.AppearsAfterItem = true; insert_index = Math.Max(insert_index - 1, 0); } else { LView_OpenFileList.InsertionMark.AppearsAfterItem = false; } LView_OpenFileList.InsertionMark.Index = insert_index; }
private void ApplySelectFileFormatOption() { /* 表示中のオプション値を保存 */ if (select_file_format_option_editor_ != null) { select_file_format_option_editor_.BackupOption(select_file_format_option_); } /* 選択中のファイルに設定を適用 */ foreach (ListViewItem item in LView_OpenFileList.SelectedItems) { if (item.Tag is FileControlParam file) { file.Format = select_file_format_; file.Option = (select_file_format_option_ != null) ? (ClassUtil.Clone(select_file_format_option_)) : (null); UpdateOpenFileListItem(item); } } LView_OpenFileList.Update(); }
private void UpdateOpenFileListView() { LView_OpenFileList.BeginUpdate(); { LView_OpenFileList.Items.Clear(); if (files_ != null) { foreach (var file in files_) { var item = new ListViewItem() { Tag = file }; /* パラメータ更新 */ UpdateOpenFileListItem(item); LView_OpenFileList.Items.Add(item); } } } LView_OpenFileList.EndUpdate(); }