⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 createprintfile.jsl

📁 使用微软的J#语言开发的把java源代码自动写的到文档中
💻 JSL
字号:
package FileTools;

import System.Collections.Generic.*;
import System.ComponentModel.*;
import System.Data.*;
import System.Drawing.*;
import System.Windows.Forms.*;
import System.IO.*;

/**
 * Summary description for CreatePrintFile.
 */
public class CreatePrintFile extends System.Windows.Forms.Form
{
	private Label label1;
	private TextBox txtInputPath;
	private Button button1;
	private Label label2;
	private TextBox txtOutputFilename;
	private Button button2;
	private FolderBrowserDialog folderBrowserDialog1;
	private Button button3;
	private OpenFileDialog openFileDialog1;
	private Button button4;
	private ListBox lstSource;
	private ListBox lstDestination;
	private Button btnAddAll;
	private Button btnAdd;
	private Button btnMove;
	private Button btnMoveAll;
	private GroupBox groupBox1;
	private Button button5;
	private TextBox txtAddItem;
	/**
	 * Required designer variable.
	 */
	private System.ComponentModel.IContainer components;

	public CreatePrintFile()
	{
		//
		// Required for Windows Form Designer support
		//
		InitializeComponent();

		//
		// TODO: Add any constructor code after InitializeComponent call
		//
	}

	#region Windows Form Designer generated code
	/**
     * Clean up any resources being used.
     */
	protected void Dispose(boolean disposing)
	{
		if (disposing)
		{
			if (components != null)
			{
				components.Dispose();
			}
		}
		super.Dispose(disposing);
	}

