|
|
|
@ -107,7 +107,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
@@ -107,7 +107,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
|
|
|
|
|
// Set WindowState after PresentationSource is initialized, because now bounds and location are properly set.
|
|
|
|
|
this.WindowState = lastNonMinimizedWindowState; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SetBounds(Rect bounds) |
|
|
|
|
{ |
|
|
|
|
this.Left = bounds.Left; |
|
|
|
@ -174,7 +174,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
@@ -174,7 +174,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
|
|
|
|
|
// keep a reference to the event handler to prevent it from being garbage collected
|
|
|
|
|
// (CommandManager.RequerySuggested only keeps weak references to the event handlers)
|
|
|
|
|
EventHandler requerySuggestedEventHandler; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CommandManager_RequerySuggested(object sender, EventArgs e) |
|
|
|
|
{ |
|
|
|
|
UpdateMenu(); |
|
|
|
@ -270,9 +270,9 @@ namespace ICSharpCode.SharpDevelop.Workbench
@@ -270,9 +270,9 @@ namespace ICSharpCode.SharpDevelop.Workbench
|
|
|
|
|
get { |
|
|
|
|
SD.MainThread.VerifyAccess(); |
|
|
|
|
return (from window in WorkbenchWindowCollection |
|
|
|
|
where window.ViewContents.Count > 0 |
|
|
|
|
select window.ViewContents[0] |
|
|
|
|
).ToList().AsReadOnly(); |
|
|
|
|
where window.ViewContents.Count > 0 |
|
|
|
|
select window.ViewContents[0] |
|
|
|
|
).ToList().AsReadOnly(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -319,7 +319,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
@@ -319,7 +319,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void WorkbenchWindowActiveViewContentChanged(object sender, EventArgs e) |
|
|
|
|
{ |
|
|
|
|
if (workbenchLayout != null) { |
|
|
|
@ -671,22 +671,29 @@ namespace ICSharpCode.SharpDevelop.Workbench
@@ -671,22 +671,29 @@ namespace ICSharpCode.SharpDevelop.Workbench
|
|
|
|
|
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); |
|
|
|
|
if (files == null) |
|
|
|
|
return; |
|
|
|
|
foreach (string file in files) { |
|
|
|
|
if (File.Exists(file)) { |
|
|
|
|
var fileName = FileName.Create(file); |
|
|
|
|
if (SD.ProjectService.IsSolutionOrProjectFile(fileName)) { |
|
|
|
|
SD.ProjectService.OpenSolutionOrProject(fileName); |
|
|
|
|
} else { |
|
|
|
|
SD.FileService.OpenFile(fileName); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// Handle opening the files outside the drop event, so that the drag source doesn't think
|
|
|
|
|
// the operation is still in progress while we're showing a "file cannot be opened" error message.
|
|
|
|
|
Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action<string[]>(HandleDrop), files); |
|
|
|
|
} |
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
MessageService.ShowException(ex); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void HandleDrop(string[] files) |
|
|
|
|
{ |
|
|
|
|
foreach (string file in files) { |
|
|
|
|
if (File.Exists(file)) { |
|
|
|
|
var fileName = FileName.Create(file); |
|
|
|
|
if (SD.ProjectService.IsSolutionOrProjectFile(fileName)) { |
|
|
|
|
SD.ProjectService.OpenSolutionOrProject(fileName); |
|
|
|
|
} else { |
|
|
|
|
SD.FileService.OpenFile(fileName); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void InitFocusTrackingEvents() |
|
|
|
|
{ |
|
|
|
|
#if DEBUG
|
|
|
|
@ -700,7 +707,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
@@ -700,7 +707,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
|
|
|
|
|
{ |
|
|
|
|
#if DEBUG
|
|
|
|
|
if (enableFocusDebugOutput) |
|
|
|
|
LoggingService.DebugFormatted(format, args); |
|
|
|
|
LoggingService.DebugFormatted(format, args); |
|
|
|
|
#endif
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -709,55 +716,55 @@ namespace ICSharpCode.SharpDevelop.Workbench
@@ -709,55 +716,55 @@ namespace ICSharpCode.SharpDevelop.Workbench
|
|
|
|
|
|
|
|
|
|
void WpfWorkbench_PreviewGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) |
|
|
|
|
{ |
|
|
|
|
FocusDebug("GotKeyboardFocus: oldFocus={0}, newFocus={1}", e.OldFocus, e.NewFocus); |
|
|
|
|
FocusDebug("GotKeyboardFocus: oldFocus={0}, newFocus={1}", e.OldFocus, e.NewFocus); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WpfWorkbench_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) |
|
|
|
|
{ |
|
|
|
|
FocusDebug("LostKeyboardFocus: oldFocus={0}, newFocus={1}", e.OldFocus, e.NewFocus); |
|
|
|
|
FocusDebug("LostKeyboardFocus: oldFocus={0}, newFocus={1}", e.OldFocus, e.NewFocus); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected override void OnPreviewKeyDown(KeyEventArgs e) |
|
|
|
|
{ |
|
|
|
|
base.OnPreviewKeyDown(e); |
|
|
|
|
if (!e.Handled && e.Key == Key.D && e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt)) { |
|
|
|
|
enableFocusDebugOutput = !enableFocusDebugOutput; |
|
|
|
|
base.OnPreviewKeyDown(e); |
|
|
|
|
if (!e.Handled && e.Key == Key.D && e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt)) { |
|
|
|
|
enableFocusDebugOutput = !enableFocusDebugOutput; |
|
|
|
|
|
|
|
|
|
StringWriter output = new StringWriter(); |
|
|
|
|
output.WriteLine("Keyboard.FocusedElement = " + GetElementName(Keyboard.FocusedElement)); |
|
|
|
|
output.WriteLine("ActiveContent = " + GetElementName(this.ActiveContent)); |
|
|
|
|
output.WriteLine("ActiveViewContent = " + GetElementName(this.ActiveViewContent)); |
|
|
|
|
output.WriteLine("ActiveWorkbenchWindow = " + GetElementName(this.ActiveWorkbenchWindow)); |
|
|
|
|
((AvalonDockLayout)workbenchLayout).WriteState(output); |
|
|
|
|
LoggingService.Debug(output.ToString()); |
|
|
|
|
e.Handled = true; |
|
|
|
|
} |
|
|
|
|
if (!e.Handled && e.Key == Key.F && e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt)) { |
|
|
|
|
if (TextOptions.GetTextFormattingMode(this) == TextFormattingMode.Display) |
|
|
|
|
TextOptions.SetTextFormattingMode(this, TextFormattingMode.Ideal); |
|
|
|
|
else |
|
|
|
|
TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display); |
|
|
|
|
SD.StatusBar.SetMessage("TextFormattingMode=" + TextOptions.GetTextFormattingMode(this)); |
|
|
|
|
} |
|
|
|
|
if (!e.Handled && e.Key == Key.R && e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt)) { |
|
|
|
|
switch (TextOptions.GetTextRenderingMode(this)) { |
|
|
|
|
case TextRenderingMode.Auto: |
|
|
|
|
case TextRenderingMode.ClearType: |
|
|
|
|
TextOptions.SetTextRenderingMode(this, TextRenderingMode.Grayscale); |
|
|
|
|
break; |
|
|
|
|
case TextRenderingMode.Grayscale: |
|
|
|
|
TextOptions.SetTextRenderingMode(this, TextRenderingMode.Aliased); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
TextOptions.SetTextRenderingMode(this, TextRenderingMode.ClearType); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
SD.StatusBar.SetMessage("TextRenderingMode=" + TextOptions.GetTextRenderingMode(this)); |
|
|
|
|
} |
|
|
|
|
if (!e.Handled && e.Key == Key.G && e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt)) { |
|
|
|
|
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); |
|
|
|
|
SD.StatusBar.SetMessage("Total memory = " + (GC.GetTotalMemory(true) / 1024 / 1024f).ToString("f1") + " MB"); |
|
|
|
|
} |
|
|
|
|
StringWriter output = new StringWriter(); |
|
|
|
|
output.WriteLine("Keyboard.FocusedElement = " + GetElementName(Keyboard.FocusedElement)); |
|
|
|
|
output.WriteLine("ActiveContent = " + GetElementName(this.ActiveContent)); |
|
|
|
|
output.WriteLine("ActiveViewContent = " + GetElementName(this.ActiveViewContent)); |
|
|
|
|
output.WriteLine("ActiveWorkbenchWindow = " + GetElementName(this.ActiveWorkbenchWindow)); |
|
|
|
|
((AvalonDockLayout)workbenchLayout).WriteState(output); |
|
|
|
|
LoggingService.Debug(output.ToString()); |
|
|
|
|
e.Handled = true; |
|
|
|
|
} |
|
|
|
|
if (!e.Handled && e.Key == Key.F && e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt)) { |
|
|
|
|
if (TextOptions.GetTextFormattingMode(this) == TextFormattingMode.Display) |
|
|
|
|
TextOptions.SetTextFormattingMode(this, TextFormattingMode.Ideal); |
|
|
|
|
else |
|
|
|
|
TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display); |
|
|
|
|
SD.StatusBar.SetMessage("TextFormattingMode=" + TextOptions.GetTextFormattingMode(this)); |
|
|
|
|
} |
|
|
|
|
if (!e.Handled && e.Key == Key.R && e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt)) { |
|
|
|
|
switch (TextOptions.GetTextRenderingMode(this)) { |
|
|
|
|
case TextRenderingMode.Auto: |
|
|
|
|
case TextRenderingMode.ClearType: |
|
|
|
|
TextOptions.SetTextRenderingMode(this, TextRenderingMode.Grayscale); |
|
|
|
|
break; |
|
|
|
|
case TextRenderingMode.Grayscale: |
|
|
|
|
TextOptions.SetTextRenderingMode(this, TextRenderingMode.Aliased); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
TextOptions.SetTextRenderingMode(this, TextRenderingMode.ClearType); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
SD.StatusBar.SetMessage("TextRenderingMode=" + TextOptions.GetTextRenderingMode(this)); |
|
|
|
|
} |
|
|
|
|
if (!e.Handled && e.Key == Key.G && e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt)) { |
|
|
|
|
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); |
|
|
|
|
SD.StatusBar.SetMessage("Total memory = " + (GC.GetTotalMemory(true) / 1024 / 1024f).ToString("f1") + " MB"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|