Beispiel #1
0
        public async void BtnRepeatMediaOutAsync_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (TgsRepeats.IsOn)
                {
                    #region Visible, Drawing, Rotating
                    BtnRepeatMediaOutAsync.Visibility          = Visibility.Collapsed;
                    BtnStopPauseRepeatMediaOutAsync.Visibility = Visibility.Visible;
                    stpStatus.Visibility = Visibility.Visible;
                    #endregion
                    #region Status
                    tbStatus.Text = (i + 1).ToString();
                    SRep_Status   = (i + 1).ToString();
                    IRep_Status   = Convert.ToInt16((i + 1).ToString());
                    #endregion
                    #region Code Set - Interactive
                    interactive.PlName = boxTtsRawBig.Text.Trim();
                    //Debug.WriteLine("interactive.PlName = boxTtsRawBig.Text.Trim(); \n" + interactive.PlName);
                    // interactive.ChangeTitle(IRep_Status, plName: interactive.PlName);
                    interactive.ChangeTitle(IRep_Status);
                    if (IRep_Status > 0)
                    {
                        boxTtsRawBig.Text = interactive.TitleName.Trim();

                        TsInterval = AdjustForTaskRunTime(TsInterval, PhRTiming.TsElapsed, Repetitions, out TsTotalTime);
                    }
                    #endregion
                    Repetitions = Convert.ToInt32(boxRepetitions.Text.Trim());
                    if (i == 0)
                    {
                        int intervalInSecs = Convert.ToInt32(boxInterval.Text.Trim());
                        TsInterval = new TimeSpan(0, 0, intervalInSecs);
                        TsInterval = AdjustForTaskRunTime(TsInterval, PhRTiming.TsElapsed, Repetitions, out TsTotalTime);
                        repeatDispTimer.Interval = TsInterval;
                        timesToTick = (Repetitions - 1);
                    }
                    //Increment Status
                    ////tbElapsed.Text = PhRTiming.TsElapsed.Seconds.ToString();
                    ////tbTotalTime.Text = TsTotalTime.Seconds.ToString();
                    if (i > 0 && i <= IRep_Status)
                    {
                        Debug.WriteLine("Hit if(i > 0 && i <= IRep_Status)");
                        Debug.Write(i.ToString() + " > 0 && " + i.ToString() + " <= " + IRep_Status.ToString() + "\n\n");
                    }

                    // Debug.WriteLine("\nAfter the if(1 == 0)...timesToTick = (repetitions - 1);\n" +
                    // timesToTick.ToString());
                    //BtnRepeatMediaOutAsync.Foreground = new SolidColorBrush(Windows.UI.Colors.Orange);
                    ttsRaw = boxTtsRawBig.Text.Trim();
                    try
                    {
                        await SpeakTextAsync(ttsRaw, MediaElementPrompter);
                    }
                    catch (Exception) { }

                    // Start Repeater Timer
                    repeatDispTimer.Start();

                    // Stop timer when reps are complete
                    i++;
                    if (i > timesToTick)
                    {
                        tbStatus.Text = "0";
                        repeatDispTimer.Stop();
                        BtnStopPauseRepeatMediaOutAsync.Visibility = Visibility.Collapsed;
                        BtnRepeatMediaOutAsync.Visibility          = Visibility.Visible;
                        BtnRepeatMediaOutAsync.Foreground          = new SolidColorBrush(Windows.UI.Colors.Orange);
                        stpStatus.Visibility = Visibility.Collapsed;
                        i = 0;
                    }
                }
                else
                {    //This condition is if TsReats.IsOn = false
                    BtnRepeatMediaOutAsync.Foreground = new SolidColorBrush(Windows.UI.Colors.Orange);
                    ttsRaw = boxTtsRawBig.Text.Trim();
                    try
                    {
                        await SpeakTextAsync(ttsRaw, MediaElementPrompter);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }
Beispiel #2
0
        public async void BtnRepeatMediaOutAsync_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ////**somewhere in below 4 lines are causing invalid cast exception
                //FrameworkElement parent = (FrameworkElement)((AppBarButton)sender).Parent;
                //MyParent = parent.Name;

                //Debug.WriteLine(" MyParent = parent.Name; : " + MyParent.ToString());

                //MySender = ((AppBarButton)sender).Name;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message.ToString());
            }
            try
            {
                if (TgsRepeats.IsOn)
                {
                    //  repeatDispTimer.Tick -= RepeatDispTimer_Tick;
                    //  TimerSetUp();
                    BtnRepeatMediaOutAsync.Visibility          = Visibility.Collapsed;
                    BtnStopPauseRepeatMediaOutAsync.Visibility = Visibility.Visible;
                    stpStatus.Visibility = Visibility.Visible;
                    tbStatus.Text        = (i + 1).ToString();

                    SRep_Status = (i + 1).ToString();
                    IRep_Status = Convert.ToInt16((i + 1).ToString());
                    Debug.WriteLine("Convert.ToInt16((i + 1).ToString()); \n" +
                                    IRep_Status.ToString());

                    #region Code Set - Interactive
                    //Below to allow what is in boxTtsRawBig to play first
                    interactive.PlName = boxTtsRawBig.Text.Trim();
                    //Debug.WriteLine("interactive.PlName = boxTtsRawBig.Text.Trim(); \n" +
                    //                    interactive.PlName);
                    // interactive.ChangeTitle(IRep_Status, plName: interactive.PlName);
                    interactive.ChangeTitle(IRep_Status);
                    if (IRep_Status > 0)
                    {
                        boxTtsRawBig.Text = interactive.TitleName.Trim();
                    }
                    #endregion

                    repetitions = Convert.ToInt32(boxRepetitions.Text.Trim());
                    if (i == 0)
                    {
                        int intervalInSecs = Convert.ToInt32(boxInterval.Text.Trim());
                        interval = new TimeSpan(0, 0, intervalInSecs);
                        repeatDispTimer.Interval = interval;
                        timesToTick = (repetitions - 1);
                    }

                    Debug.WriteLine("\nAfter the if(1 == 0)...timesToTick = (repetitions - 1);\n" +
                                    timesToTick.ToString());
                    BtnRepeatMediaOutAsync.Foreground = new SolidColorBrush(Windows.UI.Colors.Orange);
                    ttsRaw = boxTtsRawBig.Text.Trim();
                    try
                    {
                        await SpeakTextAsync(ttsRaw, MediaElementPrompter);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message.ToString());
                    }

                    // Start Repeater Timer
                    repeatDispTimer.Start();
                    //// Debug.WriteLine("BtnRepeatMediaOutAsync_Click " + timesToTick.ToString());
                    //// Debug.WriteLine("i = " + i.ToString());

                    // Stop timer when reps are complete
                    i++;
                    if (i > timesToTick)
                    {
                        tbStatus.Text = "0";
                        repeatDispTimer.Stop();
                        //  repeatDispTimer.Tick -= RepeatDispTimer_Tick;
                        BtnStopPauseRepeatMediaOutAsync.Visibility = Visibility.Collapsed;
                        BtnRepeatMediaOutAsync.Visibility          = Visibility.Visible;
                        BtnRepeatMediaOutAsync.Foreground          = new SolidColorBrush(Windows.UI.Colors.Black);
                        stpStatus.Visibility = Visibility.Collapsed;
                        i = 0;
                    }
                    //// Debug.WriteLine(repeatDispTimer.IsEnabled.ToString());
                }
                else
                {
                    //Debug.Write("Hit tgsReapeats.IsOn//when is false");
                    BtnRepeatMediaOutAsync.Foreground = new SolidColorBrush(Windows.UI.Colors.Orange);
                    ttsRaw = boxTtsRawBig.Text.Trim();
                    try
                    {
                        await SpeakTextAsync(ttsRaw, MediaElementPrompter);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message.ToString());
                    }
                }
            }

            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }