You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kev/Drawer/UCDraw/PcgDrawR/FrmImageExport.cs

72 lines
2.4 KiB
C#

1 month ago
using System;
using System.Drawing;
using System.Windows.Forms;
namespace PcgDrawR
{
public partial class FrmImageExport : DevExpress.XtraEditors.XtraForm
{
/// <summary>
/// 图片放大比例
/// </summary>
public int ImageScale { get; set; }
/// <summary>
/// 图片格式
/// </summary>
public string ImageFormat { get; set; }
/// <summary>
/// 输出图像文件路径
/// </summary>
public string ImageFilePath { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="FrmImageExport"/> class.
/// </summary>
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();
}
}
}