public async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Pictures.Clear();

                var service         = DependencyService.Get <IRateApplication>();
                var directory       = service.GetStorageDirectory();
                var audioRecordings = System.IO.Path.Combine(directory, "Audio");

                var movies = System.IO.Directory.GetFiles(audioRecordings);
                foreach (var item in movies)
                {
                    var fi = new System.IO.FileInfo(item);

                    var name = fi.Name;
                    if (name.Contains("PocketPro - "))
                    {
                        name = name.Substring(name.IndexOf(" - ") + 3);
                        name = name.Substring(0, name.IndexOf("."));
                        var timestamp = DateTime.TryParseExact(name, "yyyyMMdd_HHmmss", CultureInfo.InvariantCulture, DateTimeStyles.None, out var Date);

                        Pictures.Add(new Media()
                        {
                            Path  = item,
                            Title = fi.Name,
                            Type  = MediaType.Audio,
                            Size  = fi.Length.ToBytesCount(),
                            Date  = Date.ToString("HH:mm tt, MMMM dd")
                        });
                    }
                }

                var items = await Datastores.Pictures.GetItemsAsync(true);

                foreach (var item in items)
                {
                    Pictures.Add(item);
                }

                OnPropertyChanged("NoItems");
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Ejemplo n.º 2
0
        public virtual void AddMedia(Guid pictureId)
        {
            if (Pictures.Any(x => x.PictureId == pictureId))
            {
                Pictures.RemoveAll(x => x.PictureId == pictureId);
            }

            Pictures.Add(new ProductPicture(Id, pictureId));
        }
Ejemplo n.º 3
0
        public virtual ArtistPictureFile CreatePicture(string name, string mime, User author)
        {
            var f = new ArtistPictureFile(name, mime, author, this);

            Pictures.Add(f);

            log.Info(string.Format("{0} created {1}", author, f));

            return(f);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Captures a frame from the camera preview and saves the photo
        /// </summary>
        /// <returns></returns>
        public async Task <SoftwareBitmap> CaptureFrameAsync()
        {
            try
            {
                if (!(await this.frameProcessingSemaphore.WaitAsync(250)))
                {
                    return(null);
                }

                var myPictures = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures);

                StorageFile file = await myPictures.SaveFolder.CreateFileAsync($"photo-{DateTime.Now.ToString("yyyy-MM-dd-hh-m-s")}.jpg", CreationCollisionOption.GenerateUniqueName);

                var lowLagCapture = await _mediaCapture.PrepareLowLagPhotoCaptureAsync(ImageEncodingProperties.CreateUncompressed(MediaPixelFormat.Bgra8));

                var capturedPhoto = await lowLagCapture.CaptureAsync();

                var softwareBitmap = capturedPhoto.Frame.SoftwareBitmap;

                await lowLagCapture.FinishAsync();

                //Save image to disk
                using (var filestream = await file.OpenAsync(FileAccessMode.ReadWrite))
                {
                    // Create an encoder with the desired format
                    BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, filestream);

                    encoder.SetSoftwareBitmap(softwareBitmap);
                    await encoder.FlushAsync();

                    // Create SoftwareBitmapSource and save to Pictures collection if available
                    if (Pictures != null)
                    {
                        softwareBitmap = SoftwareBitmap.Convert(softwareBitmap, BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied);
                        var softwareBitmapSource = new SoftwareBitmapSource();
                        await softwareBitmapSource.SetBitmapAsync(softwareBitmap);

                        Pictures.Add(new BitmapWrapper(softwareBitmap, softwareBitmapSource));
                    }
                }

                return(softwareBitmap);
            }
            catch (Exception ex)
            {
                //TODO Handle the exception
            }
            finally
            {
                this.frameProcessingSemaphore.Release();
            }

            return(null);
        }
Ejemplo n.º 5
0
 public void Reset(IPage page)
 {
     Pictures.Clear();
     foreach (var picture in page.Pictures)
     {
         var editablePicture = new EditablePicture();
         editablePicture.Reset(picture);
         Pictures.Add(editablePicture);
     }
     Layout = page.Layout;
 }
