Browse Source

Merge branch 'feature/ImageScaleMode' of https://github.com/Gillibald/Avalonia into feature/ImageScaleMode

pull/1762/head
Benedikt Schroeder 8 years ago
parent
commit
9723eccb70
  1. 5
      .gitignore
  2. 2
      src/Avalonia.Controls/Primitives/SelectingItemsControl.cs
  3. 10
      src/Avalonia.Controls/Window.cs
  4. 7
      src/Gtk/Avalonia.Gtk3/KeyTransform.cs
  5. 22
      tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs

5
.gitignore

@ -165,6 +165,11 @@ $RECYCLE.BIN/
################# #################
.idea .idea
#################
## VS Code
#################
.vscode/
################# #################
## Cake ## Cake
################# #################

2
src/Avalonia.Controls/Primitives/SelectingItemsControl.cs

@ -376,7 +376,7 @@ namespace Avalonia.Controls.Primitives
break; break;
case NotifyCollectionChangedAction.Reset: case NotifyCollectionChangedAction.Reset:
SelectedIndex = IndexOf(e.NewItems, SelectedItem); SelectedIndex = IndexOf(Items, SelectedItem);
break; break;
} }
} }

10
src/Avalonia.Controls/Window.cs

@ -302,17 +302,23 @@ namespace Avalonia.Controls
internal void Close(bool ignoreCancel) internal void Close(bool ignoreCancel)
{ {
bool close = true;
try try
{ {
if (!ignoreCancel && HandleClosing()) if (!ignoreCancel && HandleClosing())
{ {
close = false;
return; return;
} }
} }
finally finally
{ {
PlatformImpl?.Dispose(); if (close)
HandleClosed(); {
PlatformImpl?.Dispose();
HandleClosed();
}
} }
} }

7
src/Gtk/Avalonia.Gtk3/KeyTransform.cs

@ -33,17 +33,24 @@ namespace Avalonia.Gtk.Common
{ GdkKey.Prior, Key.Prior }, { GdkKey.Prior, Key.Prior },
//{ GdkKey.?, Key.PageDown } //{ GdkKey.?, Key.PageDown }
{ GdkKey.End, Key.End }, { GdkKey.End, Key.End },
{ GdkKey.KP_End, Key.End },
{ GdkKey.Home, Key.Home }, { GdkKey.Home, Key.Home },
{ GdkKey.KP_Home, Key.Home },
{ GdkKey.Left, Key.Left }, { GdkKey.Left, Key.Left },
{ GdkKey.KP_Left, Key.Left },
{ GdkKey.Up, Key.Up }, { GdkKey.Up, Key.Up },
{ GdkKey.KP_Up, Key.Up },
{ GdkKey.Right, Key.Right }, { GdkKey.Right, Key.Right },
{ GdkKey.KP_Right, Key.Right },
{ GdkKey.Down, Key.Down }, { GdkKey.Down, Key.Down },
{ GdkKey.KP_Down, Key.Down },
{ GdkKey.Select, Key.Select }, { GdkKey.Select, Key.Select },
{ GdkKey.Print, Key.Print }, { GdkKey.Print, Key.Print },
{ GdkKey.Execute, Key.Execute }, { GdkKey.Execute, Key.Execute },
//{ GdkKey.?, Key.Snapshot } //{ GdkKey.?, Key.Snapshot }
{ GdkKey.Insert, Key.Insert }, { GdkKey.Insert, Key.Insert },
{ GdkKey.Delete, Key.Delete }, { GdkKey.Delete, Key.Delete },
{ GdkKey.KP_Delete, Key.Delete },
{ GdkKey.Help, Key.Help }, { GdkKey.Help, Key.Help },
//{ GdkKey.?, Key.D0 } //{ GdkKey.?, Key.D0 }
//{ GdkKey.?, Key.D1 } //{ GdkKey.?, Key.D1 }

22
tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs

@ -3,6 +3,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq; using System.Linq;
using Avalonia.Collections; using Avalonia.Collections;
using Avalonia.Controls.Presenters; using Avalonia.Controls.Presenters;
@ -13,6 +14,7 @@ using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Markup.Data; using Avalonia.Markup.Data;
using Avalonia.UnitTests; using Avalonia.UnitTests;
using Moq;
using Xunit; using Xunit;
namespace Avalonia.Controls.UnitTests.Primitives namespace Avalonia.Controls.UnitTests.Primitives
@ -686,6 +688,26 @@ namespace Avalonia.Controls.UnitTests.Primitives
Assert.Null(KeyboardNavigation.GetTabOnceActiveElement((InputElement)panel)); Assert.Null(KeyboardNavigation.GetTabOnceActiveElement((InputElement)panel));
} }
[Fact]
public void Resetting_Items_Collection_Should_Retain_Selection()
{
var itemsMock = new Mock<List<string>>();
var itemsMockAsINCC = itemsMock.As<INotifyCollectionChanged>();
itemsMock.Object.AddRange(new[] { "Foo", "Bar", "Baz" });
var target = new SelectingItemsControl
{
Items = itemsMock.Object
};
target.SelectedIndex = 1;
itemsMockAsINCC.Raise(e => e.CollectionChanged += null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
Assert.True(target.SelectedIndex == 1);
}
private FuncControlTemplate Template() private FuncControlTemplate Template()
{ {
return new FuncControlTemplate<SelectingItemsControl>(control => return new FuncControlTemplate<SelectingItemsControl>(control =>

Loading…
Cancel
Save