Ejemplo n.º 1
0
        private void formNextAction()
        {
            switch (promptState)
            {
            case PromptState.answering:
            {
                verbiage = Verbs.GetAConjugation(conjugation);
                verbiageList.Add(verbiage);
                label1.Text = verbiage.Infinitive;
                label2.Text = verbiage.Pronoun.ToString();
                label3.Text = "";

                //if (verbiage.IsIrregular)
                //{
                //    label3.Text = "Irregular";
                //}
                promptState = PromptState.prompting;
            }
            break;

            case PromptState.prompting:
            {
                label1.Text = "";
                label3.Text = "";
                label2.Text = verbiage.Pronoun.ToString() + " " + verbiage.ConjugatedVerb;
                promptState = PromptState.answering;
            }
            break;
            }
        }
Ejemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            promptState = PromptState.answering;
            string[] args = new string[1];

            args[0] = BaseDir;
            Verbs.StaticConstructor(args);

            formNextAction();
        }
Ejemplo n.º 3
0
        public static void ShowPromptForm(Form parent, PromptState state, String message)
        {
            PromptForm pf = new PromptForm(state, message);

            //pf.TopLevel = false;
            //parent.Controls.Add(pf);
            //pf.Parent = parent;
            //pf.Location = new Point((parent.Width - pf.Width) / 2, (parent.Height - pf.Height) / 2);
            pf.StartPosition = FormStartPosition.CenterScreen;
            // pf.BringToFront();
            //pf.CenterToParent();
            pf.ShowDialog();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Transition to the specified visual state, taking delays and other transition logic
        /// into account.
        /// </summary>
        /// <param name="state">
        /// New state to transition into.
        /// </param>
        /// <param name="useTransitions">
        /// True to use a VisualTransition to transition between states, false otherwise.
        /// </param>
        /// <param name="delayTransition">
        /// True if transition should be delayed even if minimum amount of time has already
        /// been spent in current state, false otherwise.
        /// </param>
        private void GoToVisualState(PromptState state, bool useTransitions, bool delayTransition)
        {
            var  currentTime       = DateTime.UtcNow;
            bool isStateTransition = !this.currentVisualState.HasValue || (state != this.currentVisualState.Value);

            this.minimumStateDurationTimer.Stop();
            this.stateTransitionDelayTimer.Stop();

            if (!isStateTransition)
            {
                // If we're not transitioning states, there is no work to do.
                return;
            }

            if (this.currentVisualState.HasValue)
            {
                // If current state is valid and new state is different from current state,
                // verify that we've spent at least the minimum amount of time required in
                // the current state
                var timeInCurrentState = currentTime.Subtract(this.timeEnteredVisualState);
                var timeRemaining      = this.MinimumStateDuration.Subtract(timeInCurrentState);

                if (timeRemaining.CompareTo(this.zeroDuration) > 0)
                {
                    // If we need to spend more time in current state before transitioning,
                    // defer transition until enough time passes.
                    this.minimumStateDurationTimer.Interval = timeRemaining;
                    this.minimumStateDurationTimer.Start();
                    return;
                }
            }

            if (delayTransition)
            {
                // If state transition is to be delayed even after spending minimum time
                // in current state, start transition delay timer.
                this.stateTransitionDelayTimer.Interval = this.StateTransitionDelay;
                this.stateTransitionDelayTimer.Start();
                return;
            }

            if (VisualStateManager.GoToState(this, GetVisualStateName(state), useTransitions))
            {
                // If state transition was successful, remember state we transitioned to
                // and time of transition.
                this.currentVisualState     = state;
                this.timeEnteredVisualState = currentTime;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Figures out the appropriate visual state name corresponding to the state
        /// trigger values.
        /// </summary>
        /// <param name="state">
        /// Logical state.
        /// </param>
        /// <returns>
        /// String name of appropriate visual state.
        /// </returns>
        private static string GetVisualStateName(PromptState state)
        {
            switch (state)
            {
            case PromptState.Hidden:
                return(HiddenState);

            case PromptState.Prompting:
                return(PromptingState);

            case PromptState.Dismissed:
                return(DismissedState);
            }

            return(HiddenState);
        }
Ejemplo n.º 6
0
        private void TimeOutTimerStep(object userSpecific)
        {
            if (SecondsRemaining == 0)
            {
                return;
            }

            if (SecondsRemaining > 0)
            {
                SecondsRemaining--;
            }

            if (SecondsRemaining == 0)
            {
                CallBack(this);
                State = PromptState.TimedOut;
            }
        }
Ejemplo n.º 7
0
        public PromptForm(PromptState state, String message)
        {
            InitializeComponent();
            try
            {
                /**
                 * 之前使用了3个pictureBox来展示三种图标,
                 * 实际上只需要一个pictureBox就可以展示,
                 * 另外加上了对话框状态的枚举状态,通过switch case来判断
                 * Modyfied by:sjh
                 * Modyfied time:2017-04-13
                 * */
                switch (state)
                {
                case PromptState.Success:     /*this.pictureBox_success.Visible = true;
                                               * this.pictureBox_fail.Visible = false;
                                               * this.pictureBox_warm.Visible = false;*/
                    this.pictureBox.Image = AutoUpdate.Resource1.pictureBox_success_Image;
                    break;

                case PromptState.Fail:        /*this.pictureBox_success.Visible = false;
                                               * this.pictureBox_fail.Visible = true;
                                               * this.pictureBox_warm.Visible = false;*/
                    this.pictureBox.Image = AutoUpdate.Resource1.pictureBox_fail_Image;
                    break;

                case PromptState.Warn:        /*this.pictureBox_success.Visible = false;
                                               * this.pictureBox_fail.Visible = false;
                                               * this.pictureBox_warm.Visible = true;*/

                    this.pictureBox.Image = AutoUpdate.Resource1.pictureBox_warn_Image;
                    break;

                default: break;
                }
                //this.label1.Text = message;
                this.textMessage.Text = message;
                this.pictureBox.Size  = pictureBox.Image.Size;
            } catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 8
0
        public void Respond(PromptAction action)
        {
            if (State != PromptState.Shown)
            {
                return;
            }

            try
            {
                Response = new PromptResponse(action);
                CallBack(this);
            }
            catch (Exception e)
            {
                CloudLog.Exception(e);
            }

            State = PromptState.Actioned;
        }
Ejemplo n.º 9
0
        private void formNextAction()
        {
            switch (promptState)
            {
            case PromptState.answering:
            {
                if (gobackIndex > 0)
                {
                    gobackIndex = 0;
                    vocabEntry  = vocabEntryList[vocabEntryList.Count - 2];
                }
                else
                {
                    vocabEntry = vocab.getRandomVocabEntry();
                    vocabEntryList.Add(vocabEntry);
                }
                label1.Text = vocabEntry.portuguese;
                label2.Text = "";
                label3.Text = "";

                //if (verbiage.IsIrregular)
                //{
                //    label3.Text = "Irregular";
                //}
                promptState = PromptState.prompting;
            }
            break;

            case PromptState.prompting:
            {
                label1.Text = vocabEntry.genderToString() + " " + vocabEntry.portuguese;
                label3.Text = "";
                label2.Text = "";
                promptState = PromptState.answering;
            }
            break;
            }
        }
Ejemplo n.º 10
0
        void InternalPrompt(bool multiline, bool move_cursor=true)
        {
            promptState = multiline ? PromptState.Multiline : PromptState.Regular;
            if (!multiline)
                blockText = "";

            startOfPrompt = Buffer.CreateMark(null, Buffer.EndIter, true);

            TextIter end = Buffer.EndIter;
            if (multiline)
                Buffer.Insert (ref end, PromptMultiLineString);
            else
                Buffer.Insert (ref end, PromptString);

            // Record the end of where we processed, used to calculate start
            // of next input line
            endOfLastProcessing = Buffer.CreateMark (null, Buffer.EndIter, true);

            // Freeze all the text except our input line
            Buffer.ApplyTag(Buffer.TagTable.Lookup("Freezer"), Buffer.StartIter, InputLineBegin);

            if (move_cursor)
            {
                Buffer.PlaceCursor (Buffer.EndIter);
                textView.ScrollMarkOnscreen (Buffer.InsertMark);
            }
        }
Ejemplo n.º 11
0
        void FinalizeLine(bool move_cursor=true)
        {
            if (this.blockText == "")
                this.blockText += InputLine;
            else
                this.blockText += Environment.NewLine + InputLine;

            // Everything but the last item (which was input),
            //in the future stack needs to get put back into the
            // past stack
            while (commandHistoryFuture.Count > 1)
                commandHistoryPast.Push (commandHistoryFuture.Pop());
            // Clear the pesky junk input line
            commandHistoryFuture.Clear();

            // Record our input line
            commandHistoryPast.Push(InputLine);
            if (scriptLines == "")
                scriptLines += InputLine;
            else
                scriptLines += Environment.NewLine + InputLine;

            var end = Buffer.EndIter;
            Buffer.Insert(ref end, Environment.NewLine);
            startOfPrompt = Buffer.CreateMark(null, Buffer.EndIter, true);
            endOfLastProcessing = Buffer.CreateMark (null, Buffer.EndIter, true);
            promptState = PromptState.None;
            Buffer.ApplyTag(Buffer.TagTable.Lookup("Freezer"), Buffer.StartIter, InputLineBegin);

            if (move_cursor)
            {
                Buffer.PlaceCursor (Buffer.EndIter);
                textView.ScrollMarkOnscreen (Buffer.InsertMark);
                // Freeze all the text except our input line
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Transition to the specified visual state, taking delays and other transition logic
        /// into account.
        /// </summary>
        /// <param name="state">
        /// New state to transition into.
        /// </param>
        /// <param name="useTransitions">
        /// True to use a VisualTransition to transition between states, false otherwise.
        /// </param>
        /// <param name="delayTransition">
        /// True if transition should be delayed even if minimum amount of time has already
        /// been spent in current state, false otherwise.
        /// </param>
        private void GoToVisualState(PromptState state, bool useTransitions, bool delayTransition)
        {
            var currentTime = DateTime.UtcNow;
            bool isStateTransition = !this.currentVisualState.HasValue || (state != this.currentVisualState.Value);
            this.minimumStateDurationTimer.Stop();
            this.stateTransitionDelayTimer.Stop();

            if (!isStateTransition)
            {
                // If we're not transitioning states, there is no work to do.
                return;
            }

            if (this.currentVisualState.HasValue)
            {
                // If current state is valid and new state is different from current state,
                // verify that we've spent at least the minimum amount of time required in
                // the current state
                var timeInCurrentState = currentTime.Subtract(this.timeEnteredVisualState);
                var timeRemaining = this.MinimumStateDuration.Subtract(timeInCurrentState);

                if (timeRemaining.CompareTo(this.zeroDuration) > 0)
                {
                    // If we need to spend more time in current state before transitioning,
                    // defer transition until enough time passes.
                    this.minimumStateDurationTimer.Interval = timeRemaining;
                    this.minimumStateDurationTimer.Start();
                    return;
                }
            }

            if (delayTransition)
            {
                // If state transition is to be delayed even after spending minimum time
                // in current state, start transition delay timer.
                this.stateTransitionDelayTimer.Interval = this.StateTransitionDelay;
                this.stateTransitionDelayTimer.Start();
                return;
            }

            if (VisualStateManager.GoToState(this, GetVisualStateName(state), useTransitions))
            {
                // If state transition was successful, remember state we transitioned to
                // and time of transition.

                if (PromptState.Hidden == state||PromptState.Dismissed==state)
                {
                    RoutedEventArgs rea = new RoutedEventArgs(PromptControl.CancelStateEvent, this);
                    this.RaiseEvent(rea);
                }
                else
                {
                    RoutedEventArgs rea = new RoutedEventArgs(PromptControl.ConfirmStateEvent, this);
                    this.RaiseEvent(rea);
                }

                this.currentVisualState = state;
                this.timeEnteredVisualState = currentTime;
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Figures out the appropriate visual state name corresponding to the state
        /// trigger values.
        /// </summary>
        /// <param name="state">
        /// Logical state.
        /// </param>
        /// <returns>
        /// String name of appropriate visual state.
        /// </returns>
        private static string GetVisualStateName(PromptState state)
        {
            switch (state)
            {
                case PromptState.Hidden:
                    return HiddenState;

                case PromptState.Prompting:
                    return PromptingState;

                case PromptState.Dismissed:
                    return DismissedState;
            }

            return HiddenState;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Update values of properties related to engagement handoff from the values of other properties that
        /// affect them.
        /// </summary>
        private void UpdateEngagementHandoffState(bool confirmHandoff)
        {
            if (this.handoffConfirmationStasisTimer.IsEnabled)
            {
                // If timer is already running, wait for it to finish
                return;
            }

            if (confirmHandoff)
            {
                // If confirming handoff, mark handoff confirmation prompts as
                // dismissed and start timer to re-update state later.
                this.ClearEngagementHandoff();
                this.LeftHandoffConfirmationState  = PromptState.Dismissed;
                this.RightHandoffConfirmationState = PromptState.Dismissed;
                this.handoffConfirmationStasisTimer.Start();

                return;
            }

            if ((this.engagementStateManager.EngagedUserTrackingId == EngagementStateManager.InvalidUserTrackingId) ||
                (this.engagementStateManager.EngagedUserTrackingId == this.engagementStateManager.PrimaryUserTrackingId) ||
                (this.engagementStateManager.TrackedUserTrackingIds.Count < 2))
            {
                // If we're currently transitioning engagement states, if there is no engaged
                // user, if engaged user is actively interacting, or there is nobody besides the
                // engaged user, then there is no need for engagement handoff UI to be shown.
                this.ClearEngagementHandoff();
                return;
            }

            int nonEngagedId = this.engagementStateManager.TrackedUserTrackingIds.FirstOrDefault(trackingId => trackingId != this.engagementStateManager.EngagedUserTrackingId);

            SkeletonPoint?lastEngagedPosition =
                this.engagementStateManager.TryGetLastPositionForId(this.engagementStateManager.EngagedUserTrackingId);
            SkeletonPoint?lastNonEngagedPosition = this.engagementStateManager.TryGetLastPositionForId(nonEngagedId);

            if (!lastEngagedPosition.HasValue || !lastNonEngagedPosition.HasValue)
            {
                // If we can't determine the relative position of engaged and non-engaged user,
                // we don't show an engagement handoff prompt at all.
                this.ClearEngagementHandoff();
                return;
            }

            PromptState engagedMessageState         = PromptState.Hidden;
            string      engagedMessageText          = string.Empty;
            Brush       engagedBrush                = this.EngagedUserMessageBrush;
            PromptState engagedConfirmationState    = PromptState.Hidden;
            PromptState nonEngagedMessageState      = PromptState.Prompting;
            string      nonEngagedMessageText       = Properties.Resources.EngagementHandoffGetStarted;
            Brush       nonEngagedBrush             = this.TrackedUserMessageBrush;
            PromptState nonEngagedConfirmationState = PromptState.Hidden;

            if ((EngagementStateManager.InvalidUserTrackingId != this.engagementStateManager.CandidateUserTrackingId) &&
                (nonEngagedId == this.engagementStateManager.CandidateUserTrackingId))
            {
                // If non-engaged user is an engagement candidate
                engagedMessageState         = PromptState.Prompting;
                engagedMessageText          = Properties.Resources.EngagementHandoffKeepControl;
                nonEngagedMessageText       = string.Empty;
                nonEngagedConfirmationState = PromptState.Prompting;
            }

            bool isEngagedOnLeft = lastEngagedPosition.Value.X < lastNonEngagedPosition.Value.X;

            this.LeftHandoffMessageState       = isEngagedOnLeft ? engagedMessageState : nonEngagedMessageState;
            this.LeftHandoffMessageText        = isEngagedOnLeft ? engagedMessageText : nonEngagedMessageText;
            this.LeftHandoffMessageBrush       = isEngagedOnLeft ? engagedBrush : nonEngagedBrush;
            this.LeftHandoffConfirmationState  = isEngagedOnLeft ? engagedConfirmationState : nonEngagedConfirmationState;
            this.RightHandoffMessageState      = isEngagedOnLeft ? nonEngagedMessageState : engagedMessageState;
            this.RightHandoffMessageText       = isEngagedOnLeft ? nonEngagedMessageText : engagedMessageText;
            this.RightHandoffMessageBrush      = isEngagedOnLeft ? nonEngagedBrush : engagedBrush;
            this.RightHandoffConfirmationState = isEngagedOnLeft ? nonEngagedConfirmationState : engagedConfirmationState;
        }
Ejemplo n.º 15
0
 public void Cancel()
 {
     State = PromptState.Cancelled;
 }
Ejemplo n.º 16
0
 private void GoToVisualState(PromptState state, bool useTransitions)
 {
     this.GoToVisualState(state, useTransitions, true);
 }
Ejemplo n.º 17
0
 private void GoToVisualState(PromptState state, bool useTransitions)
 {
     this.GoToVisualState(state, useTransitions, true);
 }