]> granicus.if.org Git - icinga2/blob - agent/windows-setup-agent/GlobalZonesInputBox.cs
Merge pull request #7064 from widhalmt/feature/icingacli-elasticsearch-7063
[icinga2] / agent / windows-setup-agent / GlobalZonesInputBox.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 GlobalZonesInputBox : Form
12         {
13                 private ListView.ListViewItemCollection globalZonesItems;
14
15                 public GlobalZonesInputBox(ListView.ListViewItemCollection globalZonesItems)
16                 {
17                         InitializeComponent();
18
19                         this.globalZonesItems = globalZonesItems;
20                 }
21
22                 private void Warning(string message)
23                 {
24                         MessageBox.Show(this, message, Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
25                 }
26
27
28                 private void btnOK_Click(object sender, EventArgs e)
29                 {
30                         if (txtGlobalZoneName.Text == "global-templates" || txtGlobalZoneName.Text == "director-global") {
31                                 Warning("This global zone is configured by default.");
32                                 return;
33                         }
34
35                         foreach (ListViewItem lvw in globalZonesItems) {
36                                 if (txtGlobalZoneName.Text == lvw.Text) {
37                                         Warning("This global zone is already defined.");
38                                         return;
39                                 }
40                         }
41
42                         DialogResult = DialogResult.OK;
43                         Close();
44                 }
45         }
46 }