Ejemplo n.º 6
0
 private void GetPictures()
 {
     for (int i = 0; i < JPGPicture.ImagesString.Count; i++)
     {
         jPGPicture.Parse(JPGPicture.ImagesString[i]);
         MyImages myImages = new MyImages();
         var      stream   = new MemoryStream(jPGPicture.ByteArrayListOfImages[i], 0, jPGPicture.ByteArrayListOfImages[i].Length);
         myImages.Picture = ImageSource.FromStream(() => stream);
         Pictures.Add(myImages);
     }
 }
Ejemplo n.º 7
0
        public void Scan(string pathToLocalDataBase)
        {
            var files = Directory.GetFiles(pathToLocalDataBase, "*.bmp");

            foreach (var file in files)
            {
                var model = Creator <PictureModel> .Create(file.ToLowerInvariant());

                Pictures.Add(model);
            }
        }
Ejemplo n.º 8
0
        private void LoadCardsToBorder()
        {
            Rectangles.Clear();
            Pictures.Clear();
            int widht  = 8;
            int height = 8;

            PexesoService.StartPexeso(height, widht);
            int x   = 2;
            int y   = 2;
            int row = 0;

            foreach (var a in PexesoService.GameCards)
            {
                Canvas.SetLeft(a.Img, x);
                Canvas.SetTop(a.Img, y);
                // Rectangle
                SolidColorBrush pomCo = new SolidColorBrush()
                {
                    Color   = Colors.Black,
                    Opacity = 1
                };
                SolidColorBrush pomCoB = new SolidColorBrush()
                {
                    Color = Colors.BlueViolet
                };
                Rectangle pomR = new Rectangle()
                {
                    Width  = PexesoService.PictureWidth,
                    Height = PexesoService.PictureHeight,
                    Fill   = pomCo,
                    Stroke = pomCoB,
                };
                Canvas.SetLeft(pomR, x);
                Canvas.SetTop(pomR, y);
                Rectangles.Add(pomR);
                Pictures.Add(a.Img);

                a.PositionX = x;
                a.PositionY = y;
                a.Status    = StatusCardEnum.Covered;
                x          += PexesoService.PictureWidth + 5;
                if (Pictures.Count % widht == 0)
                {
                    row++;
                    x  = 2;
                    y += PexesoService.PictureHeight + 5;
                }
                if (row == height)
                {
                    break;
                }
            }
        }
