Example #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            viewModel = new ImageSearchViewModel();

            var adapter = new ImageAdapter(this, viewModel);

            var recyclerView = FindViewById <RecyclerView>(Resource.Id.ImageRecyclerView);

            recyclerView.SetAdapter(adapter);

            var layoutManager = new GridLayoutManager(this, 2);

            recyclerView.SetLayoutManager(layoutManager);

            progressBar            = FindViewById <ProgressBar>(Resource.Id.ProgressBar);
            progressBar.Visibility = ViewStates.Gone;

            editText = FindViewById <EditText>(Resource.Id.SearchEditText);

            var clickButton = FindViewById <Button>(Resource.Id.GoButton);

            clickButton.Click += HandleButtonClicked;

            UserDialogs.Init(this);

            SupportActionBar.SetDisplayHomeAsUpEnabled(false);
            SupportActionBar.SetHomeButtonEnabled(false);
        }
Example #2
0
 /// <summary>
 /// Main Window.
 /// </summary>
 public ImageSearchWindow()
 {
     InitializeComponent();
     //Bind View model
     m_ImageSearchViewModel = new ImageSearchViewModel();
     DataContext            = m_ImageSearchViewModel;
 }
Example #3
0
        public ActionResult ImageSearch(ImageSearchViewModel imageSearchViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(this.View(imageSearchViewModel));
            }

            var imageSearchEngine = new ImageSearchEngine(new ImageSelector());

            ViewBag.ImagesDirectory = Server.MapPath("~/Content/images/");
            ViewBag.ApplicationRoot = VirtualPathUtility.ToAbsolute("~/");
            List <Walk_AssociatedFile> allImages;

            if (Request.Form["SearchImageCaption"].Length > 0)
            {
                allImages = this.repository.GetAllImagesWithCaptions().ToList();
            }
            else
            {
                allImages = this.repository.GetAllImages().ToList();
            }



            ImageSearchResults searchResults = imageSearchEngine.PerformSearch(allImages, Request.Form);

            imageSearchViewModel.ImageResultsAvailable = true;

            imageSearchViewModel.ImagesFound   = searchResults.ImagesFound.ToList();
            imageSearchViewModel.SearchSummary = searchResults.SearchSummary;

            return(this.View(imageSearchViewModel));
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            viewModel = new ImageSearchViewModel();

            CollectionViewImages.WeakDataSource = this;


            ButtonSearch.TouchUpInside += async(sender, args) =>
            {
                ButtonSearch.Enabled = false;
                ActivityIsLoading.StartAnimating();

                // iOS 빌트인 애니메이션
                await UIView.AnimateAsync(1.0, () => CollectionViewImages.Alpha = 0);

                // Shared 코드 호출
                await viewModel.SearchForImagesAsync(TextFieldQuery.Text);

                CollectionViewImages.ReloadData();

                await UIView.AnimateAsync(1.0, () => CollectionViewImages.Alpha = 1);

                ActivityIsLoading.StopAnimating();
                ButtonSearch.Enabled = true;
            };

            SetupCamera();
        }
Example #5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            //iOS Image Search code
            viewModel = new ImageSearchViewModel();
            CollectionViewImages.WeakDataSource = this;

            //Button Click event to get images
            ButtonSearch.TouchUpInside += async(sender, args) =>
            {
                ButtonSearch.Enabled = false;
                ActivityIsLoading.StartAnimating();

                await viewModel.SearchForImagesAsync(TextFieldQuery.Text);

                CollectionViewImages.ReloadData();

                ButtonSearch.Enabled = true;
                ActivityIsLoading.StopAnimating();
            };


            //IOS Keyboard Done Code
            var toolbar = new UIToolbar(new CGRect(0.0f, 0.0f, TextFieldQuery.Frame.Size.Width, 44.0f));

            toolbar.Items = new[]
            {
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate { TextFieldQuery.ResignFirstResponder(); })
            };
            TextFieldQuery.InputAccessoryView = toolbar;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            viewModel = new ImageSearchViewModel();

            CollectionViewImages.WeakDataSource = this;

            ButtonSearch.TouchUpInside += async(sender, args) =>
            {
                ButtonSearch.Enabled = false;
                ActivityIsLoading.StartAnimating();

                await viewModel.SearchForImagesAsync(TextFieldQuery.Text);

                CollectionViewImages.ReloadData();

                ButtonSearch.Enabled = true;
                ActivityIsLoading.StopAnimating();
            };


            NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Camera, async delegate
            {
                await viewModel.TakePhotoAndAnalyzeAsync(false);
            });
        }
