Пример #1
0
        /// <summary>
        /// Returns all nested categories from a sequence of search entries.
        /// </summary>
        /// <typeparam name="TEntry"></typeparam>
        /// <param name="category"></param>
        /// <returns></returns>
        internal static IEnumerable <string> GetAllCategoryNames <TEntry>(this ISearchCategory <TEntry> category)
        {
            yield return(category.Name);

            foreach (var name in category.SubCategories.SelectMany(GetAllCategoryNames))
            {
                yield return(string.Format("{0}.{1}", category.Name, name));
            }
        }
Пример #2
0
        public SmartSearchCategory(ISearchCategory category)
        {
            this.InitializeComponent();

            this.Category        = category;
            this.headerText.Text = category.Header;

            this.Reset();
        }
Пример #3
0
 public bool AddCategory(ISearchCategory category)
 {
     foreach (SmartSearchCategory cat in this.resultsStack.Children)
     {
         if (cat.Category == category) return false;
     }
     this.resultsStack.Children.Add(new SmartSearchCategory(category));
     return true;
 }
Пример #4
0
 public bool RemoveCategory(ISearchCategory category)
 {
     for (int i = 0; i < this.resultsStack.Children.Count; i++)
     {
         if (((SmartSearchCategory)this.resultsStack.Children[i]).Category == category)
         {
             this.resultsStack.Children.RemoveAt(i);
             return true;
         }
     }
     return false;
 }
Пример #5
0
        private static void AddCategoryToXml(
            XmlNode parent, ISearchCategory <NodeSearchElement> category)
        {
            var element = XmlHelper.AddNode(parent, "Category");

            XmlHelper.AddAttribute(element, "Name", category.Name);

            foreach (var subCategory in category.SubCategories)
            {
                AddCategoryToXml(element, subCategory);
            }

            foreach (var entry in category.Entries)
            {
                AddEntryToXml(element, entry);
            }
        }