forked from plenteum/plenteum-wallet-winforms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SelectionPrompt.cs
114 lines (103 loc) · 3.68 KB
/
SelectionPrompt.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
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
using System;
using System.Windows.Forms;
namespace PlenteumWallet
{
public partial class SelectionPrompt : PlenteumWalletForm
{
public string WalletPath { get; set; }
public string WalletPassword { get; set; }
protected override CreateParams CreateParams
{
get
{
const int CS_DROPSHADOW = 0x20000;
CreateParams cp = base.CreateParams;
cp.ClassStyle |= CS_DROPSHADOW;
return cp;
}
}
public SelectionPrompt()
{
InitializeComponent();
this.Text = Application.ProductName;
//if(IsRunningOnMono())
//{
// this.Width = this.Width + 150;
// this.Height = this.Height + 150;
//}
}
protected override void OnFormClosing(FormClosingEventArgs e)
{
Utilities.CloseProgram(e);
}
private void CreateWalletButton_Click(object sender, EventArgs e)
{
CreateWalletPrompt CWP = new CreateWalletPrompt();
Utilities.Hide(this);
var CWPreturn = CWP.ShowDialog();
if (CWPreturn == DialogResult.OK)
{
WalletPath = CWP.WalletPath;
WalletPassword = CWP.WalletPassword;
Utilities.SetDialogResult(this, DialogResult.OK);
Utilities.Close(CWP);
Utilities.Close(this);
}
this.Show();
}
private void ImportWalletButton_Click(object sender, EventArgs e)
{
ImportWalletPrompt IWP = new ImportWalletPrompt();
Utilities.Hide(this);
var IWPreturn = IWP.ShowDialog();
if (IWPreturn == DialogResult.OK)
{
WalletPath = IWP.ImportWalletPath;
WalletPassword = IWP.ImportWalletPassword;
Utilities.SetDialogResult(this, DialogResult.OK);
Utilities.Close(IWP);
Utilities.Close(this);
}
this.Show();
}
private void SelectWalletButton_Click(object sender, EventArgs e)
{
var curDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
OpenFileDialog findwalletdialog = new OpenFileDialog
{
InitialDirectory = curDir,
Filter = "wallet files (*.wallet)|*.wallet|All files (*.*)|*.*",
FilterIndex = 2,
RestoreDirectory = true
};
if (findwalletdialog.ShowDialog() == DialogResult.OK)
{
if (System.IO.File.Exists(findwalletdialog.FileName))
{
WalletPath = findwalletdialog.FileName;
var pPrompt = new PasswordPrompt();
Utilities.Hide(this);
var pResult = pPrompt.ShowDialog();
if (pResult != DialogResult.OK)
{
findwalletdialog.Dispose();
Utilities.Close(pPrompt);
this.Show();
return;
}
else
{
WalletPassword = pPrompt.WalletPassword;
Utilities.Close(pPrompt);
Utilities.SetDialogResult(this, DialogResult.OK);
Utilities.Close(this);
}
}
}
}
public static bool IsRunningOnMono()
{
return Type.GetType("Mono.Runtime") != null;
}
}
}