Browse Source

Select Items below the current by Pressing Alt Key when Clicking on Control!

pull/449/head
jkuehner 11 years ago
parent
commit
28af1f070c
  1. 68
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
  2. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/InPlaceEditorExtension.cs
  3. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs
  4. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MoveLogic.cs
  5. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/PointerTool.cs
  6. 41
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/HitTestType.cs
  7. 8
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs
  8. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

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

@ -35,6 +35,10 @@ namespace ICSharpCode.WpfDesign.Designer @@ -35,6 +35,10 @@ namespace ICSharpCode.WpfDesign.Designer
public sealed class DesignPanel : Decorator, IDesignPanel, INotifyPropertyChanged
{
#region Hit Testing
private List<DependencyObject> hitTestElements = new List<DependencyObject>();
private DependencyObject lastElement;
/// <summary>
/// this element is always hit (unless HitTestVisible is set to false)
/// </summary>
@ -54,7 +58,7 @@ namespace ICSharpCode.WpfDesign.Designer @@ -54,7 +58,7 @@ namespace ICSharpCode.WpfDesign.Designer
void RunHitTest(Visual reference, Point point, HitTestFilterCallback filterCallback, HitTestResultCallback resultCallback)
{
VisualTreeHelper.HitTest(reference, filterCallback, resultCallback,
new PointHitTestParameters(point));
new PointHitTestParameters(point));
}
HitTestFilterBehavior FilterHitTestInvisibleElements(DependencyObject potentialHitTestTarget)
@ -70,9 +74,10 @@ namespace ICSharpCode.WpfDesign.Designer @@ -70,9 +74,10 @@ namespace ICSharpCode.WpfDesign.Designer
if (designItem != null && designItem.IsDesignTimeLocked) {
return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
}
}
}
hitTestElements.Add(element);
return HitTestFilterBehavior.Continue;
}
@ -80,14 +85,17 @@ namespace ICSharpCode.WpfDesign.Designer @@ -80,14 +85,17 @@ namespace ICSharpCode.WpfDesign.Designer
/// <summary>
/// Performs a custom hit testing lookup for the specified mouse event args.
/// </summary>
public DesignPanelHitTestResult HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface)
public DesignPanelHitTestResult HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface, HitTestType hitTestType)
{
hitTestElements.Clear();
DesignPanelHitTestResult result = DesignPanelHitTestResult.NoHit;
HitTest(mousePosition, testAdorners, testDesignSurface,
delegate(DesignPanelHitTestResult r) {
result = r;
return false;
});
delegate(DesignPanelHitTestResult r) {
result = r;
return false;
}, hitTestType);
return result;
}
@ -95,7 +103,7 @@ namespace ICSharpCode.WpfDesign.Designer @@ -95,7 +103,7 @@ namespace ICSharpCode.WpfDesign.Designer
/// Performs a hit test on the design surface, raising <paramref name="callback"/> for each match.
/// Hit testing continues while the callback returns true.
/// </summary>
public void HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface, Predicate<DesignPanelHitTestResult> callback)
public void HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface, Predicate<DesignPanelHitTestResult> callback, HitTestType hitTestType)
{
if (mousePosition.X < 0 || mousePosition.Y < 0 || mousePosition.X > this.RenderSize.Width || mousePosition.Y > this.RenderSize.Height) {
return;
@ -104,6 +112,8 @@ namespace ICSharpCode.WpfDesign.Designer @@ -104,6 +112,8 @@ namespace ICSharpCode.WpfDesign.Designer
bool continueHitTest = true;
hitTestElements.Clear();
if (testAdorners) {
RunHitTest(
_adornerLayer, mousePosition, FilterHitTestInvisibleElements,
@ -135,6 +145,19 @@ namespace ICSharpCode.WpfDesign.Designer @@ -135,6 +145,19 @@ namespace ICSharpCode.WpfDesign.Designer
ViewService viewService = _context.Services.View;
DependencyObject obj = result.VisualHit;
if (hitTestType == HitTestType.ElementSelection)
{
if (Keyboard.IsKeyDown(Key.LeftAlt))
if (lastElement != null && lastElement != _context.RootItem.Component &&
hitTestElements.Contains(lastElement))
{
var idx = hitTestElements.IndexOf(lastElement) - 1;
if (idx >= 0)
obj = hitTestElements[idx];
}
}
while (obj != null) {
if ((customResult.ModelHit = viewService.GetModel(obj)) != null)
break;
@ -143,6 +166,13 @@ namespace ICSharpCode.WpfDesign.Designer @@ -143,6 +166,13 @@ namespace ICSharpCode.WpfDesign.Designer
if (customResult.ModelHit == null) {
customResult.ModelHit = _context.RootItem;
}
if (hitTestType == HitTestType.ElementSelection)
{
lastElement = obj;
}
continueHitTest = callback(customResult);
return continueHitTest ? HitTestResultBehavior.Continue : HitTestResultBehavior.Stop;
} else {
@ -223,7 +253,7 @@ namespace ICSharpCode.WpfDesign.Designer @@ -223,7 +253,7 @@ namespace ICSharpCode.WpfDesign.Designer
}
}
}
/// <summary>
/// Enables / Disables the Raster Placement
/// </summary>
@ -341,14 +371,14 @@ namespace ICSharpCode.WpfDesign.Designer @@ -341,14 +371,14 @@ namespace ICSharpCode.WpfDesign.Designer
if (e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up || e.Key == Key.Down)
{
e.Handled = true;
if (placementOp == null) {
dx = 0;
dy = 0;
placementOp = PlacementOperation.Start(Context.Services.Selection.SelectedItems, PlacementType.Move);
}
dx += (e.Key == Key.Left) ? Keyboard.IsKeyDown(Key.LeftShift) ? -10 : -1 : 0;
dy += (e.Key == Key.Up) ? Keyboard.IsKeyDown(Key.LeftShift) ? -10 : -1 : 0;
dx += (e.Key == Key.Right) ? Keyboard.IsKeyDown(Key.LeftShift) ? 10 : 1 : 0;
@ -358,18 +388,18 @@ namespace ICSharpCode.WpfDesign.Designer @@ -358,18 +388,18 @@ namespace ICSharpCode.WpfDesign.Designer
if (!Keyboard.IsKeyDown(Key.LeftCtrl))
{
info.Bounds = new Rect(info.OriginalBounds.Left + dx,
info.OriginalBounds.Top + dy,
info.OriginalBounds.Width,
info.OriginalBounds.Height);
info.OriginalBounds.Top + dy,
info.OriginalBounds.Width,
info.OriginalBounds.Height);
}
else
{
info.Bounds = new Rect(info.OriginalBounds.Left,
info.OriginalBounds.Top,
info.OriginalBounds.Width + dx,
info.OriginalBounds.Height + dy);
info.OriginalBounds.Top,
info.OriginalBounds.Width + dx,
info.OriginalBounds.Height + dy);
}
placementOp.CurrentContainerBehavior.SetPosition(info);
}
}

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/InPlaceEditorExtension.cs

