예제 #1
0
        /// <summary>
        /// Returns the parameter list for the specified action
        /// </summary>
        /// <param name="action">action to get the parameters for</param>
        /// <returns>Dictionary of parameters if possible, else throws</returns>
        private static Dictionary <string, object> _GetParameters(this IAction action)
        {
            if (null == action)
            {
                throw new ArgumentNullException("action can not be null");
            }

            var             actionType      = action.GetType();
            ActionParameter actionParameter = null;

            if (actionType == _ScreenPressActionType.Value)
            {
                var x = _ScreenPressFieldInfoList.Value.Find(s => s.Name == "x").GetValue(action);
                var y = _ScreenPressFieldInfoList.Value.Find(s => s.Name == "y").GetValue(action);

                actionParameter = new ActionParameter("press");
                actionParameter.AddParameter("x", x);
                actionParameter.AddParameter("y", y);
            }
            else if (actionType == _ScreenReleaseActionType.Value)
            {
                actionParameter = new ActionParameter("release");
            }
            else if (actionType == _ScreenMoveActionType.Value)
            {
                var x = _ScreenMoveFieldInfoList.Value.Find(s => s.Name == "x").GetValue(action);
                var y = _ScreenMoveFieldInfoList.Value.Find(s => s.Name == "y").GetValue(action);

                actionParameter = new ActionParameter("moveTo");
                actionParameter.AddParameter("x", x);
                actionParameter.AddParameter("y", y);
            }
            else if (actionType == typeof(WaitAction))
            {
                actionParameter = new ActionParameter("wait");
                actionParameter.AddParameter("ms", ((WaitAction)action).Duration);
            }

            if (null == actionParameter)
            {
                throw new NotImplementedException(string.Format("Multi Touch does not support this feature {0}", action.GetType()));
            }

            return(actionParameter.GetDictionary());
        }
        /// <summary>
        /// Returns the parameter list for the specified action
        /// </summary>
        /// <param name="action">action to get the parameters for</param>
        /// <returns>Dictionary of parameters if possible, else throws</returns>
        private static Dictionary<string, object> _GetParameters(this IAction action)
        {
            if (null == action)
            {
                throw new ArgumentNullException("action can not be null");
            }

            var actionType = action.GetType();
            ActionParameter actionParameter = null;

            if (actionType == _ScreenPressActionType.Value)
            {
                var x = _ScreenPressFieldInfoList.Value.Find(s => s.Name == "x").GetValue(action);
                var y = _ScreenPressFieldInfoList.Value.Find(s => s.Name == "y").GetValue(action);

                actionParameter = new ActionParameter("press");
                actionParameter.AddParameter("x", x);
                actionParameter.AddParameter("y", y);
            }
            else if (actionType == _ScreenReleaseActionType.Value)
            {
                actionParameter = new ActionParameter("release");
            }
            else if (actionType == _ScreenMoveActionType.Value)
            {
                var x = _ScreenMoveFieldInfoList.Value.Find(s => s.Name == "x").GetValue(action);
                var y = _ScreenMoveFieldInfoList.Value.Find(s => s.Name == "y").GetValue(action);

                actionParameter = new ActionParameter("moveTo");
                actionParameter.AddParameter("x", x);
                actionParameter.AddParameter("y", y);
            }
            else if (actionType == typeof(WaitAction))
            {
                actionParameter = new ActionParameter("wait");
                actionParameter.AddParameter("ms", ((WaitAction)action).Duration);
            }

            if (null == actionParameter)
            {
                throw new NotImplementedException(string.Format("Multi Touch does not support this feature {0}", action.GetType()));
            }

            return actionParameter.GetDictionary();
        }