forked from EvgBitWhiskey/BitWhiskey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FormSettings.cs
132 lines (121 loc) · 4.74 KB
/
FormSettings.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BitWhiskey
{
public partial class FormSettings : Form
{
public Form parent;
public AppSettingsManager settingsManager = new AppSettingsManager();
MySettings selSettings =null;
public FormSettings()
{
InitializeComponent();
LoadProfileList();
comboBoxProfile.Text = Global.settingsInit.currentprofile;
}
private void TestSaveStandart()
{
MySettings settings = new MySettings();
string settingsPath = settingsManager.GetSettingsFilePath("Standart", "settings.json");
settings.Save(settingsPath);
}
private void LoadProfileList()
{
List<string> profiles=settingsManager.GetProfiles();
comboBoxProfile.Items.Clear();
comboBoxProfile.Items.AddRange(profiles.ToArray());
}
private void buttonSave_Click(object sender, EventArgs e)
{
// TestSaveStandart();return;
string settingsPath = settingsManager.GetSettingsFilePath(comboBoxProfile.Text, "settings.json");
selSettings.defaultlimitorders = checkBoxDefLimitTrade.Checked;
ActivatePoloniexKey();
ActivateBittrexKey();
selSettings.Save(settingsPath);
Global.settingsMain = selSettings;
Global.settingsInit.currentprofile = comboBoxProfile.Text;
Global.settingsInit.Save(Path.Combine(ApplicationPath.directoryAppBin, "init.json"));
Close();
}
private void comboBoxProfile_SelectedIndexChanged(object sender, EventArgs e)
{
string settingsPath = settingsManager.GetSettingsFilePath(comboBoxProfile.Text, "settings.json");
selSettings = MySettings.Load(settingsPath);
if (selSettings.poloniexkey == "")
{
textBoxPoloniexKey.Text = "Empty";
textBoxPoloniexSecret.Text = "Empty";
}
else
{
textBoxPoloniexKey.Text = "******";
textBoxPoloniexSecret.Text = "******";
}
if (selSettings.bittrexkey == "")
{
textBoxBittrexKey.Text = "Empty";
textBoxBittrexSecret.Text = "Empty";
}
else
{
textBoxBittrexKey.Text = "******";
textBoxBittrexSecret.Text = "******";
}
checkBoxDefLimitTrade.Checked= selSettings.defaultlimitorders;
}
private void FormSettings_FormClosed(object sender, FormClosedEventArgs e)
{
parent.Activate();
if (parent.WindowState == FormWindowState.Minimized)
parent.WindowState = FormWindowState.Normal;
}
private void ActivatePoloniexKey()
{
if (textBoxPoloniexKey.Text != "******" && textBoxPoloniexKey.Text != "Empty")
{
selSettings.poloniexkey = AppCrypt.EncryptData(textBoxPoloniexKey.Text);
selSettings.poloniexsecret = AppCrypt.EncryptData(textBoxPoloniexSecret.Text);
}
}
private void ActivateBittrexKey()
{
if (textBoxBittrexKey.Text != "******" && textBoxBittrexKey.Text != "Empty")
{
selSettings.bittrexkey = AppCrypt.EncryptData(textBoxBittrexKey.Text);
selSettings.bittrexsecret = AppCrypt.EncryptData(textBoxBittrexSecret.Text);
}
}
/*
private void buttonActivatePoloniexKey_Click(object sender, EventArgs e)
{
if (textBoxPoloniexSecret.Text == "")
{
MessageBox.Show("You need to fill API Key and Secret fields");
return;
}
selSettings.poloniexkey = AppCrypt.EncryptData(textBoxPoloniexKey.Text);
selSettings.poloniexsecret = AppCrypt.EncryptData(textBoxPoloniexSecret.Text);
MessageBox.Show("Done! Save you profile to apply changes");
}
private void buttonActivateBittrexKey_Click(object sender, EventArgs e)
{
if (textBoxBittrexSecret.Text == "")
{
MessageBox.Show("You need to fill API Key and Secret fields");
return;
}
selSettings.bittrexkey = AppCrypt.EncryptData(textBoxBittrexKey.Text);
selSettings.bittrexsecret = AppCrypt.EncryptData(textBoxBittrexSecret.Text);
MessageBox.Show("Done! Save you profile to apply changes");
}
*/
}
}