]> granicus.if.org Git - icinga2/blob - agent/windows-setup-agent/EndpointInputBox.cs
Merge pull request #6305 from gunnarbeutner/feature/environment-variable
[icinga2] / agent / windows-setup-agent / EndpointInputBox.cs
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Text;
7 using System.Windows.Forms;
8
9 namespace Icinga
10 {
11         public partial class EndpointInputBox : Form
12         {
13                 public EndpointInputBox()
14                 {
15                         InitializeComponent();
16                 }
17
18                 private void Warning(string message)
19                 {
20                         MessageBox.Show(this, message, Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
21                 }
22                 
23                 private void chkConnect_CheckedChanged(object sender, EventArgs e)
24                 {
25                         txtHost.Enabled = chkConnect.Checked;
26                         txtPort.Enabled = chkConnect.Checked;
27                 }
28
29                 private void btnOK_Click(object sender, EventArgs e)
30                 {
31                         if (txtInstanceName.Text.Length == 0) {
32                                 Warning("Please enter an instance name.");
33                                 return;
34                         }
35
36                         if (chkConnect.Checked) {
37                                 if (txtHost.Text.Length == 0) {
38                                         Warning("Please enter a host name.");
39                                         return;
40                                 }
41
42                                 if (txtPort.Text.Length == 0) {
43                                         Warning("Please enter a port.");
44                                         return;
45                                 }
46                         }
47
48                         DialogResult = DialogResult.OK;
49                         Close();
50                 }
51         }
52 }