Browse Source

Removed new keyword, hiding not needed because its an interface implementation.

Fixed indentation.
pull/660/head
gumme 11 years ago
parent
commit
d87e0a64d9
  1. 158
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PartialPanelSelectionHandler.cs

158
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PartialPanelSelectionHandler.cs

@ -32,87 +32,91 @@ using ICSharpCode.WpfDesign.Extensions;
namespace ICSharpCode.WpfDesign.Designer.Extensions namespace ICSharpCode.WpfDesign.Designer.Extensions
{ {
public class PartialPanelSelectionHandler : BehaviorExtension, IHandlePointerToolMouseDown public class PartialPanelSelectionHandler : BehaviorExtension, IHandlePointerToolMouseDown
{ {
protected override void OnInitialized() protected override void OnInitialized()
{ {
base.OnInitialized(); base.OnInitialized();
this.ExtendedItem.AddBehavior(typeof(IHandlePointerToolMouseDown), this); this.ExtendedItem.AddBehavior(typeof(IHandlePointerToolMouseDown), this);
} }
#region IHandlePointerToolMouseDown
public new void HandleSelectionMouseDown(IDesignPanel designPanel, MouseButtonEventArgs e, DesignPanelHitTestResult result) public void HandleSelectionMouseDown(IDesignPanel designPanel, MouseButtonEventArgs e, DesignPanelHitTestResult result)
{ {
if (e.ChangedButton == MouseButton.Left && MouseGestureBase.IsOnlyButtonPressed(e, MouseButton.Left)) if (e.ChangedButton == MouseButton.Left && MouseGestureBase.IsOnlyButtonPressed(e, MouseButton.Left))
{ {
e.Handled = true; e.Handled = true;
new PartialRangeSelectionGesture(result.ModelHit).Start(designPanel, e); new PartialRangeSelectionGesture(result.ModelHit).Start(designPanel, e);
} }
} }
}
#endregion
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
internal class PartialRangeSelectionGesture : RangeSelectionGesture internal class PartialRangeSelectionGesture : RangeSelectionGesture
{ {
public PartialRangeSelectionGesture(DesignItem container) public PartialRangeSelectionGesture(DesignItem container)
: base(container) : base(container)
{ {
} }
protected override ICollection<DesignItem> GetChildDesignItemsInContainer(Geometry geometry) protected override ICollection<DesignItem> GetChildDesignItemsInContainer(Geometry geometry)
{ {
HashSet<DesignItem> resultItems = new HashSet<DesignItem>(); HashSet<DesignItem> resultItems = new HashSet<DesignItem>();
ViewService viewService = container.Services.View; ViewService viewService = container.Services.View;
HitTestFilterCallback filterCallback = delegate(DependencyObject potentialHitTestTarget) HitTestFilterCallback filterCallback = delegate(DependencyObject potentialHitTestTarget)
{ {
FrameworkElement element = potentialHitTestTarget as FrameworkElement; FrameworkElement element = potentialHitTestTarget as FrameworkElement;
if (element != null) if (element != null)
{ {
// ensure we are able to select elements with width/height=0 // ensure we are able to select elements with width/height=0
if (element.ActualWidth == 0 || element.ActualHeight == 0) if (element.ActualWidth == 0 || element.ActualHeight == 0)
{ {
DependencyObject tmp = element; DependencyObject tmp = element;
DesignItem model = null; DesignItem model = null;
while (tmp != null) while (tmp != null)
{ {
model = viewService.GetModel(tmp); model = viewService.GetModel(tmp);
if (model != null) break; if (model != null) break;
tmp = VisualTreeHelper.GetParent(tmp); tmp = VisualTreeHelper.GetParent(tmp);
} }
if (model != container) if (model != container)
{ {
resultItems.Add(model); resultItems.Add(model);
return HitTestFilterBehavior.ContinueSkipChildren; return HitTestFilterBehavior.ContinueSkipChildren;
} }
} }
} }
return HitTestFilterBehavior.Continue; return HitTestFilterBehavior.Continue;
}; };
HitTestResultCallback resultCallback = delegate(HitTestResult result) HitTestResultCallback resultCallback = delegate(HitTestResult result)
{ {
if (((GeometryHitTestResult)result).IntersectionDetail == IntersectionDetail.FullyInside || (Mouse.RightButton== MouseButtonState.Pressed && ((GeometryHitTestResult)result).IntersectionDetail == IntersectionDetail.Intersects)) if (((GeometryHitTestResult)result).IntersectionDetail == IntersectionDetail.FullyInside || (Mouse.RightButton== MouseButtonState.Pressed && ((GeometryHitTestResult)result).IntersectionDetail == IntersectionDetail.Intersects))
{ {
// find the model for the visual contained in the selection area // find the model for the visual contained in the selection area
DependencyObject tmp = result.VisualHit; DependencyObject tmp = result.VisualHit;
DesignItem model = null; DesignItem model = null;
while (tmp != null) while (tmp != null)
{ {
model = viewService.GetModel(tmp); model = viewService.GetModel(tmp);
if (model != null) break; if (model != null) break;
tmp = VisualTreeHelper.GetParent(tmp); tmp = VisualTreeHelper.GetParent(tmp);
} }
if (model != container) if (model != container)
{ {
resultItems.Add(model); resultItems.Add(model);
} }
} }
return HitTestResultBehavior.Continue; return HitTestResultBehavior.Continue;
}; };
VisualTreeHelper.HitTest(container.View, filterCallback, resultCallback, new GeometryHitTestParameters(geometry)); VisualTreeHelper.HitTest(container.View, filterCallback, resultCallback, new GeometryHitTestParameters(geometry));
return resultItems; return resultItems;
} }
} }
} }

Loading…
Cancel
Save