-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfrmManualSharecodeEntry.cs
116 lines (93 loc) · 3.17 KB
/
frmManualSharecodeEntry.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
115
116
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SC2Scrapbook
{
public partial class frmManualSharecodeEntry : Form
{
Models.Build activeBuild;
public frmManualSharecodeEntry()
{
InitializeComponent();
activeBuild = null;
}
private void txtShareCode_TextChanged(object sender, EventArgs e)
{
tmrUpdate.Stop();
tmrUpdate.Start();
}
private void tmrUpdate_Tick(object sender, EventArgs e)
{
tmrUpdate.Stop();
try
{
Models.Build build = null;
string data = txtShareCode.Text;
if (data.StartsWith("sc2bo://"))
data = data.Substring(8);
try
{
build = Models.Build.ParseSALT(new SALT(data));
} catch (Exception)
{
}
if (build == null) {
build = Models.Build.ParseBase64(data);
}
if (build != null)
{
pbStatus.Image = Properties.Resources.tick;
Text = string.Format("Import Build - {0}", build.Name);
}
else
{
pbStatus.Image = Properties.Resources.cross;
Text = string.Format("Import Build");
}
}
catch (Exception)
{
pbStatus.Image = Properties.Resources.cross;
Text = string.Format("Import Build");
}
}
private void cmdImport_Click(object sender, EventArgs e)
{
try
{
Models.Build build = null;
string data = txtShareCode.Text;
if (data.StartsWith("sc2bo://"))
data = data.Substring(8);
try
{
build = Models.Build.ParseSALT(new SALT(data));
}
catch (Exception)
{
}
if (build == null)
{
build = Models.Build.ParseBase64(data);
}
frmImportBuild import = new frmImportBuild(build);
if (import.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
Program.BuildsDB.Add(build);
Program.SaveBuildsXML();
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(string.Format("Failed to import build:\r\n\r\n{0}", ex.ToString()), "Import Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}