Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
WPF Designer: use transaction when moving items in outline pad. (fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrunwald committed Aug 29, 2011
1 parent c67e7b2 commit 5df40bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
Expand Up @@ -156,25 +156,26 @@ public bool CanInsert(IEnumerable<OutlineNode> nodes, OutlineNode after, bool co

public void Insert(IEnumerable<OutlineNode> nodes, OutlineNode after, bool copy)
{
if (copy) {
nodes = nodes.Select(n => OutlineNode.Create(n.DesignItem.Clone()));
}
else {
foreach (var node in nodes) {
node.DesignItem.Remove();
using (var moveTransaction = DesignItem.Context.OpenGroup("Item moved in outline view", nodes.Select(n => n.DesignItem).ToList())) {
if (copy) {
nodes = nodes.Select(n => OutlineNode.Create(n.DesignItem.Clone())).ToList();
} else {
foreach (var node in nodes) {
node.DesignItem.Remove();
}
}
}

var index = after == null ? 0 : Children.IndexOf(after) + 1;
var index = after == null ? 0 : Children.IndexOf(after) + 1;

var content = DesignItem.ContentProperty;
if (content.IsCollection) {
foreach (var node in nodes) {
content.CollectionElements.Insert(index++, node.DesignItem);
var content = DesignItem.ContentProperty;
if (content.IsCollection) {
foreach (var node in nodes) {
content.CollectionElements.Insert(index++, node.DesignItem);
}
} else {
content.SetValue(nodes.First().DesignItem);
}
}
else {
content.SetValue(nodes.First().DesignItem);
moveTransaction.Commit();
}
}

Expand Down
Expand Up @@ -19,7 +19,7 @@ public class DocumentChangeEventArgs : EventArgs
public int Offset { get; private set; }

/// <summary>
/// The text that was inserted.
/// The text that was removed.
/// </summary>
public string RemovedText { get; private set; }

Expand Down

0 comments on commit 5df40bd

Please sign in to comment.