コード例 #1
0
        /// <summary>
        /// Creator: Rasha Mohammed
        /// Created: 4/8/2020
        /// Approver: Ethan Holmes
        ///
        ///
        /// This method shows the list of picture when the window loads
        /// </summary>
        /// <remarks>
        /// Updater: Robert Holmes
        /// Updated: 04/30/2020
        /// Update: Made compatible with byte[] storage.
        ///
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgPictureList_Loaded(object sender, RoutedEventArgs e)
        {
            List <Picture> pictures = _pictureManager.RetrieveAllPictures();
            BitmapImage    bitmap   = new BitmapImage();
            Image          image;

            List <Image> ListPictures = new List <Image>();

            foreach (var picture in pictures)
            {
                image = new Image();
                try
                {
                    using (var stream = new MemoryStream(picture.ImageData))
                    {
                        image.Source = BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
                    }
                }
                catch (Exception ex)
                {
                    WPFErrorHandler.ErrorMessage("There was a problem loading the picture.\n\n" + ex.Message);
                }

                ListPictures.Add(image);
            }

            listImage.ItemsSource = ListPictures;
        }