Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 756ea17d authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

add file drag&drop functionality to xml file selector user controls

parent ba91e17a
No related branches found
Tags Build/V3.0.1.312
No related merge requests found
......@@ -177,6 +177,8 @@ namespace HashingTool.ViewModel.UserControl
}
try {
_source = fileName;
RaisePropertyChanged("Source");
using (var stream = File.OpenRead(fileName)) {
await LoadXMLFile(stream);
}
......
......@@ -7,12 +7,12 @@
xmlns:userControl="clr-namespace:HashingTool.ViewModel.UserControl"
x:Class="HashingTool.Views.VectoXMLFileSelector"
mc:Ignorable="d" d:DesignWidth="456" MinHeight="32"
d:DataContext="{d:DesignInstance views:VectoXMLFileSelector}">
d:DataContext="{d:DesignInstance views:VectoXMLFileSelector}" >
<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVis" />
</UserControl.Resources>
<StackPanel Margin="0,5" HorizontalAlignment="Stretch">
<DockPanel HorizontalAlignment="Stretch" Height="Auto" Margin="0" VerticalAlignment="Top">
<DockPanel HorizontalAlignment="Stretch" Height="Auto" Margin="0" VerticalAlignment="Top" AllowDrop="True" Drop="XMLFileBrowser_Drop">
<!--<ContentControl DockPanel.Dock="Right"
Visibility="{Binding XMLFile.HasContentValidation, Converter={StaticResource BoolToVis}}" Width="40" Height="40"
......@@ -75,7 +75,7 @@
VerticalAlignment="Top" HorizontalAlignment="Right" Width="75" />
<TextBox DockPanel.Dock="Left" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="23"
Margin="0,0,10,0" TextWrapping="NoWrap" Text="{Binding XMLFile.Source, Mode=OneWay}" IsReadOnly="True">
Margin="0,0,10,0" TextWrapping="NoWrap" Text="{Binding XMLFile.Source, Mode=OneWay}" IsReadOnly="True" PreviewDragOver="XMLFileBrowser_DragOver">
<TextBox.InputBindings>
<KeyBinding Command="{Binding XMLFile.SetXMLFileCommnd}" Key="Return" />
</TextBox.InputBindings>
......
......@@ -63,5 +63,19 @@ namespace HashingTool.Views
dialog.ErrorCount = XMLFile.XMLValidationErrors.Count;
dialog.ShowDialog();
}
private void XMLFileBrowser_Drop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
XMLFile.SetXMLFileCommnd.Execute(files?[0]);
}
}
private void XMLFileBrowser_DragOver(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Handled = true;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment