Skip to content

Commit 503bbb2

Browse files
committed
WebApi test client did not save and load user settings correctly
1 parent 5ffbbd0 commit 503bbb2

1 file changed

Lines changed: 43 additions & 32 deletions

File tree

src/Tools/SmartStore.WebApi.Client/MainForm.cs

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,51 @@ public MainForm()
1414
{
1515
InitializeComponent();
1616

17-
this.FormClosing += MainForm_Closing;
18-
1917
this.Text = Program.AppName;
2018

21-
cboMethod.SelectedIndex = 0;
22-
radioJson.Checked = true;
23-
radioOdata.Checked = true;
24-
txtPublicKey.Text = Settings.Default.ApiPublicKey;
25-
txtSecretKey.Text = Settings.Default.ApiSecretKey;
26-
cboPath.Items.FromString(Settings.Default.ApiPaths);
27-
cboQuery.Items.FromString(Settings.Default.ApiQuery);
28-
cboContent.Items.FromString(Settings.Default.ApiContent);
29-
30-
if (cboPath.Items.Count <= 0)
31-
cboPath.Items.Add("/Customers");
32-
33-
cboMethod_changeCommitted(null, null);
34-
radioApi_CheckedChanged(null, null);
35-
36-
openFileDialog1.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png";
37-
openFileDialog1.DefaultExt = ".jpg";
38-
openFileDialog1.FileName = "";
39-
openFileDialog1.Title = "Please select an image file to upload";
40-
openFileDialog1.Multiselect = true;
19+
this.Load += (object sender, EventArgs e) =>
20+
{
21+
var s = Settings.Default;
22+
s.Reload();
23+
24+
cboMethod.SelectedIndex = 0;
25+
radioJson.Checked = true;
26+
radioOdata.Checked = true;
27+
txtPublicKey.Text = s.ApiPublicKey;
28+
txtSecretKey.Text = s.ApiSecretKey;
29+
txtUrl.Text = s.ApiUrl;
30+
txtVersion.Text = s.ApiVersion;
31+
cboPath.Items.FromString(s.ApiPaths);
32+
cboQuery.Items.FromString(s.ApiQuery);
33+
cboContent.Items.FromString(s.ApiContent);
34+
35+
if (cboPath.Items.Count <= 0)
36+
cboPath.Items.Add("/Customers");
37+
38+
cboMethod_changeCommitted(null, null);
39+
radioApi_CheckedChanged(null, null);
40+
41+
openFileDialog1.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png";
42+
openFileDialog1.DefaultExt = ".jpg";
43+
openFileDialog1.FileName = "";
44+
openFileDialog1.Title = "Please select an image file to upload";
45+
openFileDialog1.Multiselect = true;
46+
};
47+
48+
this.FormClosing += (object sender, FormClosingEventArgs e) =>
49+
{
50+
var s = Settings.Default;
51+
52+
s.ApiPublicKey = txtPublicKey.Text;
53+
s.ApiSecretKey = txtSecretKey.Text;
54+
s.ApiUrl = txtUrl.Text;
55+
s.ApiVersion = txtVersion.Text;
56+
Settings.Default[radioOdata.Checked ? "ApiPaths" : "ApiPaths2"] = cboPath.Items.IntoString();
57+
s.ApiQuery = cboQuery.Items.IntoString();
58+
s.ApiContent = cboContent.Items.IntoString();
59+
60+
s.Save();
61+
};
4162
}
4263

4364
private void CallTheApi()
@@ -120,16 +141,6 @@ private void SavePathItems(bool odata)
120141
cboPath.Items.Clear();
121142
cboPath.Items.FromString(odata ? Settings.Default.ApiPaths : Settings.Default.ApiPaths2);
122143
}
123-
124-
private void MainForm_Closing(object sender, FormClosingEventArgs e)
125-
{
126-
Settings.Default["ApiPublicKey"] = txtPublicKey.Text;
127-
Settings.Default["ApiSecretKey"] = txtSecretKey.Text;
128-
Settings.Default[radioOdata.Checked ? "ApiPaths" : "ApiPaths2"] = cboPath.Items.IntoString();
129-
Settings.Default["ApiQuery"] = cboQuery.Items.IntoString();
130-
Settings.Default["ApiContent"] = cboContent.Items.IntoString();
131-
Settings.Default.Save();
132-
}
133144

134145
private void MainForm_Shown(object sender, EventArgs e)
135146
{

0 commit comments

Comments
 (0)