Example #1
0
 public void RemoveLastFilter()
 {
     if (CanUndo)
     {
         FilterModel listFilter = FilterList[FilterList.Count - 1];
         for (int i = 0; i < listFilter.Components.Count; i++)
         {
             _filters.RemoveAt(_filters.Count - 1);
         }
         FilterList.RemoveAt(FilterList.Count - 1);
     }
 }
Example #2
0
 private void btnFilterDelete_Click(object sender, RoutedEventArgs e)
 {
     if (lstFilter.SelectedValue != null && lstFilterOverview.SelectedValue != null)
     {
         for (var i = 0; i < FilterList.Count; i++)
         {
             if (FilterList[i] == lstFilter.SelectedValue)
             {
                 FilterList.RemoveAt(i);
                 break;
             }
         }
     }
 }
Example #3
0
        /// <summary>
        /// Update filter text list (in combobox)
        /// </summary>
        /// <param name="inputText"></param>
        static void UpdateFilterTextList(String inputText)
        {
            // TODO ignore not hit
            // TODO how to count items after filter?

            /*
             * if (0 == this.mainViewList.Count) {
             *  return;
             * }*/

            // delete ignore chars
            String workText = Regex.Replace(inputText, "[ |\t|\r|\n]", "");
            String testText = workText.ToLower();

            if (String.IsNullOrWhiteSpace(workText))
            {
                return;
            }

            // check already exists?
            Boolean isExist = false;

            foreach (String text in FilterList)
            {
                if (text.ToLower().Equals(testText))
                {
                    isExist = true;
                    break;
                }
            }
            if (isExist)
            {
                return;
            }

            // check similar text
            // 1. workText:"abc" / textInList:"abcd" => workText is ignore
            // 2. workText:"abc" / textInList:"ab"   => delete textInList, add workText (at first element)
            // 3. other: add workText (at first element), delete old list (list count > max)

            Boolean isAdd       = true;
            int     removeIndex = -1;

            for (int i = 0; i < FilterList.Count; i++)
            {
                String targetText = FilterList[i].ToLower();
                // pattern 1: ignore
                if (targetText.StartsWith(testText))
                {
                    isAdd = false;
                    break;
                }
                // pattern 2: delete and add
                if (testText.StartsWith(targetText))
                {
                    // delete textInList
                    removeIndex = i;
                    break;
                }
            }
            if (-1 != removeIndex)
            {
                FilterList.RemoveAt(removeIndex);
            }
            if (isAdd)
            {
                FilterList.Insert(0, workText);
            }
            if (FilterList.Count > Constants.MAX_COUNT_FILTER_LIST)
            {
                FilterList.RemoveAt(FilterList.Count - 1);
            }

            ///update setting
            List <String> newList = new List <string>();

            newList.AddRange(FilterList);
            Properties.Settings.Default.FilterTextList = newList;
        }