mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 03:44:13 +08:00
(GUI): implemented file drop event.
This commit is contained in:
parent
010384fbfa
commit
5bf4a44bf5
@ -8,6 +8,7 @@
|
||||
Title="GARbro" MinHeight="250" ResizeMode="CanResizeWithGrip"
|
||||
Loaded="WindowLoaded"
|
||||
KeyDown="WindowKeyDown"
|
||||
AllowDrop="True" Drop="OnDropEvent"
|
||||
Top="{Binding Source={x:Static p:Settings.Default}, Path=winTop, Mode=TwoWay}"
|
||||
Left="{Binding Source={x:Static p:Settings.Default}, Path=winLeft, Mode=TwoWay}"
|
||||
Height="{Binding Source={x:Static p:Settings.Default}, Path=winHeight, Mode=TwoWay}"
|
||||
|
@ -798,19 +798,9 @@ namespace GARbro.GUI
|
||||
|
||||
private void OpenFile (string filename)
|
||||
{
|
||||
if (filename == CurrentPath || string.IsNullOrEmpty (filename))
|
||||
return;
|
||||
try
|
||||
{
|
||||
if (File.Exists (filename))
|
||||
VFS.FullPath = new string[] { filename, "" };
|
||||
else
|
||||
VFS.FullPath = new string[] { filename };
|
||||
var vm = new DirectoryViewModel (VFS.FullPath, VFS.GetFiles(), VFS.IsVirtual);
|
||||
PushViewModel (vm);
|
||||
if (null != VFS.CurrentArchive)
|
||||
SetStatusText (VFS.CurrentArchive.Description);
|
||||
lv_SelectItem (0);
|
||||
OpenFileOrDir (filename);
|
||||
}
|
||||
catch (OperationCanceledException X)
|
||||
{
|
||||
@ -822,6 +812,21 @@ namespace GARbro.GUI
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenFileOrDir (string filename)
|
||||
{
|
||||
if (filename == CurrentPath || string.IsNullOrEmpty (filename))
|
||||
return;
|
||||
if (File.Exists (filename))
|
||||
VFS.FullPath = new string[] { filename, "" };
|
||||
else
|
||||
VFS.FullPath = new string[] { filename };
|
||||
var vm = new DirectoryViewModel (VFS.FullPath, VFS.GetFiles(), VFS.IsVirtual);
|
||||
PushViewModel (vm);
|
||||
if (null != VFS.CurrentArchive)
|
||||
SetStatusText (VFS.CurrentArchive.Description);
|
||||
lv_SelectItem (0);
|
||||
}
|
||||
|
||||
private void OpenRecentExec (object control, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
string filename = e.Parameter as string;
|
||||
@ -1336,6 +1341,36 @@ namespace GARbro.GUI
|
||||
else
|
||||
item.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void OnDropEvent (object sender, DragEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!e.Data.GetDataPresent (DataFormats.FileDrop))
|
||||
return;
|
||||
var files = (string[])e.Data.GetData (DataFormats.FileDrop);
|
||||
if (!files.Any())
|
||||
return;
|
||||
var filename = files.First();
|
||||
try
|
||||
{
|
||||
OpenFileOrDir (filename);
|
||||
}
|
||||
catch (Exception X)
|
||||
{
|
||||
VFS.FullPath = new string[] { Path.GetDirectoryName (filename) };
|
||||
var vm = new DirectoryViewModel (VFS.FullPath, VFS.GetFiles(), VFS.IsVirtual);
|
||||
PushViewModel (vm);
|
||||
filename = Path.GetFileName (filename);
|
||||
lv_SelectItem (filename);
|
||||
SetStatusText (string.Format("{0}: {1}", filename, X.Message));
|
||||
}
|
||||
}
|
||||
catch (Exception X)
|
||||
{
|
||||
Trace.WriteLine (X.Message, "Drop event failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SortModeToBooleanConverter : IValueConverter
|
||||
|
Loading…
x
Reference in New Issue
Block a user