/// <summary> /// Handles the Click event of the CloseButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void CloseButton_Click(object sender, RoutedEventArgs e) { selectedPhoto = null; close = true; ((MainWindow)Application.Current.MainWindow).UpdateTagCloud(); PhotosDataSource dataSource = new PhotosDataSource(ConnectionStringHelper.GetActualConnectionString()); ((MainWindow)Application.Current.MainWindow).GetAndShowImagesFromDatabase(dataSource.GetAllPhotos()); PhotoThumbnail.Source = errorImage.Source; Close(); }
/// <summary> /// Adds the photo. /// </summary> public static void AddPhoto() { string thumbnailPath = ConfigurationManager.AppSettings["thumbnailDirectory"].ToString(); string connectionString = ConnectionStringHelper.GetActualConnectionString(); OpenFileDialog openImage = new OpenFileDialog(); openImage.Filter = "Pliki obrazów (*.jpg, *.png, *.crt, *.tiff)|*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG;*.crt;*.CRT;*.tiff;*.TIFF|Wszystkie pliki (*.*)|*.*"; openImage.ShowDialog(); if (openImage.CheckFileExists && !string.IsNullOrWhiteSpace(openImage.FileName)) { string openedImageName = openImage.FileName; string fileName = Path.GetFileName(openedImageName); string filePath = openedImageName.Substring(0, openedImageName.Length - fileName.Length); string newFilePath = ChangePath(filePath); Bitmap image = AForge.Imaging.Image.FromFile(openedImageName); int[] thumbnailSizes = GetThumbnailSize(image.Width, image.Height); int thumbnailWidth = thumbnailSizes[0]; int thumbnailHeight = thumbnailSizes[1]; AForge.Imaging.Filters.ResizeBicubic filter = new AForge.Imaging.Filters.ResizeBicubic(thumbnailWidth, thumbnailHeight); Bitmap thumbnail = filter.Apply(image); string thumbnailFileName = LookForFreeFilename(thumbnailPath, fileName); string thumbnailSavedPath = Path.Combine(thumbnailPath, thumbnailFileName); thumbnail.Save(thumbnailSavedPath); newFilePath = newFilePath + fileName; PhotosDataSource db = new PhotosDataSource(connectionString); Photo photoObject = new Photo(); photoObject.FilePath = newFilePath; photoObject.ThumbnailPath = thumbnailSavedPath; photoObject.Title = fileName; photoObject.Description = string.Empty; photoObject.Archive = null; photoObject.Attribute = null; db.AddPhoto(photoObject); } }
private async Task LoadDataAsync() { var source = new PhotosDataSource(); _photoItems = await new PhotosDataSource().GetItemsAsync(true); }
protected override void OnNavigatedTo(NavigationEventArgs e) { this.Items = new ObservableCollection <object>(PhotosDataSource.GetItems().Skip(4)); base.OnNavigatedTo(e); }
/// <summary> /// Handles the Click event of the CloseButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void CloseButton_Click(object sender, RoutedEventArgs e) { selectedPhoto = null; close = true; ((MainWindow)Application.Current.MainWindow).UpdateTagCloud(); PhotosDataSource dataSource = new PhotosDataSource(ConnectionStringHelper.GetActualConnectionString()); ((MainWindow)Application.Current.MainWindow).GetAndShowImagesFromDatabase(dataSource.GetAllPhotos()); PhotoThumbnail.Source = errorImage.Source; Close(); }
/// <summary> /// Gets all tags for photo. /// </summary> /// <param name="photoID">Photo id.</param> /// <returns>Tag list.</returns> public static List<Tag> GetPhotosTags(int photoID) { PhotosDataSource photos = new PhotosDataSource(ConnectionStringHelper.GetActualConnectionString()); return photos.GetPhoto(photoID).Tags; }
/// <summary> /// Get one photo. /// </summary> /// <param name="id">Photo ID.</param> /// <returns>One photo.</returns> public static Photo GetPhoto(int id) { PhotosDataSource db = new PhotosDataSource(ConnectionStringHelper.GetActualConnectionString()); return db.GetPhoto(id); }
/// <summary> /// Gets all photos. /// </summary> /// <returns>Photos list.</returns> public static List<Photo> GetAllPhotos() { PhotosDataSource db = new PhotosDataSource(ConnectionStringHelper.GetActualConnectionString()); return db.GetAllPhotos(); }
/// <summary> /// Delete all specified photos. /// </summary> /// <param name="toDeleteList">Photo to delete.</param> /// <returns>Number of deleted photos.</returns> public static int DeletePhotos(List<Photo> toDeleteList) { PhotosDataSource db = new PhotosDataSource(ConnectionStringHelper.GetActualConnectionString()); List<int> ids = new List<int>(); foreach (Photo p in toDeleteList) { ids.Add(p.ID); } return db.DeletePhotos(ids); }
/// <summary> /// Delete selected Photo. /// </summary> /// <param name="toDelete">Photo to delete.</param> /// <returns>Deleting photo operation state.</returns> public static bool DeletePhoto(Photo toDelete) { PhotosDataSource db = new PhotosDataSource(ConnectionStringHelper.GetActualConnectionString()); return db.DeletePhoto(toDelete.ID); }
protected override void OnNavigatedTo(NavigationEventArgs e) { this.Items = new ObservableCollection <object>(PhotosDataSource.GetItems()); this.ItemTemplate = Resources["PhotoDataTemplate"] as DataTemplate; base.OnNavigatedTo(e); }