예제 #1
0
 private void NewMediaHandler(object sender, NewMediaEventArgs e)
 {
     foreach (var media in e.Media)
     {
         Media.Add(new SelectableMediaFile(media));
     }
 }
예제 #2
0
        public async Task OnGetAsync()
        {
            MediaTagsClient mtc = new MediaTagsClient();

            if (!string.IsNullOrEmpty(SearchString))
            {
                var tagsResult = await mtc.QueryTagsAsync(SearchString);

                HashSet <int> mediaIds = new HashSet <int>(tagsResult);

                foreach (int mediaId in mediaIds)
                {
                    var m = await mtc.GetMediaAsync(mediaId);

                    IList <TagDTO> Tags = new List <TagDTO>();
                    MediaDTO       md   = new MediaDTO();
                    md.Id            = m.Id;
                    md.Creation_Date = m.Creation_Date;
                    md.Description   = m.Description;
                    md.Path          = m.Path;
                    Media.Add(md);
                }
                resultNumber = Media.Count;
            }
        }
        public EnregistrementPatrimoineViewModel(INavigation navigation)
        {
            _navigation     = navigation;
            _patrimoine     = new Patrimoine();
            _typePatrimoine = new TypePatrimoine();



            _multiMediaPickerService = DependencyService.Get <IMultiMediaPickerService>();

            EnregistrementCommand = new Command(async() => await EnregistrementDuBien());
            AnnulerCommand        = new Command(async() => await Annuler());


            SelectImagesCommand = new Command(async(obj) =>
            {
                var hasPermission = await CheckPermissionsAsync();
                if (hasPermission)
                {
                    Media = new ObservableCollection <Patrimoine>();
                    await _multiMediaPickerService.PickPhotosAsync();
                }
            });

            _multiMediaPickerService.OnMediaPicked += (s, a) =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    Media.Add(a);
                });
            };

            FetchTypePatrimoine();
        }
예제 #4
0
        public async void SelectImagesCommandExecute()
        {
            await CrossMedia.Current.Initialize();

            Media.Clear();
            if (!CrossMedia.Current.IsPickPhotoSupported)
            {
                await Application.Current.MainPage.DisplayAlert("Photos Not Supported", ":( Permission not granted to photos.", "OK");

                return;
            }
            var picked = await CrossMedia.Current.PickPhotosAsync();

            if (picked == null)
            {
                return;
            }
            foreach (var file in picked)
            {
                //Media.Add(file);
                Device.BeginInvokeOnMainThread(() =>
                {
                    Media.Add(file);
                });
            }
        }
        public MainViewModel(IMultiMediaPickerService multiMediaPickerService)
        {
            _multiMediaPickerService = multiMediaPickerService;
            SelectImagesCommand      = new Command(async(obj) =>
            {
                var hasPermission = await CheckPermissionsAsync();
                if (hasPermission)
                {
                    Media = new ObservableCollection <MediaFile>();
                    await _multiMediaPickerService.PickPhotosAsync();
                }
            });

            SelectVideosCommand = new Command(async(obj) =>
            {
                var hasPermission = await CheckPermissionsAsync();
                if (hasPermission)
                {
                    Media = new ObservableCollection <MediaFile>();

                    await _multiMediaPickerService.PickVideosAsync();
                }
            });

            _multiMediaPickerService.OnMediaPicked += (s, a) =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    Media.Add(a);
                });
            };
        }
예제 #6
0
        private void AddToTimeKeyCollection(MessagesRow row)
        {
            var date         = TLUtils.ToDateTime(row.Message1.Date);
            var yearMonthKey = new DateTime(date.Year, date.Month, 1);
            var timeKeyGroup = Media.FirstOrDefault(x => x.Key == yearMonthKey);

            if (timeKeyGroup != null)
            {
                timeKeyGroup.Add(row);
            }
            else
            {
                Media.Add(new TimeKeyGroup <MessagesRow>(yearMonthKey)
                {
                    row
                });
            }
        }
예제 #7
0
        public virtual Medium AddNewPresentation(Medium presentation)
        {
            if (Media.Any(a => a.Id == presentation.Id))
            {
                throw new ArgumentException("Cannot add duplicate presentation to group.", "presentation");
            }

            presentation.TrackingState = TrackingState.Added;
            Media.Add(presentation);

            // MarkConflictingAppointments();

            var groupUpdatedEvent = new GroupUpdatedEvent(this);

            DomainEvents.Raise(groupUpdatedEvent);

            return(presentation);
        }
