private void WHLdeleteclick(object sender, MouseButtonEventArgs e)
        {
            string dev_ip = (from devices in StaticGlobal.fwdev_list
                             where devices.getDev_MAC() == StaticGlobal.firewallmac
                             select devices).ToList <FWDeviceForm>()[0].getProtecDevIP_list()[0];
            string            dst_ip   = (WHLdataGrid.SelectedItem as WHLRuleDataTable).dst_IP.ToString();
            string            src_IP   = (WHLdataGrid.SelectedItem as WHLRuleDataTable).src_IP.ToString();
            string            dst_port = (WHLdataGrid.SelectedItem as WHLRuleDataTable).dst_port.ToString();
            string            src_port = (WHLdataGrid.SelectedItem as WHLRuleDataTable).src_port.ToString();
            bool              log      = (WHLdataGrid.SelectedItem as WHLRuleDataTable).log;
            IConfigWhiteLists fw       = new ConfigWhiteLists();

            if (fw.ChangeWhiteLists(dev_ip, dst_ip, src_IP, dst_port, src_port, log, false))
            {
                StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getWHLRule_list().Remove((WHLdataGrid.SelectedItem as WHLRuleDataTable));
                UserMessageBox.Show("提示", "规则删除成功!");
            }
        }
        public void WHLApplying()
        {
            Dispatcher.Invoke(new Action(() =>
            {
                NewWHLRulebutton.IsEnabled = false;
                WHLApplybutton.IsEnabled   = false;
                WHLdataGrid.IsEnabled      = false;
                Closebutton.IsEnabled      = false;
            }));
            IConfigWhiteLists WHLrule = new ConfigWhiteLists();
            bool WHLApplyflag         = true;
            //找出需要删除的规则
            var deleteRules = StaticGlobal.WHLoldrules.Where(deleteRule => !StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getWHLRule_list().Contains(deleteRule)).ToList();

            //找出需要增加的规则
            var    addRules = StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getWHLRule_list().Where(addRule => !StaticGlobal.WHLoldrules.Contains(addRule)).ToList();
            string dev_ip   = (from devices in StaticGlobal.fwdev_list
                               where devices.getDev_MAC() == StaticGlobal.firewallmac
                               select devices).ToList <FWDeviceForm>()[0].getProtecDevIP_list()[0];

            //增加规则
            for (int i = 0; i < addRules.Count(); i++)
            {
                string dst_IP   = addRules[i].dst_IP;
                string dst_port = addRules[i].dst_port;
                string src_IP   = addRules[i].src_IP;
                string src_port = addRules[i].src_port;
                bool   log      = addRules[i].log;
                if (WHLrule.ChangeWhiteLists(dev_ip, dst_IP, src_IP, dst_port, src_port, log, true))
                {
                    WHLApplyflag = true;
                }
                else
                {
                    WHLApplyflag = false;
                }
            }
            //删除规则
            for (int j = 0; j < deleteRules.Count(); j++)
            {
                string dst_IP   = deleteRules[j].dst_IP;
                string dst_port = deleteRules[j].dst_port;
                string src_IP   = deleteRules[j].src_IP;
                string src_port = deleteRules[j].src_port;
                bool   log      = deleteRules[j].log;
                if (WHLrule.ChangeWhiteLists(dev_ip, dst_IP, src_IP, dst_port, src_port, log, false))
                {
                    WHLApplyflag = true;
                }
                else
                {
                    WHLApplyflag = false;
                }
            }
            Dispatcher.Invoke(new Action(() =>
            {
                if (WHLApplyflag)
                {
                    UserMessageBox.Show("提示", "所有规则已成功应用!");
                }
                else
                {
                    UserMessageBox.Show("提示", "部分规则未成功应用,请检查设备之间的连接!");
                }
                this.Close();
            }
                                         ));
            WHLApplyThread.Abort();
        }