Exemplo n.º 1
0
        /// <summary>
        /// Remvoe picture
        /// </summary>
        /// <param name="picture"></param>
        public void RemovePicture(Picture picture, RemoveType type)
        {
            //delete files
            Storage.DeleteFile(picture.Path);

            if (type == RemoveType.HardDelete)
            {
                //delete record
                baseData.Pictures.Remove(picture);
                this.Save();
                OnPropertyChanged("PicturesCount");
                OnPropertyChanged("Pictures");
            }

            OnPropertyChanged("AvailableSpace");
        }
Exemplo n.º 2
0
 /// <summary>
 /// Add picture
 /// </summary>
 /// <param name="picture"></param>
 public void AddPicture(Picture picture)
 {
     baseData.Pictures.Add(picture);
     this.Save();
     OnPropertyChanged("PicturesCount");
     OnPropertyChanged("Pictures");
     OnPropertyChanged("AvailableSpace");
 }
Exemplo n.º 3
0
        /// <summary>
        /// Picture save event
        /// </summary>
        private void triggerPictureSave(Picture picture)
        {
            if (this.PictureSave != null)
            {
                PictureSaveEventArgs args = new PictureSaveEventArgs();
                args.Picture = picture;

                this.PictureSave.Invoke(this, args);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// On image capture complete
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void triggerCaptureImage(object sender, CaptureImageCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                return;
            }

            var name = this.getFileName("jpg");
            Picture picture = new Picture();
            picture.Path = name;
            picture.Time = DateTime.Now;
            picture.Rotated = this.Orientation == PageOrientation.LandscapeRight;
            picture.Backup = new BackupInfo();

            var wb = e.Result;
            var stream = Storage.CreateFile(picture.Path);
            wb.SaveJpeg(stream, wb.PixelWidth, wb.PixelHeight, 0, 60);
            stream.Close();

            if (this.IsRecording) {
                this.video.Preview = name;
            } else {
                this.triggerPictureSave(picture);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Set brush
        /// </summary>
        /// <param name="value"></param>
        private void setBrush(Picture value)
        {
            BitmapImage img = null;
            IsolatedStorageFileStream stream = null;
            if (Storage.FileExists(value.Path)) 
            {
                stream = Storage.OpenFile(value.Path, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
                try
                {
                    img = new BitmapImage();
                    img.SetSource(stream);
                }
                catch
                {
                    stream.Dispose();
                    this.downloadBackup();
                }
            }
            else
            {
                this.downloadBackup();
            }
            this.Brush = img;
            //dispose
            if (stream != null)
            {
                stream.Dispose();
            }

        }