public CatalogsResultViewModel(VirtualObservatoryResponseBase result, VirtualObservatorySearchRequest request)
     : this()
 {
     _request = request as CatalogSearchRequest;
     CatalogSearchResult catalogsResult = result as CatalogSearchResult;
     _catalogs = catalogsResult.Catalogs;
 }
Exemple #2
0
        internal static UserControl PrepareView(VirtualObservatoryResponseBase result, VirtualObservatorySearchRequest request, SearchType searchType)
        {
            UserControl ret = null;

            if(searchType == SearchType.ObjectSearch)
            {
                VirtualObservatoryObjects<CelestialObject> _objectsResult = result as VirtualObservatoryObjects<CelestialObject>;

                if(_objectsResult == null)
                {
                    ret = new ObjectsDetailsView();
                    ObjectsDetailsViewModel exactModel = new ObjectsDetailsViewModel(null, request);
                    ret.DataContext = exactModel;

                    return ret;
                }
                else if(_objectsResult.Objects != null && _objectsResult.Objects.Count > 0)
                {
                    if(_objectsResult.Objects.Count == 1)
                    {
                        ret = new ObjectsDetailsView();
                        ObjectsDetailsViewModel exactModel = new ObjectsDetailsViewModel(_objectsResult.Objects.First(), request);
                        ret.DataContext = exactModel;
                    }
                    else
                    {
                        ret = new ObjectListView();
                        ObjectSearchResult res = _objectsResult as ObjectSearchResult;
                        ObjectListViewModel listViewModel = new ObjectListViewModel(res, request);
                        ret.DataContext = listViewModel;
                    }
                }
            }
            else if (searchType == SearchType.CatalogSearch)
            {
                ret = new CatalogSearchResultsView();
                CatalogsResultViewModel catalogsModel = new CatalogsResultViewModel(result, request);
                ret.DataContext = catalogsModel;
            }

            return ret;
        }
 public PageableCatalogResultViewModel(VirtualObservatoryResponseBase result, VirtualObservatorySearchRequest request)
 {
     _request = request as CatalogSearchRequest;
     CatalogSearchResult catalogsResult = result as CatalogSearchResult;
     _catalogs = new PageableCollection<Catalog>(catalogsResult.Catalogs);
 }