Browse Source

Handling KeyEvents for extension in case the extension needs it and a normal key event handling would interfer with the DesignPanel.cs keyhandling due to event bubbling prevention or such.

pull/590/head
tbulle 12 years ago
parent
commit
9f7c3209df
  1. 25
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
  2. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

25
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs

@ -29,6 +29,8 @@ using System.Windows.Threading;
using ICSharpCode.WpfDesign.Adorners; using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls; using ICSharpCode.WpfDesign.Designer.Controls;
using ICSharpCode.WpfDesign.Designer.Xaml; using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.Extensions;
using System.Linq;
namespace ICSharpCode.WpfDesign.Designer namespace ICSharpCode.WpfDesign.Designer
{ {
@ -364,10 +366,33 @@ namespace ICSharpCode.WpfDesign.Designer
placementOp = null; placementOp = null;
} }
} }
//pass the key event to the underlying objects if they have implemented IKeyUp interface
//OBS!!!! this call needs to be here, after the placementOp.Commit().
//In case the underlying object has a operation of its own this operation needs to be commited first
foreach (DesignItem di in Context.Services.Selection.SelectedItems.Reverse()) {
foreach (Extension ext in di.Extensions) {
var keyUp = ext as IKeyUp;
if (keyUp != null) {
keyUp.KeyUpAction(sender, e);
}
}
}
} }
void DesignPanel_KeyDown(object sender, KeyEventArgs e) void DesignPanel_KeyDown(object sender, KeyEventArgs e)
{ {
//pass the key event down to the underlying objects if they have implemented IKeyUp interface
//OBS!!!! this call needs to be here, before the PlacementOperation.Start.
//In case the underlying object has a operation of its own this operation needs to be set first
foreach (DesignItem di in Context.Services.Selection.SelectedItems) {
foreach (Extension ext in di.Extensions) {
var keyDown = ext as IKeyDown;
if (keyDown != null) {
keyDown.KeyDownAction(sender, e);
}
}
}
if (e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up || e.Key == Key.Down) if (e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up || e.Key == Key.Down)
{ {
e.Handled = true; e.Handled = true;

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

@ -74,6 +74,7 @@
<Compile Include="Adorners\AdornerProviderClasses.cs" /> <Compile Include="Adorners\AdornerProviderClasses.cs" />
<Compile Include="Adorners\RelativePlacement.cs" /> <Compile Include="Adorners\RelativePlacement.cs" />
<Compile Include="ExtensionMethods.cs" /> <Compile Include="ExtensionMethods.cs" />
<Compile Include="Extensions\ExtensionInterfaces.cs" />
<Compile Include="HitTestType.cs" /> <Compile Include="HitTestType.cs" />
<Compile Include="Metadata.cs" /> <Compile Include="Metadata.cs" />
<Compile Include="PlacementInformation.cs" /> <Compile Include="PlacementInformation.cs" />

Loading…
Cancel
Save