Beispiel #1
0
        // Adds the local and azure image stores when the app is first launched
        protected virtual void CreateQueryStoresOnStartup()
        {
            var appmodel = AppModel.GetModel(); // Allows access to the list of IImageStore that we have initialized with local and azure image stores

            this.QueryStores = new List <QueryImageStoreViewModel>();
            foreach (IImageStore store in appmodel.ImageStores)
            {
                QueryStores.Add(new QueryImageStoreViewModel(store, this)); // Create a ImageStoreViewModel from the IImageStore model we get from the static AppModel
            }
        }
        // Constructor that takes in the parent AppViewModel and a name for the tab
        public MainWindowViewModel(AppViewModel parent, string id, string url = "https://chasingthesunandfollowingthestars.files.wordpress.com/2011/07/half-peeled-hongmaodan.jpg")
        {
            this.Name = id;

            var appmodel = AppModel.GetModel(); // Singleton instance of AppModele

            this.searchModel        = appmodel.CreateSearchModel(this.Name);
            this.parentAppViewModel = parent;

            SetProperties(url);
            var task = this.DownloadAndSearchQueryImage(this.QueryImageUrl); // Asynchronously calls the Search task on the given url
        }
        protected virtual async Task ShowExistingSearchResponseForUrl(string downloadedQueryImagesUrl)
        {
            this.ClearSearchResultsUI();

            var m = AppModel.GetModel();

            var imageInfo = LookupQueryStores(downloadedQueryImagesUrl); // Find the url within the list of ImageStore images

            if (imageInfo == null)                                       // Unlikely as image was detected to be in store but now is not found
            {
                return;
            }

            await imageInfo.GenerateSearchResponse(); // The search response may not have been downloaded yet

            this.SearchResponse = imageInfo.SearchResponse as BingSearchResponse;

            this.RenderSearchResponse();
        }