public static ImageUploadManager UploadImage(ImageWallServiceClient client, ImageModel model, IEnumerable<string> tags, string author, double latitude, double longitude)
        {
            try {
                // Gets image buffer
                var buffer = ImageUploadHelper.GetBuffer(model.ImageStream);

                // Create hash for image
                string hash = ImageUploadHelper.GetHash(buffer);

                // Build image details
                var details = new ImageDetails() {
                    Name = System.IO.Path.GetFileName(model.Name),
                    Hash = hash,
                    Tags = new ObservableCollection<string>(tags),
                    UserId = author,
                    Created = DateTime.Now,
                    Latitude = latitude,
                    Longitude = longitude,

                    Size = buffer.Length,
                    Extension = System.IO.Path.GetExtension(model.Name)
                };

                // Begin upload with upload manager
                var manager = new ImageUploadManager(buffer, details);
                manager.BeginUploadAsync();
                return manager;
            }
            catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine(ex);
                return null;
            }
        }
        public ImageUploadManager(byte[] data, ImageDetails details)
        {
            this.data = data;
            this.detail = details;

            // Calculate number of packets to send
            this.numberOfPackets = (int)Math.Ceiling((float)this.data.Length / ImageUploadHelper.PacketSize);

            // Create client and event handles
            this.client = new ImageWallServiceClient();
            this.client.UploadImagePartCompleted += HandleUploadImagePartCompleted;
            this.client.BeginImageUploadCompleted += HandleBeginImageUploadComplete;
        }
        private void locationProvider_OnLocationCoordinateChanged(object sender, LocationChangedEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine(e.LocationCoordinate.ToString());

            this.latitude = e.LocationCoordinate.Latitude;
            this.longitude = e.LocationCoordinate.Longitude;

            ImageWallServiceClient client = new ImageWallServiceClient();
            client.GetNearbyTagsCompleted += ClientGetNearbyTagsCompleted;
            client.GetNearbyTagsAsync(e.LocationCoordinate.Latitude, e.LocationCoordinate.Longitude, 0.05);
        }
Esempio n. 4
0
 private void MainViewLoaded(object sender, RoutedEventArgs e)
 {
     try {
         this.client = new ImageWallServiceClient();
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message);
     }
 }