private void button1_Click(object sender, RoutedEventArgs e)
        {
            
            if (!string.IsNullOrEmpty(textBox1.Text))
            {
                if (this.rule.attributes == null)
                    this.rule.attributes = new IntelliScraper.Db.xpathSingleAttributesCollection();

                IntelliScraper.Db.xpathSingleAttributes attr = new IntelliScraper.Db.xpathSingleAttributes();
                attr.id = textBox1.Text;
                this.rule.attributes.Add(attr);

                

                Factory.Instance.Save();
                load(this.id, isFromCollection, coll);
            }
        }
        public void load()
        {
    

            if (attr == null)
            {
                attr = new IntelliScraper.Db.xpathSingleAttributes();
                attr.id = this.attrId;
            }

            cmbGrIds.Items.Clear();
            cmbGetType.Items.Clear();
            listBox2.Items.Clear();
            foreach (string v in Enum.GetNames(typeof(IntelliScraper.Db.xpathSingleAttributesGetType)))
                cmbGetType.Items.Add(v);

            //Load Process data
            List<string> ppId = new List<string>();
            foreach (var o in Factory.Instance.getAllPostProcessObj())
            {
                string _id = (string)o.GetType().GetProperty("id").GetValue(o, null);
                string type = (string)o.GetType().Name;
                string val = _id + " (" + type + ")";
                ppId.Add(val);
            }

            //Load Attributes Details
            if (this.rule != null)
            {
                if(rule.attributes != null)
                {
                    this.attr = (from x in rule.attributes where x.id == this.attrId select x).SingleOrDefault();
                    if (this.attr != null)
                    {
                        txtAttrName.Text = attr.attributeName;
                        txtId.Text = attr.id;
                        txtXpath.Text = attr.xpath;
                        cmbGetType.SelectedValue = attr.getType.ToString();
                        if (attr.getType.ToString() == "attribute")
                            txtAttrName.IsEnabled = true;

                        //remove alredy assigned rules and add to list
                        listBox1.Items.Clear();
                        if (attr.postProcessTrigger != null)
                        {
                            foreach (var pp in attr.postProcessTrigger)
                            {
                                listBox1.Items.Add(pp.id + " (" + pp.type.ToString() + ")");
                                //string val = pp.id + " (" + pp.type.ToString() + ")";
                                //ppId.Remove(val);
                            }
                        }

                        //Add Groups
                        if (attr.postProcessGroupId != null)
                        {
                            List<string> aviableGroupPpRules = new List<string>();
                            foreach (var r in rule.postProcessTriggerGroup)
                            {
                                cmbGrIds.Items.Add(r.id);
                            }


                            foreach (var s in attr.postProcessGroupId)
                            {
                                cmbGrIds.Items.Remove(s);
                                listBox2.Items.Add(s);
                            }
                           
                        }


                    }
                   
               }
            }

            cmbPp.Items.Clear();
            foreach (string p in ppId)
                cmbPp.Items.Add(p);

        }