Example #1
0
        public void RefreshThumbnails(ImageCollection images)
        {
            if (imageLoadingState == ImageLoadingState.Loading ||
                imageLoadingState == ImageLoadingState.CancelLoading)
            {
                CancelLoading(images);
                return;
            }

            Debug.Assert(imageLoadingState == ImageLoadingState.Idle);

            // Show them in list view.
            Items.Clear();
            ImageList imageListLarge = new ImageList();
            imageListLarge.ColorDepth = ColorDepth.Depth24Bit;
            imageListLarge.ImageSize = new Size( cxThumbnail, cyThumbnail);
            LargeImageList = imageListLarge;

            BeginUpdate();

            // Add items first to prevent flickers.
            foreach (ImageInfo imageFile in images)
            {
                ListViewItem item = new ListViewItem();
                item.ImageIndex = -1;
                item.Text = Path.GetFileName(imageFile.ImagePath);
                item.Tag = imageFile;
                Items.Add(item);
            }

            EndUpdate();

            // Switch the state.
            imageLoadingState = ImageLoadingState.Loading;
            imageLoadingDone = new ThumbnailLoadingDoneDelegate(ImageLoadingDone);

            // Use asynchronous delegate to load image thumbnails.
            LoadThumbnailsDelegate loadThumbnails = new LoadThumbnailsDelegate(LoadThumbnails);
            loadThumbnails.BeginInvoke( images, null, new Object());
        }
Example #2
0
        public void BurnToCD(ImageCollection images)
        {
            if (_burnCD != null)
            {
                throw new InvalidOperationException("An existing burning session is in progress.");
            }

            try
            {
                _burnCD = new XPBurnCD();
                _burnCD.ActiveFormat = RecordType.afData;

                _burnCD.AddProgress += new NotifyCDProgress(OnAddProgress);
                _burnCD.BurnComplete += new NotifyCompletionStatus(OnBurnComplete);
                _burnCD.ClosingDisc += new NotifyEstimatedTime(OnClosingDisc);
                _burnCD.EraseComplete += new NotifyCompletionStatus(OnEraseComplete);
                _burnCD.PreparingBurn += new NotifyEstimatedTime(OnPreparingBurn);
                _burnCD.RecorderChange += new NotifyPnPActivity(OnRecorderChange);
                _burnCD.TrackProgress += new NotifyCDProgress(OnTrackProgress);
                _burnCD.BlockProgress +=new NotifyCDProgress(OnBlockProgress);
                // _burnCD.ErrorHappened +=new NotifyErrorStatus(ErrorHappened);

                foreach (ImageInfo ii in images)
                {
                    _burnCD.AddFile(ii.ImagePath, ii.ImagePath);
                }

                if (_burnCD.MediaInfo.isWritable)
                {
                    _burnCD.RecordDisc(false, false);
                }
            }
            catch (Exception ex)
            {
                AddMessage(ex.ToString());
            }
        }
Example #3
0
        /// <summary>
        /// This method will be called by delegate asynchronously.
        /// </summary>
        private void LoadThumbnails(ImageCollection images)
        {
            try
            {
                bool cancel = false;
                for ( int i = 0; i < Items.Count && i < images.Count && !cancel; i++)
                {
                    // [TODO] prevent loading the entire image for thumbnail...
                    using (Image image = ImageFast.FromFile(images[i].ImagePath))
                    {
                        // generate thumbnail padding with background color
                        Image thumbnail = ImageHelper.GetThumbnail(image, cxThumbnail, cyThumbnail, BackColor);

                        SetListItemImage( Items[i], thumbnail, out cancel);
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.Write(ex.ToString());
            }

            BeginInvoke( imageLoadingDone, null);
        }
Example #4
0
        /// <summary>
        /// Called when image loading is canceled.
        /// effects: switch the image loading state to Idle and refresh list view.
        /// </summary>
        private void ImageLoadingDoneAndRefresh()
        {
            ImageLoadingDone();
            RefreshThumbnails(imagesToRefresh);

            imagesToRefresh = null;
        }
Example #5
0
        private void CancelLoading(ImageCollection images)
        {
            imagesToRefresh = images;

            // remove all attached ImageInfo before canceling the loading to prevent flash
            foreach (ListViewItem item in Items)
            {
                item.Tag = null;
            }

            // change the status to cancel image loading
            imageLoadingState = ImageLoadingState.CancelLoading;

            // delay the refresh until image loading is canceled
            imageLoadingDone = new ThumbnailLoadingDoneDelegate(ImageLoadingDoneAndRefresh);
        }