UpdateClass + eventhandling of updates

This commit is contained in:
2015-09-06 23:21:04 +02:00
parent d36becfce2
commit fb52d949b6
3 changed files with 29 additions and 23 deletions

View File

@ -44,6 +44,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CodeChanger.cs" />
<Compile Include="frmProgAidHome.cs">
<SubType>Form</SubType>
</Compile>

View File

@ -106,6 +106,7 @@
this.cmbFilename.Name = "cmbFilename";
this.cmbFilename.Size = new System.Drawing.Size(80, 21);
this.cmbFilename.TabIndex = 7;
this.cmbFilename.SelectedIndexChanged += new System.EventHandler(this.cmbFilename_SelectedIndexChanged);
//
// label3
//
@ -122,6 +123,7 @@
this.txtProgramName.Name = "txtProgramName";
this.txtProgramName.Size = new System.Drawing.Size(100, 20);
this.txtProgramName.TabIndex = 9;
this.txtProgramName.TextChanged += new System.EventHandler(this.txtProgramName_TextChanged);
//
// label4
//

View File

@ -20,10 +20,13 @@ namespace CobProgAid
string resourceKey;
string workItem = string.Empty;
ShowCode ShCd;
CodeChanger coch;
public frmProgAidHome()
{
InitializeComponent();
coch = new CodeChanger();
Subscribe(coch);
}
private void btnClose_Click(object sender, EventArgs e)
@ -40,7 +43,7 @@ namespace CobProgAid
lstProgTyp.Items.Add(resourceKey);
}
foreach(string file in Properties.Settings.Default.FileNames)
foreach (string file in Properties.Settings.Default.FileNames)
{
cmbFilename.Items.Add(file);
}
@ -50,17 +53,7 @@ namespace CobProgAid
{
workItem = resourceSet.GetString(lstProgTyp.SelectedItem.ToString());
//string comment = resourceSet.
txtShow.Text = workItem;
if (cmbFilename.Text != "")
{
txtShow.Text= txtShow.Text.Replace("XXXXX", cmbFilename.Text);
}
if (txtProgramName.Text != "")
{
txtShow.Text = txtShow.Text.Replace("YYYYYYY", txtProgramName.Text);
txtShow.Text = txtShow.Text.Replace("TO"+ cmbFilename.Text.Trim(), txtProgramName.Text);
txtShow.Text = txtShow.Text.Replace("$FNL", txtProgramName.Text.Length.ToString("00"));
}
coch.Template = workItem;
}
@ -69,18 +62,28 @@ namespace CobProgAid
ShCd = new ShowCode();
ShCd.Parent = this;
ShCd.Labeltext = resourceKey;
ShCd.CodeShower.Text = workItem;
if (cmbFilename.Text != "")
{
ShCd.CodeShower.Text = ShCd.CodeShower.Text.Replace("XXXXX", cmbFilename.Text);
}
if (txtProgramName.Text != "")
{
ShCd.CodeShower.Text = ShCd.CodeShower.Text.Replace("YYYYYYY", txtProgramName.Text);
ShCd.CodeShower.Text = ShCd.CodeShower.Text.Replace("TO" + cmbFilename.Text.Trim(), txtProgramName.Text);
ShCd.CodeShower.Text = ShCd.CodeShower.Text.Replace("$FNL", txtProgramName.Text.Length.ToString("00"));
}
ShCd.CodeShower.Text = coch.CodeOut;
ShCd.ShowDialog();
}
private void txtProgramName_TextChanged(object sender, EventArgs e)
{
coch.ProgName = txtProgramName.Text;
}
private void cmbFilename_SelectedIndexChanged(object sender, EventArgs e)
{
coch.FileName = cmbFilename.Text;
}
public void Subscribe(CodeChanger m)
{
m.Updated += new CodeChanger.UpdHandler(UpdateText);
}
private void UpdateText(CodeChanger m, EventArgs e)
{
txtShow.Text = coch.CodeOut;
}
}
}