using System; using System.Windows.Forms; namespace PcgDrawR { public partial class FrmImageExport : DevExpress.XtraEditors.XtraForm { /// /// 图片放大比例 /// public int ImageScale { get; set; } /// /// 图片格式 /// public string ImageFormat { get; set; } /// /// 输出图像文件路径 /// public string ImageFilePath { get; set; } /// /// Initializes a new instance of the class. /// public FrmImageExport() { InitializeComponent(); } private void btnFolder_Click(object sender, EventArgs e) { // 创建并配置 SaveFileDialog SaveFileDialog saveFileDialog = new SaveFileDialog { Filter = "Image Files (*.png)|*.png|Image Files (*.jpeg)|*.jpeg|All Files (*.*)|*.*", // 设置文件类型过滤器 Title = "保存图像文件", // 对话框标题 DefaultExt = "png", // 默认文件扩展名 AddExtension = true, // 自动添加扩展名 }; // 显示对话框并处理结果 if (saveFileDialog.ShowDialog() == DialogResult.OK) { ImageFilePath = saveFileDialog.FileName; txtImageOutput.Text = saveFileDialog.FileName; } else { ImageFilePath = string.Empty; } } private void btnExecute_Click(object sender, EventArgs e) { this.ImageScale = int.Parse(comboBoxEditResolution.Text); this.ImageFilePath = txtImageOutput.Text; this.ImageFormat = System.IO.Path.GetExtension(ImageFilePath); this.btnExecute.DialogResult = DialogResult.OK; DialogResult = DialogResult.OK; this.Close(); } private void btnExit_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; this.btnExit.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.Close(); } } }