• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

ファイル整理用ツールのWinFormサンプル実装


Commit MetaInfo

Revisiond9c818af7bc1577f2964a5cb57d2e8eb44741f96 (tree)
Time2018-12-27 13:05:40
Authoryoshy <yoshy@user...>
Commiteryoshy

Log Message

リファクタ - ドラッグ情報中のリストを配列に変更

Change Summary

Incremental Difference

--- a/FolderCategorizer/Infra/Helper/PathHelper.cs
+++ b/FolderCategorizer/Infra/Helper/PathHelper.cs
@@ -54,20 +54,20 @@ namespace FolderCategorizer.Infra.Helper
5454 return Path.GetFullPath(Path.Combine(dir, name));
5555 }
5656
57- public static bool IsDstPathIncludedSrcPathList(string dstPath, List<string> srcPaths)
57+ public static bool IsDstPathIncludedSrcPathList(string dstFolderPath, string[] srcFolderPaths)
5858 {
59- foreach (string srcPath in srcPaths)
59+ foreach (string srcFolderPath in srcFolderPaths)
6060 {
61- string srcParent = Path.GetDirectoryName(srcPath);
61+ string srcParent = Path.GetDirectoryName(srcFolderPath);
6262
63- if (dstPath.StartsWith(srcPath))
63+ if (dstFolderPath.StartsWith(srcFolderPath))
6464 {
65- string dstParent = Path.GetDirectoryName(dstPath);
65+ string dstParent = Path.GetDirectoryName(dstFolderPath);
6666
6767 if (srcParent == dstParent)
6868 {
69- string srcName = Path.GetFileName(srcPath);
70- string dstName = Path.GetFileName(dstPath);
69+ string srcName = Path.GetFileName(srcFolderPath);
70+ string dstName = Path.GetFileName(dstFolderPath);
7171
7272 if (srcName == dstName)
7373 {
@@ -82,7 +82,7 @@ namespace FolderCategorizer.Infra.Helper
8282 return true;
8383 }
8484 }
85- else if (dstPath == srcParent)
85+ else if (dstFolderPath == srcParent)
8686 {
8787 return true;
8888 // 対象フォルダがソースの親の場合はフルパスが自分になるのでNG
--- a/FolderCategorizer/Presentation/View/MainForm.cs
+++ b/FolderCategorizer/Presentation/View/MainForm.cs
@@ -85,51 +85,48 @@ namespace FolderCategorizer.Presentation.View
8585 [Serializable]
8686 public class DraggedFileListEntriesHolder
8787 {
88- public List<FileListEntry> DroppedEntries { get; set; } = null;
88+ public FileListEntry[] DroppedEntries { get; set; } = null;
8989
9090 public string SrcRefreshPath { get; set; } = string.Empty;
9191
92- public List<FileListEntry> SelectedFileListViewItems { get; set; } = null;
92+ public FileListEntry[] SelectedListEntries { get; set; } = null;
9393
94- public TreeNodeStatus[] SelectedFolderTreeViewNodeStatuses { get; set; } = null;
94+ public TreeNodeStatus[] SelectedNodeStatuses { get; set; } = null;
9595
96- public List<string> ProhibitedDropFolderTopPaths { get; set; } = null;
96+ public string[] SrcFolderPaths { get; set; } = null;
9797
9898 //public ImageList DraggedImageList { get; set; } = null;
9999
100100 public DraggedFileListEntriesHolder()
101101 {
102- DroppedEntries = new List<FileListEntry>();
103- SelectedFileListViewItems = new List<FileListEntry>();
104- SelectedFolderTreeViewNodeStatuses = new TreeNodeStatus[0];
105- ProhibitedDropFolderTopPaths = new List<string>();
102+ DroppedEntries = new FileListEntry[0];
103+ SelectedListEntries = new FileListEntry[0];
104+ SelectedNodeStatuses = new TreeNodeStatus[0];
105+ SrcFolderPaths = new string[0];
106106 }
107107
108- public DraggedFileListEntriesHolder(List<ListViewItem> selectedItems, TreeNode[] selectedNodes, List<string> prohibitedFolders, string srcRefreshPath)
108+ public DraggedFileListEntriesHolder(FileListEntry[] selectedListEntries, TreeNodeStatus[] selectedNodeStatuses, string[] prohibitedFolders, string srcRefreshPath)
109109 {
110- SelectedFileListViewItems = FileListEntry.FromTagOf(selectedItems).ToList();
111- SelectedFolderTreeViewNodeStatuses = TreeNodeStatus.FromTagOf(selectedNodes);
112- ProhibitedDropFolderTopPaths = prohibitedFolders;
110+ SelectedListEntries = selectedListEntries;
111+ SelectedNodeStatuses = selectedNodeStatuses;
112+ SrcFolderPaths = prohibitedFolders;
113113 SrcRefreshPath = srcRefreshPath;
114114
115- DroppedEntries = SelectedFileListViewItems;
115+ DroppedEntries = SelectedListEntries;
116116 }
117117
118- public DraggedFileListEntriesHolder(List<ListViewItem> selectedItems, TreeNode[] selectedNodes, TreeNode draggedNode)
118+ public DraggedFileListEntriesHolder(FileListEntry[] selectedItems, TreeNodeStatus[] selectedNodes, TreeNode draggedNode)
119119 {
120- SelectedFileListViewItems = FileListEntry.FromTagOf(selectedItems).ToList();
121- SelectedFolderTreeViewNodeStatuses = TreeNodeStatus.FromTagOf(selectedNodes);
120+ SelectedListEntries = selectedItems;
121+ SelectedNodeStatuses = selectedNodes;
122122
123123 SrcRefreshPath = Path.GetDirectoryName(TreeNodeStatus.FromTagOf(draggedNode).RelativePath);
124124
125- DroppedEntries = new List<FileListEntry>();
126- ProhibitedDropFolderTopPaths = new List<string>();
127-
128125 FileListEntry droppedEntry = new FileListEntry(
129126 draggedNode.Name, Path.GetDirectoryName(TreeNodeStatus.FromTagOf(draggedNode).RelativePath), FileListEntry.EntryType.FOLDER);
130127
131- DroppedEntries.Add(droppedEntry);
132- ProhibitedDropFolderTopPaths.Add(droppedEntry.RelativePath);
128+ DroppedEntries = new FileListEntry[] { droppedEntry };
129+ SrcFolderPaths = new string[] { droppedEntry.RelativePath };
133130 }
134131 }
135132
@@ -186,7 +183,7 @@ namespace FolderCategorizer.Presentation.View
186183 return ((TreeNodeStatus)node?.Tag);
187184 }
188185
189- public static TreeNodeStatus[] FromTagOf(params TreeNode[] nodes)
186+ public static TreeNodeStatus[] ToArrayFromTagsOf(params TreeNode[] nodes)
190187 {
191188 return FromTagOf(nodes.AsEnumerable());
192189 }
@@ -394,18 +391,35 @@ namespace FolderCategorizer.Presentation.View
394391 return (FileListEntry)item?.Tag;
395392 }
396393
397- public static FileListEntry[] FromTagOf(IEnumerable<ListViewItem> items)
394+ public static List<FileListEntry> ToListFromTagsOf(IEnumerable items)
398395 {
399- FileListEntry[] objs = new FileListEntry[items.Count()];
400-
401- int i = 0;
396+ List<FileListEntry> entries = new List<FileListEntry>();
402397
403398 foreach (ListViewItem item in items)
404399 {
405- objs[i++] = FileListEntry.FromTagOf(item);
400+ FileListEntry entry = FileListEntry.FromTagOf(item);
401+
402+ switch (entry.Type)
403+ {
404+ case FileListEntry.EntryType.FOLDER:
405+ case FileListEntry.EntryType.FILE:
406+ break;
407+
408+ default:
409+ case FileListEntry.EntryType.INVALID:
410+ case FileListEntry.EntryType.UPWARDS:
411+ continue;
412+ }
413+
414+ entries.Add(entry);
406415 }
407416
408- return objs;
417+ return entries;
418+ }
419+
420+ public static FileListEntry[] ToArrayFromTagsOf(IEnumerable items)
421+ {
422+ return ToListFromTagsOf(items).ToArray(); ;
409423 }
410424
411425 public static string ToTypeName(EntryType type)
@@ -479,6 +493,21 @@ namespace FolderCategorizer.Presentation.View
479493 public DateTime CreationTime { get; set; }
480494
481495 public DateTime LastWriteTime { get; set; }
496+
497+ public bool IsFolder()
498+ {
499+ return Type == EntryType.FOLDER;
500+ }
501+
502+ public bool IsFile()
503+ {
504+ return Type == EntryType.FILE;
505+ }
506+
507+ public bool IsUpwards()
508+ {
509+ return Type == EntryType.UPWARDS;
510+ }
482511 }
483512
484513 private class FileListEntrySorter : IComparer
@@ -3226,18 +3255,6 @@ namespace FolderCategorizer.Presentation.View
32263255 IGNORE_ALL_TARGET2_NOT_FOUND_ERROR = 3,
32273256 }
32283257
3229- private List<FileListEntry> CreateSelectedSrcEntries()
3230- {
3231- List<FileListEntry> entries = new List<FileListEntry>();
3232-
3233- foreach (ListViewItem lvi in lvFileList.SelectedItems)
3234- {
3235- entries.Add(FileListEntry.FromTagOf(lvi));
3236- }
3237-
3238- return entries;
3239- }
3240-
32413258 private static bool CreateModifyMultiTargetFileList(
32423259 List<string> outTargetPaths, List<string> outTargetPathsForMsg1, List<string> outTargetPathsForMsg2,
32433260 AbstractFileSystemMultiTargetOperationRequest req)
@@ -3581,37 +3598,16 @@ namespace FolderCategorizer.Presentation.View
35813598
35823599 private void DoDragTreeView_TreeNode(ListView lv, TreeView tvSrcFolder1, TreeView tvSrcFolder2, TreeNode draggedItem)
35833600 {
3584- List<ListViewItem> selectedItems = new List<ListViewItem>(lv.SelectedItems.Count);
3585-
3586- foreach (ListViewItem lvi in lvFileList.SelectedItems)
3587- {
3588- FileListEntry entry = FileListEntry.FromTagOf(lvi);
3589-
3590- switch (entry.Type)
3591- {
3592- case FileListEntry.EntryType.UPWARDS:
3593- case FileListEntry.EntryType.FOLDER:
3594- case FileListEntry.EntryType.FILE:
3595- break;
3596-
3597- default:
3598- case FileListEntry.EntryType.INVALID:
3599- continue;
3600- }
3601-
3602- selectedItems.Add(lvi);
3603- }
3601+ FileListEntry[] entries = FileListEntry.ToArrayFromTagsOf(lvFileList.SelectedItems);
36043602
36053603 // ツリー上で、選択後にボタンを離さずファイルリストにドロップすると、
36063604 // 選択ノードが切り替わらずにドラッグ動作が開始されるため、
36073605 // ここで強制的にドラッグされたノードを選択状態にする
36083606 SelectTreeViewNode(TreeNodeStatus.FromTagOf(draggedItem).RelativePath);
36093607
3610- TreeNode[] selectedNodes = new TreeNode[] { tvSrcFolder1.SelectedNode, tvSrcFolder2.SelectedNode };
3608+ TreeNodeStatus[] statuses = TreeNodeStatus.ToArrayFromTagsOf(tvSrcFolder1.SelectedNode, tvSrcFolder2.SelectedNode);
36113609
3612- DraggedFileListEntries = new DraggedFileListEntriesHolder(selectedItems, selectedNodes, draggedItem);
3613-
3614- lv.DoDragDrop(DraggedFileListEntries, DragDropEffects.Move | DragDropEffects.Copy);
3610+ DraggedFileListEntries = new DraggedFileListEntriesHolder(entries, statuses, draggedItem);
36153611 }
36163612
36173613 private DragDropEffects DragEnterTreeView_DraggedFileListEntries(DraggedFileListEntriesHolder holder, TreeView tv, int keyState, DragDropEffects allowedEffect, Point p)
@@ -3621,7 +3617,7 @@ namespace FolderCategorizer.Presentation.View
36213617 tv.Focus();
36223618
36233619 return DragOverCommon_DraggedFileListEntries_SwitchEffect(keyState, allowedEffect,
3624- DragOverTreeView_DraggedFileListEntries_EmphasisDstItem(tv, p, holder.ProhibitedDropFolderTopPaths));
3620+ DragOverTreeView_DraggedFileListEntries_EmphasisDstItem(tv, p, holder.SrcFolderPaths));
36253621 }
36263622
36273623 private void DragEnterTreeView_DraggedFileListEntries_EnterDragMode()
@@ -3632,10 +3628,10 @@ namespace FolderCategorizer.Presentation.View
36323628 private DragDropEffects DragOverTreeView_DraggedFileListEntries(DraggedFileListEntriesHolder holder, TreeView tv, int keyState, DragDropEffects allowedEffect, Point p)
36333629 {
36343630 return DragOverCommon_DraggedFileListEntries_SwitchEffect(keyState, allowedEffect,
3635- DragOverTreeView_DraggedFileListEntries_EmphasisDstItem(tv, p, holder.ProhibitedDropFolderTopPaths));
3631+ DragOverTreeView_DraggedFileListEntries_EmphasisDstItem(tv, p, holder.SrcFolderPaths));
36363632 }
36373633
3638- private static bool DragOverTreeView_DraggedFileListEntries_EmphasisDstItem(TreeView tv, Point p, List<string> srcPaths)
3634+ private static bool DragOverTreeView_DraggedFileListEntries_EmphasisDstItem(TreeView tv, Point p, string[] srcFolderPaths)
36393635 {
36403636 TreeNode dstNode = DragDropTreeView_GetNodeAt(tv, p);
36413637
@@ -3648,7 +3644,7 @@ namespace FolderCategorizer.Presentation.View
36483644
36493645 TreeNodeStatus dstStatus = TreeNodeStatus.FromTagOf(dstNode);
36503646
3651- if (PathHelper.IsDstPathIncludedSrcPathList(dstStatus.RelativePath, srcPaths))
3647+ if (PathHelper.IsDstPathIncludedSrcPathList(dstStatus.RelativePath, srcFolderPaths))
36523648 {
36533649 // invalid dst path
36543650 return false;
@@ -3661,14 +3657,14 @@ namespace FolderCategorizer.Presentation.View
36613657
36623658 private void DragLeaveTreeView_DraggedFileListEntries(DraggedFileListEntriesHolder holder)
36633659 {
3664- DragLeaveCommon_DraggedFileListEntries_RestoreSelectedNodes(holder.SelectedFolderTreeViewNodeStatuses);
3660+ DragLeaveCommon_DraggedFileListEntries_RestoreSelectedNodes(holder.SelectedNodeStatuses);
36653661
36663662 DragLeaveCommon_DraggedFileListEntries_LeaveDragMode();
36673663 }
36683664
36693665 private void DragDropTreeView_DraggedFileListEntries(DraggedFileListEntriesHolder holder, TreeView tv, Point p, DragDropEffects effect)
36703666 {
3671- DragLeaveCommon_DraggedFileListEntries_RestoreSelectedNodes(holder.SelectedFolderTreeViewNodeStatuses);
3667+ DragLeaveCommon_DraggedFileListEntries_RestoreSelectedNodes(holder.SelectedNodeStatuses);
36723668
36733669 DragLeaveCommon_DraggedFileListEntries_LeaveDragMode();
36743670
@@ -3706,39 +3702,12 @@ namespace FolderCategorizer.Presentation.View
37063702
37073703 private void DoDragDropFileList_DraggedFileListEntries_CreateEntries(ListView lv, TreeView tvSrcFolder1, TreeView tvSrcFolder2)
37083704 {
3709- List<ListViewItem> selectedItems = new List<ListViewItem>(lv.SelectedItems.Count);
3710-
3711- List<string> prohibitedFolders = new List<string>();
3712-
3713- foreach (ListViewItem lvi in lvFileList.SelectedItems)
3714- {
3715- FileListEntry entry = FileListEntry.FromTagOf(lvi);
3716-
3717- switch (entry.Type)
3718- {
3719- case FileListEntry.EntryType.UPWARDS:
3720- continue;
3705+ FileListEntry[] selectedListEntries = FileListEntry.ToArrayFromTagsOf(lvFileList.SelectedItems);
3706+ string[] prohibitedFolders = selectedListEntries.Where(x => x.IsFolder()).Select(x => x.RelativePath).ToArray();
37213707
3722- case FileListEntry.EntryType.FOLDER:
3723- prohibitedFolders.Add(entry.RelativePath);
3724- break;
3708+ TreeNodeStatus[] selectedNodeStatuses = TreeNodeStatus.ToArrayFromTagsOf(tvSrcFolder1.SelectedNode, tvSrcFolder2.SelectedNode);
37253709
3726- case FileListEntry.EntryType.FILE:
3727- break;
3728-
3729- default:
3730- case FileListEntry.EntryType.INVALID:
3731- continue;
3732- }
3733-
3734- selectedItems.Add(lvi);
3735- }
3736-
3737- //ListViewHelper.DeselectAllItems(lv);
3738-
3739- TreeNode[] selectedNodes = new TreeNode[] { tvSrcFolder1.SelectedNode, tvSrcFolder2.SelectedNode };
3740-
3741- DraggedFileListEntries = new DraggedFileListEntriesHolder(selectedItems, selectedNodes, prohibitedFolders, GetCurrentRelativePath());
3710+ DraggedFileListEntries = new DraggedFileListEntriesHolder(selectedListEntries, selectedNodeStatuses, prohibitedFolders, GetCurrentRelativePath());
37423711 }
37433712
37443713 private DragDropEffects DragEnterFileList_DraggedFileListEntries(DraggedFileListEntriesHolder holder, int keyState, DragDropEffects allowedEffect, ListView lv, Point p)
@@ -3747,8 +3716,7 @@ namespace FolderCategorizer.Presentation.View
37473716
37483717 lv.Focus();
37493718
3750- return DragOverFileList_DraggedFileListEntries_SwitchEffect(keyState, allowedEffect,
3751- DragOverFileList_DraggedFileListEntries_EmphasisDstItem(lv, p, holder.ProhibitedDropFolderTopPaths));
3719+ return DragOverFileList_DraggedFileListEntries(holder, keyState, allowedEffect, lv, p);
37523720 }
37533721
37543722 private void DragEnterFileList_DraggedFileListEntries_EnterDragMode()
@@ -3758,13 +3726,19 @@ namespace FolderCategorizer.Presentation.View
37583726 DisableFileCategorizeBox();
37593727 }
37603728
3729+ private DragDropEffects DragOverFileList_DraggedFileListEntries_PreSwitchEffect(DragEventArgs e)
3730+ {
3731+ return DragOverCommon_DraggedFileListEntries_SwitchEffect(e.KeyState, e.AllowedEffect,
3732+ DragDropFileList_GetItemAt(lvFileList, new Point(e.X, e.Y)) != null);
3733+ }
3734+
37613735 private DragDropEffects DragOverFileList_DraggedFileListEntries(DraggedFileListEntriesHolder holder, int keyState, DragDropEffects allowedEffect, ListView lv, Point p)
37623736 {
3763- return DragOverFileList_DraggedFileListEntries_SwitchEffect(keyState, allowedEffect,
3764- DragOverFileList_DraggedFileListEntries_EmphasisDstItem(lv, p, holder.ProhibitedDropFolderTopPaths));
3737+ return DragOverCommon_DraggedFileListEntries_SwitchEffect(keyState, allowedEffect,
3738+ DragOverFileList_DraggedFileListEntries_EmphasisDstItem(lv, p, holder.SrcFolderPaths));
37653739 }
37663740
3767- private static bool DragOverFileList_DraggedFileListEntries_EmphasisDstItem(ListView lv, Point p, List<string> srcPaths)
3741+ private static bool DragOverFileList_DraggedFileListEntries_EmphasisDstItem(ListView lv, Point p, string[] srcFolderPaths)
37683742 {
37693743 ListViewItem dstItem = DragDropFileList_GetItemAt(lv, p);
37703744
@@ -3794,7 +3768,7 @@ namespace FolderCategorizer.Presentation.View
37943768 break;
37953769 }
37963770
3797- if (PathHelper.IsDstPathIncludedSrcPathList(dstEntry.RelativePath, srcPaths))
3771+ if (PathHelper.IsDstPathIncludedSrcPathList(dstEntry.RelativePath, srcFolderPaths))
37983772 {
37993773 // invalid dst path
38003774 return false;
@@ -3805,14 +3779,9 @@ namespace FolderCategorizer.Presentation.View
38053779 return true;
38063780 }
38073781
3808- private static DragDropEffects DragOverFileList_DraggedFileListEntries_SwitchEffect(int keyState, DragDropEffects allowedEffect, bool isValidDropTarget)
3809- {
3810- return DragOverCommon_DraggedFileListEntries_SwitchEffect(keyState, allowedEffect, isValidDropTarget);
3811- }
3812-
38133782 private void DragLeaveFileList_DraggedFileListEntries(DraggedFileListEntriesHolder holder)
38143783 {
3815- DragLeaveFileList_DraggedFileListEntries_RestoreSelectedItems(holder.SelectedFileListViewItems);
3784+ DragLeaveFileList_DraggedFileListEntries_RestoreSelectedItems(holder.SelectedListEntries);
38163785
38173786 DragLeaveCommon_DraggedFileListEntries_LeaveDragMode();
38183787 }
@@ -3844,9 +3813,9 @@ namespace FolderCategorizer.Presentation.View
38443813
38453814 private void DragDropFileList_DraggedFileListEntries(DraggedFileListEntriesHolder holder, ListView lv, Point p, DragDropEffects effect)
38463815 {
3847- List<FileListEntry> srcEntries = holder.DroppedEntries;
3816+ FileListEntry[] srcEntries = holder.DroppedEntries;
38483817
3849- DragLeaveFileList_DraggedFileListEntries_RestoreSelectedItems(holder.SelectedFileListViewItems);
3818+ DragLeaveFileList_DraggedFileListEntries_RestoreSelectedItems(holder.SelectedListEntries);
38503819
38513820 DragLeaveCommon_DraggedFileListEntries_LeaveDragMode();
38523821
@@ -3921,7 +3890,7 @@ namespace FolderCategorizer.Presentation.View
39213890 }
39223891
39233892 private FileSystemOperationResult DragDropCommon_DraggedFileListEntries(
3924- string dstRelativePath, string srcRefreshPath, List<FileListEntry> srcEntries, DragDropEffects effect)
3893+ string dstRelativePath, string srcRefreshPath, FileListEntry[] srcEntries, DragDropEffects effect)
39253894 {
39263895 string srcTopPath1 = IsSrcFolder1Enabled ? txtSrcFolder1.Text : string.Empty;
39273896 string srcTopPath2 = IsSrcFolder2Enabled ? txtSrcFolder2.Text : string.Empty;
@@ -3945,18 +3914,18 @@ namespace FolderCategorizer.Presentation.View
39453914 }
39463915
39473916 private FileSystemOperationResult DragDropCommon_DraggedFileListEntries(
3948- string dstFullPath1, string dstFullPath2, string srcTopPath1, string srcTopPath2, List<FileListEntry> srcEntries,
3917+ string dstFullPath1, string dstFullPath2, string srcTopPath1, string srcTopPath2, FileListEntry[] srcEntries,
39493918 string dstRefreshPath, string srcRefreshPath, DragDropEffects effect)
39503919 {
39513920 switch (DragDropCommon_SwitchEffect(effect))
39523921 {
39533922 case DragDropEffects.Copy:
39543923 return DoFileSystemOperation(new FileSystemCopyOperationRequest(
3955- this, dstFullPath1, dstFullPath2, srcTopPath1, srcTopPath2, srcEntries, dstRefreshPath, srcRefreshPath));
3924+ this, dstFullPath1, dstFullPath2, srcTopPath1, srcTopPath2, srcEntries.ToList(), dstRefreshPath, srcRefreshPath));
39563925
39573926 case DragDropEffects.Move:
39583927 return DoFileSystemOperation(new FileSystemMoveOperationRequest(
3959- this, dstFullPath1, dstFullPath2, srcTopPath1, srcTopPath2, srcEntries, dstRefreshPath, srcRefreshPath));
3928+ this, dstFullPath1, dstFullPath2, srcTopPath1, srcTopPath2, srcEntries.ToList(), dstRefreshPath, srcRefreshPath));
39603929
39613930 default:
39623931 return new FileSystemOperationResult(null).Abort();
@@ -4250,7 +4219,7 @@ namespace FolderCategorizer.Presentation.View
42504219 return;
42514220 }
42524221
4253- List<FileListEntry> entries = CreateSelectedSrcEntries();
4222+ List<FileListEntry> entries = FileListEntry.ToListFromTagsOf(lvFileList.SelectedItems);
42544223
42554224 if (entries.Count == 0)
42564225 {
@@ -4345,7 +4314,7 @@ namespace FolderCategorizer.Presentation.View
43454314
43464315 private void btnCreateNewFolderAndMove_Click(object sender, EventArgs e)
43474316 {
4348- List<FileListEntry> srcEntries = CreateSelectedSrcEntries();
4317+ List<FileListEntry> srcEntries = FileListEntry.ToListFromTagsOf(lvFileList.SelectedItems);
43494318
43504319 if (srcEntries.Count == 0)
43514320 {
@@ -4471,7 +4440,7 @@ namespace FolderCategorizer.Presentation.View
44714440
44724441 private void DeleteFileToolStripMenuItem_Click(object sender, EventArgs e)
44734442 {
4474- List<FileListEntry> entries = CreateSelectedSrcEntries();
4443+ List<FileListEntry> entries = FileListEntry.ToListFromTagsOf(lvFileList.SelectedItems);
44754444
44764445 if (entries.Count == 0)
44774446 {
@@ -4559,7 +4528,7 @@ namespace FolderCategorizer.Presentation.View
45594528
45604529 private void OverwriteCreationTimeToolStripMenuItem_Click(object sender, EventArgs e)
45614530 {
4562- List<FileListEntry> entries = CreateSelectedSrcEntries();
4531+ List<FileListEntry> entries = FileListEntry.ToListFromTagsOf(lvFileList.SelectedItems);
45634532
45644533 if (entries.Count == 0)
45654534 {
@@ -4575,7 +4544,7 @@ namespace FolderCategorizer.Presentation.View
45754544
45764545 private void OverwriteLastWriteTimeToolStripMenuItem_Click(object sender, EventArgs e)
45774546 {
4578- List<FileListEntry> entries = CreateSelectedSrcEntries();
4547+ List<FileListEntry> entries = FileListEntry.ToListFromTagsOf(lvFileList.SelectedItems);
45794548
45804549 if (entries.Count == 0)
45814550 {
@@ -4591,7 +4560,7 @@ namespace FolderCategorizer.Presentation.View
45914560
45924561 private void ExchangeCreationAndLastWriteTimeToolStripMenuItem_Click(object sender, EventArgs e)
45934562 {
4594- List<FileListEntry> entries = CreateSelectedSrcEntries();
4563+ List<FileListEntry> entries = FileListEntry.ToListFromTagsOf(lvFileList.SelectedItems);
45954564
45964565 if (entries.Count == 0)
45974566 {
@@ -4609,7 +4578,7 @@ namespace FolderCategorizer.Presentation.View
46094578 {
46104579 List<FileListEntry> entries = new List<FileListEntry>();
46114580
4612- entries.AddRange(CreateSelectedSrcEntries().Where((x) => x.Type == FileListEntry.EntryType.FOLDER));
4581+ entries.AddRange(FileListEntry.ToListFromTagsOf(lvFileList.SelectedItems).Where((x) => x.Type == FileListEntry.EntryType.FOLDER));
46134582
46144583 if (entries.Count == 0)
46154584 {
@@ -4736,7 +4705,7 @@ namespace FolderCategorizer.Presentation.View
47364705
47374706 private void lvFileList_ItemDrag(object sender, ItemDragEventArgs e)
47384707 {
4739- Logger.Info("lvFileList_ItemDrag");
4708+ //Logger.Info("lvFileList_ItemDrag");
47404709
47414710 if (e.Button == MouseButtons.Left)
47424711 {
@@ -4744,6 +4713,7 @@ namespace FolderCategorizer.Presentation.View
47444713
47454714 DataObjectEx data = new DataObjectEx();
47464715 data.SetData(DataFormats.Serializable, true, DraggedFileListEntries);
4716+
47474717 DragDropEffects res = ShellUtils.DragSource.DoDragDrop(
47484718 data, lvFileList, DragDropEffects.Copy | DragDropEffects.Move, PointToClient(MousePosition));
47494719
@@ -4753,45 +4723,47 @@ namespace FolderCategorizer.Presentation.View
47534723
47544724 private void lvFileList_DragEnter(object sender, DragEventArgs e)
47554725 {
4756- Logger.Info("lvFileList_DragEnter");
4726+ //Logger.Info("lvFileList_DragEnter");
47574727
4758- e.Effect = DragDropEffects.None;
4728+ bool isDataSerializable = e.Data.GetDataPresent(DataFormats.Serializable);
47594729
4760- DragDropEffects effect = DragOverFileList_DraggedFileListEntries_SwitchEffect(e.KeyState, e.AllowedEffect,
4761- DragDropFileList_GetItemAt(lvFileList, new Point(e.X, e.Y)) != null);
4730+ DragDropEffects effect = isDataSerializable ? DragOverFileList_DraggedFileListEntries_PreSwitchEffect(e) : DragDropEffects.None;
47624731
47634732 dropHelperFileListView.DragEnter(lvFileList.PointToClient(new Point(e.X, e.Y)), effect, e.Data);
47644733
4765- if (e.Data.GetDataPresent(DataFormats.Serializable))
4734+ if (isDataSerializable)
47664735 {
47674736 e.Effect = DragEnterFileList_DraggedFileListEntries(
47684737 (DraggedFileListEntriesHolder)e.Data.GetData(DataFormats.Serializable),
47694738 e.KeyState, e.AllowedEffect, lvFileList, new Point(e.X, e.Y));
4770- }
4739+ }
4740+
4741+ e.Effect = effect;
47714742 }
47724743
47734744 private void lvFileList_DragOver(object sender, DragEventArgs e)
47744745 {
4775- Logger.Info("lvFileList_DragOver");
4746+ //Logger.Info("lvFileList_DragOver");
47764747
4777- e.Effect = DragDropEffects.None;
4748+ bool isDataSerializable = e.Data.GetDataPresent(DataFormats.Serializable);
47784749
4779- DragDropEffects effect = DragOverFileList_DraggedFileListEntries_SwitchEffect(e.KeyState, e.AllowedEffect,
4780- DragDropFileList_GetItemAt(lvFileList, new Point(e.X, e.Y)) != null);
4750+ DragDropEffects effect = isDataSerializable ? DragOverFileList_DraggedFileListEntries_PreSwitchEffect(e) : DragDropEffects.None;
47814751
47824752 dropHelperFileListView.DragOver(lvFileList.PointToClient(new Point(e.X, e.Y)), effect);
47834753
4784- if (e.Data.GetDataPresent(DataFormats.Serializable))
4754+ if (isDataSerializable)
47854755 {
4786- e.Effect = DragOverFileList_DraggedFileListEntries(
4756+ effect = DragOverFileList_DraggedFileListEntries(
47874757 (DraggedFileListEntriesHolder)e.Data.GetData(DataFormats.Serializable, true),
47884758 e.KeyState, e.AllowedEffect, lvFileList, new Point(e.X, e.Y));
47894759 }
4760+
4761+ e.Effect = effect;
47904762 }
47914763
47924764 private void lvFileList_DragLeave(object sender, EventArgs e)
47934765 {
4794- Logger.Info("lvFileList_DragLeave");
4766+ //Logger.Info("lvFileList_DragLeave");
47954767
47964768 dropHelperFileListView.DragLeave();
47974769
@@ -4800,7 +4772,7 @@ namespace FolderCategorizer.Presentation.View
48004772
48014773 private void lvFileList_DragDrop(object sender, DragEventArgs e)
48024774 {
4803- Logger.Info("lvFileList_DragDrop");
4775+ //Logger.Info("lvFileList_DragDrop");
48044776
48054777 dropHelperFileListView.Drop(PointToClient(MousePosition), e.Effect, e.Data);
48064778