ImageTimeTag/Form1.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

namespace ImageTimeTag
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void loadImg_btn_Click(object sender, EventArgs e)
        {
            String imagePath = imagePath_box.Text;
            if (!Directory.Exists(imagePath))
            {
                MessageBox.Show("未找到图片路径");
                return;
            }

            var imgFiles = Directory.GetFiles(imagePath, "*.jpg");
            if (imgFiles.Length > 0)
            {
                //panel1.BackgroundImage = new Bitmap(imgFiles[0]);
                using (var g = panel1.CreateGraphics())
                {
                    g.DrawImage(new Bitmap(imgFiles[0]), new Rectangle(0, 0, panel1.Width, panel1.Height));
                }
                changeImageTextStyle();
            }
        }

        private void color_btn_Click(object sender, EventArgs e)
        {
            var result = colorDialog1.ShowDialog();
            if (result == DialogResult.OK)
            {
                imgColor = colorDialog1.Color;
                changeImageTextStyle();
            }
        }

        private void font_btn_Click(object sender, EventArgs e)
        {
            var result = fontDialog1.ShowDialog();
            if (result == DialogResult.OK)
            {
                imgFont = fontDialog1.Font;
                changeImageTextStyle();
            }
        }

        Font imgFont = new Font("Arial", 12);
        Color imgColor = Color.Yellow;
        private void changeImageTextStyle()
        {
            using (var g = panel1.CreateGraphics())
            {
                g.DrawString("2022-10-08", imgFont, new SolidBrush(imgColor), new PointF(panel1.Width * 48 / 100, panel1.Height * 2 / 100));
            }
        }

后面还有 50 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。