File tree Expand file tree Collapse file tree 5 files changed +66
-0
lines changed
Expand file tree Collapse file tree 5 files changed +66
-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 Copy : AbstractAction
7+ {
8+ public bool DoCopy ( )
9+ {
10+ File . Copy (
11+ this . GetSourcePath ( ) ,
12+ this . GetTargetPath ( ) +
13+ Path . DirectorySeparatorChar +
14+ Path . GetFileName ( this . GetCurrent ( ) . Cells [ 0 ] . Value . ToString ( )
15+ )
16+ ) ;
17+
18+ return true ;
19+ }
20+
21+ public override bool ExecuteAction ( )
22+ {
23+ return base . ExecuteAction ( ) ;
24+ }
25+
26+ public override bool Matches ( DataGridViewRow row )
27+ {
28+ if ( ! base . Matches ( row ) )
29+ {
30+ return false ;
31+ }
32+
33+ if (
34+ (
35+ this . GetFileExtension ( ) == "*.*" &&
36+ Path . GetFileNameWithoutExtension (
37+ this . GetCurrent ( ) . Cells [ ( int ) NameAssociationCellIndex . Name ] . Value . ToString ( )
38+ ) . Contains ( this . GetSearchPattern ( ) )
39+ ) ||
40+ (
41+ Path . GetFileNameWithoutExtension (
42+ this . GetCurrent ( ) . Cells [ ( int ) NameAssociationCellIndex . Name ] . Value . ToString ( )
43+ ) . Contains ( this . GetSearchPattern ( ) ) &&
44+ this . GetFileExtension ( ) == Path . GetExtension ( this . GetCurrent ( ) . Cells [ ( int ) NameAssociationCellIndex . Name ] . Value . ToString ( ) )
45+ ) &&
46+ (
47+ Directory . Exists ( this . GetTargetPath ( ) + Path . DirectorySeparatorChar )
48+ )
49+ )
50+ {
51+ return true ;
52+ }
53+
54+ return false ;
55+ }
56+ }
57+ }
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ public enum AvailableActions
1212 {
1313 [ Description ( "grid.Action.Move" ) ]
1414 Move = 0 ,
15+ [ Description ( "grid.Action.Copy" ) ]
16+ Copy = 1 ,
1517 }
1618
1719 public class AvailableAction
Original file line number Diff line number Diff line change 174174 <data name =" grid.Action.Move" xml : space =" preserve" >
175175 <value >Verschieben</value >
176176 </data >
177+ <data name =" grid.Action.Copy" xml : space =" preserve" >
178+ <value >Kopieren</value >
179+ </data >
177180</root >
Original file line number Diff line number Diff line change 363363 <data name =" grid.Action.Move" xml : space =" preserve" >
364364 <value >Move</value >
365365 </data >
366+ <data name =" grid.Action.Copy" xml : space =" preserve" >
367+ <value >Copy</value >
368+ </data >
366369</root >
Original file line number Diff line number Diff line change 5050 </ItemGroup >
5151 <ItemGroup >
5252 <Compile Include =" Actions.cs" />
53+ <Compile Include =" Action\Copy.cs" />
5354 <Compile Include =" Action\IAction.cs" />
5455 <Compile Include =" Action\Move.cs" />
5556 <Compile Include =" Form2.cs" >
You can’t perform that action at this time.
0 commit comments