📄 bindowsappcreator.cs
字号:
using System;using System.IO;using System.Collections;using System.Text.RegularExpressions;namespace FormExport { public class BindowsAppCreator { private string m_AppName; private string m_AppDir; private string m_BindowsBase; private string m_TemplatesDir; private string m_Markup; public BindowsAppCreator( string AppName ) { m_AppName = AppName; m_AppDir = m_AppName; m_TemplatesDir = "./templates/"; m_Markup = "<Application><Window caption='__APP__NAME__ Application' width='600' height='400' centered='true'></Window><Resources><Script src='__APP__NAME__.js'/></Resources></Application>"; m_BindowsBase = "../../../html/"; } private void CreateAppFile( string src, string dst ) { string SrcFullPath = this.m_TemplatesDir; if (!Directory.Exists( SrcFullPath )) { throw new Exception( "Directory " + SrcFullPath + " does not exist" ); } SrcFullPath += src; if (!File.Exists( SrcFullPath )) { throw new Exception( "File " + m_TemplatesDir + " does not exist" ); } string DstFullPath = this.m_AppDir; if (!Directory.Exists( DstFullPath )) { throw new Exception( "Directory " + DstFullPath + " does not exist" ); } if ( DstFullPath.Substring( DstFullPath.Length - 1) != "\\" ) DstFullPath += "\\"; DstFullPath += dst; StreamReader fin = new StreamReader( SrcFullPath ); StreamWriter fout= new StreamWriter( DstFullPath ); String s; do { s = fin.ReadLine(); if ( s == null ) break; s = s.Replace( "__APP__NAME__", m_AppName ); s = s.Replace( "__BINDOWS_BASE__", m_BindowsBase ); fout.WriteLine( s ); } while( true ); fin.Close(); fout.Close(); } private void CreateAdf() { string DstFullPath = this.m_AppDir; if (!Directory.Exists( DstFullPath )) { throw new Exception( "Directory " + DstFullPath + " does not exist" ); } if ( DstFullPath.Substring( DstFullPath.Length - 1) != "\\" ) DstFullPath += "\\"; DstFullPath += ( this.m_AppName + ".xml" ); StreamWriter fout= new StreamWriter( DstFullPath ); string s = this.m_Markup; s = s.Replace( "__APP__NAME__", m_AppName ); s = s.Replace( "__BINDOWS_BASE__", m_AppName ); fout.Write( s ); fout.Close(); } public string Markup { get { return this.m_Markup; } set { this.m_Markup = value; } } public void Create() { string DstFullPath = this.m_AppDir; if (!Directory.Exists( DstFullPath )) { Directory.CreateDirectory( DstFullPath ); } CreateAdf(); CreateAppFile( "index.html", "index.html" ); CreateAppFile( "sample.hta", this.m_AppName + ".hta" ); CreateAppFile( "sample.js", this.m_AppName + ".js" ); CreateAppFile( "launcher.html", "launcher.html" ); }/**/ }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -