@@ -107,7 +107,7 @@ protected override void OnSourceInitialized(EventArgs e)
107
107
// Set WindowState after PresentationSource is initialized, because now bounds and location are properly set.
108
108
this . WindowState = lastNonMinimizedWindowState ;
109
109
}
110
-
110
+
111
111
void SetBounds ( Rect bounds )
112
112
{
113
113
this . Left = bounds . Left ;
@@ -174,7 +174,7 @@ void ExecuteCommand(ICommand command, object caller)
174
174
// keep a reference to the event handler to prevent it from being garbage collected
175
175
// (CommandManager.RequerySuggested only keeps weak references to the event handlers)
176
176
EventHandler requerySuggestedEventHandler ;
177
-
177
+
178
178
void CommandManager_RequerySuggested ( object sender , EventArgs e )
179
179
{
180
180
UpdateMenu ( ) ;
@@ -270,9 +270,9 @@ public ICollection<IViewContent> PrimaryViewContents {
270
270
get {
271
271
SD . MainThread . VerifyAccess ( ) ;
272
272
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 ( ) ;
276
276
}
277
277
}
278
278
@@ -319,7 +319,7 @@ private set {
319
319
}
320
320
}
321
321
}
322
-
322
+
323
323
void WorkbenchWindowActiveViewContentChanged ( object sender , EventArgs e )
324
324
{
325
325
if ( workbenchLayout != null ) {
@@ -671,22 +671,29 @@ protected override void OnDrop(DragEventArgs e)
671
671
string [ ] files = ( string [ ] ) e . Data . GetData ( DataFormats . FileDrop ) ;
672
672
if ( files == null )
673
673
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 ) ;
684
677
}
685
678
} catch ( Exception ex ) {
686
679
MessageService . ShowException ( ex ) ;
687
680
}
688
681
}
689
682
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
+
690
697
void InitFocusTrackingEvents ( )
691
698
{
692
699
#if DEBUG
@@ -700,7 +707,7 @@ internal static void FocusDebug(string format, params object[] args)
700
707
{
701
708
#if DEBUG
702
709
if ( enableFocusDebugOutput )
703
- LoggingService . DebugFormatted ( format , args ) ;
710
+ LoggingService . DebugFormatted ( format , args ) ;
704
711
#endif
705
712
}
706
713
@@ -709,55 +716,55 @@ internal static void FocusDebug(string format, params object[] args)
709
716
710
717
void WpfWorkbench_PreviewGotKeyboardFocus ( object sender , KeyboardFocusChangedEventArgs e )
711
718
{
712
- FocusDebug ( "GotKeyboardFocus: oldFocus={0}, newFocus={1}" , e . OldFocus , e . NewFocus ) ;
719
+ FocusDebug ( "GotKeyboardFocus: oldFocus={0}, newFocus={1}" , e . OldFocus , e . NewFocus ) ;
713
720
}
714
721
715
722
void WpfWorkbench_PreviewLostKeyboardFocus ( object sender , KeyboardFocusChangedEventArgs e )
716
723
{
717
- FocusDebug ( "LostKeyboardFocus: oldFocus={0}, newFocus={1}" , e . OldFocus , e . NewFocus ) ;
724
+ FocusDebug ( "LostKeyboardFocus: oldFocus={0}, newFocus={1}" , e . OldFocus , e . NewFocus ) ;
718
725
}
719
726
720
727
protected override void OnPreviewKeyDown ( KeyEventArgs e )
721
728
{
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 ;
725
732
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
+ }
761
768
}
762
769
#endif
763
770
0 commit comments