Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2413 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
30 changed files with 350 additions and 51 deletions
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
// <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 ICSharpCode.WpfDesign.Extensions; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using ICSharpCode.WpfDesign.Adorners; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.Extensions |
||||
{ |
||||
/// <summary>
|
||||
/// Provides <see cref="IChildResizeSupport"/> behavior for <see cref="Canvas"/>.
|
||||
/// </summary>
|
||||
[ExtensionFor(typeof(Canvas))] |
||||
public sealed class CanvasChildResizeSupport : BehaviorExtension, IChildResizeSupport |
||||
{ |
||||
/// <inherits/>
|
||||
protected override void OnInitialized() |
||||
{ |
||||
base.OnInitialized(); |
||||
this.ExtendedItem.AddBehavior(typeof(IChildResizeSupport), this); |
||||
} |
||||
|
||||
/// <inherits/>
|
||||
public bool CanResizeChild(DesignItem child) |
||||
{ |
||||
return DefaultChildResizeSupport.Instance.CanResizeChild(child); |
||||
} |
||||
|
||||
/// <inherits/>
|
||||
public Placement GetPlacement(DesignItem child, double horizontalChange, double verticalChange, HorizontalAlignment horizontal, VerticalAlignment vertical) |
||||
{ |
||||
return RootElementResizeSupport.Instance.GetPlacement(child, horizontalChange, verticalChange, horizontal, vertical); |
||||
} |
||||
|
||||
/// <inherits/>
|
||||
public void Resize(DesignItem childItem, double horizontalChange, double verticalChange, HorizontalAlignment horizontal, VerticalAlignment vertical) |
||||
{ |
||||
RelativePlacement p = (RelativePlacement)GetPlacement(childItem, horizontalChange, verticalChange, horizontal, vertical); |
||||
DefaultChildResizeSupport.Resize(childItem, p); |
||||
|
||||
bool marginIsSet = childItem.Properties[FrameworkElement.MarginProperty].IsSet; |
||||
|
||||
DesignItemProperty left = childItem.Properties.GetAttachedProperty(Canvas.LeftProperty); |
||||
DesignItemProperty top = childItem.Properties.GetAttachedProperty(Canvas.TopProperty); |
||||
|
||||
if (left.IsSet) { |
||||
left.SetValue( p.XOffset + (double)left.ValueOnInstance); |
||||
} else if (p.XOffset != 0 && !marginIsSet) { |
||||
left.SetValue( p.XOffset ); |
||||
} |
||||
if (top.IsSet) { |
||||
top.SetValue( p.YOffset + (double)top.ValueOnInstance); |
||||
} else if (p.YOffset != 0 && !marginIsSet) { |
||||
top.SetValue( p.YOffset ); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
// <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.Windows; |
||||
|
||||
namespace ICSharpCode.WpfDesign.XamlDom.Tests |
||||
{ |
||||
/// <summary>
|
||||
/// Provides an example attached property.
|
||||
/// </summary>
|
||||
public static class ExampleService |
||||
{ |
||||
public static readonly DependencyProperty ExampleProperty = DependencyProperty.RegisterAttached( |
||||
"Example", typeof(string), typeof(ExampleService) |
||||
); |
||||
|
||||
public static string GetExample(DependencyObject element) |
||||
{ |
||||
TestHelperLog.Log("ExampleService.GetExample"); |
||||
return (string)element.GetValue(ExampleProperty); |
||||
} |
||||
|
||||
public static void SetExample(DependencyObject element, string value) |
||||
{ |
||||
TestHelperLog.Log("ExampleService.SetExample"); |
||||
element.SetValue(ExampleProperty, value); |
||||
} |
||||
} |
||||
|
||||
public class ExampleDependencyObject : DependencyObject |
||||
{ |
||||
|
||||
} |
||||
} |
Loading…
Reference in new issue