Example #7
0
        public ImageAdapter(Activity activity, ImageSearchViewModel viewModel)
        {
            _viewModel = viewModel;
            _activity  = activity;

            _viewModel.Images.CollectionChanged += (sender, args) => _activity.RunOnUiThread(NotifyDataSetChanged);
        }
Example #8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.main);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);

            viewModel = new ImageSearchViewModel();

            //var progress = FindViewById<ProgressBar>(Resource.Id.my_progress);
            //var query = FindViewById<EditText>(Resource.Id.my_query);
            //var button = FindViewById<Button>(Resource.Id.my_button);

            //button.Click += async (sender, args) =>
            //{
            //    button.Enabled = false;
            //    progress.Visibility = ViewStates.Visible;

            //    await viewModel.SearchForImagesAsync(string.Format("cute {0}", query.Text.Trim()));

            //    progress.Visibility = ViewStates.Gone;
            //    button.Enabled = true;
            //};

            SetupMainView();
            SetupCamera();
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.main);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);


            viewModel = new ImageSearchViewModel();


            progress = FindViewById <ProgressBar>(Resource.Id.my_progress);
            query    = FindViewById <EditText>(Resource.Id.my_query);
            button   = FindViewById <Button>(Resource.Id.my_button);

            button.Click += async(sender, args) =>
            {
                viewModel.SearchForImageCommand.Execute(null);
            };


            query.Text                 = viewModel.SearchQuery;
            query.TextChanged         += (sender, args) => viewModel.SearchQuery = query.Text;
            viewModel.PropertyChanged += ViewModel_PropertyChanged;


            SetupMainView();
            SetupCamera();
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);


            viewModel = new ImageSearchViewModel();

            //Setup RecyclerView

            adapter = new ImageAdapter(this, viewModel);

            recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);

            recyclerView.SetAdapter(adapter);

            layoutManager = new GridLayoutManager(this, 2);

            recyclerView.SetLayoutManager(layoutManager);

            progressBar            = FindViewById <ProgressBar>(Resource.Id.my_progress);
            progressBar.Visibility = ViewStates.Gone;

            var query = FindViewById <EditText>(Resource.Id.my_query);

            // Get our button from the layout resource,
            // and attach an event to it
            var clickButton = FindViewById <Button>(Resource.Id.my_button);

            //Button Click event to get images

            //clickButton.Click += async (sender, args) =>
            //{
            //    clickButton.Enabled = false;
            //    progressBar.Visibility = ViewStates.Visible;

            //    await viewModel.SearchForImagesAsync(query.Text.Trim());


            //    progressBar.Visibility = ViewStates.Gone;
            //    clickButton.Enabled = true;
            //};

            clickButton.Click += async(sender, args) =>
            {
                clickButton.Enabled    = false;
                progressBar.Visibility = ViewStates.Visible;

                await viewModel.SearchForImagesAsync(query.Text.Trim());

                clickButton.Enabled    = true;
                progressBar.Visibility = ViewStates.Gone;
            };

            UserDialogs.Init(this);
            SupportActionBar.SetDisplayHomeAsUpEnabled(false);
            SupportActionBar.SetHomeButtonEnabled(false);
        }
        public DetailsPage(ImageResult result, ImageSearchViewModel viewModel)
        {
            InitializeComponent();
            this.result = result;

            this.viewModel = viewModel;
            this.viewModel.SelectedImage = result;

            BindingContext = viewModel;
        }
        private async void ContinuousRecognitionSession_ResultGenerated(SpeechContinuousRecognitionSession sender, SpeechContinuousRecognitionResultGeneratedEventArgs args)
        {
            if (!this.Completed)
            {
                try
                {
                    //sender.StopAsync();
                    //this.Completed = true;
                    sender.CancelAsync();
                }
                catch (Exception)
                {
                }
                await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    var mensaje = args.Result.Text.Replace(".", string.Empty);
                    if (mensaje.Contains("Text"))
                    {
                        mensaje = "Texto";
                    }
                    var vm = new ImageSearchViewModel();
                    // mensaje = "Texto";
                    vm.Search(mensaje);
                    if (vm.SearchResult.Count > 0)
                    {
                        Frame.Navigate(typeof(SearchListView), vm);
                    }
                    else
                    {
                        var auth       = new Authentication("713034f5c7994f089c1d5a70c1a12ede", "54c4cd393679455d90a48250cde0cfa4");
                        var token      = auth.GetAccessToken();
                        var requestUri = "https://speech.platform.bing.com/synthesize";

                        var sb = new StringBuilder();
                        sb.AppendFormat("No se han encontrado resultados de búsqueda.");

                        var cortana = new Synthesize(new Synthesize.InputOptions()
                        {
                            RequestUri         = new Uri(requestUri),
                            Text               = sb.ToString(),
                            VoiceType          = Gender.Female,
                            Locale             = "es-es",
                            VoiceName          = "Microsoft Server Speech Text to Speech Voice (en-US, ZiraRUS)",
                            OutputFormat       = AudioOutputFormat.Riff16Khz16BitMonoPcm,
                            AuthorizationToken = "Bearer " + token.access_token,
                        });

                        cortana.OnAudioAvailable += PlayAudio;
                        cortana.OnError          += ErrorHandler;
                        cortana.Speak(CancellationToken.None);
                        cortana = null;
                    }
                });
            }
        }
