Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProcessingCommandTask"/> class.
        /// </summary>
        /// <param name="viewer">Image viewer that shows the image.</param>
        public ImageProcessingCommandExecutor(ImageViewer viewer)
        {
            _viewer = viewer;

            _openFileDialog = new OpenFileDialog();
            CodecsFileFilters.SetOpenFileDialogFilter(_openFileDialog);
        }
        /// <summary>
        /// Shows the image selection dialog of visual tool.
        /// </summary>
        private void ShowVisualToolImageSelectionDialog()
        {
            // create open file dialog
            using (OpenFileDialog openImageDialog = new OpenFileDialog())
            {
                // set image files filters
                CodecsFileFilters.SetOpenFileDialogFilter(openImageDialog);
                // if image file selected
                if (openImageDialog.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        // get overlay tool
                        OverlayImageTool tool = ((OverlayImageTool)VisualTool);
                        // set overlay image
                        tool.Image = new VintasoftImage(openImageDialog.FileName);

                        // if OverlayImageTool.MaintainAspectRatio must be enabled
                        if (MessageBox.Show("Do you want to maintain image aspect ratio?", "Question",
                                            MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            tool.MaintainAspectRatio = true;
                        }
                        else
                        {
                            tool.MaintainAspectRatio = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        // show error message
                        DemosTools.ShowErrorMessage(ex);
                    }
                }
            }
        }