예제 #8
0
        private async void OnImageScanned(object sender, EventArgs e)
        {
            var args = e as DeviceImageScannedEventArgs;

            await Application.Current.Dispatcher.BeginInvoke(new Action(async() =>
            {
                var media = new Media()
                {
                    Size = args.ImageBytes.Length,
                    Page = args.Page,
                    Source = await ImageConverter.ConvertToImageSource(args.ImageBytes)
                };



                Media.Add(media);
            }), System.Windows.Threading.DispatcherPriority.Normal);
        }
예제 #9
0
        public PlayerDetailViewModel(Player player = null)
        {
            Title  = player?.FirstName + " Profil";
            Player = player;
            _multiMediaPickerService = DependencyService.Get <IMultiMediaPickerService>();

            SelectImagesCommand = new Command(async(obj) =>
            {
                var hasPermission = await CheckPermissionsAsync();
                if (hasPermission)
                {
                    Media          = new ObservableCollection <MediaFile>();
                    var mediaFiles = await _multiMediaPickerService.PickPhotosAsync();

                    foreach (var mediaFile in mediaFiles)
                    {
                        Media.Add(mediaFile);
                    }
                }
            });

            SelectVideosCommand = new Command(async(obj) =>
            {
                var hasPermission = await CheckPermissionsAsync();
                if (hasPermission)
                {
                    Media          = new ObservableCollection <MediaFile>();
                    var mediaFiles = await _multiMediaPickerService.PickVideosAsync();

                    foreach (var mediaFile in mediaFiles)
                    {
                        Media.Add(mediaFile);
                    }
                }
            });

            _multiMediaPickerService.OnMediaPicked += (s, a) =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    Media.Add(a);
                });
            };
        }
예제 #10
0
        public async Task GetMedia()
        {
            try
            {
                IReadOnlyList <StorageFile> files =
                    await GetMediaFromFolder(_location, CommonFileQuery.OrderByName);

                if (files.Count > 0)
                {
                    await DispatchHelper.InvokeAsync(() => HasNoMedia = false);
                }
                else
                {
                    await DispatchHelper.InvokeAsync(() => HasNoMedia = true);
                }

                int j = 0;
                foreach (StorageFile storageFile in files)
                {
                    var mediaVM = new MediaViewModel(storageFile);
                    await mediaVM.Initialize();

                    // Get back to UI thread
                    await DispatchHelper.InvokeAsync(() =>
                    {
                        Media.Add(mediaVM);
                        int i = new Random().Next(0, files.Count - 1);
                        if (j < 5 && i <= (files.Count - 1) / 2)
                        {
                            MediaRandom.Add(mediaVM);
                            j++;
                        }
                        MediaGroupedByAlphabet = Media.OrderBy(x => x.AlphaKey).GroupBy(x => x.AlphaKey);
                        ExecuteSemanticZoom();
                    });
                }
            }
            catch
            {
            }
        }
예제 #11
0
        public void Parse(FilterType filter, string value) //Stars
        {
            switch (filter)
            {
            case FilterType.Stars:
            {
                Filtrate <byte>(SharedData.Database.Song.Select(s => (byte)s.Duration).ToList(), byte.Parse(value))
                .ToList().ForEach(s => Media.Add(SharedData.Database.Song.Where(song => song.Duration == s).FirstOrDefault()));
            } break;

            case FilterType.Title:
            {
                Filtrate <string>(SharedData.Database.Song.Select(s => s.Name).ToList(), value)
                .ToList().ForEach(s => Media.Add(SharedData.Database.Song.Where(song => song.Name == s).FirstOrDefault()));
            } break;

            case FilterType.Count:
            {
                Filtrate <int>(SharedData.Database.Song.Select(s => s.Counter).ToList(), int.Parse(value))
                .ToList().ForEach(s => Media.Add(SharedData.Database.Song.Where(song => song.Counter == s).FirstOrDefault()));
            } break;

            case FilterType.Duration:
            {
                Filtrate <int>(SharedData.Database.Song.Select(s => (int)s.Duration).ToList(), int.Parse(value))
                .ToList().ForEach(s => Media.Add(SharedData.Database.Song.Where(song => song.Duration == s).FirstOrDefault()));
            } break;

            case FilterType.Favourite:
            {
                Filtrate <bool>(SharedData.Database.Song.Select(s => (bool)s.Favourite).ToList(), bool.Parse(value))
                .ToList().ForEach(s => Media.Add(SharedData.Database.Song.Where(song => song.Favourite == s).FirstOrDefault()));
            } break;

            default:     // Artist
            {
                Filtrate <string>(SharedData.Database.Song.Select(s => s.Artist.Name).ToList(), value)
                .ToList().ForEach(s => Media.Add(SharedData.Database.Song.Where(song => song.Artist.Name == s).FirstOrDefault()));
            } break;
            }
        }
