161 lines
3.7 KiB
C#
161 lines
3.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CobProgAid
|
|
{
|
|
public class CodeChanger
|
|
{
|
|
|
|
public event UpdHandler Updated;
|
|
public EventArgs e = null;
|
|
public delegate void UpdHandler(CodeChanger m, EventArgs e);
|
|
|
|
//-------------------------------------------
|
|
private string template;
|
|
private string templateName;
|
|
private string filename;
|
|
private string progname;
|
|
|
|
private string xmlcopy;
|
|
private string xmlreadcopy;
|
|
private string xmlfilename;
|
|
|
|
public string Template
|
|
{
|
|
get {
|
|
return template;
|
|
}
|
|
set
|
|
{
|
|
template = value;
|
|
process();
|
|
}
|
|
}
|
|
public string TemplateName
|
|
{
|
|
get
|
|
{
|
|
return templateName;
|
|
}
|
|
set
|
|
{
|
|
templateName = value;
|
|
}
|
|
}
|
|
|
|
public string CodeOut { get; set; }
|
|
|
|
public string FileName
|
|
{
|
|
get
|
|
{
|
|
return filename;
|
|
}
|
|
set
|
|
{
|
|
filename = value;
|
|
process();
|
|
}
|
|
}
|
|
public string ProgName
|
|
{
|
|
get
|
|
{
|
|
return progname;
|
|
}
|
|
|
|
set
|
|
{
|
|
progname = value;
|
|
process();
|
|
}
|
|
}
|
|
|
|
//------------------------------------------------------
|
|
public string XMLcopy
|
|
{
|
|
get
|
|
{
|
|
return xmlcopy;
|
|
}
|
|
|
|
set
|
|
{
|
|
xmlcopy = value;
|
|
process();
|
|
}
|
|
}
|
|
public string XMLfilename
|
|
{
|
|
get
|
|
{
|
|
return xmlfilename;
|
|
}
|
|
|
|
set
|
|
{
|
|
xmlfilename = value;
|
|
process();
|
|
}
|
|
}
|
|
public string XMLReadCopy
|
|
{
|
|
get
|
|
{
|
|
return xmlreadcopy;
|
|
}
|
|
|
|
set
|
|
{
|
|
xmlreadcopy = value;
|
|
process();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------
|
|
|
|
|
|
|
|
private void process()
|
|
{
|
|
string workText = Template;
|
|
if (filename!=null&&filename != "")
|
|
{
|
|
workText = workText.Replace("XXXXX", filename);
|
|
}
|
|
if ((templateName != "CobMallLasFil" && (filename == null || filename == "")
|
|
&& progname != null && progname != "") || filename != null && filename != "" && progname != null && progname != "")
|
|
{
|
|
workText = workText.Replace("YYYYYYY", progname);
|
|
if (templateName == "CobMallLasFil")
|
|
{
|
|
workText = workText.Replace("TO" + filename.Trim(), progname);
|
|
}
|
|
workText = workText.Replace("$FNL", progname.Length.ToString("00"));
|
|
}
|
|
if (xmlcopy != null && xmlcopy != "")
|
|
{
|
|
workText = workText.Replace("$copyxmlxd", xmlcopy);
|
|
}
|
|
|
|
if (xmlreadcopy != null && xmlreadcopy != "")
|
|
{
|
|
workText = workText.Replace("$copyxmlrun", xmlreadcopy);
|
|
}
|
|
|
|
if (xmlfilename != null && xmlfilename != "")
|
|
{
|
|
workText = workText.Replace("$xmlfilnamn", xmlfilename);
|
|
}
|
|
|
|
CodeOut = workText;
|
|
Updated(this, e);
|
|
}
|
|
}
|
|
}
|