Пример #1
0
 /// <summary>
 /// take picture by camera and upload to sky dirve
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void cameraCapture_Completed(object sender, PhotoResult e)
 {
     if (e.TaskResult == TaskResult.OK)
     {
         string           msgUp    = SkyPhoto.Resources.Resources.msgUp;
         string           msgTitle = SkyPhoto.Resources.Resources.msgUpTitle;
         MessageBoxResult m        = MessageBox.Show(msgUp, msgTitle, MessageBoxButton.OKCancel);
         if (m == MessageBoxResult.OK)
         {
             // if ok uplaod to sky drive
             UploadPicture(e);
         }
         else
         {
             // if cancle save picture to gallery
             string   ext      = e.OriginalFileName.Substring(e.OriginalFileName.LastIndexOf('.'));
             DateTime dt       = DateTime.Now;
             string   fileName = String.Format("{0:d_M_yyyy_hh_mm_ss}", dt);
             fileName += ext;
             Microsoft.Xna.Framework.Media.MediaLibrary mediaLibrary = new Microsoft.Xna.Framework.Media.MediaLibrary();
             // Save the image to the saved pictures album.
             mediaLibrary.SavePicture(fileName, e.ChosenPhoto);
         }
     }
 }
Пример #2
0
        private void setupPlayerUI()
        {
            Microsoft.Xna.Framework.Media.MediaLibrary library = new Microsoft.Xna.Framework.Media.MediaLibrary();

            m_playButtonBitmap     = new BitmapImage(new Uri("/Images/" + App.CurrentTheme + "/play.png", UriKind.Relative));
            m_pauseButtonBitmap    = new BitmapImage(new Uri("/Images/" + App.CurrentTheme + "/pause.png", UriKind.Relative));
            PlayButtonImage.Source = m_playButtonBitmap;

            m_stopButtonBitmap     = new BitmapImage(new Uri("/Images/" + App.CurrentTheme + "/stop.png", UriKind.Relative));
            StopButtonImage.Source = m_stopButtonBitmap;

            m_nextButtonBitmap     = new BitmapImage(new Uri("/Images/" + App.CurrentTheme + "/ff.png", UriKind.Relative));
            NextButtonImage.Source = m_nextButtonBitmap;

            m_prevButtonBitmap     = new BitmapImage(new Uri("/Images/" + App.CurrentTheme + "/rew.png", UriKind.Relative));
            PrevButtonImage.Source = m_prevButtonBitmap;
        }
Пример #3
0
 /// <summary>
 /// WebClient event handler
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     if (CurrentPhoto != null)
     {
         try
         {
             Microsoft.Xna.Framework.Media.MediaLibrary mediaLibrary = new Microsoft.Xna.Framework.Media.MediaLibrary();
             // Save the image to the saved pictures album.
             mediaLibrary.SavePicture(CurrentPhoto.Title, e.Result);
         }
         catch (WebException we)
         {
             string downFaild = SkyPhoto.Resources.Resources.downFaild;
             MessageBox.Show(downFaild);
         }
     }
     HideProgressBar();
 }
