diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
index f8204dfc66..9ddfc7eefb 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
@@ -34,6 +34,8 @@ using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls;
using ICSharpCode.WpfDesign.Designer.UIExtensions;
using ICSharpCode.WpfDesign.Designer.Xaml;
+using ICSharpCode.WpfDesign.Extensions;
+using System.Linq;
namespace ICSharpCode.WpfDesign.Designer
{
@@ -372,6 +374,21 @@ namespace ICSharpCode.WpfDesign.Designer
int dx = 0;
int dy = 0;
+ ///
+ /// If interface implementing class sets this to false defaultkeyaction will be
+ ///
+ ///
+ ///
+ bool InvokeDefaultKeyDownAction(Extension e)
+ {
+ var keyDown = e as IKeyDown;
+ if (keyDown != null) {
+ return keyDown.InvokeDefaultAction;
+ }
+
+ return true;
+ }
+
private void DesignPanel_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up || e.Key == Key.Down)
@@ -383,10 +400,33 @@ namespace ICSharpCode.WpfDesign.Designer
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)
{
+ //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) {
e.Handled = true;
@@ -398,9 +438,16 @@ namespace ICSharpCode.WpfDesign.Designer
}
if (placementOp == null) {
+
+ //check if any objects don't want the default action to be invoked
+ List placedItems = Context.Services.Selection.SelectedItems.Where(x => x.Extensions.All(InvokeDefaultKeyDownAction)).ToList();
+
+ //if no remaining objects, break
+ if (placedItems.Count < 1) return;
+
dx = 0;
dy = 0;
- placementOp = PlacementOperation.Start(Context.Services.Selection.SelectedItems, placementType);
+ placementOp = PlacementOperation.Start(placedItems, placementType);
}
switch (e.Key) {
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionInterfaces.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionInterfaces.cs
new file mode 100644
index 0000000000..39eaa785ea
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionInterfaces.cs
@@ -0,0 +1,46 @@
+/*
+ * Created by SharpDevelop.
+ * User: trubra
+ * Date: 2014-11-06
+ * Time: 11:45
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+using System;
+using System.Windows.Input;
+
+namespace ICSharpCode.WpfDesign.Extensions
+{
+ ///
+ /// interface that can be implemented if a control is to be alerted of KeyDown Event on DesignPanel
+ ///
+ public interface IKeyDown
+ {
+ ///
+ /// Action to be performed on keydown on specific control
+ ///
+ ///
+ ///
+ void KeyDownAction(object sender, KeyEventArgs e);
+
+ ///
+ /// if that control wants the default DesignPanel action to be suppressed, let this return false
+ ///
+ bool InvokeDefaultAction { get; }
+ }
+
+ ///
+ /// interface that can be implemented if a control is to be alerted of KeyUp Event on DesignPanel
+ ///
+ public interface IKeyUp
+ {
+ ///
+ /// Action to be performed on keyup on specific control
+ ///
+ ///
+ ///
+ void KeyUpAction(object sender, KeyEventArgs e);
+ }
+
+
+}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj
index 2111deb033..7bc841aa26 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj
@@ -75,6 +75,7 @@
+