Browse Source

DragMoveMouseGesture bugfix: use coordinates relative to design panel because MoveLogic expects those.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4774 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
fb3be54913
  1. 20
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs
  2. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs
  3. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs
  4. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
  5. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignContext.cs
  6. 20
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ServiceContainer.cs
  7. 62
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ServiceRequiredException.cs
  8. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

20
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs

@ -164,49 +164,45 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -164,49 +164,45 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
set { SetValue(Window.WindowStyleProperty, value); }
}
#pragma warning disable 0067
// disable "event is never used" warning
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
public event EventHandler Activated;
public event EventHandler Activated { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
public event EventHandler Closed;
public event EventHandler Closed { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
public event EventHandler Closing;
public event EventHandler Closing { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
public event EventHandler ContentRendered;
public event EventHandler ContentRendered { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
public event EventHandler Deactivated;
public event EventHandler Deactivated { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
public event EventHandler LocationChanged;
public event EventHandler LocationChanged { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
public event EventHandler SourceInitialized;
public event EventHandler SourceInitialized { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
public event EventHandler StateChanged;
#pragma warning restore
public event EventHandler StateChanged { add {} remove {} }
}
/// <summary>

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

@ -39,6 +39,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -39,6 +39,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
public virtual Rect GetPosition(PlacementOperation operation, DesignItem item)
{
if (item.View == null)
return Rect.Empty;
var p = item.View.TranslatePoint(new Point(), operation.CurrentContainer.View);
return new Rect(p, item.View.RenderSize);
}

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs

@ -27,11 +27,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -27,11 +27,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
Debug.Assert(clickedOn != null);
this.isDoubleClick = isDoubleClick;
if (clickedOn.Parent != null)
this.positionRelativeTo = clickedOn.Parent.View;
else
this.positionRelativeTo = clickedOn.View;
this.positionRelativeTo = clickedOn.Services.DesignPanel;
moveLogic = new MoveLogic(clickedOn);
}

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

@ -169,7 +169,6 @@ @@ -169,7 +169,6 @@
<Compile Include="PropertyGrid\PropertyGridView.xaml.cs">
<DependentUpon>PropertyGridView.xaml</DependentUpon>
</Compile>
<Compile Include="ServiceRequiredException.cs" />
<Compile Include="Services\ChooseClass.cs" />
<Compile Include="Services\ChooseClassDialog.xaml.cs">
<DependentUpon>ChooseClassDialog.xaml</DependentUpon>

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignContext.cs

@ -116,9 +116,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -116,9 +116,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
if (affectedItems == null)
throw new ArgumentNullException("affectedItems");
UndoService undoService = this.Services.GetService<UndoService>();
if (undoService == null)
throw new ServiceRequiredException(typeof(UndoService));
UndoService undoService = this.Services.GetRequiredService<UndoService>();
UndoTransaction g = undoService.StartTransaction(affectedItems);
g.Title = changeGroupTitle;
return g;

20
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ServiceContainer.cs

@ -96,11 +96,15 @@ namespace ICSharpCode.WpfDesign @@ -96,11 +96,15 @@ namespace ICSharpCode.WpfDesign
}
}
T GetServiceOrThrowException<T>() where T : class
/// <summary>
/// Gets a required service.
/// Never returns null; instead a ServiceRequiredException is thrown when the service cannot be found.
/// </summary>
public T GetRequiredService<T>() where T : class
{
T service = (T)GetService(typeof(T));
if (service == null) {
throw new DesignerException("Could not find guaranteed service " + typeof(T).FullName);
throw new ServiceRequiredException(typeof(T));
}
return service;
}
@ -111,7 +115,7 @@ namespace ICSharpCode.WpfDesign @@ -111,7 +115,7 @@ namespace ICSharpCode.WpfDesign
/// </summary>
public ISelectionService Selection {
get {
return GetServiceOrThrowException<ISelectionService>();
return GetRequiredService<ISelectionService>();
}
}
@ -121,7 +125,7 @@ namespace ICSharpCode.WpfDesign @@ -121,7 +125,7 @@ namespace ICSharpCode.WpfDesign
/// </summary>
public IToolService Tool {
get {
return GetServiceOrThrowException<IToolService>();
return GetRequiredService<IToolService>();
}
}
@ -131,7 +135,7 @@ namespace ICSharpCode.WpfDesign @@ -131,7 +135,7 @@ namespace ICSharpCode.WpfDesign
/// </summary>
public IComponentService Component {
get {
return GetServiceOrThrowException<IComponentService>();
return GetRequiredService<IComponentService>();
}
}
@ -141,7 +145,7 @@ namespace ICSharpCode.WpfDesign @@ -141,7 +145,7 @@ namespace ICSharpCode.WpfDesign
/// </summary>
public ViewService View {
get {
return GetServiceOrThrowException<ViewService>();
return GetRequiredService<ViewService>();
}
}
@ -151,7 +155,7 @@ namespace ICSharpCode.WpfDesign @@ -151,7 +155,7 @@ namespace ICSharpCode.WpfDesign
/// </summary>
public Extensions.ExtensionManager ExtensionManager {
get {
return GetServiceOrThrowException<Extensions.ExtensionManager>();
return GetRequiredService<Extensions.ExtensionManager>();
}
}
@ -161,7 +165,7 @@ namespace ICSharpCode.WpfDesign @@ -161,7 +165,7 @@ namespace ICSharpCode.WpfDesign
/// </summary>
public IDesignPanel DesignPanel {
get {
return GetServiceOrThrowException<IDesignPanel>();
return GetRequiredService<IDesignPanel>();
}
}
}

62
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ServiceRequiredException.cs

@ -0,0 +1,62 @@ @@ -0,0 +1,62 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Runtime.Serialization;
namespace ICSharpCode.WpfDesign
{
/// <summary>
/// Exception class used for designer failures.
/// </summary>
[Serializable]
public class ServiceRequiredException : DesignerException
{
/// <summary>
/// Gets the missing sevice.
/// </summary>
public Type ServiceType { get; private set; }
/// <summary>
/// Create a new ServiceRequiredException instance.
/// </summary>
public ServiceRequiredException(Type serviceType)
: this("Service " + serviceType.FullName + " is required.")
{
this.ServiceType = serviceType;
}
/// <summary>
/// Create a new ServiceRequiredException instance.
/// </summary>
public ServiceRequiredException()
{
}
/// <summary>
/// Create a new ServiceRequiredException instance.
/// </summary>
public ServiceRequiredException(string message) : base(message)
{
}
/// <summary>
/// Create a new ServiceRequiredException instance.
/// </summary>
public ServiceRequiredException(string message, Exception innerException) : base(message, innerException)
{
}
/// <summary>
/// Create a new ServiceRequiredException instance.
/// </summary>
protected ServiceRequiredException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

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

@ -109,6 +109,7 @@ @@ -109,6 +109,7 @@
<Compile Include="PropertyGrid\TypeHelper.cs" />
<Compile Include="ServiceContainer.cs" />
<Compile Include="DesignItem.cs" />
<Compile Include="ServiceRequiredException.cs" />
<Compile Include="Services.cs" />
<Compile Include="Tools.cs" />
</ItemGroup>

Loading…
Cancel
Save