Пример #4
0
        /// <inheritdoc />
        public async Task SaveToCameraRoll(MediaFile mediafile, bool overwrite = true)
        {
            string targetFilename = mediafile.Filename;

            this.tracer.Debug("SaveToCameraRoll with targetFilename={0}, overwrite={1}", targetFilename, overwrite);

            try
            {
                using (var mediaLibrary = new Microsoft.Xna.Framework.Media.MediaLibrary())
                {
                    mediaLibrary.SavePictureToCameraRoll(targetFilename, mediafile.GetStream());
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                throw new UnauthorizedAccessException("Make sure that you add the ID_CAP_MEDIALIB_PHOTO capability in your WmAppManifest.", ex);
            }
        }
Пример #5
0
        public static void WriteStreamToFile(System.IO.Stream stream, String filename)
        {
            Microsoft.Xna.Framework.Media.MediaLibrary library = new Microsoft.Xna.Framework.Media.MediaLibrary();

            // write to "Saved Pictures"
            if (SaveToAlbum)
            {
                stream.Position = 0;
                library.SavePicture(filename, stream);
                Console.WriteLine("Saved Image: " + filename + " to 'Saved Pictures' album");
            }

            // write to "Camera Roll"
            if (SaveToCameraRoll)
            {
                stream.Position = 0;
                library.SavePictureToCameraRoll(filename, stream);
                Console.WriteLine("Saved Image: " + filename + " to Camera Roll");
            }

            stream.Dispose();
        }
Пример #6
0
 public MediaLibrarySong ToMediaLibrarySong()
 {
     using(MediaLibrary library = new MediaLibrary()){
         return library.Songs.Where(song =>
         {
             return string.Equals(SongName, song.Name, StringComparison.InvariantCultureIgnoreCase) &&
                 string.Equals(ArtistName , song.Artist.Name, StringComparison.InvariantCultureIgnoreCase);
         }).FirstOrDefault();
     }
 }
Пример #7
0
        public void GetSongsOnDevice(object state)
        {
            Dictionary<string, AnalyzedSong> uniqueSongs =
                new Dictionary<string, AnalyzedSong>();

            using (var mediaLib = new XnaMediaLibrary())
            {
                foreach (XnaSong s in mediaLib.Songs)
                {
                    string id = string.Concat(s.Artist.Name, s.Name)
                        .Replace(" ", "");
                    uniqueSongs[id] = new AnalyzedSong
                    {
                        ItemId = id,
                        ArtistName = s.Artist.Name,
                        SongName = s.Name
                    };

                }

                SongsOnDevice.AddRange(uniqueSongs.Values
                    .OrderBy(s => s.ArtistName)
                    .ThenBy(s => s.SongName));
            }

            SongsOnDeviceLoaded = true;
            logger.Info("Completed GetSongsOnDevice");
        }
Пример #8
0
        private void btnSaveImage_Click(object sender, EventArgs e)
        {
            if (Item == null) return;
            var source = imgPhoto.Source as BitmapImage;
            if (source == null) return;

            var bmp = new WriteableBitmap(source);
            var library = new Microsoft.Xna.Framework.Media.MediaLibrary();
            var memstr = new MemoryStream();
            bmp.SaveJpeg(memstr, source.PixelWidth, source.PixelHeight, 0, 100);
            memstr.Position = 0;

            LoadingManager.Start();
            ThreadHelper.RunUniqueAsync(() =>
            {
                var succ = false;
                var error = "";
                try
                {
                    library.SavePicture("Image", memstr);

                    succ = true;
                }
                catch (Exception ex)
                {
                    error = ex.Message;
                }

                ThreadHelper.RunOnUI(() =>
                {
                    if (succ)
                    {
                        MessageBox.Show("The image is successfully saved to your phone.", "Done!", MessageBoxButton.OK);
                    }
                    else
                    {
                        MessageBox.Show("There was an error saving image to your phone.", "Failed!", MessageBoxButton.OK);
                    }

                    LoadingManager.Stop();
                });
            });
        }
 private void setupPlayerUI()
 {
     Microsoft.Xna.Framework.Media.MediaLibrary library = new Microsoft.Xna.Framework.Media.MediaLibrary();
 }
Пример #10
0
 /// <summary>
 /// take picture by camera and upload to sky dirve
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void cameraCapture_Completed(object sender, PhotoResult e)
 {
     if (e.TaskResult == TaskResult.OK)
     {
         string msgUp = SkyPhoto.Resources.Resources.msgUp;
         string msgTitle = SkyPhoto.Resources.Resources.msgUpTitle;
         MessageBoxResult m = MessageBox.Show(msgUp, msgTitle, MessageBoxButton.OKCancel);
         if (m == MessageBoxResult.OK)
         {
             // if ok uplaod to sky drive
             UploadPicture(e);
         }
         else
         {
             // if cancle save picture to gallery
             string ext = e.OriginalFileName.Substring(e.OriginalFileName.LastIndexOf('.'));
             DateTime dt = DateTime.Now;
             string fileName = String.Format("{0:d_M_yyyy_hh_mm_ss}", dt);
             fileName += ext;
             Microsoft.Xna.Framework.Media.MediaLibrary mediaLibrary = new Microsoft.Xna.Framework.Media.MediaLibrary();
             // Save the image to the saved pictures album.
             mediaLibrary.SavePicture(fileName, e.ChosenPhoto);
         }
     }
 }
Пример #11
0
        /// <summary>
        /// WebClient event handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            if (CurrentPhoto != null)
            {
                try
                {
                    Microsoft.Xna.Framework.Media.MediaLibrary mediaLibrary = new Microsoft.Xna.Framework.Media.MediaLibrary();
                    // Save the image to the saved pictures album.
                    mediaLibrary.SavePicture(CurrentPhoto.Title, e.Result);

                }
                catch (WebException we)
                {
                    string downFaild = SkyPhoto.Resources.Resources.downFaild;
                    MessageBox.Show(downFaild);
                }
            }
            HideProgressBar();
        }
