Added CodeChanger class
This commit is contained in:
77
CobProgAid/CobProgAid/CodeChanger.cs
Normal file
77
CobProgAid/CobProgAid/CodeChanger.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user