예제 #12
0
        public JsonResult Upload(HttpPostedFileBase file)
        {
            if (file != null)
            {
                Media media = new Media()
                {
                    file     = file,
                    savePath = Server.MapPath(GetMediaPath())
                };

                Image image = media.Add();

                var jsonImage = new
                {
                    image.id,
                    image.file_dir,
                    image.filename
                };

                return(Json(jsonImage));
            }

            return(Json("false"));
        }
예제 #13
0
        /// <summary>
        /// Parses the specified SDP.
        /// </summary>
        /// <param name="sdp">The input SDP text.</param>
        public void Parse(string sdp)
        {
            sdp = sdp.Replace("\r\n", "\n");
            sdp = sdp.Replace("\r", "\n");
            sdp = sdp.Trim();
            foreach (String line in sdp.Split('\n'))
            {
                //Per line parsing
                string[] values        = line.Split("=".ToCharArray(), 2);
                string   k             = values[0];
                string   currentObject = "";
                switch (k)
                {
                case "o":
                    Originator    = new SDPOriginator(values[1]);
                    currentObject = Originator.ToString();
                    break;

                case "c":
                    Connection    = new SDPConnection(values[1]);
                    currentObject = Connection.ToString();
                    break;

                case "m":
                {
                    SDPMedia currentMedia = new SDPMedia(values[1]);
                    Media.Add(currentMedia);
                    currentObject = currentMedia.ToString();
                }
                break;

                default:
                    currentObject = values[1];
                    break;
                }

                if (k == "m")
                {
                    SDPMedia obj = Media.Last();
                }
                else if (Media.Count > 0)
                {
                    SDPMedia obj = Media.Last();
                    if (k == "a" && values[1].StartsWith("rtpmap:"))
                    {
                        string[] split      = values[1].Remove(0, 7).Split(" ".ToCharArray(), 2);
                        string   pt         = split[0];
                        string[] rest       = split[1].Split("/".ToCharArray(), 2);
                        string   name       = rest[0];
                        string   rate       = null;
                        string   parameters = null;
                        if (rest.Length > 1)
                        {
                            string[] final = rest[1].Split("/".ToCharArray(), 2);
                            rate = final[0];

                            parameters = null;
                            if (final.Length > 1)
                            {
                                parameters = final[1];
                            }
                        }

                        foreach (SDPMediaFormat f in obj.Mediaformats)
                        {
                            if (f.Pt == pt)
                            {
                                f.Name = name;
                                if (rate != null)
                                {
                                    f.Rate = rate;
                                }
                                if (parameters != null)
                                {
                                    f.Parameters = parameters;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (!Multiple.Contains(k))
                        {
                            obj.OtherAttributes.Add(k, currentObject);
                        }
                        else
                        {
                            if (!obj.OtherAttributes.ContainsKey(k))
                            {
                                obj.OtherAttributes.Add(k, currentObject);
                            }

                            //TODO HANDLE multiple attributes of the same type;
                            //if (obj.properties.ContainsKey(k))
                            //{
                            //    obj[k, true].Add(current_attribute);
                            //}
                            //else
                            //{
                            //    obj[k, true] = new List<AttributeClass>();
                            //    obj[k, true].Add(current_attribute);
                            //}
                        }
                    }
                }
                else
                {
                    if (k != "o" && k != "c")
                    {
                        SDP obj = this;
                        if (!Multiple.Contains(k))
                        {
                            obj.Other.Add(k, currentObject);
                        }
                        else
                        {
                            obj.Other.Add(k, currentObject);
                            //TODO HANDLE multiple attributes of the same type;
                            //if (obj.properties.ContainsKey(k))
                            //{
                            //    obj[k, true].Add(current_attribute);
                            //}
                            //else
                            //{
                            //    obj[k, true] = new List<AttributeClass>();
                            //    obj[k, true].Add(current_attribute);
                            //}
                        }
                    }
                }
            }
        }
        public async Task <IActionResult> OnGetAsync(string code, string state)
        {
            _logger.LogInformation("Auth/OAuth for state [{state}] returned the code [{code}]", state, code);

            try
            {
                var response = HttpContext.Session.Get <OAuthResponse>(Strings.SessionKey) ?? await _api.AuthenticateAsync(code, state).ConfigureAwait(false);

                if (response == null)
                {
                    Message = "OAutResponse is null. Redirecting to login page";
                    return(RedirectToLoginPage());
                }

                var media = await _api.GetMediaListAsync(response).ConfigureAwait(false);

                _logger.LogInformation("Initial media response returned with [{count}] records ", media.Data.Count);
                Media.Add(media);

                //
                //  TODO: toggle the following boolean for a quick and dirty way of getting all a user's media.
                //
                if (true)
                {
                    while (!string.IsNullOrWhiteSpace(media?.Paging?.Next))
                    {
                        var next  = media?.Paging?.Next;
                        var count = media?.Data?.Count;
                        _logger.LogInformation("Getting next page [{next}]", next);

                        media = await _api.GetMediaListAsync(next).ConfigureAwait(false);

                        _logger.LogInformation("next media response returned with [{count}] records ", count);

                        Media.Add(media);
                    }
                }

                Code     = code;
                State    = state;
                UserInfo = response.User;
                HttpContext.Session.Set(Strings.SessionKey, response);

                Message = $"{UserInfo.Username} has connected to Instagram successfully.";
            }
            catch (InstagramOAuthException ex)
            {
                Message = $"InstagramOAuthException! {ex.Message} ";
                _logger.LogError(ex, "Instagram OAuth error - instagram response message : [{message}] error_type : [{type}] error_code : [{code}] fb_trace [{fbTrace}]", ex.Message, ex.ErrorType, ex.ErrorCode, ex.FbTraceId);
            }
            catch (InstagramApiException ex)
            {
                Message = $"InstagramApiException! {ex.Message} ";
                _logger.LogError(ex, "Instagram API error - instagram response message : [{message}] error_type : [{type}] error_code : [{code}] error_sub_code : [{subCode}] fb_trace [{fbTrace}]", ex.Message, ex, ex.StackTrace, ex.Message, ex.ErrorType, ex.ErrorCode, ex.ErrorSubcode, ex.FbTraceId);
            }
            catch (InstagramException ex)
            {
                Message = $"InstagramException! {ex.Message} ";
                _logger.LogError(ex, "General Instagram error - instagram response message : [{message}] error_type : [{type}] error_code : [{code}] fb_trace [{fbTrace}]", ex.Message, ex, ex.StackTrace, ex.Message, ex.ErrorType, ex.ErrorCode, ex.FbTraceId);
            }
            catch (Exception ex)
            {
                Message = $"Exception! {ex.Message} ";
                _logger.LogError(ex, "Unknown exception calling with message [{message}] and exception [{ex}] and stack [{stack}]", ex.Message, ex, ex.StackTrace);
            }

            return(Page());
        }
예제 #15
0
        public MainViewModel(IMultiMediaPickerService multiMediaPickerService)
        {
            //Am nevoie de un singur element in lista, pentru

            numberOfHiddenPhotos = "+0";


            var aa = new FourMediaFileModel()
            {
                Path1        = "/data/user/0/com.crossgeeks.MultiMediaPickerSample/files/TmpMedia/IMG-20200725-WA0002_37.jpg",
                PreviewPath1 = "/data/user/0/com.crossgeeks.MultiMediaPickerSample/files/TmpMedia/IMG-20200725-WA0002-THUMBNAIL_37.jpg",

                Path2        = "/data/user/0/com.crossgeeks.MultiMediaPickerSample/files/TmpMedia/IMG-20200724-WA0004_2.jpg",
                PreviewPath2 = "/data/user/0/com.crossgeeks.MultiMediaPickerSample/files/TmpMedia/IMG-20200724-WA0004-THUMBNAIL_2.jpg",

                Path3        = "/data/user/0/com.crossgeeks.MultiMediaPickerSample/files/TmpMedia/20200718_104804_1.jpg",
                PreviewPath3 = "/data/user/0/com.crossgeeks.MultiMediaPickerSample/files/TmpMedia/20200718_104804-THUMBNAIL_1.jpg",

                Path4        = "/data/user/0/com.crossgeeks.MultiMediaPickerSample/files/TmpMedia/20200714_171640.jpg",
                PreviewPath4 = "/data/user/0/com.crossgeeks.MultiMediaPickerSample/files/TmpMedia/20200714_171640-THUMBNAIL.jpg"
            };


            MediaToBeGrouped.Add(aa);



            ShowFullImageCommand = new Command(ShowFullImage);


            _multiMediaPickerService = multiMediaPickerService;

            //PageAppearingCommand = new Command(PageAppearing);
            //PageDisappearingCommand = new Command(PageDisappearing);

            SelectImagesCommand = new Command(async(obj) =>
            {
                var hasPermission = await CheckPermissionsAsync();
                if (hasPermission)
                {
                    Media = new ObservableCollection <MediaFile>();
                    await _multiMediaPickerService.PickPhotosAsync();
                }
            });

            SelectVideosCommand = new Command(async(obj) =>
            {
                var hasPermission = await CheckPermissionsAsync();
                if (hasPermission)
                {
                    Media = new ObservableCollection <MediaFile>();

                    await _multiMediaPickerService.PickVideosAsync();
                }
            });

            _multiMediaPickerService.OnMediaPicked += (s, a) =>
            {
                //Device.BeginInvokeOnMainThread(() =>
                //{
                Media.Add(a);

                //});

                // MediaToBeGrouped.Add(a);
            };
        }
예제 #16
0
        public BrowseMediaViewModel(INavigation navigation)
        {
            this.Navigation = navigation;

            _multiMediaPickerService = ServiceContainer.Resolve <IMultiMediaPickerService>();
            database = ServiceContainer.Resolve <IDatabase>();
            Media    = new ObservableCollection <MediaDetails>();

            Tags = new string[]
            {
                "Object 1",
                "Object 2",
                "Object 3",
                "Object 4"
            };

            SelectImagesCommand = new Command(async(obj) =>
            {
                popupDisplaying = true;
                Media           = new ObservableCollection <MediaDetails>();
                await _multiMediaPickerService.PickPhotosAsync();
                popupDisplaying = false;
            });

            SelectVideosCommand = new Command(async(obj) =>
            {
                popupDisplaying = true;
                Media           = new ObservableCollection <MediaDetails>();
                await _multiMediaPickerService.PickVideosAsync();
                popupDisplaying = false;
            });

            RemoveImageCommand = new Command <MediaDetails>((obj) =>
            {
                FileHelper.DeleteLocalFiles(obj);
                Media.Remove(obj);
            });

            CompleteCommand = new Command(async(obj) =>
            {
                if (popupDisplaying)
                {
                    return;
                }

                foreach (var item in Media)
                {
                    if (!string.IsNullOrEmpty(SelectedTag))
                    {
                        item.Tags = new Common.Models.TagArea[] { new Common.Models.TagArea()
                                                                  {
                                                                      Id = SelectedTag
                                                                  } }
                    }
                    ;                                                                                                                         // TEMP

                    item.Location = new GeoLocation(10, 10);
                    database.SaveItem(item);
                }
            });

            _multiMediaPickerService.OnMediaPicked += (s, a) =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    Media.Add(a);
                });
            };
        }