Пример #12
0
 private void setupPlayerUI()
 {
     Microsoft.Xna.Framework.Media.MediaLibrary library = new Microsoft.Xna.Framework.Media.MediaLibrary();
 }
Пример #13
0
        private void setupPlayerUI()
        {
            Microsoft.Xna.Framework.Media.MediaLibrary library = new Microsoft.Xna.Framework.Media.MediaLibrary();

            m_playButtonBitmap = new BitmapImage(new Uri("/Images/" + App.CurrentTheme + "/play.png", UriKind.Relative));
            m_pauseButtonBitmap = new BitmapImage(new Uri("/Images/" + App.CurrentTheme + "/pause.png", UriKind.Relative));
            PlayButtonImage.Source = m_playButtonBitmap;

            m_stopButtonBitmap = new BitmapImage(new Uri("/Images/" + App.CurrentTheme + "/stop.png", UriKind.Relative));
            StopButtonImage.Source = m_stopButtonBitmap;

            m_nextButtonBitmap = new BitmapImage(new Uri("/Images/" + App.CurrentTheme + "/ff.png", UriKind.Relative));
            NextButtonImage.Source = m_nextButtonBitmap;

            m_prevButtonBitmap = new BitmapImage(new Uri("/Images/" + App.CurrentTheme + "/rew.png", UriKind.Relative));
            PrevButtonImage.Source = m_prevButtonBitmap;
        }
        private void setupPlayerUI()
        {
            Microsoft.Xna.Framework.Media.MediaLibrary library = new Microsoft.Xna.Framework.Media.MediaLibrary();

            m_playButtonBitmap = new BitmapImage(new Uri("/Images/play.png", UriKind.Relative));
            m_pauseButtonBitmap = new BitmapImage(new Uri("/Images/pause.png", UriKind.Relative));

            m_screenUpdateTimer.Stop();
            m_screenUpdateTimer.Interval = new TimeSpan(0, 0, 0, 0, 500); // Fire the timer every half a second.
            m_screenUpdateTimer.Tick += new EventHandler(m_screenUpdateTimer_Tick);
        }
Пример #15
0
        public static void GetSongsOnDevice(object state)
        {
            App thisApp = App.Current as App;
            List<AnalyzedSong> songs = thisApp.Model.SongsOnDevice;
            Dictionary<string, AnalyzedSong> uniqueSongs =
                new Dictionary<string, AnalyzedSong>();

            lock (songs)
            {
                using (var mediaLib = new XnaMediaLibrary())
                {
                    foreach(XnaSong s in mediaLib.Songs)
                    {
                        string id = string.Concat(s.Artist.Name, s.Name)
                            .Replace(" ", "");
                        uniqueSongs[id] = new AnalyzedSong
                        {
                            ItemId = id,
                            ArtistName = s.Artist.Name,
                            SongName = s.Name
                        };

                    }

                    songs.AddRange(uniqueSongs.Values
                        .OrderBy(s => s.ArtistName)
                        .ThenBy(s => s.SongName));
                }

                thisApp.Model.SongsOnDeviceLoaded = true;

            }
        }