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" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CodeChanger.cs" />
<Compile Include="frmProgAidHome.cs"> <Compile Include="frmProgAidHome.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>

View File

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

View File

@ -20,10 +20,13 @@ namespace CobProgAid
string resourceKey; string resourceKey;
string workItem = string.Empty; string workItem = string.Empty;
ShowCode ShCd; ShowCode ShCd;
CodeChanger coch;
public frmProgAidHome() public frmProgAidHome()
{ {
InitializeComponent(); InitializeComponent();
coch = new CodeChanger();
Subscribe(coch);
} }
private void btnClose_Click(object sender, EventArgs e) private void btnClose_Click(object sender, EventArgs e)
@ -50,17 +53,7 @@ namespace CobProgAid
{ {
workItem = resourceSet.GetString(lstProgTyp.SelectedItem.ToString()); workItem = resourceSet.GetString(lstProgTyp.SelectedItem.ToString());
//string comment = resourceSet. //string comment = resourceSet.
txtShow.Text = workItem; coch.Template = 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"));
}
} }
@ -69,18 +62,28 @@ namespace CobProgAid
ShCd = new ShowCode(); ShCd = new ShowCode();
ShCd.Parent = this; ShCd.Parent = this;
ShCd.Labeltext = resourceKey; ShCd.Labeltext = resourceKey;
ShCd.CodeShower.Text = workItem; ShCd.CodeShower.Text = coch.CodeOut;
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.ShowDialog(); 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;
}
} }
} }