예제 #1
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Show graphics profiling information while debugging.
            //if (System.Diagnostics.Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are being GPU accelerated with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;
            }

            // Standard Silverlight initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();


            var apiKey = App.Current.Resources["apiKey"] as string;

            if (String.IsNullOrEmpty(apiKey))
            {
                DispatcherSynchronizationContext.Current.Post((s) =>
                {
                    MessageBox.Show("Please enter your Flickr API key in app.xaml");
                }, null
                                                              );
                return;
            }

            FlickrClient.Initialize(apiKey, "");
            Flickr = FlickrClient.Current;

            ProgressBar pb = new ProgressBar();

            pb.Height = 20;

            RootFrame.HeaderContent = pb;

            Binding pbBinding = new Binding("IsLoading");

            pbBinding.Source = DataManager.Current;
            pb.SetBinding(ProgressBar.IsIndeterminateProperty, pbBinding);

            DataManager.ShouldCollectStatistics = true;
        }
예제 #2
0
        public FlickrBoxContext(FlickrClient client)
        {
            if (!client.Authenticated)
            {
                throw new ArgumentException("Client has to be authenticated!");
            }

            Client = client;

            init();
        }
        public async Task PhotosetsGetPhotos_Fail()
        {
            var client = new FlickrClient(new FlickrClientOptions
            {
                // incorrect api_key
                ApiKey     = "etAZ7DrhMq2yqTtWxTNWKbQnwpPmGxZn",
                UserId     = "118310678@N03",
                PhotosetId = "72157641322954544"
            });

            var result = await client.GetPhotosAsync();

            Assert.NotNull(result.ErrorMessage);
        }
예제 #4
0
        public Gallery()
        {
            InitializeComponent();

            _flickrclient = new FlickrClient();
            _flickrclient.SearchCompleted += new EventHandler<SearchCompletedEventArgs>(flickrClient_SearchCompleted);
            _flickrsearch = new FlickrSearch.FlickrSearch()
            {
                ApiKey = _flickrapikey,
                Page = 1,
                PerPage = _resultsperpage,
                Text = "landscape"
            };

            //        _flickrclient.SearchAsync(_flickrsearch);

            PhotoList.GestureDetected += new ScrollView.GestureDetectedHandler(PhotoList_GestureDetected);
        }
        public async Task PhotosetsGetPhotos_Success()
        {
            var client = new FlickrClient(new FlickrClientOptions
            {
                ApiKey     = Defaults.API_KEY,
                UserId     = "118310678@N03",
                PhotosetId = "72157641322954544"
            });

            var result = await client.GetPhotosAsync();

            Assert.Null(result.ErrorMessage);
            Assert.NotNull(result.Photos);

            if (result.Photos.Count > 0)
            {
                Assert.NotNull(result.Photos[0].Title);
            }
        }
예제 #6
0
        static void Main(string[] args)
        {
            var apiKey      = ConfigurationSettings.AppSettings["apiKey"];
            var secret      = ConfigurationSettings.AppSettings["sharedSecret"];
            var authKeyPath = System.IO.Path.Combine("auth.key");

            FlickrClient client;

            if (!File.Exists(authKeyPath))
            {
                client = new FlickrClient(apiKey, secret);
                var auth = new FlickrAuthentication(client);

                Console.WriteLine("Please authenticate flickrbox and press a return");
                Process.Start(auth.AuthenticationUrl);

                Console.ReadLine();

                client.Authenticate(auth);

                File.WriteAllText(authKeyPath, auth.Token);

                Console.WriteLine("Authenticated!");
            }
            else
            {
                var token = File.ReadAllText(authKeyPath);
                client = new FlickrClient(apiKey, secret, token);
                Console.WriteLine("Already authenticated!");
            }

            var context = new FlickrBoxContext(client);


            Console.ReadLine();
        }
        internal static async Task Main(string[] args)
        {
            FlickrPhotosetsGetPhotosResult flickrResult;

            using (var flickrClient = new FlickrClient(_flickrClientOptions))
                flickrResult = await flickrClient.GetPhotosAsync();

            if (!flickrResult.IsOk)
            {
                Error("An error occurred while getting the list of photos from Flickr API");
                Error(flickrResult.ErrorMessage);
                return;
            }

            Info("Successfully received the list of photos from Flickr API");
            Info($"Count of photos: {flickrResult.Photos.Count}");

            if (flickrResult.Photos.Count == 0)
            {
                Error("List of photos is empty");
                return;
            }

            var context = new MongoDbContext("mongodb://localhost");
            var i       = 0;

            using (var faceClient = new FacePlusPlusClient(_faceClientOptions))
                foreach (var photo in flickrResult.Photos)
                {
                    Console.Write("Processing - " + ++i);
                    if (await context.Photos.Find(p => p.Name == photo.Title).AnyAsync())
                    {
                        Info(" '" + photo.Title + " already Exist'");
                        continue;
                    }

                    var faceResult = await faceClient.GetEmotionsForPhotoAsync(photo.Photo('c'));

                    if (!faceResult.IsOk)
                    {
                        Error($"Error occurred while processing photo named {photo.Title}");
                        Error(faceResult.ErrorMessage);
                        return;
                    }

                    var emotions = new List <Emotion>();
                    foreach (var emotion in faceResult.Emotions)
                    {
                        emotions.Add(new Emotion
                        {
                            Fear      = emotion.Fear,
                            Anger     = emotion.Anger,
                            Disgust   = emotion.Disgust,
                            Neutral   = emotion.Neutral,
                            Sadness   = emotion.Sadness,
                            Surprise  = emotion.Surprise,
                            Happiness = emotion.Happiness
                        });
                    }

                    await context.Photos.InsertOneAsync(new DBPhotoModel
                    {
                        Name     = photo.Title,
                        Url      = photo.Photo(),
                        Emotions = emotions
                    });

                    Info(" '" + photo.Title + " Added'");
                }

            Console.ForegroundColor = ConsoleColor.Green;
            Info("All data ready! :)");
            Console.ForegroundColor = ConsoleColor.Gray;
        }
예제 #8
0
 public GalleryDownloader()
 {
     photos = new List <Texture2D>();
     client = new FlickrClient(this);
 }