Exemple #1
0
        private void ListBoxWhitelist_MouseDoubleClick(object sender, MouseEventArgs mouseEventArgs)
        {
            var index = listBoxIpWhitelist.IndexFromPoint(mouseEventArgs.Location);

            if (index == ListBox.NoMatches)
            {
                return;
            }
            var item      = (string)listBoxIpWhitelist.Items[index];
            var strings   = SettingsManager.GetIpAddressAndNetmaskFromSetting(item);
            var ipAddress = IPAddress.Parse(strings[0]);
            var netmask   = IPAddress.Parse(strings[1]);

            using (var ipAddressEntryForm = new IpAddressEntryForm(ipAddress, netmask))
            {
                var dialogResult = ipAddressEntryForm.ShowDialog();
                if (dialogResult == DialogResult.OK)
                {
                    item = $"{ipAddressEntryForm.IpAddressString}/{ipAddressEntryForm.NetmaskString}";
                    listBoxIpWhitelist.Items[index]     = item;
                    Settings.Default.IpWhitelist[index] = item;
                    Settings.Default.Save();
                }
            }
        }
Exemple #2
0
 private void ButtonAdd_Click(object sender, EventArgs e)
 {
     using (var ipAddressEntryForm =
                new IpAddressEntryForm(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("0.0.0.0")))
     {
         var dialogResult = ipAddressEntryForm.ShowDialog();
         if (dialogResult == DialogResult.OK)
         {
             var item = $"{ipAddressEntryForm.IpAddressString}/{ipAddressEntryForm.NetmaskString}";
             listBoxIpWhitelist.Items.Add(item);
             Settings.Default.IpWhitelist.Add(item);
             Settings.Default.Save();
         }
     }
 }