Working with a WPF application. I am very much wonderin if it is possible to get a function luke the examle below into a class function (im not yet very experianced with C#).
private void counter01_Tick(object sender, EventArgs e)
{
if (counter01Ticks > 0)
{
//subtract 1 each time
counter01Ticks--;
//subtrack 1 secon each time
counter01Span = counter01Span.Subtract(TimeSpan.FromSeconds(1));
//update the progressbar
progBar01.Value++;
//get the % to show
progBar01Text.Text = Convert.ToString(Math.Round(((progBar01.Value / progBar01.Maximum) * 100), 0)) + "%";
//Label1 will show the count down.
string countDown = counter01Span.ToString();
TimeRemain01.Content = countDown;
}
else
{
counter01.Stop();
resetCounter01();
WarningMessage msgWarnOne = new WarningMessage();
msgWarnOne.warnMessage.Text = Properties.Settings.Default.msgScout01;
msgWarnOne.ShowDialog();
}
}
It is just a part of a counter. but i want to add more counters to my application later on. Therefore i marked all the parameters with a number (01) in my code.
So what i do not want to do, i copy-paste the code and change the number for every counter, but rather have the number as a input number or something.
Would that be possible? if i9 would understand it for this small part of code, i think i will be able to do it with the other parts too (above is only the tick form a counter).
@Users that user the answer below: http://www.c-sharpcorner.com/uploadfile/mahesh/user-control-in-wpf/ Has helped me understand it better and migh be usefull to read too.