	/**
	 * Required method for Designer support - do not modify
	 * the contents of this method with the code editor.
	 */
	private void InitializeComponent()
	{
		this.label1 = new System.Windows.Forms.Label();
		this.txtInputPath = new System.Windows.Forms.TextBox();
		this.button1 = new System.Windows.Forms.Button();
		this.label2 = new System.Windows.Forms.Label();
		this.txtOutputFilename = new System.Windows.Forms.TextBox();
		this.button2 = new System.Windows.Forms.Button();
		this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
		this.button3 = new System.Windows.Forms.Button();
		this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
		this.button4 = new System.Windows.Forms.Button();
		this.lstSource = new System.Windows.Forms.ListBox();
		this.lstDestination = new System.Windows.Forms.ListBox();
		this.btnAddAll = new System.Windows.Forms.Button();
		this.btnAdd = new System.Windows.Forms.Button();
		this.btnMove = new System.Windows.Forms.Button();
		this.btnMoveAll = new System.Windows.Forms.Button();
		this.groupBox1 = new System.Windows.Forms.GroupBox();
		this.button5 = new System.Windows.Forms.Button();
		this.txtAddItem = new System.Windows.Forms.TextBox();
		this.groupBox1.SuspendLayout();
		this.SuspendLayout();
		// 
		// label1
		// 
		this.label1.set_AutoSize(true);
		this.label1.set_Location(new System.Drawing.Point(27, 22));
		this.label1.set_Name("label1");
		this.label1.set_Size(new System.Drawing.Size(65, 12));
		this.label1.set_TabIndex(0);
		this.label1.set_Text("文件路径:");
		// 
		// txtInputPath
		// 
		this.txtInputPath.set_Location(new System.Drawing.Point(110, 13));
		this.txtInputPath.set_Name("txtInputPath");
		this.txtInputPath.set_Size(new System.Drawing.Size(404, 21));
		this.txtInputPath.set_TabIndex(1);
		this.txtInputPath.set_Text("D:\\LogisticCore");
		// 
		// button1
		// 
		this.button1.set_Location(new System.Drawing.Point(128, 320));
		this.button1.set_Name("button1");
		this.button1.set_Size(new System.Drawing.Size(75, 23));
		this.button1.set_TabIndex(3);
		this.button1.set_Text("生成文件");
		this.button1.set_UseVisualStyleBackColor(true);
		this.button1.add_Click(new System.EventHandler(this.button1_Click));
		// 
		// label2
		// 
		this.label2.set_AutoSize(true);
		this.label2.set_Location(new System.Drawing.Point(27, 55));
		this.label2.set_Name("label2");
		this.label2.set_Size(new System.Drawing.Size(77, 12));
		this.label2.set_TabIndex(4);
		this.label2.set_Text("输出文件名:");
		// 
		// txtOutputFilename
		// 
		this.txtOutputFilename.set_Location(new System.Drawing.Point(110, 46));
		this.txtOutputFilename.set_Name("txtOutputFilename");
		this.txtOutputFilename.set_Size(new System.Drawing.Size(404, 21));
		this.txtOutputFilename.set_TabIndex(5);
		this.txtOutputFilename.set_Text("d:\\源程序合并\\源程序文档.txt");
		// 
		// button2
		// 
		this.button2.set_Location(new System.Drawing.Point(276, 320));
		this.button2.set_Name("button2");
		this.button2.set_Size(new System.Drawing.Size(75, 23));
		this.button2.set_TabIndex(6);
		this.button2.set_Text("退出");
		this.button2.set_UseVisualStyleBackColor(true);
		this.button2.add_Click(new System.EventHandler(this.button2_Click));
		// 
		// button3
		// 
		this.button3.set_Location(new System.Drawing.Point(520, 13));
		this.button3.set_Name("button3");
		this.button3.set_Size(new System.Drawing.Size(26, 23));
		this.button3.set_TabIndex(8);
		this.button3.set_Text("...");
		this.button3.set_UseVisualStyleBackColor(true);
		this.button3.add_Click(new System.EventHandler(this.button3_Click));
		// 
		// openFileDialog1
		// 
		this.openFileDialog1.set_FileName("openFileDialog1");
		// 
		// button4
		// 
		this.button4.set_Location(new System.Drawing.Point(520, 43));
		this.button4.set_Name("button4");
		this.button4.set_Size(new System.Drawing.Size(26, 23));
		this.button4.set_TabIndex(9);
		this.button4.set_Text("...");
		this.button4.set_UseVisualStyleBackColor(true);
		this.button4.add_Click(new System.EventHandler(this.button4_Click));
		// 
		// lstSource
		// 
		this.lstSource.set_FormattingEnabled(true);
		this.lstSource.set_ItemHeight(12);
		this.lstSource.get_Items().AddRange(new Object[] {
            "*.jsl",
            "*.java",
            "*.aspx",
            "*.css",
            "*.asmx",
            "*.config",
            "*.html",
            "*.htm",
            "*.txt",
            "*.sql"}
		);
		this.lstSource.set_Location(new System.Drawing.Point(18, 20));
		this.lstSource.set_Name("lstSource");
		this.lstSource.set_Size(new System.Drawing.Size(120, 148));
		this.lstSource.set_TabIndex(10);
		// 
		// lstDestination
		// 
		this.lstDestination.set_FormattingEnabled(true);
		this.lstDestination.set_ItemHeight(12);
		this.lstDestination.set_Location(new System.Drawing.Point(268, 21));
		this.lstDestination.set_Name("lstDestination");
		this.lstDestination.set_Size(new System.Drawing.Size(120, 160));
		this.lstDestination.set_TabIndex(11);
		// 
		// btnAddAll
		// 
		this.btnAddAll.set_Location(new System.Drawing.Point(166, 23));
		this.btnAddAll.set_Name("btnAddAll");
		this.btnAddAll.set_Size(new System.Drawing.Size(75, 23));
		this.btnAddAll.set_TabIndex(12);
		this.btnAddAll.set_Text(">>");
		this.btnAddAll.set_UseVisualStyleBackColor(true);
		this.btnAddAll.add_Click(new System.EventHandler(this.btnAddAll_Click));
		// 
		// btnAdd
		// 
		this.btnAdd.set_Location(new System.Drawing.Point(166, 56));
		this.btnAdd.set_Name("btnAdd");
		this.btnAdd.set_Size(new System.Drawing.Size(75, 23));
		this.btnAdd.set_TabIndex(13);
		this.btnAdd.set_Text(">");
		this.btnAdd.set_UseVisualStyleBackColor(true);
		this.btnAdd.add_Click(new System.EventHandler(this.btnAdd_Click));
		// 
		// btnMove
		// 
		this.btnMove.set_Location(new System.Drawing.Point(166, 122));
		this.btnMove.set_Name("btnMove");
		this.btnMove.set_Size(new System.Drawing.Size(75, 23));
		this.btnMove.set_TabIndex(14);
		this.btnMove.set_Text("<");
		this.btnMove.set_UseVisualStyleBackColor(true);
		this.btnMove.add_Click(new System.EventHandler(this.btnMove_Click));
		// 
		// btnMoveAll
		// 
		this.btnMoveAll.set_Location(new System.Drawing.Point(166, 89));
		this.btnMoveAll.set_Name("btnMoveAll");
		this.btnMoveAll.set_Size(new System.Drawing.Size(75, 23));
		this.btnMoveAll.set_TabIndex(15);
		this.btnMoveAll.set_Text("<<");
		this.btnMoveAll.set_UseVisualStyleBackColor(true);
		this.btnMoveAll.add_Click(new System.EventHandler(this.btnMoveAll_Click));
		// 
		// groupBox1
		// 
		this.groupBox1.get_Controls().Add(this.button5);
		this.groupBox1.get_Controls().Add(this.txtAddItem);
		this.groupBox1.get_Controls().Add(this.lstDestination);
		this.groupBox1.get_Controls().Add(this.btnMove);
		this.groupBox1.get_Controls().Add(this.btnMoveAll);
		this.groupBox1.get_Controls().Add(this.lstSource);
		this.groupBox1.get_Controls().Add(this.btnAddAll);
		this.groupBox1.get_Controls().Add(this.btnAdd);
		this.groupBox1.set_Location(new System.Drawing.Point(110, 101));
		this.groupBox1.set_Name("groupBox1");
		this.groupBox1.set_Size(new System.Drawing.Size(404, 199));
		this.groupBox1.set_TabIndex(16);
		this.groupBox1.set_TabStop(false);
		this.groupBox1.set_Text("请选择");
		// 
		// button5
		// 
		this.button5.set_Location(new System.Drawing.Point(166, 155));
		this.button5.set_Name("button5");
		this.button5.set_Size(new System.Drawing.Size(75, 23));
		this.button5.set_TabIndex(18);
		this.button5.set_Text("手工添加");
		this.button5.set_UseVisualStyleBackColor(true);
		this.button5.add_Click(new System.EventHandler(this.button5_Click));
		// 
		// txtAddItem
		// 
		this.txtAddItem.set_Location(new System.Drawing.Point(18, 160));
		this.txtAddItem.set_Name("txtAddItem");
		this.txtAddItem.set_Size(new System.Drawing.Size(120, 21));
		this.txtAddItem.set_TabIndex(17);
		this.txtAddItem.set_Text("*.xml");
		// 
		// CreatePrintFile
		// 
		this.set_AutoScaleDimensions(new System.Drawing.SizeF(6F, 12F));
		this.set_AutoScaleMode(System.Windows.Forms.AutoScaleMode.Font);
		this.set_ClientSize(new System.Drawing.Size(1016, 562));
		this.get_Controls().Add(this.groupBox1);
		this.get_Controls().Add(this.button4);
		this.get_Controls().Add(this.button3);
		this.get_Controls().Add(this.button2);
		this.get_Controls().Add(this.txtOutputFilename);
		this.get_Controls().Add(this.label2);
		this.get_Controls().Add(this.button1);
		this.get_Controls().Add(this.txtInputPath);
		this.get_Controls().Add(this.label1);
		this.set_Name("CreatePrintFile");
		this.set_Text("生成文件");
		this.set_WindowState(System.Windows.Forms.FormWindowState.Maximized);
		this.groupBox1.ResumeLayout(false);
		this.groupBox1.PerformLayout();
		this.ResumeLayout(false);
		this.PerformLayout();

	}
	#endregion

