Browse Source

Format changes

pull/315/head
tbulle 12 years ago
parent
commit
a3c162e9c0
  1. 39
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs
  2. 38
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs

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

@ -52,8 +52,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
public static IOutlineNode Create(DesignItem designItem) public static IOutlineNode Create(DesignItem designItem)
{ {
IOutlineNode node; IOutlineNode node;
if (!outlineNodes.TryGetValue(designItem, out node)) if (!outlineNodes.TryGetValue(designItem, out node)) {
{
node = new OutlineNode(designItem); node = new OutlineNode(designItem);
outlineNodes[designItem] = node; outlineNodes[designItem] = node;
} }
@ -69,17 +68,12 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
{ {
Children.Clear(); Children.Clear();
if (DesignItem.ContentPropertyName != null) if (DesignItem.ContentPropertyName != null) {
{
var content = DesignItem.ContentProperty; var content = DesignItem.ContentProperty;
if (content.IsCollection) if (content.IsCollection) {
{
UpdateChildrenCore(content.CollectionElements); UpdateChildrenCore(content.CollectionElements);
} } else {
else if (content.Value != null) {
{
if (content.Value != null)
{
UpdateChildrenCore(new[] { content.Value }); UpdateChildrenCore(new[] { content.Value });
} }
} }
@ -88,26 +82,17 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
void UpdateChildrenCore(IEnumerable<DesignItem> items) void UpdateChildrenCore(IEnumerable<DesignItem> items)
{ {
foreach (var item in items) foreach (var item in items) {
{ if (ModelTools.CanSelectComponent(item)) {
if (ModelTools.CanSelectComponent(item))
{
var node = OutlineNode.Create(item); var node = OutlineNode.Create(item);
Children.Add(node); Children.Add(node);
} } else {
else
{
var content = item.ContentProperty; var content = item.ContentProperty;
if (content != null) if (content != null) {
{ if (content.IsCollection) {
if (content.IsCollection)
{
UpdateChildrenCore(content.CollectionElements); UpdateChildrenCore(content.CollectionElements);
} } else {
else if (content.Value != null) {
{
if (content.Value != null)
{
UpdateChildrenCore(new[] { content.Value }); UpdateChildrenCore(new[] { content.Value });
} }
} }

38
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs

@ -33,15 +33,13 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
var hidden = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).ValueOnInstance; var hidden = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).ValueOnInstance;
if (hidden != null && (bool)hidden) if (hidden != null && (bool)hidden) {
{
_isDesignTimeVisible = false; _isDesignTimeVisible = false;
((FrameworkElement)DesignItem.Component).Visibility = Visibility.Hidden; ((FrameworkElement)DesignItem.Component).Visibility = Visibility.Hidden;
} }
var locked = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).ValueOnInstance; var locked = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).ValueOnInstance;
if (locked != null && (bool)locked) if (locked != null && (bool)locked) {
{
_isDesignTimeLocked = true; _isDesignTimeLocked = true;
} }
@ -83,8 +81,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
} }
set set
{ {
if (isSelected != value) if (isSelected != value) {
{
isSelected = value; isSelected = value;
SelectionService.SetSelectedComponents(new[] { DesignItem }, SelectionService.SetSelectedComponents(new[] { DesignItem },
value ? SelectionTypes.Add : SelectionTypes.Remove); value ? SelectionTypes.Add : SelectionTypes.Remove);
@ -150,8 +147,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
{ {
get get
{ {
if (string.IsNullOrEmpty(DesignItem.Name)) if (string.IsNullOrEmpty(DesignItem.Name)) {
{
return DesignItem.ComponentType.Name; return DesignItem.ComponentType.Name;
} }
return DesignItem.ComponentType.Name + " (" + DesignItem.Name + ")"; return DesignItem.ComponentType.Name + " (" + DesignItem.Name + ")";
@ -165,8 +161,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
void DesignItem_PropertyChanged(object sender, PropertyChangedEventArgs e) void DesignItem_PropertyChanged(object sender, PropertyChangedEventArgs e)
{ {
if (e.PropertyName == DesignItem.ContentPropertyName) if (e.PropertyName == DesignItem.ContentPropertyName) {
{
UpdateChildren(); UpdateChildren();
} }
} }
@ -179,8 +174,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
if (placementBehavior == null) if (placementBehavior == null)
return false; return false;
var operation = PlacementOperation.Start(nodes.Select(node => node.DesignItem).ToArray(), DummyPlacementType); var operation = PlacementOperation.Start(nodes.Select(node => node.DesignItem).ToArray(), DummyPlacementType);
if (operation != null) if (operation != null) {
{
bool canEnter = placementBehavior.CanEnterContainer(operation, true); bool canEnter = placementBehavior.CanEnterContainer(operation, true);
operation.Abort(); operation.Abort();
return canEnter; return canEnter;
@ -192,14 +186,10 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
{ {
using (var moveTransaction = DesignItem.Context.OpenGroup("Item moved in outline view", nodes.Select(n => n.DesignItem).ToList())) using (var moveTransaction = DesignItem.Context.OpenGroup("Item moved in outline view", nodes.Select(n => n.DesignItem).ToList()))
{ {
if (copy) if (copy) {
{
nodes = nodes.Select(n => OutlineNode.Create(n.DesignItem.Clone())).ToList(); nodes = nodes.Select(n => OutlineNode.Create(n.DesignItem.Clone())).ToList();
} } else {
else foreach (var node in nodes) {
{
foreach (var node in nodes)
{
node.DesignItem.Remove(); node.DesignItem.Remove();
} }
} }
@ -207,15 +197,11 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
var index = after == null ? 0 : Children.IndexOf(after) + 1; var index = after == null ? 0 : Children.IndexOf(after) + 1;
var content = DesignItem.ContentProperty; var content = DesignItem.ContentProperty;
if (content.IsCollection) if (content.IsCollection) {
{ foreach (var node in nodes) {
foreach (var node in nodes)
{
content.CollectionElements.Insert(index++, node.DesignItem); content.CollectionElements.Insert(index++, node.DesignItem);
} }
} } else {
else
{
content.SetValue(nodes.First().DesignItem); content.SetValue(nodes.First().DesignItem);
} }
moveTransaction.Commit(); moveTransaction.Commit();

Loading…
Cancel
Save