-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMainForm.cs
More file actions
66 lines (55 loc) · 1.54 KB
/
Copy pathMainForm.cs
File metadata and controls
66 lines (55 loc) · 1.54 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
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Diagnostics;
namespace UtopiaCryptocards
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm : Form
{
UtopiaLib.Client client = null;
public MainForm()
{
InitializeComponent();
//listView1.SmallImageList = imageList2;
}
void openURL(string url = "https://example.com") {
Process.Start(url);
}
void ViewGithubClick(object sender, EventArgs e)
{
openURL("https://github.com/Sagleft/utopia-custom-cryptocards");
}
void ButtonVisitSiteClick(object sender, EventArgs e)
{
openURL("https://u.is");
}
void printToLog(string info = "") {
textBox_connectionLog.AppendText(" > " + info + Environment.NewLine);
}
void ButtonConnectClick(object sender, EventArgs e)
{
string api_host = textBox_host.Text;
string api_token = textBox_token.Text;
int api_port = 22800;
if(! Int32.TryParse(textBox_port.Text, out api_port)) {
printToLog("Failed to parse port, using default value: " + 22800);
}
printToLog("attempt to connect to the Utopia client..");
try {
client = new UtopiaLib.Client(api_host, api_port, api_token);
if(client.checkClientConnection()) {
printToLog("successful connection!");
printToLog("loading a list of crypto cards..");
updateCardsList();
} else {
printToLog("failed to connect to client");
}
} catch (Exception ex) {
printToLog("catched exception: " + ex.Message);
}
}
}
}