Example #13
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);


            viewModel = new ImageSearchViewModel();

            //Setup RecyclerView
            adapter      = new ImageAdapter(this, viewModel);
            recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);
            recyclerView.SetAdapter(adapter);
            layoutManager = new GridLayoutManager(this, 2);
            recyclerView.SetLayoutManager(layoutManager);

            progressBar            = FindViewById <ProgressBar>(Resource.Id.my_progress);
            progressBar.Visibility = ViewStates.Gone;

            var query = FindViewById <EditText>(Resource.Id.my_query);

            var clickButton = FindViewById <Button>(Resource.Id.my_button);

            clickButton.Click += async(sender, e) =>
            {
                clickButton.Enabled    = false;
                progressBar.Visibility = ViewStates.Visible;
                await viewModel.SearchForImagesAsync(query.Text.Trim());

                clickButton.Enabled    = true;
                progressBar.Visibility = ViewStates.Gone;
            };

//DEMO: 2b - Image Analysis
            //Button Click event to get images
            adapter.ItemClick += async(object sender, ImageAdapterClickEventArgs e) =>
            {
                clickButton.Enabled    = false;
                progressBar.Visibility = ViewStates.Visible;

                var result = await viewModel.GetImageDescription(viewModel.Images[e.Position].ImageLink);

                new AlertDialog.Builder(this)
                .SetTitle("Image Analysis")
                .SetMessage(result)
                .SetNeutralButton("OK", delegate { })
                .Show();

                progressBar.Visibility = ViewStates.Gone;
                clickButton.Enabled    = true;
            };

            UserDialogs.Init(this);

            SupportActionBar.SetDisplayHomeAsUpEnabled(false);
            SupportActionBar.SetHomeButtonEnabled(false);
        }
        public ActionResult Index(ImageSearchViewModel model)
        {
            if (model.SearchButton == null)
            {
                return(View());
            }

            else
            {
                return(View(new ImageSearchViewModel()));
            }
        }
Example #15
0
        public async void FillImageCells()
        {
            viewModel = new ImageSearchViewModel();
            CollectionViewImages.WeakDataSource = this;


            ActivityIsLoading.StartAnimating();

            await viewModel.SearchForImagesAsync(_query);

            CollectionViewImages.ReloadData();

            ActivityIsLoading.StopAnimating();
        }
