public void Init() { if (launcherShape.HasTextFrame == Microsoft.Office.Core.MsoTriState.msoTrue) { // Copy duration from launcher to actual countdown timerShape.TextFrame.TextRange.Text = launcherShape.TextFrame.TextRange.Text; // Get duration timerDuration = timerShape.TextFrame.TextRange.Text; // Convert it to TimeSpan if (!TimeSpan.TryParseExact(timerDuration, "mm\\:ss", CultureInfo.InvariantCulture, out timerDurationTimeSpan)) { Status = CountDownStatusEnum.Invalid; } else { // copy style & position from the launcher to the actual countdown timerShape.Width = launcherShape.Width; timerShape.Height = launcherShape.Height; timerShape.Left = launcherShape.Left; timerShape.Top = launcherShape.Top; launcherShape.PickUp(); timerShape.Apply(); Status = CountDownStatusEnum.Ready; } } else { Status = CountDownStatusEnum.Invalid; } }
public void Start() { if (Status == CountDownStatusEnum.Ready) { timerShape.Visible = Microsoft.Office.Core.MsoTriState.msoTrue; if (launcherShape != null) { launcherShape.Visible = Microsoft.Office.Core.MsoTriState.msoFalse; } // Start timer and ignite Count down timer = new Timer(Constants.RefreshTimeSpan.TotalMilliseconds); timer.Elapsed += OnTimerElapsed; timer.Start(); Status = CountDownStatusEnum.Running; } }
public void Stop() { timerShape.TextFrame.TextRange.Text = timerDuration; // Restore launcher view timerShape.Visible = Microsoft.Office.Core.MsoTriState.msoFalse; if (launcherShape != null) { launcherShape.Visible = Microsoft.Office.Core.MsoTriState.msoTrue; } if (timer != null) { timer.Dispose(); } Status = CountDownStatusEnum.Ready; }