/// <summary>
        /// Save with showing a dialog
        /// </summary>
        /// <param name="surface"></param>
        /// <param name="captureDetails"></param>
        /// <returns>Path to filename</returns>
        public static string SaveWithDialog(ISurface surface, ICaptureDetails captureDetails)
        {
            string returnValue = null;

            using (SaveImageFileDialog saveImageFileDialog = new SaveImageFileDialog(captureDetails))
            {
                DialogResult dialogResult = saveImageFileDialog.ShowDialog();
                if (dialogResult.Equals(DialogResult.OK))
                {
                    try
                    {
                        string fileNameWithExtension         = saveImageFileDialog.FileNameWithExtension;
                        SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(FormatForFilename(fileNameWithExtension));
                        if (conf.OutputFilePromptQuality)
                        {
                            QualityDialog qualityDialog = new QualityDialog(outputSettings);
                            qualityDialog.ShowDialog();
                        }
                        // TODO: For now we always overwrite, should be changed
                        Save(surface, fileNameWithExtension, true, outputSettings, conf.OutputFileCopyPathToClipboard);
                        returnValue = fileNameWithExtension;
                        IniConfig.Save();
                    }
                    catch (ExternalException)
                    {
                        MessageBox.Show(Language.GetFormattedString("error_nowriteaccess", saveImageFileDialog.FileName).Replace(@"\\", @"\"), Language.GetString("error"));
                    }
                }
            }
            return(returnValue);
        }
示例#2
0
        /// <summary>
        /// Save with showing a dialog
        /// </summary>
        /// <param name="surface"></param>
        /// <param name="captureDetails"></param>
        /// <returns>Path to filename</returns>
        public static string SaveWithDialog(ISurface surface, ICaptureDetails captureDetails)
        {
            string returnValue = null;

            using (SaveImageFileDialog saveImageFileDialog = new SaveImageFileDialog(captureDetails))
            {
                DialogResult dialogResult = saveImageFileDialog.ShowDialog();
                if (dialogResult.Equals(DialogResult.OK))
                {
                    try
                    {
                        string fileNameWithExtension         = saveImageFileDialog.FileNameWithExtension;
                        SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(FormatForFilename(fileNameWithExtension));
                        if (conf.OutputFilePromptQuality)
                        {
                            QualityDialog qualityDialog = new QualityDialog(outputSettings);
                            qualityDialog.ShowDialog();
                        }
                        // For now we always overwrite, should be changed
                        Save(surface, fileNameWithExtension, true, outputSettings, conf.OutputFileCopyPathToClipboard);
                        returnValue = fileNameWithExtension;
                        IniConfig.Save();
                    }
                    catch (ExternalException)
                    {
                        MessageBox.Show(string.Format("Cannot save file to {0}.\r\nPlease check write accessibility of the selected storage location.",
                                                      saveImageFileDialog.FileName).Replace(@"\\", @"\"), "Error");
                    }
                }
            }
            return(returnValue);
        }
        public static string SaveWithDialog(Image image, ICaptureDetails captureDetails)
        {
            string returnValue = null;
            SaveImageFileDialog saveImageFileDialog = new SaveImageFileDialog(captureDetails);
            DialogResult        dialogResult        = saveImageFileDialog.ShowDialog();

            if (dialogResult.Equals(DialogResult.OK))
            {
                try {
                    string fileNameWithExtension = saveImageFileDialog.FileNameWithExtension;
                    // TODO: For now we overwrite, should be changed
                    ImageOutput.Save(image, fileNameWithExtension, true);
                    returnValue = fileNameWithExtension;
                    conf.OutputFileAsFullpath = fileNameWithExtension;
                    IniConfig.Save();
                } catch (System.Runtime.InteropServices.ExternalException) {
                    MessageBox.Show(Language.GetFormattedString(LangKey.error_nowriteaccess, saveImageFileDialog.FileName).Replace(@"\\", @"\"), Language.GetString(LangKey.error));
                }
            }
            return(returnValue);
        }