Example #16
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            viewModel = new ImageSearchViewModel();

            _query = Intent.GetStringExtra("Query") ?? "Data not available";

            //Setup RecyclerView
            RecyclerView();

            //Get additional images
            FillImageCells();

            UserDialogs.Init(this);
            SupportActionBar.SetDisplayHomeAsUpEnabled(false);
            SupportActionBar.SetHomeButtonEnabled(false);
        }
        public DetailsPage()
        {
            InitializeComponent();
            this.result = new ImageResult
            {
                ContextLink   = "http://upload.wikimedia.org/wikipedia/commons/thumb/4/40/Capuchin_Costa_Rica.jpg/200px-Capuchin_Costa_Rica.jpg",
                FileFormat    = "jpg",
                ImageLink     = "http://upload.wikimedia.org/wikipedia/commons/thumb/4/40/Capuchin_Costa_Rica.jpg/200px-Capuchin_Costa_Rica.jpg",
                ThumbnailLink = "http://upload.wikimedia.org/wikipedia/commons/thumb/4/40/Capuchin_Costa_Rica.jpg/200px-Capuchin_Costa_Rica.jpg",
                Title         = "Capuchin"
            };

            this.viewModel = new ImageSearchViewModel
            {
                SelectedImage = this.result
            };

            BindingContext = viewModel;
        }
Example #18
0
        public async Task <IActionResult> Search(string search, int?pageNumber)
        {
            search = search ?? string.Empty;

            var images = this.User.IsInRole(GlobalConstants.MasterAdministratorRoleName) ||
                         this.User.IsInRole(GlobalConstants.AdministratorRoleName)
                ? await this.imageService.GetBySearchTermWithDeletedAsync <ImageSearchListViewModel>(search)
                : await this.imageService.GetBySearchTermAsync <ImageSearchListViewModel>(search);

            var onePageOfImages = await images.ToList()
                                  .PaginateAsync(pageNumber, GlobalConstants.ImagesOnSearchPageCount);

            var imageSearchViewModel = new ImageSearchViewModel
            {
                SearchTerm         = search,
                SearchResultImages = onePageOfImages
            };

            return(PartialView("_ImageSearchListPartial", imageSearchViewModel));
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            viewModel = new ImageSearchViewModel();

            CollectionViewImages.WeakDataSource = this;

            ButtonSearch.TouchUpInside += async(sender, args) =>
            {
                ButtonSearch.Enabled = false;
                ActivityIsLoading.StartAnimating();

                await viewModel.SearchForImagesAsync(TextFieldQuery.Text);

                CollectionViewImages.ReloadData();

                ButtonSearch.Enabled = true;
                ActivityIsLoading.StopAnimating();
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            viewModel = new ImageSearchViewModel();

            CollectionViewImages.WeakDataSource  = this;
            CollectionViewImages.AllowsSelection = true;

            CollectionViewImages.Delegate = this;

            ButtonSearch.TouchUpInside += async(sender, e) =>
            {
                ButtonSearch.Enabled = false;
                ActivityIsLoading.StartAnimating();

                await viewModel.SearchForImagesAsync(TextFieldQuery.Text);

                CollectionViewImages.ReloadData();

                ButtonSearch.Enabled = true;
                ActivityIsLoading.StopAnimating();
            };

            var cameraButton = new UIBarButtonItem(UIBarButtonSystemItem.Camera,
                                                   async(sender, e) =>
            {
                ActivityIsLoading.StartAnimating();
                await viewModel.TakePhotAsync();
                ActivityIsLoading.StopAnimating();
            });

            var pickButton = new UIBarButtonItem(UIBarButtonSystemItem.Organize,
                                                 async(sender, e) =>
            {
                ActivityIsLoading.StartAnimating();
                await viewModel.TakePhotAsync(false);
                ActivityIsLoading.StopAnimating();
            });

            this.NavigationItem.RightBarButtonItems = new UIBarButtonItem[] { cameraButton, pickButton };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            viewModel = new ImageSearchViewModel();

            CollectionViewImages.WeakDataSource = this;
            CollectionViewImages.WeakDelegate   = this;

            viewModel.Images.CollectionChanged += (sender, args) => BeginInvokeOnMainThread(() => CollectionViewImages.ReloadData());
            viewModel.PropertyChanged          += ViewModel_PropertyChanged;
            TextFieldQuery.Text            = viewModel.SearchQuery;
            TextFieldQuery.EditingChanged += (sender, args) => viewModel.SearchQuery = TextFieldQuery.Text;

            ButtonSearch.TouchUpInside += (sender, args) =>
            {
                viewModel.SearchForImageCommand.Execute(null);
            };

            SetupCamera();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var viewModel = new ImageSearchViewModel();

            var adapter = new ImageAdapter(this, viewModel);

            var recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);

            recyclerView.SetAdapter(adapter);

            var layoutManager = new GridLayoutManager(this, 2);

            recyclerView.SetLayoutManager(layoutManager);

            var progressBar = FindViewById <ProgressBar>(Resource.Id.my_progress);

            progressBar.Visibility = ViewStates.Gone;

            var query = FindViewById <EditText>(Resource.Id.my_query);

            var clickButton = FindViewById <Button>(Resource.Id.my_button);

            clickButton.Click += async(sender, args) =>
            {
                clickButton.Enabled    = false;
                progressBar.Visibility = ViewStates.Visible;

                await viewModel.SearchForImagesAsync(query.Text.Trim());

                progressBar.Visibility = ViewStates.Gone;
                clickButton.Enabled    = true;
            };

            UserDialogs.Init(this);

            SupportActionBar.SetDisplayHomeAsUpEnabled(false);
            SupportActionBar.SetHomeButtonEnabled(false);
        }
