private void glControl_Paint(object sender, PaintEventArgs e) { if (_dicomImageLoader != null) { GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); if (_imageLoadingState == ImageLoadingState.Loaded) { GenerateAndBindTexture(); _imageLoadingState = ImageLoadingState.Rendered; } OnRenderFrame(e); glControl.SwapBuffers(); } }
private async void glControl_Load(object sender, EventArgs e) { GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.Enable(EnableCap.Texture2D); _dicomImageLoader = new DicomImageLoader(); _imageProvider = new Dictionary <string, Image>(); _image = await _dicomImageLoader.LoadDcmImage(); _imageProvider.UpsertOriginalImage(_image); _imageLoadingState = ImageLoadingState.Loaded; this.Invoke(new MethodInvoker(glControl.Refresh)); glControl.SwapBuffers(); }
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()); }
/// <summary> /// Called when image loading is done. /// /// effects: switch the image loading state to Idle. /// </summary> private void ImageLoadingDone() { imageLoadingState = ImageLoadingState.Idle; imageLoadingDone = null; }
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); }