-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
FavoriteKeyStoreSelectionControl.xaml.cs
59 lines (51 loc) · 2.11 KB
/
FavoriteKeyStoreSelectionControl.xaml.cs
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
48
49
50
51
52
53
54
55
56
57
58
59
using Leosac.KeyManager.Library.UI.Domain;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
namespace Leosac.KeyManager.Library.UI
{
/// <summary>
/// Interaction logic for FavoriteSelectionControl.xaml
/// </summary>
public partial class FavoriteKeyStoreSelectionControl : UserControl
{
public FavoriteKeyStoreSelectionControl()
{
InitializeComponent();
Favorites = DesignerProperties.GetIsInDesignMode(this) ? new Favorites() : Favorites.GetSingletonInstance();
}
public Favorites? Favorites
{
get { return (Favorites)GetValue(FavoritesProperty); }
set { SetValue(FavoritesProperty, value); }
}
public static readonly DependencyProperty FavoritesProperty = DependencyProperty.Register(nameof(Favorites), typeof(Favorites), typeof(FavoriteKeyStoreSelectionControl));
public Favorite SelectedKeyStoreFavorite
{
get { return (Favorite)GetValue(SelectedKeyStoreFavoriteProperty); }
set { SetValue(SelectedKeyStoreFavoriteProperty, value); }
}
public static readonly DependencyProperty SelectedKeyStoreFavoriteProperty = DependencyProperty.Register(nameof(SelectedKeyStoreFavorite), typeof(Favorite), typeof(FavoriteKeyStoreSelectionControl));
private async void BtnNew_Click(object sender, RoutedEventArgs e)
{
var model = new KeyStoreSelectorDialogViewModel { Message = "Save a new Favorite Key Store" };
var dialog = new KeyStoreSelectorDialog
{
DataContext = model
};
object? ret = await DialogHelper.ForceShow(dialog, "FavSelectionDialog");
if (ret != null)
{
var store = model.CreateKeyStore();
if (store != null)
{
var fav = Favorites?.CreateFromKeyStore(store);
if (fav != null)
{
SelectedKeyStoreFavorite = fav;
}
}
}
}
}
}