Esempio n. 1
0
        /************************************************************************************************************************/

        private void RoundEventTime(EventSequenceDrawer.Context context)
        {
            var time  = context.GetTime(context.SelectedEvent);
            var value = time.floatValue;

            var format = System.Globalization.NumberFormatInfo.InvariantInfo;
            var text   = value.ToString(format);
            var dot    = text.IndexOf('.');

            if (dot < 0)
            {
                return;
            }

Round:
            var newValue = (float)System.Math.Round(value, text.Length - dot - 2, System.MidpointRounding.AwayFromZero);

            if (newValue == value)
            {
                dot--;
                goto Round;
            }

            time.floatValue = newValue;
        }
        /************************************************************************************************************************/
        #region Events
        /************************************************************************************************************************/

        private void GatherEventTimes(EventSequenceDrawer.Context context)
        {
            EventTimes.Clear();

            if (context.TimeCount > 0)
            {
                var depth = context.Times.depth;
                var time  = context.GetTime(0);

                while (time.depth > depth)
                {
                    EventTimes.Add(time.floatValue * _Duration);
                    time.Next(false);
                }

                _EndTime = EventTimes[EventTimes.Count - 1];
                if (!float.IsNaN(_EndTime))
                {
                    _HasEndTime = true;
                    return;
                }
            }

            _EndTime    = AnimancerEvent.Sequence.GetDefaultNormalizedEndTime(_Speed) * _Duration;
            _HasEndTime = false;
            if (EventTimes.Count == 0)
            {
                EventTimes.Add(_EndTime);
            }
            else
            {
                EventTimes[EventTimes.Count - 1] = _EndTime;
            }
        }
Esempio n. 3
0
        /************************************************************************************************************************/

        private void NudgeEventTime(EventSequenceDrawer.Context context, bool right)
        {
            var time = context.GetTime(context.SelectedEvent);

            var value = time.floatValue;

            value = NormalizedToSeconds(value);
            value = SecondsToPixels(value);

            var nudge = right ? 1f : -1f;

            if (Event.current.shift)
            {
                nudge *= 10;
            }
            value += nudge;

            value           = PixelsToSeconds(value);
            value           = SecondsToNormalized(value);
            time.floatValue = value;
        }