|
|
|
@ -19,6 +19,7 @@
@@ -19,6 +19,7 @@
|
|
|
|
|
using System; |
|
|
|
|
using System.Diagnostics; |
|
|
|
|
using System.IO; |
|
|
|
|
using System.Linq; |
|
|
|
|
using System.Text; |
|
|
|
|
using System.Windows; |
|
|
|
|
using System.Windows.Controls; |
|
|
|
@ -376,6 +377,81 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
@@ -376,6 +377,81 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
|
|
|
|
|
AssertLog(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
public void UndoRedoRemoveClearResetInputBindings() |
|
|
|
|
{ |
|
|
|
|
const string originalXaml = "<TextBlock Text=\"My text\" />"; |
|
|
|
|
|
|
|
|
|
DesignItem textBlock = CreateCanvasContext(originalXaml); |
|
|
|
|
UndoService s = textBlock.Context.Services.GetService<UndoService>(); |
|
|
|
|
IComponentService component = textBlock.Context.Services.Component; |
|
|
|
|
|
|
|
|
|
Assert.IsFalse(s.CanUndo); |
|
|
|
|
Assert.IsFalse(s.CanRedo); |
|
|
|
|
|
|
|
|
|
DesignItemProperty inputbinding = textBlock.Properties["InputBindings"]; |
|
|
|
|
Assert.IsTrue(inputbinding.IsCollection); |
|
|
|
|
|
|
|
|
|
const string expectedXaml = @"<TextBlock Text=""My text"" Cursor=""Hand"">
|
|
|
|
|
<TextBlock.InputBindings> |
|
|
|
|
<MouseBinding Gesture=""LeftDoubleClick"" Command=""ApplicationCommands.New"" /> |
|
|
|
|
</TextBlock.InputBindings> |
|
|
|
|
</TextBlock>";
|
|
|
|
|
|
|
|
|
|
using (ChangeGroup changeGroup = textBlock.Context.OpenGroup("", new[] { textBlock })) |
|
|
|
|
{ |
|
|
|
|
DesignItem di = component.RegisterComponentForDesigner(new System.Windows.Input.MouseBinding()); |
|
|
|
|
di.Properties["Gesture"].SetValue(System.Windows.Input.MouseAction.LeftDoubleClick); |
|
|
|
|
di.Properties["Command"].SetValue("ApplicationCommands.New"); |
|
|
|
|
|
|
|
|
|
inputbinding.CollectionElements.Add(di); |
|
|
|
|
|
|
|
|
|
textBlock.Properties["Cursor"].SetValue(System.Windows.Input.Cursors.Hand); |
|
|
|
|
|
|
|
|
|
changeGroup.Commit(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Assert.IsTrue(s.CanUndo); |
|
|
|
|
Assert.IsFalse(s.CanRedo); |
|
|
|
|
AssertCanvasDesignerOutput(expectedXaml, textBlock.Context); |
|
|
|
|
|
|
|
|
|
using (ChangeGroup changeGroup = textBlock.Context.OpenGroup("", new[] { textBlock })) |
|
|
|
|
{ |
|
|
|
|
DesignItem di = inputbinding.CollectionElements.First(); |
|
|
|
|
|
|
|
|
|
// Remove, Clear, Reset combination caused exception at first Undo after this group commit before the issue was fixed
|
|
|
|
|
inputbinding.CollectionElements.Remove(di); |
|
|
|
|
inputbinding.CollectionElements.Clear(); |
|
|
|
|
inputbinding.Reset(); |
|
|
|
|
|
|
|
|
|
di = component.RegisterComponentForDesigner(new System.Windows.Input.MouseBinding()); |
|
|
|
|
di.Properties["Gesture"].SetValue(System.Windows.Input.MouseAction.LeftDoubleClick); |
|
|
|
|
di.Properties["Command"].SetValue("ApplicationCommands.New"); |
|
|
|
|
|
|
|
|
|
inputbinding.CollectionElements.Add(di); |
|
|
|
|
|
|
|
|
|
textBlock.Properties["Cursor"].SetValue(System.Windows.Input.Cursors.Hand); |
|
|
|
|
|
|
|
|
|
changeGroup.Commit(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
s.Undo(); |
|
|
|
|
s.Undo(); |
|
|
|
|
Assert.IsFalse(s.CanUndo); |
|
|
|
|
Assert.IsTrue(s.CanRedo); |
|
|
|
|
AssertCanvasDesignerOutput(originalXaml, textBlock.Context); |
|
|
|
|
|
|
|
|
|
s.Redo(); |
|
|
|
|
s.Redo(); |
|
|
|
|
Assert.IsTrue(s.CanUndo); |
|
|
|
|
Assert.IsFalse(s.CanRedo); |
|
|
|
|
AssertCanvasDesignerOutput(expectedXaml, textBlock.Context); |
|
|
|
|
|
|
|
|
|
Assert.IsTrue(((System.Windows.Input.InputBindingCollection)inputbinding.ValueOnInstance).Count == inputbinding.CollectionElements.Count); |
|
|
|
|
|
|
|
|
|
AssertLog(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
public void AddTextBoxToCanvas() |
|
|
|
|
{ |
|
|
|
|