private void SetImagePageCombo(SelectedMedia media = null) { using (ControlTransaction.Update(ImagePageCombo)) { ImagePageCombo.Enabled = false; foreach (SelectedMedia oldMedia in ImagePageCombo.Items) { if (oldMedia == null || oldMedia == media) { continue; } DisposeMediaItem(oldMedia.Item); } ImagePageCombo.Items.Clear(); if (media == null) { media = new SelectedMedia("1"); } ImagePageCombo.Items.Add(media); ImagefilePathText.Text = media.Path; AlternativeTextBox.Text = media.AltText; ImagePageCombo.SelectedIndex = 0; } }
private async Task RemoveMedia(MediaFileModel mediaFile) { _mediaToDelete.Add(mediaFile); var fileHelper = DependencyService.Get <IFileHelper>(); fileHelper.DeleteFile(mediaFile.Path); SelectedMedia.Remove(mediaFile); SetMediaHeight(); }
public async void AddAudio() { if (((App)App.Current).AudioRecording != null) { var recording = new MediaFileModel(((App)App.Current).AudioRecording.Path, LocalRecordId, MediaFileModel.MediaType.Audio); SelectedMedia.Add(recording); OnPropertyChanged(nameof(SelectedMedia)); ((App)App.Current).AudioRecording = null; } }
private async Task SelectAudio() { var statusStorage = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage); if (statusStorage != PermissionStatus.Granted) { if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Storage)) { await Application.Current.MainPage.DisplayAlert("Benötige Speicher-Berechtigung", "Zum Speichern von Fundmeldungen, Bildern und Audiodateien wird die Speicher-Berechtigung benötigt.", "Okay"); } var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Storage }); statusStorage = results[Permission.Storage]; } if (statusStorage == PermissionStatus.Granted) { var allowedType = new string[1]; switch (Device.RuntimePlatform) { case Device.Android: allowedType[0] = "audio/*"; break; case Device.iOS: allowedType[0] = "UTType.Audio"; break; default: break; } var fileData = await CrossFilePicker.Current.PickFile(allowedType); if (fileData == null) { return; // user canceled file picking } var fileHelper = DependencyService.Get <IFileHelper>(); var file = fileHelper.CopyFileToApp(fileData.FilePath); SelectedMedia.Add(new MediaFileModel(file.Path, LocalRecordId, MediaFileModel.MediaType.Audio)); SetMediaHeight(); } }
private void SetImagePageCombo(SelectedMedia media = null) { using (ControlTransaction.Update(ImagePageCombo)) { ImagePageCombo.Enabled = false; ImagePageCombo.Items.Clear(); if (media != null) { ImagePageCombo.Items.Add(media); ImagefilePathText.Text = media.Path; } else { ImagePageCombo.Items.Add(new SelectedMedia("1")); ImagefilePathText.Text = ""; } ImagePageCombo.SelectedIndex = 0; } }
private async Task SelectPhoto() { try { var statusPhotos = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Photos); var statusStorage = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage); if (statusPhotos != PermissionStatus.Granted) { if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Photos)) { await Application.Current.MainPage.DisplayAlert("Benötige Foto-Berechtigung", "Zum Auswählen von Bildern wird die Foto-Berechtigung benötigt.", "Okay"); } var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Photos }); statusPhotos = results[Permission.Photos]; } if (statusStorage != PermissionStatus.Granted) { if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Storage)) { await Application.Current.MainPage.DisplayAlert("Benötige Speicher-Berechtigung", "Zum Speichern von Bildern und Fundmeldungen wird die Speicher-Berechtigung benötigt.", "Okay"); } var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Storage }); statusStorage = results[Permission.Storage]; } if (statusPhotos == PermissionStatus.Granted && statusStorage == PermissionStatus.Granted) { await CrossMedia.Current.Initialize(); var file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions { PhotoSize = PhotoSize.Medium, }); if (file != null) { var fileHelper = DependencyService.Get <IFileHelper>(); var copyMedia = fileHelper.CopyFileToApp(file.Path); SelectedMedia.Add(new MediaFileModel(copyMedia.Path, LocalRecordId, MediaFileModel.MediaType.Image)); SetMediaHeight(); } } else if (statusPhotos != PermissionStatus.Unknown && statusStorage != PermissionStatus.Unknown) { await Application.Current.MainPage.DisplayAlert("Berechtigung verweigert", "Ohne Berechtigungen können keine Bilder aufgenommen und die Fundmeldung nicht gespeichert werden.", "Okay"); } else if (statusPhotos != PermissionStatus.Unknown) { await Application.Current.MainPage.DisplayAlert("Berechtigung verweigert", "Ohne Berechtigung können keine Bilder ausgewählt werden.", "Okay"); } else if (statusStorage != PermissionStatus.Unknown) { await Application.Current.MainPage.DisplayAlert("Berechtigung verweigert", "Ohne Berechtigung kann die Fundmeldung nicht gespeichert werden.", "Okay"); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
private async Task TakePhoto() { try { var statusCamera = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Camera); var statusStorage = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage); if (statusCamera != PermissionStatus.Granted) { if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Camera)) { await Application.Current.MainPage.DisplayAlert("Benötige Kamera-Berechtigung", "Zum Aufnehmen von Bildern wird die Kamera-Berechtigung benötigt.", "Okay"); } var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Camera }); statusCamera = results[Permission.Camera]; } if (statusStorage != PermissionStatus.Granted) { if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Storage)) { await Application.Current.MainPage.DisplayAlert("Benötige Speicher-Berechtigung", "Zum Speichern von Bildern und Fundmeldungen wird die Speicher-Berechtigung benötigt.", "Okay"); } var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Storage }); statusStorage = results[Permission.Storage]; } if (statusCamera == PermissionStatus.Granted && statusStorage == PermissionStatus.Granted) { await CrossMedia.Current.Initialize(); var file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions { Directory = "", Name = string.Format("IMG_{0}", DateTime.Now.ToString("yyyyMMdd_HHmmss")) }); if (file != null) { SelectedMedia.Add(new MediaFileModel(file.Path, LocalRecordId, MediaFileModel.MediaType.Image)); SetMediaHeight(); } } else if (statusCamera != PermissionStatus.Unknown && statusStorage != PermissionStatus.Unknown) { await Application.Current.MainPage.DisplayAlert("Berechtigung verweigert", "Ohne Berechtigungen können keine Bilder aufgenommen und die Fundmeldung nicht gespeichert werden.", "Okay"); } else if (statusCamera != PermissionStatus.Unknown) { await Application.Current.MainPage.DisplayAlert("Berechtigung verweigert", "Ohne Berechtigung können keine Bilder aufgenommen werden.", "Okay"); } else if (statusStorage != PermissionStatus.Unknown) { await Application.Current.MainPage.DisplayAlert("Berechtigung verweigert", "Ohne Berechtigung kann die Fundmeldung nicht gespeichert werden.", "Okay"); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
private void SetImagePageCombo(SelectedMedia media = null) { using (ControlTransaction.Update(ImagePageCombo)) { ImagePageCombo.Enabled = false; foreach (SelectedMedia oldMedia in ImagePageCombo.Items) { if (oldMedia == null || oldMedia == media) continue; DisposeMediaItem(oldMedia.Item); } ImagePageCombo.Items.Clear(); if (media == null) media = new SelectedMedia("1"); ImagePageCombo.Items.Add(media); ImagefilePathText.Text = media.Path; ImagePageCombo.SelectedIndex = 0; } }
public MediaCollection(SelectedMedia selectedMedia) { m_Parent = selectedMedia; }
internal SelectForm(IMediaManager iMediaManager) { InitializeComponent(); m_IMediaManager = iMediaManager; #if FULL this.WindowState = FormWindowState.Maximized; this.FormBorderStyle = FormBorderStyle.None; this.AutoScroll = false; #endif m_SelectedMedia = new SelectedMedia(this); m_SelectingMedia = new SelectingMedia(this); m_Artist = new Artist(this); headerCtrl1.StyleItems = new List <DirectoryInfo>(new DirectoryInfo(Properties.Settings.Default.RootPath).GetDirectories()).ConvertAll <String>( delegate(DirectoryInfo di) { return(di.Name); }).ToArray(); headerCtrl1.Mode = HeaderCtrl.Modes.Styles; headerCtrl1.ItemClick += delegate(Object sender, EventArgs e) { HeaderCtrl hc = (HeaderCtrl)sender; HeaderCtrl.ItemClickEventArgs itemClickEventArgs = e as HeaderCtrl.ItemClickEventArgs; m_Artist.ClearItems(); if (hc.Mode == HeaderCtrl.Modes.Styles) { foreach (DirectoryInfo tempDirectoryInfo in new DirectoryInfo(Path.Combine(Properties.Settings.Default.RootPath, itemClickEventArgs.Item)).GetDirectories()) { m_Artist.AddItem(tempDirectoryInfo.FullName); } } else if (hc.Mode == HeaderCtrl.Modes.AYa || hc.Mode == HeaderCtrl.Modes.AZ || hc.Mode == HeaderCtrl.Modes.ZeroNine) { List <DirectoryInfo> diList = new List <DirectoryInfo>(); new List <DirectoryInfo>(new DirectoryInfo(Properties.Settings.Default.RootPath).GetDirectories()).ForEach( delegate(DirectoryInfo di) { diList.AddRange(di.GetDirectories(itemClickEventArgs.Item + "*")); }); foreach (DirectoryInfo tempDirInfo in FiltrateDirs(diList.ToArray(), true, itemClickEventArgs.Item)) { m_Artist.AddItem(tempDirInfo.FullName); } } }; headerCtrl1.SearchClick += delegate { using (Search.SearchForm search = new musicbox.Search.SearchForm(m_IMediaManager)) { DialogResult dlgResult = search.ShowDialog(this); if (dlgResult == DialogResult.OK) { m_Artist.ClearItems(); m_SelectingMedia.ClearItems(); foreach (DirectoryInfo directoryInfo in search.Results.Directories) { m_Artist.AddItem(directoryInfo.FullName); } foreach (FileInfo fileInfo in search.Results.Files) { string fileExtension = Path.GetExtension(fileInfo.FullName); _Media media; if (m_IMediaManager.TryGetMedia(fileExtension, out media)) { m_SelectingMedia.AddItem(new FileNameAndMedia(fileInfo.FullName, media)); } } } } }; // new EventHandler(stylesCtrl1_SearchClick); m_Artist.ItemClick += delegate(Object sender, Artist.ArtistClickEventArgs e) { Artist ai = (Artist)sender; if (e.Item.Length > 0) { m_SelectingMedia.ClearItems(); foreach (_Media media in m_IMediaManager.GetAllMedia()) { foreach (FileInfo fileInfo in new DirectoryInfo(e.Item).GetFiles("*" + media.Extension)) { m_SelectingMedia.AddItem(new FileNameAndMedia(fileInfo.FullName, media)); } } } }; m_SelectingMedia.ItemClick += new EventHandler <SelectingMedia.SelectingMediaEventArgs>(m_SelectingMedia_ItemClick); //{ /* if (!m_SelectedMedia.Items.IsNameExist(e.Item.FileName)) * { * String[] lastOrdered = LastOrdered.Instance.GetItems(); * if (!Array.Exists<String>(lastOrdered, * delegate(String value) * { * return value == e.Item.FileName; * })) * { * if (!Properties.Settings.Default.MoneylessModeEnabled) * { * if (m_SelectedMedia.RestSum >= e.Item.IMedia.Price) * { * m_SelectedMedia.Items.Add(new FileNameAndIMediaWithIsMoneyless(e.Item.IMedia, false)); * } * } * else * { * m_SelectedMedia.Items.Add(new FileNameAndIMediaWithIsMoneyless(e.Item.IMedia, true)); * } * } * else * ApplicationMessage.Show(this, m_MediaExistInPlaylist); * * } * else * ApplicationMessage.Show(this, m_MediaYetOrder);*/ /* } * else * ApplicationMessage.Show(this,m_strMoneyNotEnough);*/ //------------------------------------- //}; m_SelectedMedia.GoClicked += new EventHandler(m_SelectedMedia_GoClicked); }