forked from casascius/Bitcoin-Address-Utility
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
120 lines (94 loc) · 3.85 KB
/
Copy pathProgram.cs
File metadata and controls
120 lines (94 loc) · 3.85 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Copyright 2012 Mike Caldwell (Casascius)
// Copyright (C) 2026 odolvlobo
// This file is part of Bitcoin Address Utility.
// Bitcoin Address Utility is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Bitcoin Address Utility is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Bitcoin Address Utility. If not, see http://www.gnu.org/licenses/.
using System.Windows;
using BtcAddress.Views;
namespace BtcAddress
{
static class Program
{
public static MainWindow AddressUtility = null;
public static Base58CalcWindow Base58Calc = null;
public static MofNcalcWindow MofNcalc = null;
public static PpecKeygenWindow IntermediateGen = null;
public static KeyCombinerWindow KeyCombiner = null;
public static DecryptKeyWindow DecryptKey = null;
public static Bip38ConfValidatorWindow ConfValidator = null;
public static EscrowToolsShellWindow EscrowTools = null;
public static PaperWalletPrinterWindow PaperWalletPrinter = null;
public static void ShowAddressUtility()
{
AddressUtility = showWindow<MainWindow>(AddressUtility, () => AddressUtility = null);
}
public static void ShowAddressUtility(Casascius.Bitcoin.KeyCollectionItem item)
{
ShowAddressUtility();
if (AddressUtility == null || item == null)
{
return;
}
AddressUtility.Dispatcher.BeginInvoke(new System.Action(() =>
{
AddressUtility.DisplayKeyCollectionItem(item);
AddressUtility.Activate();
}));
}
public static void ShowBase58Calc()
{
Base58Calc = showWindow<Base58CalcWindow>(Base58Calc, () => Base58Calc = null);
}
public static void ShowMofNcalc()
{
MofNcalc = showWindow<MofNcalcWindow>(MofNcalc, () => MofNcalc = null);
}
public static void ShowIntermediateGen()
{
IntermediateGen = showWindow<PpecKeygenWindow>(IntermediateGen, () => IntermediateGen = null);
}
public static void ShowKeyCombiner()
{
KeyCombiner = showWindow<KeyCombinerWindow>(KeyCombiner, () => KeyCombiner = null);
}
public static void ShowConfValidator()
{
ConfValidator = showWindow<Bip38ConfValidatorWindow>(ConfValidator, () => ConfValidator = null);
}
public static void ShowKeyDecrypter()
{
DecryptKey = showWindow<DecryptKeyWindow>(DecryptKey, () => DecryptKey = null);
}
public static void ShowEscrowTools()
{
EscrowTools = showWindow<EscrowToolsShellWindow>(EscrowTools, () => EscrowTools = null);
}
public static void ShowPaperWalletPrinter()
{
PaperWalletPrinter = showWindow<PaperWalletPrinterWindow>(PaperWalletPrinter, () => PaperWalletPrinter = null);
}
private static T showWindow<T>(T currentWindow, System.Action onClosed) where T : Window, new()
{
if (currentWindow == null || !currentWindow.IsVisible)
{
T rv = new T();
rv.Closed += (_, __) => onClosed?.Invoke();
rv.Show();
return rv;
}
else
{
currentWindow.Activate();
return currentWindow;
}
}
}
}