@@ -107,7 +107,7 @@ protected override void OnSourceInitialized(EventArgs e)
107107 // Set WindowState after PresentationSource is initialized, because now bounds and location are properly set.
108108 this . WindowState = lastNonMinimizedWindowState ;
109109 }
110-
110+
111111 void SetBounds ( Rect bounds )
112112 {
113113 this . Left = bounds . Left ;
@@ -174,7 +174,7 @@ void ExecuteCommand(ICommand command, object caller)
174174 // keep a reference to the event handler to prevent it from being garbage collected
175175 // (CommandManager.RequerySuggested only keeps weak references to the event handlers)
176176 EventHandler requerySuggestedEventHandler ;
177-
177+
178178 void CommandManager_RequerySuggested ( object sender , EventArgs e )
179179 {
180180 UpdateMenu ( ) ;
@@ -270,9 +270,9 @@ public ICollection<IViewContent> PrimaryViewContents {
270270 get {
271271 SD . MainThread . VerifyAccess ( ) ;
272272 return ( from window in WorkbenchWindowCollection
273- where window . ViewContents . Count > 0
274- select window . ViewContents [ 0 ]
275- ) . ToList ( ) . AsReadOnly ( ) ;
273+ where window . ViewContents . Count > 0
274+ select window . ViewContents [ 0 ]
275+ ) . ToList ( ) . AsReadOnly ( ) ;
276276 }
277277 }
278278
@@ -319,7 +319,7 @@ private set {
319319 }
320320 }
321321 }
322-
322+
323323 void WorkbenchWindowActiveViewContentChanged ( object sender , EventArgs e )
324324 {
325325 if ( workbenchLayout != null ) {
@@ -671,22 +671,29 @@ protected override void OnDrop(DragEventArgs e)
671671 string [ ] files = ( string [ ] ) e . Data . GetData ( DataFormats . FileDrop ) ;
672672 if ( files == null )
673673 return ;
674- foreach ( string file in files ) {
675- if ( File . Exists ( file ) ) {
676- var fileName = FileName . Create ( file ) ;
677- if ( SD . ProjectService . IsSolutionOrProjectFile ( fileName ) ) {
678- SD . ProjectService . OpenSolutionOrProject ( fileName ) ;
679- } else {
680- SD . FileService . OpenFile ( fileName ) ;
681- }
682- }
683- }
674+ // Handle opening the files outside the drop event, so that the drag source doesn't think
675+ // the operation is still in progress while we're showing a "file cannot be opened" error message.
676+ Dispatcher . BeginInvoke ( DispatcherPriority . Normal , new Action < string [ ] > ( HandleDrop ) , files ) ;
684677 }
685678 } catch ( Exception ex ) {
686679 MessageService . ShowException ( ex ) ;
687680 }
688681 }
689682
683+ void HandleDrop ( string [ ] files )
684+ {
685+ foreach ( string file in files ) {
686+ if ( File . Exists ( file ) ) {
687+ var fileName = FileName . Create ( file ) ;
688+ if ( SD . ProjectService . IsSolutionOrProjectFile ( fileName ) ) {
689+ SD . ProjectService . OpenSolutionOrProject ( fileName ) ;
690+ } else {
691+ SD . FileService . OpenFile ( fileName ) ;
692+ }
693+ }
694+ }
695+ }
696+
690697 void InitFocusTrackingEvents ( )
691698 {
692699 #if DEBUG
@@ -700,7 +707,7 @@ internal static void FocusDebug(string format, params object[] args)
700707 {
701708 #if DEBUG
702709 if ( enableFocusDebugOutput )
703- LoggingService . DebugFormatted ( format , args ) ;
710+ LoggingService . DebugFormatted ( format , args ) ;
704711 #endif
705712 }
706713
@@ -709,55 +716,55 @@ internal static void FocusDebug(string format, params object[] args)
709716
710717 void WpfWorkbench_PreviewGotKeyboardFocus ( object sender , KeyboardFocusChangedEventArgs e )
711718 {
712- FocusDebug ( "GotKeyboardFocus: oldFocus={0}, newFocus={1}" , e . OldFocus , e . NewFocus ) ;
719+ FocusDebug ( "GotKeyboardFocus: oldFocus={0}, newFocus={1}" , e . OldFocus , e . NewFocus ) ;
713720 }
714721
715722 void WpfWorkbench_PreviewLostKeyboardFocus ( object sender , KeyboardFocusChangedEventArgs e )
716723 {
717- FocusDebug ( "LostKeyboardFocus: oldFocus={0}, newFocus={1}" , e . OldFocus , e . NewFocus ) ;
724+ FocusDebug ( "LostKeyboardFocus: oldFocus={0}, newFocus={1}" , e . OldFocus , e . NewFocus ) ;
718725 }
719726
720727 protected override void OnPreviewKeyDown ( KeyEventArgs e )
721728 {
722- base . OnPreviewKeyDown ( e ) ;
723- if ( ! e . Handled && e . Key == Key . D && e . KeyboardDevice . Modifiers == ( ModifierKeys . Control | ModifierKeys . Shift | ModifierKeys . Alt ) ) {
724- enableFocusDebugOutput = ! enableFocusDebugOutput ;
729+ base . OnPreviewKeyDown ( e ) ;
730+ if ( ! e . Handled && e . Key == Key . D && e . KeyboardDevice . Modifiers == ( ModifierKeys . Control | ModifierKeys . Shift | ModifierKeys . Alt ) ) {
731+ enableFocusDebugOutput = ! enableFocusDebugOutput ;
725732
726- StringWriter output = new StringWriter ( ) ;
727- output . WriteLine ( "Keyboard.FocusedElement = " + GetElementName ( Keyboard . FocusedElement ) ) ;
728- output . WriteLine ( "ActiveContent = " + GetElementName ( this . ActiveContent ) ) ;
729- output . WriteLine ( "ActiveViewContent = " + GetElementName ( this . ActiveViewContent ) ) ;
730- output . WriteLine ( "ActiveWorkbenchWindow = " + GetElementName ( this . ActiveWorkbenchWindow ) ) ;
731- ( ( AvalonDockLayout ) workbenchLayout ) . WriteState ( output ) ;
732- LoggingService . Debug ( output . ToString ( ) ) ;
733- e . Handled = true ;
734- }
735- if ( ! e . Handled && e . Key == Key . F && e . KeyboardDevice . Modifiers == ( ModifierKeys . Control | ModifierKeys . Shift | ModifierKeys . Alt ) ) {
736- if ( TextOptions . GetTextFormattingMode ( this ) == TextFormattingMode . Display )
737- TextOptions . SetTextFormattingMode ( this , TextFormattingMode . Ideal ) ;
738- else
739- TextOptions . SetTextFormattingMode ( this , TextFormattingMode . Display ) ;
740- SD . StatusBar . SetMessage ( "TextFormattingMode=" + TextOptions . GetTextFormattingMode ( this ) ) ;
741- }
742- if ( ! e . Handled && e . Key == Key . R && e . KeyboardDevice . Modifiers == ( ModifierKeys . Control | ModifierKeys . Shift | ModifierKeys . Alt ) ) {
743- switch ( TextOptions . GetTextRenderingMode ( this ) ) {
744- case TextRenderingMode . Auto :
745- case TextRenderingMode . ClearType :
746- TextOptions . SetTextRenderingMode ( this , TextRenderingMode . Grayscale ) ;
747- break ;
748- case TextRenderingMode . Grayscale :
749- TextOptions . SetTextRenderingMode ( this , TextRenderingMode . Aliased ) ;
750- break ;
751- default :
752- TextOptions . SetTextRenderingMode ( this , TextRenderingMode . ClearType ) ;
753- break ;
754- }
755- SD . StatusBar . SetMessage ( "TextRenderingMode=" + TextOptions . GetTextRenderingMode ( this ) ) ;
756- }
757- if ( ! e . Handled && e . Key == Key . G && e . KeyboardDevice . Modifiers == ( ModifierKeys . Control | ModifierKeys . Shift | ModifierKeys . Alt ) ) {
758- GC . Collect ( GC . MaxGeneration , GCCollectionMode . Forced ) ;
759- SD . StatusBar . SetMessage ( "Total memory = " + ( GC . GetTotalMemory ( true ) / 1024 / 1024f ) . ToString ( "f1" ) + " MB" ) ;
760- }
733+ StringWriter output = new StringWriter ( ) ;
734+ output . WriteLine ( "Keyboard.FocusedElement = " + GetElementName ( Keyboard . FocusedElement ) ) ;
735+ output . WriteLine ( "ActiveContent = " + GetElementName ( this . ActiveContent ) ) ;
736+ output . WriteLine ( "ActiveViewContent = " + GetElementName ( this . ActiveViewContent ) ) ;
737+ output . WriteLine ( "ActiveWorkbenchWindow = " + GetElementName ( this . ActiveWorkbenchWindow ) ) ;
738+ ( ( AvalonDockLayout ) workbenchLayout ) . WriteState ( output ) ;
739+ LoggingService . Debug ( output . ToString ( ) ) ;
740+ e . Handled = true ;
741+ }
742+ if ( ! e . Handled && e . Key == Key . F && e . KeyboardDevice . Modifiers == ( ModifierKeys . Control | ModifierKeys . Shift | ModifierKeys . Alt ) ) {
743+ if ( TextOptions . GetTextFormattingMode ( this ) == TextFormattingMode . Display )
744+ TextOptions . SetTextFormattingMode ( this , TextFormattingMode . Ideal ) ;
745+ else
746+ TextOptions . SetTextFormattingMode ( this , TextFormattingMode . Display ) ;
747+ SD . StatusBar . SetMessage ( "TextFormattingMode=" + TextOptions . GetTextFormattingMode ( this ) ) ;
748+ }
749+ if ( ! e . Handled && e . Key == Key . R && e . KeyboardDevice . Modifiers == ( ModifierKeys . Control | ModifierKeys . Shift | ModifierKeys . Alt ) ) {
750+ switch ( TextOptions . GetTextRenderingMode ( this ) ) {
751+ case TextRenderingMode . Auto :
752+ case TextRenderingMode . ClearType :
753+ TextOptions . SetTextRenderingMode ( this , TextRenderingMode . Grayscale ) ;
754+ break ;
755+ case TextRenderingMode . Grayscale :
756+ TextOptions . SetTextRenderingMode ( this , TextRenderingMode . Aliased ) ;
757+ break ;
758+ default :
759+ TextOptions . SetTextRenderingMode ( this , TextRenderingMode . ClearType ) ;
760+ break ;
761+ }
762+ SD . StatusBar . SetMessage ( "TextRenderingMode=" + TextOptions . GetTextRenderingMode ( this ) ) ;
763+ }
764+ if ( ! e . Handled && e . Key == Key . G && e . KeyboardDevice . Modifiers == ( ModifierKeys . Control | ModifierKeys . Shift | ModifierKeys . Alt ) ) {
765+ GC . Collect ( GC . MaxGeneration , GCCollectionMode . Forced ) ;
766+ SD . StatusBar . SetMessage ( "Total memory = " + ( GC . GetTotalMemory ( true ) / 1024 / 1024f ) . ToString ( "f1" ) + " MB" ) ;
767+ }
761768 }
762769 #endif
763770
0 commit comments