//新增Host规则
        public static void addHostRule(string ip, string port, string url)
        {
            //新建数据
            HostModel rule = new HostModel(mainData.Count, true, ip, port, url);

            //添加数据
            mainData.Add(rule);
            //添加UI
            container.addHostRule(rule);
        }
Ejemplo n.º 2
0
        public void addHostRule(HostModel rule)
        {
            //创建UI对象
            Label label = new Label();

            //设置UI对象属性
            label.Template    = Resources["content_host"] as ControlTemplate;
            label.DataContext = rule;
            //添加Rule
            this.host.Children.Add(label);
        }
 //禁止所有Host规则
 public static void disabledAllHostFromData()
 {
     //遍历更新数据
     for (int i = 0, len = mainData.Count; i < len; i++)
     {
         HostModel item = mainData[i] as HostModel;
         //更新数据
         item.Enable = false;
     }
     //重新写入文件
     DataTool.writeConfigToFile();
 }