Browse Source

Press "Alt" key to Enter a Container, do not Enter automatically.

Show a Info Text in the Container so that the User knows this!
=> same Behavior like in VS, because when you Enter automaticaly you can not move Contrls on Top of a Container with the Mouse
pull/52/head
jkuehner 12 years ago
parent
commit
95d7bbf84b
  1. 101
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/InfoTextEnterArea.cs
  2. 25
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs
  3. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs
  4. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/RootItemBehavior.cs
  5. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MoveLogic.cs
  6. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
  7. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs
  8. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs

101
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/InfoTextEnterArea.cs

@ -0,0 +1,101 @@ @@ -0,0 +1,101 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Threading;
using System.Windows.Media.Animation;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Services;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Gray out everything except a specific area.
/// </summary>
sealed class InfoTextEnterArea : FrameworkElement
{
Geometry designSurfaceRectangle;
Geometry activeAreaGeometry;
Geometry combinedGeometry;
AdornerPanel adornerPanel;
IDesignPanel designPanel;
const double MaxOpacity = 0.3;
public InfoTextEnterArea()
{
this.IsHitTestVisible = false;
}
public Geometry ActiveAreaGeometry {
get { return activeAreaGeometry; }
set {
activeAreaGeometry = value;
combinedGeometry = activeAreaGeometry;
}
}
Rect currentAnimateActiveAreaRectToTarget;
internal void AnimateActiveAreaRectTo(Rect newRect)
{
if (newRect.Equals(currentAnimateActiveAreaRectToTarget))
return;
activeAreaGeometry.BeginAnimation(
RectangleGeometry.RectProperty,
new RectAnimation(newRect, new Duration(new TimeSpan(0,0,0,0,100))),
HandoffBehavior.SnapshotAndReplace);
currentAnimateActiveAreaRectToTarget = newRect;
}
internal static void Start(ref InfoTextEnterArea grayOut, ServiceContainer services, UIElement activeContainer, string text)
{
Debug.Assert(activeContainer != null);
Start(ref grayOut, services, activeContainer, new Rect(activeContainer.RenderSize), text);
}
internal static void Start(ref InfoTextEnterArea grayOut, ServiceContainer services, UIElement activeContainer, Rect activeRectInActiveContainer, string text)
{
Debug.Assert(services != null);
Debug.Assert(activeContainer != null);
DesignPanel designPanel = services.GetService<IDesignPanel>() as DesignPanel;
OptionService optionService = services.GetService<OptionService>();
if (designPanel != null && grayOut == null && optionService != null && optionService.GrayOutDesignSurfaceExceptParentContainerWhenDragging) {
grayOut = new InfoTextEnterArea();
grayOut.designSurfaceRectangle = new RectangleGeometry(
new Rect(0, 0, ((Border)designPanel.Child).Child.RenderSize.Width, ((Border)designPanel.Child).Child.RenderSize.Height));
grayOut.designPanel = designPanel;
grayOut.adornerPanel = new AdornerPanel();
grayOut.adornerPanel.Order = AdornerOrder.Background;
grayOut.adornerPanel.SetAdornedElement(designPanel.Context.RootItem.View, null);
grayOut.ActiveAreaGeometry = new RectangleGeometry(activeRectInActiveContainer, 0, 0, (Transform)activeContainer.TransformToVisual(grayOut.adornerPanel.AdornedElement));
var tb = new TextBlock(){Text = text};
tb.FontSize = 10;
tb.ClipToBounds = true;
tb.Width = ((FrameworkElement) activeContainer).ActualWidth;
tb.Height = ((FrameworkElement) activeContainer).ActualHeight;
tb.VerticalAlignment = VerticalAlignment.Top;
tb.HorizontalAlignment = HorizontalAlignment.Left;
tb.RenderTransform = (Transform)activeContainer.TransformToVisual(grayOut.adornerPanel.AdornedElement);
grayOut.adornerPanel.Children.Add(tb);
designPanel.Adorners.Add(grayOut.adornerPanel);
}
}
static readonly TimeSpan animationTime = new TimeSpan(2000000);
internal static void Stop(ref InfoTextEnterArea grayOut)
{
if (grayOut != null) {
IDesignPanel designPanel = grayOut.designPanel;
AdornerPanel adornerPanelToRemove = grayOut.adornerPanel;
designPanel.Adorners.Remove(adornerPanelToRemove);
grayOut = null;
}
}
}
}

25
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs

