コード例 #1
0
        /// <summary>
        /// Clear all of the searches and go to the Top List without any chosen results
        /// </summary>
        public void ClearSearches()
        {
            AllSearches.Clear();
            var newSearch = new SearchVM();

            AllSearches.Add(newSearch);
            CurrentSearch = newSearch;
            CurrentSearch.GoToTopList();
        }
コード例 #2
0
        /// <summary>
        /// Switch to another search. Search must be present in AllSearches already
        /// </summary>
        /// <param name="switchTo">Search to switch to</param>
        public void SwitchToSearch(SearchVM switchTo)
        {
            if (AllSearches.Contains(switchTo))
            {
                var currSearch = CurrentSearch;
                CurrentSearch = switchTo;

                if (String.IsNullOrWhiteSpace(currSearch.CurrentText))
                {
                    AllSearches.Remove(currSearch);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Initiate a new ListVM
        /// </summary>
        public ListVM()
        {
            WillLogout    = String.IsNullOrEmpty(App.StartupArgs.SessionToken);
            RememberUser  = App.RememberMe;
            CurrentSearch = new SearchVM();
            AllSearches   = new ObservableCollection <SearchVM>();
            AllSearches.Add(CurrentSearch);

            SearchOkCmnd    = new ActionCommand(() => NewSearch(SearchTerms));
            SearchListsCmnd = new ActionCommand(GoToTopList);

            CopyToClipboardCmd = new ActionCommand(CopyToClipboard);

            SwitchToSearchCmd = new ActionCommand <SearchVM>(SwitchToSearch);

            ClearSearchesCmd = new ActionCommand(ClearSearches);

            GoToTopList();
        }
コード例 #4
0
 /// <summary>
 /// Prepare a new search, using either the current search if not currently already selected, or creating a new search VM
 /// </summary>
 /// <param name="perform">Action to perform on the appropriate search VM</param>
 private void PrepareNewSearch(Action <SearchVM> perform)
 {
     if (String.IsNullOrWhiteSpace(CurrentSearch.CurrentText))
     {
         if (perform != null)
         {
             perform(CurrentSearch);
         }
     }
     else
     {
         var newSearch = new SearchVM();
         AllSearches.Add(newSearch);
         CurrentSearch = newSearch;
         if (perform != null)
         {
             perform(newSearch);
         }
     }
 }
コード例 #5
0
        /// <summary>
        /// Convert Child items into new ViewModel Items
        /// </summary>
        /// <param name="inItems">Children items to convert</param>
        /// <param name="parentVM">ListVM object that is the highest parent</param>
        /// <param name="itemParentVM">The parent Item's ViewModel</param>
        /// <returns>New range of ListItemVM objects for the children</returns>
        public static IEnumerable <ListItemVM> GetChildItems(IEnumerable <IcdCodeItem> inItems, SearchVM parentVM, ListItemVM itemParentVM)
        {
            var useParentTitle = new List <string>();

            if (itemParentVM != null)
            {
                useParentTitle.AddRange(itemParentVM.ParentTitle);
                useParentTitle.Add(itemParentVM.Title.Title);
            }

            var resultGroups = from child in inItems
                               group child by child.Code.ChildType;


            var directChildren = (from result in resultGroups
                                  where result.Key == IcdCodeStrings.ChildType_Direct
                                  from ret in result
                                  select ret).ToList();

            if (directChildren.Count > 0)
            {
                yield return(new ListItemVM(0, IcdCodeItemMethods.NewDividerItem(SpecificityString), Enumerable.Empty <string>())
                {
                    ParentVM = parentVM,
                    ParentItemVM = itemParentVM
                });

                foreach (var child in directChildren)
                {
                    yield return(new ListItemVM(0, child, useParentTitle)
                    {
                        ParentVM = parentVM,
                        ParentItemVM = itemParentVM
                    });
                }
                yield break;
            }

            foreach (var type in ChildTypes)
            {
                var currChildren = (from result in resultGroups
                                    where result.Key == type.Key
                                    from ret in result
                                    select ret).ToList();
                if (currChildren.Count > 0)
                {
                    yield return(new ListItemVM(0, IcdCodeItemMethods.NewDividerItem(type.Value), Enumerable.Empty <string>())
                    {
                        ParentVM = parentVM,
                        ParentItemVM = itemParentVM
                    });

                    foreach (var child in currChildren)
                    {
                        yield return(new ListItemVM(0, child, Enumerable.Empty <string>())
                        {
                            ParentVM = parentVM,
                            ParentItemVM = itemParentVM
                        });
                    }
                }
            }
        }