private void SwitchCategory(object sender, RoutedEventArgs e) { Button s = (Button)sender; Toolcat cat = (Toolcat)Enum.Parse(typeof(Toolcat), s.Name, true); RenderItems(cat); TbSearch.Text = ""; }
private void RenderItems(Toolcat Category, string searchtext = null, bool noanim = false) { if (!_loaded) { return; } View.Children.Clear(); List <ToolBase> list; if (!string.IsNullOrEmpty(searchtext)) { list = (from i in _tools where i.Description.ToLower().Contains(searchtext.ToLower()) orderby i.Description ascending select i).ToList(); RenderList(list); return; } if (!noanim) { WpfHelpers.FindStoryBoard(this, "Change").Begin(); } int counter = 0; switch (Category) { case Toolcat.All: list = (from i in _tools orderby i.Description ascending select i).ToList(); counter += RenderList(list); Header.Text = string.Format("Tools ({0})", counter); break; case Toolcat.Favorites: var items = (from i in _tools where App._Config.UsageStats.ContainsKey(i.Description) orderby App._Config.UsageStats[i.Description] descending select i); counter += RenderList(items.ToList()); counter += RenderBooks("**fav**"); Header.Text = string.Format("Most used ({0})", counter); break; case Toolcat.Analog: list = (from i in _tools where i.Category == ToolCategory.Analog orderby i.Description ascending select i).ToList(); counter += RenderList(list); Header.Text = string.Format("Analog Tools ({0})", counter); break; case Toolcat.Digital: list = (from i in _tools where i.Category == ToolCategory.Digital orderby i.Description ascending select i).ToList(); counter += RenderList(list); Header.Text = string.Format("Digital Tools ({0})", counter); break; case Toolcat.Other: list = (from i in _tools where i.Category == ToolCategory.Other orderby i.Description ascending select i).ToList(); counter += RenderList(list); Header.Text = string.Format("Other Tools ({0})", counter); break; case Toolcat.Web: list = (from i in _tools where i.Category == ToolCategory.Web orderby i.Description ascending select i).ToList(); counter += RenderList(list); Header.Text = string.Format("Web Tools ({0})", counter); break; case Toolcat.External: list = (from i in _tools where i.Category == ToolCategory.External orderby i.Description ascending select i).ToList(); counter += RenderList(list); Header.Text = string.Format("External Programs ({0})", counter); break; case Toolcat.Books: counter += RenderBooks(); Header.Text = string.Format("Books ({0})", counter); break; } }