Пример #1
0
        private ActionResult SeekAction(ArTimeSpan value)
        {
            TimeSpan newValue;

            if (value.IsRelative)
            {
                newValue = TimeSource.Progress + value.Value;
            }
            else
            {
                newValue = value.Value;
            }

            if (newValue < TimeSpan.Zero)
            {
                newValue = TimeSpan.Zero;
            }

            if (newValue > TimeSource.Duration)
            {
                newValue = TimeSource.Duration;
            }

            Seek(newValue, 1);

            return(new ActionResult(true, "Seeking"));
        }
Пример #2
0
        private object ConvertParameter(string value, Type targetType, out bool success)
        {
            success = true;

            try
            {
                if (typeof(IConvertible).IsAssignableFrom(targetType))
                {
                    return(Convert.ChangeType(value, targetType));
                }

                if (targetType == typeof(string))
                {
                    return(value);
                }

                if (targetType == typeof(ArTimeSpan))
                {
                    ArTimeSpan result = new ArTimeSpan();
                    if (!result.TryParse(value))
                    {
                        success = false;
                        return(null);
                    }

                    return(result);
                }

                if (targetType == typeof(ArInt))
                {
                    ArInt result = new ArInt();
                    if (!result.TryParse(value))
                    {
                        success = false;
                        return(null);
                    }

                    return(result);
                }
            }
            catch
            {
                //
            }

            success = false;
            return(false);
        }