	//退出
	private void button2_Click(Object sender, System.EventArgs e)
	{
		Close();
	}

	private void button1_Click(Object sender, System.EventArgs e)
	{
		//检查是否已选择
		int count=lstDestination.get_Items().get_Count();
		if (count <= 0)
		{
			//没有选择
			MessageBox.Show("请选择!");
			return;
		}

		String aInputPath = txtInputPath.get_Text();
		String aOutputFileName = txtOutputFilename.get_Text();
		PrintFile aPrintFile = new PrintFile();
		//检查目录是否存在
		if (!Directory.Exists(aInputPath))
		{
			//目录不存在
			MessageBox.Show("目录不存在");
			return;
		}

		//检查目标文件的路径是否存在,如果不存在,则建立
		FileInfo aFile = new FileInfo(aOutputFileName);
		if(!Directory.Exists( aFile.get_Directory().ToString()))
		{
			//建立新目录
			Directory.CreateDirectory(aFile.get_Directory().ToString());
		}

		//做一些初始化工作
		String[] aExtendList=new String[count];
		String aItem;
		for (int li_ii = 0; li_ii < count; li_ii++)
		{
			aItem = lstDestination.get_Items().get_Item(li_ii).ToString();
			aExtendList[li_ii] = aItem;
		}
		aPrintFile.set_fileExtends(aExtendList);
		aPrintFile.set_outputFileName(aOutputFileName);

		//先把输出文件清空
		FileInfo aOutputFile = new FileInfo(aOutputFileName);
		StreamWriter aStreamWrite= aOutputFile.CreateText();
		aStreamWrite.Close();
		//打印的目录文件
		FileInfo aListFile = new FileInfo(aOutputFile + ".list");
		StreamWriter aListFileStreamWrite = aListFile.CreateText();
		aListFileStreamWrite.Close();

		//打印当前目录下的文件
		DirectoryInfo aDirectoryInfo = new DirectoryInfo(aInputPath);
		aPrintFile.set_workPath(aInputPath);
		aPrintFile.processDirectory(aDirectoryInfo);
		MessageBox.Show("操作完成!");
		
		
	}

