资源简介

winfrom给图片批量添加文字或图片水印。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using watermark.BLL;

namespace watermark
{
    public partial class Form1 : Form
    {
        List listExtention = new List();
        public Form1()
        {
            InitializeComponent();
            Form.CheckForIllegalCrossThreadCalls = false;
            listExtention.AddRange(new string[] { “.jpg“ “.gif“ “.png“ });
            ConfigFile.Instanse.fileName = AppDomain.CurrentDomain.baseDirectory + “watermark.ini“;
        }

        private void Form1_FormClosed(object sender FormClosedEventArgs e)
        {
            Application.Exit();
            Application.ExitThread();
        }
        #region 在新线程中运行函数
        /// 
        /// 在新线程中运行函数
        /// 

        /// 传入 函数名(无参、无返回值)
        /// 是否为后台线程(后台线程,窗口关闭后就终止线程)
        public static void ThreadNew(VoidFunction func bool IsBackground)
        {
            Thread th1 = new Thread(new ThreadStart(func));
            th1.IsBackground = IsBackground;//后台线程,窗口关闭后就终止线程
            th1.Start();
        }
        /// 
        /// 在新线程中运行函数
        /// 

        /// 传入 函数名(有一个参数、无返回值)
        /// object参数
        /// 是否为后台线程(后台线程,窗口关闭后就终止线程)
        public static Thread ThreadNew(ParamFunction func object para bool IsBackground)
        {
            Thread th1 = new Thread(new ParameterizedThreadStart(func));
            //判断状态
            //((int)th1.ThreadState &((int)ThreadState.Running | (int)ThreadState.Suspended) ) == 0 
            th1.IsBackground = IsBackground;
            th1.Start(para);
            return th1;
        }
        /// 
        /// 允许线程之间进行操作
        /// 

        public static void OprateBetweenThread()
        {
            System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
        }

        /// 
        /// 无参的、返回值为void的委托,可以用来做参数名
        /// 

        public delegate void VoidFunction();

        /// 
        /// 有一个参数的、返回值为void的委托,可以用来做参数名
        /// 

        public delegate void ParamFunction(object para);


        #endregion
        private void btn_selectDir_Click(object sender EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            if (fbd.ShowDialog() == DialogResult.OK)
            {
                txtDir.Text = fbd.SelectedPath;
                ConfigFile.Instanse[“txtDir“] = txtDir.Text;
            }
        }

        private void btn_selectMark_Click(object sender EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            //设置文件类型
            ofd.Filter = “

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-03-04 15:06  winfrom_watermark\
     文件       24358  2019-03-04 15:06  winfrom_watermark\favicon.ico
     目录           0  2019-03-04 16:18  winfrom_watermark\winfrom_watermark\
     文件        1020  2019-03-04 11:18  winfrom_watermark\winfrom_watermark.sln
     文件       46080  2019-03-04 16:20  winfrom_watermark\winfrom_watermark.v12.suo
     目录           0  2019-03-04 11:31  winfrom_watermark\winfrom_watermark\bin\
     目录           0  2019-03-04 14:02  winfrom_watermark\winfrom_watermark\bin\Debug\
     文件         160  2019-03-04 14:24  winfrom_watermark\winfrom_watermark\bin\Debug\watermark.ini
     文件       46080  2019-03-04 16:18  winfrom_watermark\winfrom_watermark\bin\Debug\winfrom_watermark.exe
     文件       48640  2019-03-04 16:18  winfrom_watermark\winfrom_watermark\bin\Debug\winfrom_watermark.pdb
     文件       24216  2019-03-04 16:20  winfrom_watermark\winfrom_watermark\bin\Debug\winfrom_watermark.vshost.exe
     目录           0  2019-03-04 11:31  winfrom_watermark\winfrom_watermark\bin\Release\
     目录           0  2019-03-04 12:09  winfrom_watermark\winfrom_watermark\BLL\
     文件        8570  2019-03-04 11:30  winfrom_watermark\winfrom_watermark\BLL\ConfigFile.cs
     文件        3479  2019-03-04 12:09  winfrom_watermark\winfrom_watermark\BLL\DesEncrypt.cs
     文件       12600  2019-03-04 16:18  winfrom_watermark\winfrom_watermark\Form1.cs
     文件        9580  2019-03-04 15:16  winfrom_watermark\winfrom_watermark\Form1.Designer.cs
     文件       44942  2019-03-04 15:16  winfrom_watermark\winfrom_watermark\Form1.resx
     目录           0  2019-03-04 11:18  winfrom_watermark\winfrom_watermark\obj\
     目录           0  2019-03-04 16:18  winfrom_watermark\winfrom_watermark\obj\Debug\
     文件         865  2019-03-04 11:18  winfrom_watermark\winfrom_watermark\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        7017  2019-03-04 12:18  winfrom_watermark\winfrom_watermark\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     目录           0  2019-03-04 11:18  winfrom_watermark\winfrom_watermark\obj\Debug\TempPE\
     文件       24924  2019-03-04 15:52  winfrom_watermark\winfrom_watermark\obj\Debug\watermark.Form1.resources
     文件         962  2019-03-04 16:20  winfrom_watermark\winfrom_watermark\obj\Debug\winfrom_watermark.csproj.FileListAbsolute.txt
     文件         977  2019-03-04 15:52  winfrom_watermark\winfrom_watermark\obj\Debug\winfrom_watermark.csproj.GenerateResource.Cache
     文件        2356  2019-03-04 11:30  winfrom_watermark\winfrom_watermark\obj\Debug\winfrom_watermark.csprojResolveAssemblyReference.cache
     文件       46080  2019-03-04 16:18  winfrom_watermark\winfrom_watermark\obj\Debug\winfrom_watermark.exe
     文件       48640  2019-03-04 16:18  winfrom_watermark\winfrom_watermark\obj\Debug\winfrom_watermark.pdb
     文件         180  2019-03-04 11:32  winfrom_watermark\winfrom_watermark\obj\Debug\winfrom_watermark.Properties.Resources.resources
     文件         470  2019-03-04 11:55  winfrom_watermark\winfrom_watermark\Program.cs
............此处省略16个文件信息

评论

共有 条评论