예제 #17
0
        public FlujoViewModel(User usuario)
        {
            Globals.FlujoViewModelInstance = this;
            Usuario = usuario;
            MultiMediaPickerService = Globals.MultiMediaPickerService;
            RepositoryService       = Globals.RepositoryService;

            AddPhotoCommand = new Command((obj) =>
            {
                Plugin.Media.Abstractions.MediaFile mediaFile = obj as Plugin.Media.Abstractions.MediaFile;
                if (mediaFile == null)
                {
                    return;
                }

                if (Media == null)
                {
                    Media = new ObservableCollection <XGaleryPhotos.Models.MediaFile>();
                }

                Media.Add(new MediaFile()
                {
                    Id          = Guid.NewGuid().ToString(),
                    Type        = MediaFileType.Image,
                    Path        = mediaFile.Path,
                    PreviewPath = mediaFile.Path
                }
                          );
            });

            BuscarFlujoCommand = new Command((obj) =>
            {
                string flujoNro = obj as string;
                Flujo           = RepositoryService.GetFlujoByNro(flujoNro);
            });

            EnviarOnBaseCommand = new Command((obj) =>
            {
                Globals.RepositoryService.UpdateFotos(Flujo, Usuario.UserName);
            });

            PhotoTappedCommand = new Command((obj) =>
            {
                var mediaSelected = obj as XGaleryPhotos.Models.MediaFile;
                Globals.RepositoryService.AddMediaFile(mediaSelected);
                Globals.PhotoDisplayPageInstance.ResetSource();
                Globals.NavegacionPageInstance.PushAsync(Globals.PhotoDisplayPageInstance);
            });

            SelectImagesCommand = new Command(async(obj) =>
            {
                var hasPermission = await CheckPermissionsAsync();
                if (hasPermission)
                {
                    if (Media == null)
                    {
                        Media = new ObservableCollection <XGaleryPhotos.Models.MediaFile>();
                    }
                    await MultiMediaPickerService.PickPhotosAsync();
                }
            });

            MultiMediaPickerService.OnMediaPicked += (s, a) =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    Media.Add(a);
                });
            };
        }