Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit be80f41

Browse files
author
tbulle
committed
Merge remote-tracking branch 'origin/WpfDesignerPropGrid'
2 parents 19746ab + c22443b commit be80f41

5 files changed

Lines changed: 33 additions & 8 deletions

File tree

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,15 @@ public void HitTest(Point mousePosition, bool testAdorners, bool testDesignSurfa
8686
return;
8787
}
8888
// First try hit-testing on the adorner layer.
89-
89+
9090
bool continueHitTest = true;
91-
91+
92+
HitTestFilterCallback filterBehavior = CustomHitTestFilterBehavior ?? FilterHitTestInvisibleElements;
93+
CustomHitTestFilterBehavior = null;
9294
if (testAdorners) {
95+
9396
RunHitTest(
94-
_adornerLayer, mousePosition, FilterHitTestInvisibleElements,
97+
_adornerLayer, mousePosition, filterBehavior,
9598
delegate(HitTestResult result) {
9699
if (result != null && result.VisualHit != null && result.VisualHit is Visual) {
97100
DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit);
@@ -110,14 +113,14 @@ public void HitTest(Point mousePosition, bool testAdorners, bool testDesignSurfa
110113
}
111114
});
112115
}
113-
116+
114117
if (continueHitTest && testDesignSurface) {
115118
RunHitTest(
116-
this.Child, mousePosition, FilterHitTestInvisibleElements,
119+
this.Child, mousePosition, filterBehavior,
117120
delegate(HitTestResult result) {
118121
if (result != null && result.VisualHit != null && result.VisualHit is Visual) {
119122
DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit);
120-
123+
121124
ViewService viewService = _context.Services.View;
122125
DependencyObject obj = result.VisualHit;
123126
while (obj != null) {
@@ -165,6 +168,8 @@ public DesignPanel()
165168

166169
#region Properties
167170

171+
//Set custom HitTestFilterCallbak
172+
public HitTestFilterCallback CustomHitTestFilterBehavior { get; set; }
168173
/// <summary>
169174
/// Gets/Sets the design context.
170175
/// </summary>

src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public PropertyGrid()
4545
public CategoriesCollection Categories { get; private set; }
4646
public PropertyNodeCollection Events { get; private set; }
4747

48-
public EventHandler AggregatePropertiesUpdated;
48+
public EventHandler AggregatePropertiesUpdated { get; set; }
4949

5050
private PropertyGridGroupMode _groupMode;
5151

src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ protected virtual DesignItem CreateItem(DesignContext context)
142142
return item;
143143
}
144144

145+
public static bool AddItemWithCustomSizePosition(DesignItem container, Type createdItem, Size size, Point position)
146+
{
147+
CreateComponentTool cct = new CreateComponentTool(createdItem);
148+
return AddItemWithCustomSize(container, cct.CreateItem(container.Context), position, size);
149+
}
150+
145151
public static bool AddItemWithDefaultSize(DesignItem container, Type createdItem, Size size)
146152
{
147153
CreateComponentTool cct = new CreateComponentTool(createdItem);

src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ToolService.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using System;
55
using System.Windows.Input;
6-
6+
using System.Windows.Media;
77
namespace ICSharpCode.WpfDesign.Designer.Services
88
{
99
// See IToolService for description.
@@ -22,6 +22,11 @@ public DefaultToolService(DesignContext context)
2222
});
2323
}
2424

25+
public HitTestFilterCallback DesignPanelHitTestFilterCallback
26+
{
27+
set{ _designPanel.CustomHitTestFilterBehavior = value; }
28+
}
29+
2530
public void Dispose()
2631
{
2732
if (_designPanel != null) {

src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Windows;
77
using System.Windows.Controls;
88
using System.Windows.Input;
9+
using System.Windows.Media;
910

1011
using ICSharpCode.WpfDesign.Adorners;
1112

@@ -38,6 +39,10 @@ public interface ITool
3839
/// </summary>
3940
public interface IToolService
4041
{
42+
/// <summary>
43+
/// Set custom HitTestFilterCallback for DesignPanel
44+
/// </summary>
45+
HitTestFilterCallback DesignPanelHitTestFilterCallback{ set; }
4146
/// <summary>
4247
/// Gets the 'pointer' tool.
4348
/// The pointer tool is the default tool for selecting and moving elements.
@@ -62,6 +67,10 @@ public interface IToolService
6267
public interface IDesignPanel : IInputElement
6368
{
6469
/// <summary>
70+
/// Set a custom filter callback so that any element can be filtered out
71+
/// </summary>
72+
HitTestFilterCallback CustomHitTestFilterBehavior { get; set; }
73+
/// <summary>
6574
/// Gets the design context used by the DesignPanel.
6675
/// </summary>
6776
DesignContext Context { get; }

0 commit comments

Comments
 (0)