@ -5,6 +5,7 @@ using System; @@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using ICSharpCode.WpfDesign.Extensions;
using System.Windows.Controls;
using System.Windows;
@ -32,7 +33,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -32,7 +33,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
_contentControlsNotAllowedToAdd.Add(typeof (HeaderedContentControl));
_contentControlsNotAllowedToAdd.Add(typeof (Label));
_contentControlsNotAllowedToAdd.Add(typeof (ListBoxItem));
_contentControlsNotAllowedToAdd.Add(typeof (ButtonBase));
//_contentControlsNotAllowedToAdd.Add(typeof (ButtonBase));
_contentControlsNotAllowedToAdd.Add(typeof (StatusBarItem));
_contentControlsNotAllowedToAdd.Add(typeof (ToolTip));
}
@ -63,6 +64,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -63,6 +64,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
public virtual void EndPlacement(PlacementOperation operation)
{
InfoTextEnterArea.Stop(ref infoTextEnterArea);
}
public virtual Rect GetPosition(PlacementOperation operation, DesignItem item)
@ -98,8 +100,27 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -98,8 +100,27 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
}
}
public virtual bool CanEnterContainer(PlacementOperation operation)
private static InfoTextEnterArea infoTextEnterArea;
public virtual bool CanEnterContainer(PlacementOperation operation, bool shouldAlwaysEnter)
{
var canEnter = internalCanEnterContainer(operation);
if (canEnter && !shouldAlwaysEnter && !Keyboard.IsKeyDown(Key.LeftAlt) && !Keyboard.IsKeyDown(Key.RightAlt))
{
var b = new Rect(0, 0, ((FrameworkElement)this.ExtendedItem.View).ActualWidth, ((FrameworkElement)this.ExtendedItem.View).ActualHeight);
InfoTextEnterArea.Start(ref infoTextEnterArea, this.Services, this.ExtendedItem.View, b, "Press \"Alt\" to Enter Container");
return false;
}
return canEnter;
}
private bool internalCanEnterContainer(PlacementOperation operation)
{
InfoTextEnterArea.Stop(ref infoTextEnterArea);
if (ExtendedItem.Component is Expander)
{
if (!((Expander) ExtendedItem.Component).IsExpanded)

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs

@ -178,7 +178,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView @@ -178,7 +178,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
return false;
var operation = PlacementOperation.Start(nodes.Select(node => node.DesignItem).ToArray(), DummyPlacementType);
if (operation != null) {
bool canEnter = placementBehavior.CanEnterContainer(operation);
bool canEnter = placementBehavior.CanEnterContainer(operation, true);
operation.Abort();
return canEnter;
}

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/RootItemBehavior.cs

@ -73,7 +73,7 @@ namespace ICSharpCode.WpfDesign.Designer @@ -73,7 +73,7 @@ namespace ICSharpCode.WpfDesign.Designer
throw new NotImplementedException();
}
public bool CanEnterContainer(PlacementOperation operation)
public bool CanEnterContainer(PlacementOperation operation, bool shouldAlwaysEnter)
{
return false;
}

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

@ -128,7 +128,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -128,7 +128,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
}
IPlacementBehavior b = result.ModelHit.GetBehavior<IPlacementBehavior>();
if (b != null && b.CanEnterContainer(operation)) {
if (b != null && b.CanEnterContainer(operation, false)) {
operation.ChangeContainer(result.ModelHit);
return true;
}

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

@ -87,6 +87,7 @@ @@ -87,6 +87,7 @@
<DependentUpon>EnumBar.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\EnumButton.cs" />
<Compile Include="Controls\InfoTextEnterArea.cs" />
<Compile Include="Controls\GrayOutDesignerExceptActiveArea.cs">
<SubType>Code</SubType>
</Compile>

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs

@ -57,7 +57,7 @@ namespace ICSharpCode.WpfDesign @@ -57,7 +57,7 @@ namespace ICSharpCode.WpfDesign
/// <summary>
/// Gets if entering this container is allowed for the specified operation.
/// </summary>
bool CanEnterContainer(PlacementOperation operation);
bool CanEnterContainer(PlacementOperation operation, bool shouldAlwaysEnter);
/// <summary>
/// Let the placed children enter this container.

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs

@ -246,7 +246,7 @@ namespace ICSharpCode.WpfDesign @@ -246,7 +246,7 @@ namespace ICSharpCode.WpfDesign
}
op.currentContainer = container;
op.currentContainerBehavior = container.GetBehavior<IPlacementBehavior>();
if (op.currentContainerBehavior == null || !op.currentContainerBehavior.CanEnterContainer(op)) {
if (op.currentContainerBehavior == null || !op.currentContainerBehavior.CanEnterContainer(op, true)) {
op.changeGroup.Abort();
return null;
}

Loading…
Cancel
Save