blob: d95e03bcbb8adbcf855e23ab8dd6bb5d35777558 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using Xamarin.PropertyEditing.ViewModels;
namespace Xamarin.PropertyEditing.Windows
{
internal partial class TypeSelectorWindow
: WindowEx
{
internal TypeSelectorWindow (IEnumerable<ResourceDictionary> mergedResources, AsyncValue<IReadOnlyDictionary<IAssemblyInfo, ILookup<string, ITypeInfo>>> assignableTypes)
{
DataContext = new TypeSelectorViewModel (assignableTypes);
InitializeComponent ();
Resources.MergedDictionaries.AddItems (mergedResources);
}
internal static ITypeInfo RequestType (FrameworkElement owner, AsyncValue<IReadOnlyDictionary<IAssemblyInfo, ILookup<string, ITypeInfo>>> assignableTypes)
{
Window hostWindow = Window.GetWindow (owner);
var w = new TypeSelectorWindow (owner.Resources.MergedDictionaries, assignableTypes) {
Owner = hostWindow,
};
if (!w.ShowDialog () ?? false)
return null;
return ((TypeSelectorViewModel)w.DataContext).SelectedType;
}
private void OnSelectedItemChanged (object sender, RoutedPropertyChangedEventArgs<object> e)
{
this.ok.IsEnabled = (e.NewValue as ITypeInfo) != null;
}
private void OnItemActivated (object sender, System.EventArgs e)
{
DialogResult = true;
}
private void OnOkClicked (object sender, RoutedEventArgs e)
{
DialogResult = true;
}
}
}
|