Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2417 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
31 changed files with 689 additions and 98 deletions
@ -0,0 +1,105 @@
@@ -0,0 +1,105 @@
|
||||
// <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; |
||||
using ICSharpCode.WpfDesign.Extensions; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.Extensions |
||||
{ |
||||
/// <summary>
|
||||
/// Supports resizing a Window.
|
||||
/// </summary>
|
||||
[ExtensionFor(typeof(Window))] |
||||
public class WindowResizeBehavior : BehaviorExtension, IRootPlacementBehavior |
||||
{ |
||||
/// <inherits/>
|
||||
protected override void OnInitialized() |
||||
{ |
||||
base.OnInitialized(); |
||||
this.ExtendedItem.AddBehavior(typeof(IRootPlacementBehavior), this); |
||||
} |
||||
|
||||
/// <inherits/>
|
||||
public bool CanPlace(DesignItem child, PlacementType type, PlacementAlignment position) |
||||
{ |
||||
return type == PlacementType.Resize && |
||||
(position == PlacementAlignments.Right |
||||
|| position == PlacementAlignments.BottomRight |
||||
|| position == PlacementAlignments.Bottom); |
||||
} |
||||
|
||||
/// <inherits/>
|
||||
public void StartPlacement(PlacementOperation operation) |
||||
{ |
||||
UIElement element = (UIElement)operation.PlacedItem.Component; |
||||
operation.Left = 0; |
||||
operation.Top = 0; |
||||
operation.Right = GetWidth(element); |
||||
operation.Bottom = GetHeight(element); |
||||
} |
||||
|
||||
static double GetWidth(UIElement element) |
||||
{ |
||||
double v = (double)element.GetValue(FrameworkElement.WidthProperty); |
||||
if (double.IsNaN(v)) |
||||
return element.RenderSize.Width; |
||||
else |
||||
return v; |
||||
} |
||||
|
||||
static double GetHeight(UIElement element) |
||||
{ |
||||
double v = (double)element.GetValue(FrameworkElement.HeightProperty); |
||||
if (double.IsNaN(v)) |
||||
return element.RenderSize.Height; |
||||
else |
||||
return v; |
||||
} |
||||
|
||||
/// <inherits/>
|
||||
public void UpdatePlacement(PlacementOperation operation) |
||||
{ |
||||
UIElement element = (UIElement)operation.PlacedItem.Component; |
||||
if (operation.Right != GetWidth(element)) { |
||||
operation.PlacedItem.Properties[FrameworkElement.WidthProperty].SetValue(operation.Right); |
||||
} |
||||
if (operation.Bottom != GetHeight(element)) { |
||||
operation.PlacedItem.Properties[FrameworkElement.HeightProperty].SetValue(operation.Bottom); |
||||
} |
||||
} |
||||
|
||||
/// <inherits/>
|
||||
public void FinishPlacement(PlacementOperation operation) |
||||
{ |
||||
} |
||||
|
||||
/// <inherits/>
|
||||
public bool CanLeaveContainer(PlacementOperation operation) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
/// <inherits/>
|
||||
public void LeaveContainer(PlacementOperation operation) |
||||
{ |
||||
throw new NotSupportedException(); |
||||
} |
||||
|
||||
/// <inherits/>
|
||||
public bool CanEnterContainer(PlacementOperation operation) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
/// <inherits/>
|
||||
public void EnterContainer(PlacementOperation operation) |
||||
{ |
||||
throw new NotSupportedException(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
// <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; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.Services |
||||
{ |
||||
/// <summary>
|
||||
/// Contains a set of options regarding the default designer components.
|
||||
/// </summary>
|
||||
public sealed class OptionService |
||||
{ |
||||
/// <summary>
|
||||
/// Gets/Sets whether the design surface should be grayed out while dragging/selection.
|
||||
/// </summary>
|
||||
public bool GrayOutDesignSurfaceExceptParentContainerWhenDragging = true; |
||||
} |
||||
} |
@ -0,0 +1,77 @@
@@ -0,0 +1,77 @@
|
||||
// <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.Diagnostics; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using ICSharpCode.WpfDesign.XamlDom; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.Xaml |
||||
{ |
||||
sealed class XamlModelCollectionElementsCollection : Collection<DesignItem> |
||||
{ |
||||
readonly XamlModelProperty modelProperty; |
||||
readonly XamlProperty property; |
||||
|
||||
public XamlModelCollectionElementsCollection(XamlModelProperty modelProperty, XamlProperty property) |
||||
{ |
||||
this.modelProperty = modelProperty; |
||||
this.property = property; |
||||
|
||||
XamlDesignContext context = (XamlDesignContext)modelProperty.DesignItem.Context; |
||||
foreach (XamlPropertyValue val in property.CollectionElements) { |
||||
//context._componentService.GetDesignItem(val);
|
||||
if (val is XamlObject) { |
||||
base.InsertItem(this.Count, context._componentService.GetDesignItem( ((XamlObject)val).Instance )); |
||||
} |
||||
} |
||||
} |
||||
|
||||
protected override void ClearItems() |
||||
{ |
||||
base.ClearItems(); |
||||
property.CollectionElements.Clear(); |
||||
} |
||||
|
||||
XamlDesignItem CheckItem(DesignItem item) |
||||
{ |
||||
if (item == null) |
||||
throw new ArgumentNullException("item"); |
||||
if (item.Context != modelProperty.DesignItem.Context) |
||||
throw new ArgumentException("The item must belong to the same context as this collection", "item"); |
||||
XamlDesignItem xitem = item as XamlDesignItem; |
||||
Debug.Assert(xitem != null); |
||||
return xitem; |
||||
} |
||||
|
||||
protected override void InsertItem(int index, DesignItem item) |
||||
{ |
||||
XamlDesignItem xitem = CheckItem(item); |
||||
property.CollectionElements.Insert(index, xitem.XamlObject); |
||||
|
||||
base.InsertItem(index, item); |
||||
} |
||||
|
||||
protected override void RemoveItem(int index) |
||||
{ |
||||
XamlDesignItem item = (XamlDesignItem)this[index]; |
||||
|
||||
property.CollectionElements.RemoveAt(index); |
||||
base.RemoveItem(index); |
||||
} |
||||
|
||||
protected override void SetItem(int index, DesignItem item) |
||||
{ |
||||
XamlDesignItem xitem = CheckItem(item); |
||||
property.CollectionElements[index] = xitem.XamlObject; |
||||
|
||||
|
||||
base.SetItem(index, item); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,66 @@
@@ -0,0 +1,66 @@
|
||||
// <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.Collections.ObjectModel; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.WpfDesign.XamlDom |
||||
{ |
||||
partial class XamlProperty |
||||
{ |
||||
/// <summary>
|
||||
/// The collection used by XamlProperty.CollectionElements
|
||||
/// </summary>
|
||||
sealed class CollectionElementsCollection : Collection<XamlPropertyValue> |
||||
{ |
||||
XamlProperty property; |
||||
|
||||
internal CollectionElementsCollection(XamlProperty property) |
||||
{ |
||||
this.property = property; |
||||
} |
||||
|
||||
internal void AddByParser(XamlPropertyValue value) |
||||
{ |
||||
base.InsertItem(this.Count, value); |
||||
} |
||||
|
||||
protected override void ClearItems() |
||||
{ |
||||
while (Count > 0) { |
||||
RemoveAt(Count - 1); |
||||
} |
||||
} |
||||
|
||||
protected override void RemoveItem(int index) |
||||
{ |
||||
XamlPropertyInfo info = property.propertyInfo; |
||||
object collection = info.GetValue(property.ParentObject.Instance); |
||||
if (!CollectionSupport.RemoveItemAt(info.ReturnType, collection, index)) { |
||||
CollectionSupport.RemoveItem(info.ReturnType, collection, this[index].GetValueFor(info)); |
||||
} |
||||
|
||||
this[index].RemoveNodeFromParent(); |
||||
this[index].ParentProperty = null; |
||||
base.RemoveItem(index); |
||||
} |
||||
|
||||
protected override void InsertItem(int index, XamlPropertyValue item) |
||||
{ |
||||
XamlPropertyInfo info = property.propertyInfo; |
||||
object collection = info.GetValue(property.ParentObject.Instance); |
||||
info.AddValue(collection, item); |
||||
|
||||
item.AddNodeTo(property); |
||||
item.ParentProperty = property; |
||||
|
||||
base.InsertItem(index, item); |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue