I'm trying to add an overlay clock to a program that basically displays the time. However, it also opens Powerpoint Shows that act as advertisements. I've added a second time display via a form and label overtop the powerpoint, but because I'm relying on the Process.WaitForExit() function I'm unable to update the clock while the powerpoint is running. How do I solve this?
What the powerpoint code looks like:
PptxClock p = new PptxClock();
Process powerPoint = new Process();
//Start the time display over the powerpoint slides
p.Show();
//Now it's time to open the powerpoint
powerPoint.StartInfo.FileName = ppfile;
powerPoint.Start();
// increment the counter so next iteration we play the next file in the list
slidetoplay += 1;
powerPoint.WaitForExit();
//The powerpoint should be over by this point. Disable the clock now.
p.Close();
What I want to run during powerPoint.WaitForExit():
private Timer ChangeTime;
//Run SetPos and WhatWeek as soon as the form loads
private void PptxClock_Load(object sender, EventArgs e)
{
UpdateTime();
SetTimer();
}
public void UpdateTime()
{
OverlayTime.Text = "Time: " + DateTime.Now.ToString("h:mm:ss") + ".";
}
//Set the timer
private void SetTimer()
{
ChangeTime = new Timer
{
Enabled = true,
Interval = 500
};
ChangeTime.Tick += new EventHandler(ChangeTime_Tick);
ChangeTime.Start();
}
//Update the time every tick. We only need the time for this simple form.
//The timer declaration is required to do this.
private void ChangeTime_Tick(object sender, EventArgs e)
{
OverlayTime.Text = "Time: " + DateTime.Now.ToString("h:mm:ss") + ".";
Console.WriteLine(DateTime.Now.ToString("h:mm:ss"));
}
I just want to be able to change the contents of the p form's time label.