public OverlayState(ImageBox overlayImageBox) { this._overlayImgBox = overlayImageBox; }
public SideBySideState(ImageBox leftImageBox, ImageBox rightImageBox) { this._leftImgBox = leftImageBox; this._rightImgBox = rightImageBox; }
private void AddImageBox() { imageBox = new ImageBox(); imageBox.Dock = DockStyle.Fill; uiUnableToDisplayImgTableLayout.Controls.Add(imageBox, 1, 0); }
void imageBox_ZoomChanged(object sender, EventArgs e) { _logger.Debug("imageBox_ZoomChanged"); string senderName = ((ImageBox)sender).Name; if (this._zoomImpactedImageBox != string.Empty && senderName == this._zoomImpactedImageBox) { _logger.Warn("imageBox_ZoomChanged won't change [{0}] to prevent infinite loop", senderName); //this._zoomImpactedImageBox = ""; return; } ImageBox sourceImage = new ImageBox(); ImageBox targetImage = new ImageBox(); imageBoxSelector(sender, ref sourceImage, ref targetImage); this._zoomImpactedImageBox = targetImage.Name; _logger.Debug("imageBox_ZoomChanged-{0} with Zoom-{1}", senderName, sourceImage.Zoom); //set the zoom level to be the exact same value //targetImage.Zoom = sourceImage.Zoom; //targetImage.CenterAt(sourceImage.Location); targetImage.ZoomToRegion(sourceImage.GetSourceImageRegion()); targetImage.Zoom = sourceImage.Zoom; }
protected void imageBoxSelector(object sender, ref ImageBox sourceImage, ref ImageBox targetImage) { //_logger.Trace("imageBoxSelector-" + ((ImageBox)sender).Name); sourceImage = ((Cyotek.Windows.Forms.ImageBox)sender); targetImage = new Cyotek.Windows.Forms.ImageBox(); switch (sourceImage.Name.ToLower()) { case "sidebysideleftimagebox": targetImage = sideBySideRightImageBox; break; case "sidebysiderightimagebox": targetImage = sideBySideLeftImageBox; break; } }
/// <summary> /// sync the scroll behavior /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void sideBySideImageBox_Scroll(object sender, ScrollEventArgs e) { _logger.Debug("sideBySideImageBox_Scroll-" + ((ImageBox)sender).Name); ImageBox sourceImage = new ImageBox(), targetImage = new ImageBox(); imageBoxSelector(sender, ref sourceImage, ref targetImage); int verticalVal = sourceImage.VerticalScroll.Value; int horizontalVal = sourceImage.HorizontalScroll.Value; targetImage.ScrollTo(horizontalVal, verticalVal); }
private void CreateAndShowImageBox() { imageBox = new ImageBox(); imageBox.Dock = DockStyle.Fill; uiPreviewerSplitContainer.Panel2.Controls.Add(imageBox); try { Image image = Image.FromFile(filePath); LoadImage(new Bitmap(image)); } catch (OutOfMemoryException oom) { //MessageBox.Show(@"Debugging: Known issue. Webpage takes a large chunk of memory, causing the image loading in the previewer to fail. // The image is still saved/logged/hashed, it just can't be previewed. Further debug info: " + oom); //can we call ShowCannotOpenPanel here, instead? uiPreviewerSplitContainer.Panel2.Controls.Clear(); uiPreviewerSplitContainer.Panel2.Controls.Add(new ImageLoadFailed()); //Debug.WriteLine("-- OUT OF MEMORY --"); //ShowCannotOpenPanel(GetImageSize()); //we can carry on, show the previewer so they can name the image and leave a note. //TODO: put a friendly message on the right, and a link to the image currently residing in the cache //so they can see it. } catch (FileNotFoundException fnf) { MessageBox.Show($"Unable to find the image file! Debug: {fnf}"); //safely close OSIRT, here??? } catch(Exception e) { //MessageBox.Show($"Unable to load image file! Debug: {e}"); Debug.WriteLine("--- General exception ---"); } }