Example #23
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.main);
            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            if (toolbar != null)
            {
                SetSupportActionBar(toolbar);
            }

            viewModel = new ImageSearchViewModel();

            var progress = FindViewById <ProgressBar>(Resource.Id.my_progress);
            var query    = FindViewById <EditText>(Resource.Id.my_query);


            progress.Visibility = ViewStates.Gone;


            var clickButton = FindViewById <Button>(Resource.Id.my_button);


            clickButton.Click += async(sender, args) =>
            {
                clickButton.Enabled = false;
                progress.Visibility = ViewStates.Visible;

                await viewModel.SearchForImagesAsync(query.Text);

                progress.Visibility = ViewStates.Gone;
                clickButton.Enabled = true;
            };

            SetupMainView();
            SetupCamera();
        }
Example #24
0
 public SearchPage()
 {
     InitializeComponent();
     BindingContext = vm = new ImageSearchViewModel();
 }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);


            viewModel = new ImageSearchViewModel();

            //Setup RecyclerView

            adapter = new ImageAdapter(this, viewModel);

            recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);

            recyclerView.SetAdapter(adapter);

            layoutManager = new GridLayoutManager(this, 2);

            recyclerView.SetLayoutManager(layoutManager);

            progressBar            = FindViewById <ProgressBar>(Resource.Id.my_progress);
            progressBar.Visibility = ViewStates.Gone;

            var query = FindViewById <EditText>(Resource.Id.my_query);

            // Get our button from the layout resource,
            // and attach an event to it
            var clickButton = FindViewById <Button>(Resource.Id.my_button);


            clickButton.Click += async(sender, args) =>
            {
                clickButton.Enabled    = false;
                progressBar.Visibility = ViewStates.Visible;

                await viewModel.SearchForImagesAsync(query.Text);

                progressBar.Visibility = ViewStates.Gone;
                clickButton.Enabled    = true;
            };

            var photo = FindViewById <Button>(Resource.Id.button1);

            photo.Click += async(sender, args) =>
            {
                await viewModel.TakePhotoAndAnalyzeAsync();
            };


            adapter.ItemClick += async(sender, args) =>
            {
                clickButton.Enabled    = false;
                progressBar.Visibility = ViewStates.Visible;

                await viewModel.AnalyzeImageAsync(viewModel.Images[args.Position].ThumbnailLink);

                progressBar.Visibility = ViewStates.Gone;
                clickButton.Enabled    = true;
            };



            UserDialogs.Init(this);
            SupportActionBar.SetDisplayHomeAsUpEnabled(false);
            SupportActionBar.SetHomeButtonEnabled(false);
        }
Example #26
0
        public ActionResult ImageSearch()
        {
            var imageSearchViewModel = new ImageSearchViewModel();

            return(this.View(imageSearchViewModel));
        }