	private void button3_Click(Object sender, System.EventArgs e)
	{
		folderBrowserDialog1.set_SelectedPath(txtInputPath.get_Text());
		if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
		{
			txtInputPath.set_Text(folderBrowserDialog1.get_SelectedPath());
			String aPath = txtInputPath.get_Text();
			int aIndex1 = aPath.LastIndexOf('\\');
			if (aIndex1 > 0)
			{
				String aName = aPath.Substring(aIndex1+1);
				aName = "d:\\源程序合并\\" + aName + "源程序.txt";
				txtOutputFilename.set_Text(aName);
			}

		}
	}

	private void button4_Click(Object sender, System.EventArgs e)
	{
		openFileDialog1.set_FileName(txtOutputFilename.get_Text());
		if (openFileDialog1.ShowDialog() == DialogResult.OK)
		{
			txtOutputFilename.set_Text(openFileDialog1.get_FileName());

		}
	}

	private void btnAdd_Click(Object sender, System.EventArgs e)
	{
		//添加一条
		Object  aSelectItem= lstSource.get_SelectedItem();
		if (aSelectItem != null)
		{
			if (!checkExist(aSelectItem))
			{
				lstDestination.get_Items().Add(aSelectItem);
			}
		}
	}

	private boolean checkExist(Object aObject)
	{
		int result=lstDestination.FindStringExact(aObject.ToString());
		if (result == ListBox.NoMatches)
		{
			return false;
		}
		else
		{
			return true;
		}
	}

	private void btnAddAll_Click(Object sender, System.EventArgs e)
	{
		//增加全部
		int count= lstSource.get_Items().get_Count();
		if (count > 0)
		{
			Object aItem;
			for (int li_ii = 0; li_ii < count; li_ii++)
			{
				aItem = lstSource.get_Items().get_Item(li_ii);
				if (!checkExist(aItem))
				{
					lstDestination.get_Items().Add(aItem);
				}
			}

		}
	}

	private void btnMoveAll_Click(Object sender, System.EventArgs e)
	{
		//移出全部
		lstDestination.get_Items().Clear();
	}

	private void btnMove_Click(Object sender, System.EventArgs e)
	{
		//移出一条
		Object aSelectItem = lstDestination.get_SelectedItem();
		lstDestination.get_Items().Remove(aSelectItem);
	}

	//手工添加
	private void button5_Click(Object sender, System.EventArgs e)
	{
		String aItem = txtAddItem.get_Text();
		if (!aItem.Equals(""))
		{
			if (!checkExist(aItem))
			{
				lstDestination.get_Items().Add(aItem);
				txtAddItem.set_Text("");
			}
		}
	}


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -