Browse Source

WPF Designer: use transaction when moving items in outline pad. (fixes http://community.sharpdevelop.net/forums/t/13248.aspx)

4.1
Daniel Grunwald 15 years ago
parent
commit
5df40bdd49
  1. 31
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs
  2. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/DocumentChangeEventArgs.cs

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

@ -156,25 +156,26 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView @@ -156,25 +156,26 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
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();
}
}

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/DocumentChangeEventArgs.cs

@ -19,7 +19,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -19,7 +19,7 @@ namespace ICSharpCode.AvalonEdit.Document
public int Offset { get; private set; }
/// <summary>
/// The text that was inserted.
/// The text that was removed.
/// </summary>
public string RemovedText { get; private set; }

Loading…
Cancel
Save