//Returns value when button pressed.
        private void ReceiveResult(string result)
        {
            bool check = result.EndsWith(", CHECKED_TRUE");
            bool yes   = result.StartsWith(yesValue);
            bool no    = result.StartsWith(noValue);

            if (saveChecked)
            {
                if (saveCondition == SaveCondition.Both ||
                    (saveCondition == SaveCondition.YesOnly && yes) ||
                    (saveCondition == SaveCondition.NoOnly && no))
                {
                    defaultChecked = check;
                    SavePrefs();
                }
            }

            if (yes)
            {
                if (OnYes != null)
                {
                    OnYes.Invoke(yesValue, check);
                }
            }
            else if (no)
            {
                if (OnNo != null)
                {
                    OnNo.Invoke(noValue, check);
                }
            }
        }
Example #2
0
 //Returns value when button pressed.
 private void ReceiveResult(string result)
 {
     if (result == yesValue)
     {
         if (OnYes != null)
         {
             OnYes.Invoke(yesValue);
         }
     }
     else if (result == noValue)
     {
         if (OnNo != null)
         {
             OnNo.Invoke(noValue);
         }
     }
 }
Example #3
0
        void RecognizeYes()
        {
            if (recogInterval[Gesture.Yes] > 0)
            {
                return;
            }
            try
            {
                var         diffSum = 0.0f;
                var         didYes  = false;
                const float minDiff = 40.0f;

                var beforeX = hdms.First().eulerAngles.x;
                var index   = 0;
                foreach (var hdm in hdms)
                {
                    if (index < recogIndex[Gesture.Yes])
                    {
                        continue;
                    }
                    index++;
                    diffSum += GetAngleDiff(beforeX, hdm.eulerAngles.x);
                    if (diffSum > minDiff)
                    {
                        didYes = true;
                    }
                    beforeX = hdm.eulerAngles.x;
                }
                if (didYes && Math.Abs(diffSum) < 5f)
                {
                    if (YesHandler != null)
                    {
                        YesHandler.Invoke();
                    }
                    recogInterval[Gesture.Yes] = gestureInterval;
                    recogIndex[Gesture.Yes]    = hdms.Count;
                }
            }
            catch (InvalidOperationException)
            {
                //pass
            }
        }