File tree Expand file tree Collapse file tree 5 files changed +64
-0
lines changed
Expand file tree Collapse file tree 5 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 1+ using System . IO ;
2+ using System . Windows . Forms ;
3+
4+ namespace PatternFileMover . Action
5+ {
6+ internal class Delete : AbstractAction
7+ {
8+ public bool DoDelete ( )
9+ {
10+ try
11+ {
12+ File . Delete ( this . GetSourcePath ( ) ) ;
13+ }
14+ catch ( IOException )
15+ {
16+ return false ;
17+ }
18+
19+ return true ;
20+ }
21+
22+ public override bool ExecuteAction ( )
23+ {
24+ return base . ExecuteAction ( ) ;
25+ }
26+
27+ public override bool Matches ( DataGridViewRow row )
28+ {
29+ if ( ! base . Matches ( row ) )
30+ {
31+ return false ;
32+ }
33+
34+ if (
35+ (
36+ this . GetFileExtension ( ) == "*.*" &&
37+ Path . GetFileNameWithoutExtension (
38+ this . GetCurrent ( ) . Cells [ ( int ) NameAssociationCellIndex . Name ] . Value . ToString ( )
39+ ) . Contains ( this . GetSearchPattern ( ) )
40+ ) ||
41+ (
42+ Path . GetFileNameWithoutExtension (
43+ this . GetCurrent ( ) . Cells [ ( int ) NameAssociationCellIndex . Name ] . Value . ToString ( )
44+ ) . Contains ( this . GetSearchPattern ( ) ) &&
45+ this . GetFileExtension ( ) == Path . GetExtension ( this . GetCurrent ( ) . Cells [ ( int ) NameAssociationCellIndex . Name ] . Value . ToString ( ) )
46+ )
47+ )
48+ {
49+ return true ;
50+ }
51+
52+ return false ;
53+ }
54+ }
55+ }
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ public enum AvailableActions
1818 CopyOverwrite = 2 ,
1919 [ Description ( "grid.Action.MoveOverwrite" ) ]
2020 MoveOverwrite = 3 ,
21+ [ Description ( "grid.Action.Delete" ) ]
22+ Delete = 4 ,
2123 }
2224
2325 public class AvailableAction
Original file line number Diff line number Diff line change 183183 <data name =" grid.Action.MoveOverwrite" xml : space =" preserve" >
184184 <value >Verschieben (Überschreiben)</value >
185185 </data >
186+ <data name =" grid.Action.Delete" xml : space =" preserve" >
187+ <value >Löschen</value >
188+ </data >
186189</root >
Original file line number Diff line number Diff line change 372372 <data name =" grid.Action.MoveOverwrite" xml : space =" preserve" >
373373 <value >Move (Overwrite)</value >
374374 </data >
375+ <data name =" grid.Action.Delete" xml : space =" preserve" >
376+ <value >Delete</value >
377+ </data >
375378</root >
Original file line number Diff line number Diff line change 5252 <Compile Include =" Actions.cs" />
5353 <Compile Include =" Action\Copy.cs" />
5454 <Compile Include =" Action\CopyOverwrite.cs" />
55+ <Compile Include =" Action\Delete.cs" />
5556 <Compile Include =" Action\IAction.cs" />
5657 <Compile Include =" Action\Move.cs" />
5758 <Compile Include =" Action\MoveOverwrite.cs" />
You can’t perform that action at this time.
0 commit comments