Added CodeChanger class

This commit is contained in:
2015-09-06 23:32:48 +02:00
parent fb52d949b6
commit 257a0f9a13

View File

@ -0,0 +1,77 @@
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 filename;
private string progname;
public string Template
{
get {
return template;
}
set
{
template = value;
process();
}
}
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();
}
}
private void process()
{
string workText = Template;
if (filename!=null&&filename != "")
{
workText = workText.Replace("XXXXX", filename);
}
if (filename != null && progname != null && progname != "" && filename != "")
{
workText = workText.Replace("YYYYYYY", progname);
workText = workText.Replace("TO" + filename.Trim(), progname);
workText = workText.Replace("$FNL", progname.Length.ToString("00"));
}
CodeOut = workText;
Updated(this, e);
}
}
}