Esempio n. 1
0
        private void updateImageView()
        {
            if (stackedImage == null)
            {
                if (currentImage == null)
                {
                    var path = thumbnailsView.CurrentObjectPath;
                    if (path.Length > 0)
                    {
                        if (File.Exists(path))
                        {
                            currentImage       = ImageTools.LoadImage(libraw, path, currentSession);
                            currentStack       = null;
                            positionLabel.Text = "...";
                        }
                        else if (Directory.Exists(path))
                        {
                            string cfaPath = path + "\\CFA";
                            if (Directory.Exists(cfaPath))
                            {
                                prepareStack(cfaPath);
                                currentImage                  = new RawImageWrapper(libraw, currentStack[currentStackIndex].FilePath, currentSession);
                                positionLabel.Text            = string.Format("{0} of {1}", currentStackIndex + 1, currentStack.Length);
                                stackCheckBox.Visible         = true;
                                stackSelectedCheckBox.Checked = !currentStack[currentStackIndex].IsExcluded;
                                stackSelectedCheckBox.Enabled = true;
                            }
                            else
                            {
                                string rawPath = path + "\\RAW";
                                if (Directory.Exists(rawPath))
                                {
                                    prepareStack(rawPath);
                                    currentImage                  = new RawImageWrapper(libraw, currentStack[currentStackIndex].FilePath, currentSession);
                                    positionLabel.Text            = string.Format("{0} of {1}", currentStackIndex + 1, currentStack.Length);
                                    stackCheckBox.Visible         = true;
                                    stackSelectedCheckBox.Checked = !currentStack[currentStackIndex].IsExcluded;
                                    stackSelectedCheckBox.Enabled = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        stackSelectedCheckBox.Enabled = true;
                    }
                }

                if (currentImage != null)
                {
                    if (quickPreviewRadioButton.Checked)
                    {
                        pictureBox.Image = currentImage.Preview;
                        showZoomImage();
                    }
                    else if (rawPreviewRadioButton.Checked)
                    {
                        RawImage rawImage = currentImage.RawImage;
                        if (rawImage != null)
                        {
                            int saturation = (int)satNumericUpDown.Value;
                            pictureBox.Image = rawImage.RenderBitmapHalfRes(currentCurve, saturation);
                            showZoomImage();
                        }
                        else
                        {
                            pictureBox.Image = null;
                        }
                    }
                    if (infoRadioButton.Checked)
                    {
                        RawImage rawImage = currentImage.RawImage;
                        if (rawImage != null)
                        {
                            pictureBox.Image = rawImage.GetHistogram();
                            showZoomImage();
                        }
                        else
                        {
                            pictureBox.Image = null;
                        }
                    }
                }
                else
                {
                    pictureBox.Image = null;
                }

                updateStackView();
                stackCheckBox.Visible = currentStack != null;
                prevButton.Enabled    = (currentStack != null && currentStackIndex > 0);
                nextButton.Enabled    = (currentStack != null && currentStackIndex < currentStack.Length - 1);
            }
            else
            {
                if (pictureBox.Image != null)
                {
                    pictureBox.Image.Dispose();
                }
                int saturation = (int)satNumericUpDown.Value;
                pictureBox.Image = stackedImage.RenderBitmap(stackedImageCurve, saturation);
                showZoomImage();
            }
        }