1
0
mirror of https://github.com/chylex/Backup-Essentials.git synced 2025-05-31 00:34:09 +02:00

Added Drag&Drop events

This commit is contained in:
chylex 2015-04-09 20:33:09 +02:00
parent e4191482e6
commit 0e9e1f2611
2 changed files with 24 additions and 2 deletions

View File

@ -7,7 +7,7 @@
xmlns:custom="clr-namespace:BackupEssentials.Controls"
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
mc:Ignorable="d" x:Class="BackupEssentials.MainWindow"
Title="Backup" Height="600" Width="800" WindowStartupLocation="CenterScreen" WindowStyle="None" ResizeMode="CanResizeWithGrip" Background="#FF000000" AllowsTransparency="True" AllowDrop="True" MinWidth="800" MinHeight="600">
Title="Backup" Height="600" Width="800" WindowStartupLocation="CenterScreen" WindowStyle="None" ResizeMode="CanResizeWithGrip" Background="#FF000000" AllowsTransparency="True" AllowDrop="True" MinWidth="800" MinHeight="600" DragEnter="OnDragEnter" DragLeave="OnDragLeave" Drop="OnDragDrop">
<Window.Resources>
<Style TargetType="ResizeGrip">
<Setter Property="Margin" Value="2"/>

View File

@ -17,6 +17,8 @@ namespace BackupEssentials{
private new Rect RestoreBounds = new Rect();
private bool IsMaximized = false;
private string[] DropData = null;
public MainWindow(){
InitializeComponent();
Instance = this;
@ -91,6 +93,24 @@ namespace BackupEssentials{
ShowPage(GetType().Assembly.GetType("BackupEssentials."+btn.ClickPage,false));
}
private void OnDragEnter(object sender, System.Windows.DragEventArgs e){
if (DropData == null && e.Data.GetDataPresent(System.Windows.DataFormats.FileDrop))DropData = e.Data.GetData(System.Windows.DataFormats.FileDrop) as string[];
else e.Effects = System.Windows.DragDropEffects.None;
e.Handled = true;
}
private void OnDragLeave(object sender, System.Windows.DragEventArgs e){
DropData = null;
}
private void OnDragDrop(object sender, System.Windows.DragEventArgs e){
if (DropData != null){
// TODO display backup page
DropData = null;
}
}
public void ShowPage(Type pageType){
ShowPage(pageType,null);
}
@ -104,7 +124,9 @@ namespace BackupEssentials{
if (!page.AllowDrop){
page.AllowDrop = true;
// TODO handle events
page.DragEnter += new System.Windows.DragEventHandler(OnDragEnter);
page.DragLeave += new System.Windows.DragEventHandler(OnDragLeave);
page.Drop += new System.Windows.DragEventHandler(OnDragDrop);
}
}
}