Ejemplo n.º 9
0
        public virtual AlbumPictureFile CreatePicture(string name, string mime, User author)
        {
            var f = new AlbumPictureFile(name, mime, author, this);

            Pictures.Add(f);

            if (CoverPicture == null)
            {
                CoverPicture = f;
            }

            return(f);
        }
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Pictures.Clear();

                var service         = DependencyService.Get <IRateApplication>();
                var directory       = service.GetStorageDirectory();
                var moviesDirectory = System.IO.Path.Combine(directory, "Movies");

                var movies = System.IO.Directory.GetFiles(moviesDirectory);
                foreach (var item in movies)
                {
                    var fi = new System.IO.FileInfo(item);
                    if (fi.FullName.EndsWith(".mp4"))
                    {
                        Pictures.Add(new Media()
                        {
                            Path      = item,
                            ThumbPath = $"{fi.FullName.Replace(".mp4", String.Empty)}.png",
                            Title     = fi.Name,
                            Type      = MediaType.Picture
                        });
                    }
                }

                var items = await Datastores.Pictures.GetItemsAsync(true);

                foreach (var item in items)
                {
                    Pictures.Add(item);
                }

                OnPropertyChanged("NoItems");
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        private void CollectImages(string path)
        {
            var directoryInfo = new DirectoryInfo(path);

            if (directoryInfo.Exists)
            {
                var files = directoryInfo.GetFiles("*.jpg");

                foreach (var fileInfo in files)
                {
                    Pictures.Add(new Picture(fileInfo.FullName));
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        ///     Loads the users pictures from the webserver
        /// </summary>
        /// <param name="controller">The controller which Monobehaviour's used in the request</param>
        /// <param name="onComplete">The method to fire when the loading is done</param>
        public void LoadPictures(MonoBehaviour controller, Action <FileProtocolQueue> onComplete = null)
        {
            Pictures.Clear();
            var fileQueue = new FileProtocolQueue(onComplete, www => Pictures.Add(www.texture));

            foreach (var imageName in ImageNames)
            {
                fileQueue.Attach(new FileProtocol(Protocol.Download, controller)
                                 .Target("finder")
                                 .For(ProfileInfo.PlayerUID)
                                 .AddParameter("name", imageName) as FileProtocol);
            }
            fileQueue.Commit();
        }
Ejemplo n.º 13
0
        void IPortfolioDataSource.AddPicture(Picture picture)
        {
            if (picture.PictureId != 0)
            {
                var entry = Pictures.Find(picture.PictureId);
                Entry <Picture>(entry).CurrentValues.SetValues(picture);

                SaveChanges();
                return;
            }

            Pictures.Add(picture);
            SaveChanges();
        }
Ejemplo n.º 14
0
        public void AttachPicture(Guid pictureId)
        {
            var picture = new ProductPicture
            {
                ProductId = Id,
                PictureId = pictureId
            };

            Pictures.Add(picture);

            var @event = new ProductPictureAddedDomainEvent(Id, picture.PictureId);

            AddDomainEvent(@event);
        }
Ejemplo n.º 15
0
        public int ExtractPicturesFromDescription()
        {
            int insert_index = 0;

            if (LongDescription != null)
            {
                string[] imgs = LongDescription.Split(new string[] { "<img " }, StringSplitOptions.RemoveEmptyEntries);
                if (imgs.Length > 1)
                {
                    for (int i = 1; i < imgs.Length; i++)
                    {
                        string[] src = imgs[i].Split(new string[] { "src=" }, StringSplitOptions.None);
                        if (src.Length > 1)
                        {
                            string[] path = src[1].Split(new char[] { '"' });
                            {
                                if (path.Length > 2)
                                {
                                    if (path[1].Length > 10)
                                    {
                                        bool duplicate = false;
                                        foreach (GeocachePicture gp in Pictures)
                                        {
                                            string cs1 = gp.Path;
                                            string cs2 = path[1];
                                            cs1 = cs1.Substring(cs1.Length - 10, 10);
                                            cs2 = cs2.Substring(cs2.Length - 10, 10);
                                            if (cs1.Equals(cs2))
                                            {
                                                duplicate = true;
                                            }
                                        }
                                        if (!duplicate)
                                        {
                                            GeocachePicture p = new GeocachePicture();
                                            p.OriginalPath = path[1];
                                            p.Path         = path[1];
                                            Pictures.Add(p); //.Insert(insert_index, p);
                                            insert_index++;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(insert_index);
        }
Ejemplo n.º 16
0
        public TourView(Tour tour)
        {
            this.ID           = tour.ID;
            this.Name         = tour.Name;
            this.PriceUSD     = tour.PriceUSD;
            this.PriceEUR     = (decimal)this.PriceUSD * CurrencyConvert("USD", "EUR");
            this.PriceUAH     = (decimal)this.PriceUSD * CurrencyConvert("USD", "UAH");
            this.Days_Program = new List <string>();
            Day_Connection current_day = tour.Day_Connection1;

            while (true)
            {
                Days_Program.Add(current_day.Day.Description);
                current_day = tour.Day_Connection.FirstOrDefault(c => c.DayID == current_day.NextDayID);
                if (current_day == null)
                {
                    break;
                }
            }


            this.Route = new List <string>();
            Route_Connection current_route_connection = tour.Route_Connection1;

            while (current_route_connection.NextConnectionID != tour.StartConnectionID)
            {
                Route.Add(current_route_connection.TourLocation.Map);
                current_route_connection = tour.Route_Connection.FirstOrDefault(r => r.ID == current_route_connection.NextConnectionID);
                if (current_route_connection == null)
                {
                    break;
                }
            }

            this.Description = tour.Description;
            this.FoodType    = tour.FoodType.Description;

            this.Pictures = new List <string>();
            foreach (var p in tour.Picture)
            {
                Pictures.Add(p.PicturePath);
            }

            this.TourDate = new List <DateTime?>( );
            foreach (var d in tour.TourDate)
            {
                this.TourDate.Add(d.StartDate);
            }
        }
        public void AddPicture(Model.Picture picture)
        {
            XML.MediaXML mediaXML = new XML.MediaXML();

            mediaXML.Load("pictures.xml");
            if (!mediaXML.HasMedia(picture.Path))
            {
                mediaXML.Add(picture.Path, picture.Stream);
                mediaXML.WriteInFile("pictures.xml");

                if (picture.Name.Contains(this._SearchInput))
                {
                    Pictures.Add(picture);
                }
                PicturesTmp.Add(picture);
            }
        }
Ejemplo n.º 18
0
        public SamplePicturesViewModel()
        {
            var picture   = new BitmapImage(new Uri("ms-appx:///Assets/Logo.png"));
            var thumbnail = new BitmapImage(new Uri("ms-appx:///Assets/SmallLogo.png"));

            Pictures.Add(new PictureModel
            {
                Caption   = "Picture One",
                Picture   = picture,
                Thumbnail = thumbnail
            });
            //Pictures.Add(new PictureModel
            //{
            //    Caption = "Picture Two",
            //    Picture = picture,
            //    Thumbnail = thumbnail
            //});
        }
Ejemplo n.º 19
0
 public void AddOrUpdatePictures(ICollection <Picture> aPictureCollection)
 {
     if (aPictureCollection != null && aPictureCollection.Count > 0)
     {
         foreach (var item in aPictureCollection)
         {
             var existItem = Pictures.FirstOrDefault(p => p.UId == item.UId);
             if (existItem == null)
             {
                 Pictures.Add(item);
             }
             else
             {
                 existItem.Update(item.PictureId, item.UseType);
             }
         }
     }
 }
Ejemplo n.º 20
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Pictures.Clear();
                var service           = DependencyService.Get <IRateApplication>();
                var directory         = service.GetStorageDirectory();
                var picturesDirectory = System.IO.Path.Combine(directory, "Pictures");
                var pictures          = System.IO.Directory.GetFiles(picturesDirectory);
                foreach (var item in pictures)
                {
                    var fi = new System.IO.FileInfo(item);

                    Pictures.Add(new Media()
                    {
                        Path = item, Title = fi.Name, Type = MediaType.Picture
                    });
                }

                var items = await Datastores.Pictures.GetItemsAsync(true);

                foreach (var item in items)
                {
                    Pictures.Add(item);
                }

                OnPropertyChanged("NoItems");
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public void FindPicture()
        {
            WebClient webClient = new WebClient();
            string    result    = webClient.DownloadString("https://www.imdb.com" + this.MovieId);

            int startsWith = result.IndexOf("titleImageStrip");  //herbir castın başında bu item olduğundan başlangıç noktası bu olarak alınır

            if (startsWith == -1)
            {
                return;
            }
            result = result.Substring(startsWith);
            int endsWith = result.IndexOf("</div>");

            result = result.Substring(0, endsWith);

            string name, url;


            while (result.IndexOf("alt") != -1)
            {
                startsWith = result.IndexOf("alt");
                result     = result.Substring(startsWith);
                startsWith = result.IndexOf('"');
                result     = result.Substring(startsWith + 1);
                endsWith   = result.IndexOf('"');

                name = result.Substring(0, endsWith);

                startsWith = result.IndexOf("loadlate=");
                result     = result.Substring(startsWith);
                startsWith = result.IndexOf('"');
                result     = result.Substring(startsWith + 1);
                endsWith   = result.IndexOf('"');

                url = result.Substring(0, endsWith);

                Picture Picture = new Picture(name, url);

                Pictures.Add(Picture);
            }
        }
Ejemplo n.º 22
0
        private void AddImagesMethod()
        {
            OpenFileDialog op = new OpenFileDialog();

            op.Multiselect = true;
            op.Title       = "Choisir une image";
            op.Filter      = "All supported graphics|*.jpg;*.jpeg;*.png|" +
                             "JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" +
                             "Portable Network Graphic (*.png)|*.png";
            if (op.ShowDialog() == true)
            {
                foreach (var file in op.FileNames)
                {
                    MemoryStream      memStream = new MemoryStream();
                    JpegBitmapEncoder encoder   = new JpegBitmapEncoder();
                    encoder.Frames.Add(BitmapFrame.Create(new BitmapImage(new Uri(file))));
                    encoder.Save(memStream);
                    Pictures.Add(memStream.ToArray());
                }
            }
        }
Ejemplo n.º 23
0
        async Task CargarImagenesCompatiblesAsync()
        {
            try
            {
                List <FileInfo> lista = await Task.Run(() => ListarImagenesCompatibles());

                for (int i = 0; i < lista.Count; i++)
                {
                    Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        Pictures.Add(new Picture(lista[i], i));
                        if (CurrentPicture.Path.Equals(lista[i].FullName))
                        {
                            CurrentPicture = Pictures[i];
                        }
                    }));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 24
0
        public void AddPicture(ProductPicture picture)
        {
            if (Pictures == null)
            {
                Pictures = new List <ProductPicture>();
            }

            if (Pictures.Any(p => p.Position == picture.Position))
            {
                foreach (var productPicture in Pictures.Where(p => p.Position >= picture.Position))
                {
                    productPicture.IncreasePosition();
                }
            }

            Pictures.Add(picture);
            if (picture.Position == 0)
            {
                Picture = picture.Url;
            }

            PicturesCount = Pictures.Count;
        }
Ejemplo n.º 25
0
        private void Description_DragDrop(System.Windows.DragEventArgs args)
        {
            if (!args.Data.GetDataPresent(typeof(WriteableBitmap)))
            {
                return;
            }
            var data = args.Data.GetData(typeof(WriteableBitmap)) as BitmapSource;

            if (data == null)
            {
                return;
            }
            var fe = args.OriginalSource as FrameworkElement;

            if (fe == null)
            {
                return;
            }

            var img = new MoviePicture(data);

            Pictures.Add(img);
        }
Ejemplo n.º 26
0
        public void Init(Event evnt)
        {
            SelectedEvent = evnt;
            Pictures.Remove(p => true);
            Participate = SelectedEvent.Participate;

            var imageSourceLocations = _pictureSaver.GetPicturesFromDisk(SelectedEvent.IdForFileSystem).ToList();

            if (imageSourceLocations.Count >= 1)
            {
                HeaderPicture = new Picture(imageSourceLocations.Last());

                foreach (var imageSourceLocation in imageSourceLocations)
                {
                    Pictures.Insert(0, new Picture(imageSourceLocation));
                }
            }
            else
            {
                HeaderPicture = new Picture("journey3");
                Pictures.Add(new Picture("pictureDefault"));
            }
        }
Ejemplo n.º 27
0
 public void InsertPicture(Picture pix)
 {
     Pictures.Add(pix);
 }
Ejemplo n.º 28
0
 public void AddPicture(Picture picture)
 {
     picture.ItemId = Id;
     Pictures.Add(picture);
 }
Ejemplo n.º 29
0
 /// <summary>
 /// 往工作类里面添加图片以及代号
 /// </summary>
 /// <param name="key">代号,默认为每个listbox的代号</param>
 /// <param name="filePath">完整的图片路径</param>
 public static void AddPicture(int key, string filePath)
 {
     Pictures.Remove(key);
     Pictures.Add(key, filePath);
 }
Ejemplo n.º 30
0
 public void AddPicture(ProfilePicture picture)
 {
     Pictures ??= new List <ProfilePicture>();
     Pictures.Add(picture);
     PicturesCount = Pictures?.Count ?? 0;
 }