forked from Ken98045/On-Guard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MQTTSettings.cs
96 lines (79 loc) · 2.76 KB
/
MQTTSettings.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Configuration;
using SAAI.Properties;
namespace SAAI
{
public partial class MQTTSettings : Form
{
public MQTTSettings()
{
InitializeComponent();
ServerText.Text = Settings.Default.MQTTServerAddress;
PortNumeric.Value = Settings.Default.MQTTPort;
UserText.Text = Settings.Default.MQTTUser;
PasswordText.Text = Settings.Default.MQTTPassword;
CoolDownNumeric.Value = Settings.Default.MQTTCoolDown;
UseSecureLinkCheck.Checked = Settings.Default.MQTTUseSecureLink;
MotionActivityText.Text = Settings.Default.MQTTMotionTopic;
MotionActivityPayloadText.Text = Settings.Default.MQTTMotionPayload;
StoppedActivityTopicText.Text = Settings.Default.MQTTStoppedTopic;
StoppedPayloadText.Text = Settings.Default.MQTTStoppedPayload;
if (PortNumeric.Value == 0)
{
PortNumeric.Value = 1883;
}
if (string.IsNullOrEmpty(ServerText.Text))
{
ServerText.Text = "localhost";
}
}
private void OKButton_Click(object sender, EventArgs e)
{
Settings.Default.MQTTServerAddress = ServerText.Text;
Settings.Default.MQTTPort = (int)PortNumeric.Value;
Settings.Default.MQTTUser = UserText.Text;
Settings.Default.MQTTPassword = PasswordText.Text;
Settings.Default.MQTTCoolDown = (int) CoolDownNumeric.Value;
Settings.Default.MQTTUseSecureLink = UseSecureLinkCheck.Checked;
Settings.Default.MQTTMotionTopic = MotionActivityText.Text;
Settings.Default.MQTTMotionPayload = MotionActivityPayloadText.Text;
Settings.Default.MQTTStoppedTopic = StoppedActivityTopicText.Text;
Settings.Default.MQTTStoppedPayload = StoppedPayloadText.Text;
Settings.Default.Save();
DialogResult = DialogResult.OK;
}
private void CancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
}
public class MQTTData
{
public MQTTData(string serverAddress, int port, string userName, string password)
{
ServerAddress = serverAddress;
Port = port;
UserName = userName;
Password = password;
}
public MQTTData(MQTTData data)
{
ServerAddress = data.ServerAddress;
Port = data.Port;
UserName = data.UserName;
Password = data.Password;
}
public string ServerAddress { get; set; }
public int Port { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
}
}