@ -159,7 +159,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -159,7 +159,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
void MouseDown(object sender,MouseEventArgs e)
{
result = designPanel.HitTest(e.GetPosition(designPanel), false, true);
result = designPanel.HitTest(e.GetPosition(designPanel), false, true, HitTestType.Default);
if(result.ModelHit==ExtendedItem && result.VisualHit is TextBlock) {
Start = Mouse.GetPosition(null);
Current = Start;
@ -171,7 +171,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -171,7 +171,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
void MouseMove(object sender, MouseEventArgs e)
{
Current += e.GetPosition(null) - Start;
result = designPanel.HitTest(e.GetPosition(designPanel), false, true);
result = designPanel.HitTest(e.GetPosition(designPanel), false, true, HitTestType.Default);
if (result.ModelHit == ExtendedItem && result.VisualHit is TextBlock) {
if (numClicks > 0) {
if (isMouseDown &&
@ -190,7 +190,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -190,7 +190,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
void MouseUp(object sender,MouseEventArgs e)
{
result = designPanel.HitTest(e.GetPosition(designPanel), false, true);
result = designPanel.HitTest(e.GetPosition(designPanel), false, true, HitTestType.Default);
if (result.ModelHit == ExtendedItem && result.VisualHit is TextBlock && numClicks>0){
if (!isGettingDragged) {
PlaceEditor(result.VisualHit, e);

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

@ -86,7 +86,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -86,7 +86,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
if (e.Data.GetData(typeof(CreateComponentTool)) != this) return;
// TODO: dropLayer in designPanel
designPanel.IsAdornerLayerHitTestVisible = false;
DesignPanelHitTestResult result = designPanel.HitTest(p, false, true);
DesignPanelHitTestResult result = designPanel.HitTest(p, false, true, HitTestType.Default);
if (result.ModelHit != null) {
designPanel.Focus();
@ -180,7 +180,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -180,7 +180,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
if (e.ChangedButton == MouseButton.Left && MouseGestureBase.IsOnlyButtonPressed(e, MouseButton.Left)) {
e.Handled = true;
IDesignPanel designPanel = (IDesignPanel)sender;
DesignPanelHitTestResult result = designPanel.HitTest(e.GetPosition(designPanel), false, true);
DesignPanelHitTestResult result = designPanel.HitTest(e.GetPosition(designPanel), false, true, HitTestType.Default);
if (result.ModelHit != null) {
IPlacementBehavior behavior = result.ModelHit.GetBehavior<IPlacementBehavior>();
if (behavior != null) {

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MoveLogic.cs

@ -124,7 +124,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -124,7 +124,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
return true; // continue hit testing
result = r;
return false; // finish hit testing
});
}, HitTestType.Default);
return result;
}

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/PointerTool.cs

@ -42,7 +42,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -42,7 +42,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
void OnMouseDown(object sender, MouseButtonEventArgs e)
{
IDesignPanel designPanel = (IDesignPanel)sender;
DesignPanelHitTestResult result = designPanel.HitTest(e.GetPosition(designPanel), false, true);
DesignPanelHitTestResult result = designPanel.HitTest(e.GetPosition(designPanel), false, true, HitTestType.ElementSelection);
if (result.ModelHit != null) {
IHandlePointerToolMouseDown b = result.ModelHit.GetBehavior<IHandlePointerToolMouseDown>();
if (b != null) {

41
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/HitTestType.cs

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ICSharpCode.WpfDesign
{
/// <summary>
///
/// </summary>
public enum HitTestType
{
/// <summary>
///
/// </summary>
Default,
/// <summary>
///
/// </summary>
ElementSelection,
}
}

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

@ -99,14 +99,14 @@ namespace ICSharpCode.WpfDesign @@ -99,14 +99,14 @@ namespace ICSharpCode.WpfDesign
/// <summary>
/// Performs a hit test on the design surface.
/// </summary>
DesignPanelHitTestResult HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface);
DesignPanelHitTestResult HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface, HitTestType hitTestType);
/// <summary>
/// Performs a hit test on the design surface, raising <paramref name="callback"/> for each match.
/// Hit testing continues while the callback returns true.
/// </summary>
void HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface, Predicate<DesignPanelHitTestResult> callback);
void HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface, Predicate<DesignPanelHitTestResult> callback, HitTestType hitTestType);
// The following members were missing in <see cref="IInputElement"/>, but
// are supported on the DesignPanel:

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

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

Loading…
Cancel
Save