private void Window_Drop(object sender, DragEventArgs e)
{
if (e.Data is System.Windows.DataObject &&
((System.Windows.DataObject)e.Data).ContainsFileDropList())
{
bool fileAdded = false;
foreach (string filePath in ((System.Windows.DataObject)e.Data).GetFileDropList())
{
Tab newTab = new Tab();
tab.Add(newTab);
// Hook up tab band event handlers
newTab.Title.MouseLeftButtonUp += this.TabClick;
newTab.Title.ContextMenu = (ContextMenu)Resources["TabTitleContextMenu"];
newTab.CloseButton.MouseLeftButtonUp += this.TabClose;
TabBar.Children.Add(newTab.Title);
Editor.Children.Add(newTab.TextEditor);
newTab.OpenFile(filePath);
fileAdded = true;
}
if (fileAdded)
{
// Switch focus to the new file
if (currentTabIndex >= 0)
{
tab[currentTabIndex].TextEditor.Visibility = Visibility.Hidden;
tab[currentTabIndex].Title.Opacity = 0.5;
}
int newTabFocus = tab.Count - 1;
this.currentTabIndex = newTabFocus;
tab[newTabFocus].Title.Opacity = 1.0;
tab[newTabFocus].TextEditor.Visibility = Visibility.Visible;
tab[newTabFocus].TextEditor.Focus();
}
}
}