Пример #1
0
        private void save()
        {
            string resultMsg = "Filter haven't created";

              if (txtFilterName.Text == "")
              {
            MessageBox.Show("You must type filter name", "Warning");
              }
              else
              {
            if (editMode == EditModes.CreateNew) //save new filter
            {
              if (radioBasicFilter.Checked)
              {
            ITag selected_tag = ((TagBriefInfoForCmb)cmbTag.SelectedItem).getTag();
            IOperator selected_operator = ((OperationBriefInfo)cmbOperator.SelectedItem).getOperator();

            //create basic filter
            IFilter filter = new BasicFilter(txtFilterName.Text, selected_tag, selected_operator, txtValue.Text);
            Data.insertFilter(filter);
            resultMsg = "Created 1 basic filter";
              }
              else if (rbCombinedFilter.Checked)
              {
            resultMsg = "Created 1 combined filter";
            createCombinedFilter();
              }
              else if (rbNotFilter.Checked)
              {

            IFilter selected_filter1 = ((FilterBriefInfoForCmb)cmbFilterOfNotFilter.SelectedItem).getFilter();

            IFilter newFilter = new Filter_NOT(txtFilterName.Text, selected_filter1);
            Data.insertFilter(newFilter);
            resultMsg = "Created 1 NOT filter";

              }
            }
            else if (editMode == EditModes.EditOld) //save edited filter
            {
              if (rbNotFilter.Checked)
              {

            IFilter selected_filter1 = ((FilterBriefInfoForCmb)cmbFilterOfNotFilter.SelectedItem).getFilter();
            ((Filter_NOT)editedFilter).edit(selected_filter1);
            resultMsg = "Updated 1 NOT filter: " + editedFilter.Name;

              }
              else if (radioBasicFilter.Checked)
              {
            ITag selected_tag = ((TagBriefInfoForCmb)cmbTag.SelectedItem).getTag();
            IOperator selected_operator = ((OperationBriefInfo)cmbOperator.SelectedItem).getOperator();
            ((BasicFilter)editedFilter).edit(txtFilterName.Text, selected_tag, selected_operator, txtValue.Text);
            resultMsg = "Updated 1 Basic filter: " + editedFilter.Name;
              }
              else if (rbCombinedFilter.Checked)
              {
            Data.removeFilter(editedFilter);
            createCombinedFilter();
            resultMsg = "Updated 1 Combined filter: " + editedFilter.Name;
              }
            }
              }
              MessageBox.Show(resultMsg);
              updateScreen();
        }
Пример #2
0
        void demoTaoNotFilter()
        {
            //lay tag
              IEnumerator<ITag> arrTag = Data.getTagCollection().GetEnumerator();
              arrTag.MoveNext();
              ITag fromTag = arrTag.Current;

              //tao operator
              IOperator strContainOper = StringContaining.getInstance();

              AbstractFilter basicFilter = new BasicFilter("From 9", fromTag, strContainOper, "9");
              IFilter notFilter = new Filter_NOT("Not from 9", basicFilter);
              //thu apply cac filter cho email

              foreach (IEmail e in Data.getEmailCollection())
              {
            if (notFilter.apply(e))
              MessageBox.Show("tim thay roi:" + fromTag.getEmailTag(e));
              }
        }