File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3939 Watermark =" {DynamicResource Text.Apply.File.Placeholder}"
4040 IsEnabled =" {Binding !FromClipboard, Mode=OneWay}"
4141 IsVisible =" {Binding !FromClipboard, Mode=OneWay}"
42- Text =" {Binding PatchFile, Mode=TwoWay}" >
42+ Text =" {Binding PatchFile, Mode=TwoWay}"
43+ DragDrop.AllowDrop=" True"
44+ DragDrop.DragOver=" DragOverPatchFileBox"
45+ DragDrop.Drop=" DropOnPatchFileBox" >
4346 <TextBox .Styles>
4447 <Style Selector =" TextBox:disabled Path" >
4548 <Setter Property =" Opacity" Value =" .6" />
Original file line number Diff line number Diff line change 11using Avalonia ;
22using Avalonia . Controls ;
3+ using Avalonia . Input ;
34using Avalonia . Interactivity ;
45using Avalonia . Platform . Storage ;
56
@@ -38,5 +39,52 @@ private async void SelectPatchFile(object _, RoutedEventArgs e)
3839
3940 e . Handled = true ;
4041 }
42+
43+ private void DragOverPatchFileBox ( object sender , DragEventArgs e )
44+ {
45+ if ( ! e . DataTransfer . Contains ( DataFormat . File ) )
46+ {
47+ e . DragEffects = DragDropEffects . None ;
48+ e . Handled = true ;
49+ return ;
50+ }
51+
52+ var files = e . DataTransfer . TryGetFiles ( ) ;
53+ if ( files is not { Length : 1 } )
54+ {
55+ e . DragEffects = DragDropEffects . None ;
56+ e . Handled = true ;
57+ return ;
58+ }
59+
60+ var file = files [ 0 ] . Path . LocalPath ;
61+ if ( ! file . EndsWith ( ".patch" ) && ! file . EndsWith ( ".diff" ) )
62+ {
63+ e . DragEffects = DragDropEffects . None ;
64+ e . Handled = true ;
65+ return ;
66+ }
67+
68+ e . DragEffects = DragDropEffects . Move ;
69+ e . Handled = true ;
70+ return ;
71+ }
72+
73+ private void DropOnPatchFileBox ( object sender , DragEventArgs e )
74+ {
75+ if ( ! e . DataTransfer . Contains ( DataFormat . File ) )
76+ return ;
77+
78+ var files = e . DataTransfer . TryGetFiles ( ) ;
79+ if ( files is not { Length : 1 } )
80+ return ;
81+
82+ var file = files [ 0 ] . Path . LocalPath ;
83+ if ( ! file . EndsWith ( ".patch" ) && ! file . EndsWith ( ".diff" ) )
84+ return ;
85+
86+ TxtPatchFile . Text = file ;
87+ e . Handled = true ;
88+ }
4189 }
4290}
You can’t perform that action at this time.
0 commit comments