private void SetThumbnail(Image image)
		{
			if (Disposing) return;
			if (IsDisposed)
				return;
			if (!IsHandleCreated)
				return;

			if (this.InvokeRequired)
			{
				SetThumbnailDelegate d = new SetThumbnailDelegate(SetThumbnail);

				if (IsDisposed || _thumbnailWorker == null || !IsHandleCreated)
						return;
				this.Invoke(d, new object[] {image});
			}
			else
			{
				 lock (this)
				{
					if (LargeImageList == null)
					{
						Debug.Fail("(Only seeing this in the debug version) Thumbnail viewer worker still woking after the form was closed.");
						return;
					}
					LargeImageList.Images.Add(image); //Images[i].repl

					int index = LargeImageList.Images.Count - 1;
					Items[index - 1].ImageIndex = index;
				}
			}
		}
Beispiel #2
0
        private void SetThumbnail(Image image, string key)
        {
            if (Disposing)
            {
                return;
            }

            if (this.InvokeRequired && (myWorker.ThreadState == ThreadState.Running || myWorker.ThreadState == ThreadState.Background))
            {
                SetThumbnailDelegate d = new SetThumbnailDelegate(SetThumbnail);
                this.Invoke(d, new object[] { image, key });
            }
            else
            {
                try
                {
                    int index = 0;

                    LargeImageList.Images.Add(image);                     //Images[i].repl
                    index = LargeImageList.Images.Count - 1;

                    Items[index - 1].ImageIndex = index;
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.Assert(false);
                    return;
                }
            }
        }
 private void SetThumbnail(Image image)
 {
     if (Disposing)
     {
         return;
     }
     if (this.InvokeRequired)
     {
         SetThumbnailDelegate d = new SetThumbnailDelegate(SetThumbnail);
         this.Invoke(d, new object[] { image });
     }
     else
     {
         LargeImageList.Images.Add(image);
         int index = LargeImageList.Images.Count - 1;
         Items[index - 1].ImageIndex = index;
     }
 }
Beispiel #4
0
        private void SetThumbnail(Image image)
        {
            if (Disposing)
            {
                return;
            }
            if (IsDisposed)
            {
                return;
            }
            if (!IsHandleCreated)
            {
                return;
            }

            if (this.InvokeRequired)
            {
                SetThumbnailDelegate d = new SetThumbnailDelegate(SetThumbnail);

                if (IsDisposed || _thumbnailWorker == null || !IsHandleCreated)
                {
                    return;
                }
                this.Invoke(d, new object[] { image });
            }
            else
            {
                lock (this)
                {
                    if (LargeImageList == null)
                    {
                        Debug.Fail("(Only seeing this in the debug version) Thumbnail viewer worker still woking after the form was closed.");
                        return;
                    }
                    LargeImageList.Images.Add(image);                     //Images[i].repl

                    int index = LargeImageList.Images.Count - 1;
                    Items[index - 1].ImageIndex = index;
                }
            }
        }
Beispiel #5
0
        private void SetThumbnail(Image image, string key)
        {
            if (Disposing)
            {
                return;
            }

            if (this.InvokeRequired)
            {
                SetThumbnailDelegate d = new SetThumbnailDelegate(SetThumbnail);
                this.Invoke(d, new object[] { image, key });
            }
            else
            {
                try
                {
                    int index = 0;
                    if (!LargeImageList.Images.ContainsKey(key))
                    {
                        LargeImageList.Images.Add(key, image); //Images[i].repl
                        index = LargeImageList.Images.Count - 1;
                    }
                    else
                    {
                        index = LargeImageList.Images.IndexOfKey(key);
                    }

                    Items[index - 1].ImageIndex = index;
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.Assert(false);
                    return;
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// Set the image thumbnail for specified list item. Note that we have to consider threading issues here.
        /// </summary>
        /// <param name="item">[in] the list item to</param>
        /// <param name="thumbnail">[in] the image for specified list item</param>
        /// <param name="cancel">[out] indicate if image loading is canceled</param>
        private void SetListItemImage( ListViewItem item, Image thumbnail, out bool cancel)
        {
            if (this.InvokeRequired == false)
            {
                // cache image thumbnail
                ImageInfo ii = (ImageInfo) item.Tag;
                if (ii != null)
                {
                    ii.Thumbnail = thumbnail;

                    // invalidate the item rectangle to ensure repaint
                    item.ListView.Invalidate(GetItemRect(item.Index));
                }

                cancel = (imageLoadingState == ImageLoadingState.CancelLoading);
            }
            else
            {
                // Add thumbnail on the thread that owns the control's underlying window handle.
                SetThumbnailDelegate d = new SetThumbnailDelegate(SetListItemImage);

                // Avoid boxing and losing our return value.
                object inoutCancel = false;
                BeginInvoke( d, new Object[] { item, thumbnail, inoutCancel });

                cancel = (bool) inoutCancel;
            }
        }