public override ID GetParentID(ItemDefinition itemDefinition, CallContext context) { if (itemDefinition.ID == FolderId) { return(ParentId); } if (ControllerType.GetControllerType(ParentId, itemDefinition.ID) != null) { return(FolderId); } ControllerAction action; if ((action = ControllerAction.GetControllerAction(ParentId, itemDefinition.ID)) != null) { return(ControllerType.GetControllerIds(ParentId.ToGuid()).Where(kv => kv.Value.Type == action.ControllerType.Type) .Select(kv => new ID(kv.Key)).FirstOrDefault()); } //if (itemDefinition.ID == TemplateFolderId) // return ItemIDs.TemplateRoot; //if (itemDefinition.ID == TemplateId) // return TemplateFolderId; return(base.GetParentID(itemDefinition, context)); }
public async Task <ActionResult> CreateRole([Bind(Include = "RoleId,RoleName,Description")] Role role, List <int> selectedActions) { if (ModelState.IsValid) { if (!String.Equals(role.RoleName, "SuperAdmin", StringComparison.CurrentCultureIgnoreCase)) { if (selectedActions != null) { foreach (var selectedAction in selectedActions) { ControllerAction controllerAction = _dbContext.ControllerActions.Find(selectedAction); role.ControllerActions.Add(controllerAction); } } } _dbContext.Roles.Add(role); await _dbContext.SaveChangesAsync(); return(RedirectToAction("RoleList")); } ViewBag.AllActionCategories = await _dbContext.ActionCategories.AsNoTracking().ToListAsync(); return(View(role)); }
public ActionResult MenuRoleAction(int id) { ViewBag.Title = "Role Action"; int menuID = id; int company_id = SessionUtil.GetCompanyID(); IList <ControllerAction> list = new List <ControllerAction>(); var listController = STUtil.GetListController(); //Nedd to check data in respwct of ViewBag.action_name = new List <SelectListItem>(); ViewBag.menu_id = menuID; foreach (var c in listController) { string controllerName = c.Value; var listAllAction = STUtil.GetListAllActionByController(controllerName); var listAssignedAction = (from r in db.menu_access_controller_action where r.menu_id == menuID && r.controller_name == controllerName orderby r.action_name select new SelectListItem { Value = r.action_name, Text = r.action_name, }).ToList(); foreach (var aa in listAllAction) { ControllerAction ca = new ControllerAction(); ca.ControllerName = controllerName; ca.ActionName = aa.Text; ca.IsAssigned = listAssignedAction.Where(a => a.Text == aa.Text).Count() > 0 ? true : false; list.Add(ca); } } return(PartialView("_MenuRoleAction", list)); }
void AddAllActions(IDList list, ControllerType controllerType) { foreach (var action in ControllerAction.GetAllActions(ParentId.ToGuid()).Where(a => a.ControllerType.Type == controllerType.Type)) { list.Add(new ID(action.Id)); } }
private async Task DeleteControllerActionAsync(ControllerAction controllerAction) { try { if (await _dialogService.ShowQuestionDialogAsync( Translate("Confirm"), Translate("AreYouSureToDeleteThisControllerAcrion"), Translate("Yes"), Translate("No"), _disappearingTokenSource.Token)) { await _dialogService.ShowProgressDialogAsync( false, async (progressDialog, token) => { var controllerEvent = controllerAction.ControllerEvent; await _creationManager.DeleteControllerActionAsync(controllerAction); if (controllerEvent.ControllerActions.Count == 0) { await _creationManager.DeleteControllerEventAsync(controllerEvent); } }, Translate("Deleting")); } } catch (OperationCanceledException) { } }
public override FieldList GetItemFields(ItemDefinition item, VersionUri version, CallContext context) { Assert.ArgumentNotNull(item, "item"); Assert.ArgumentNotNull(version, "version"); Assert.ArgumentNotNull(context, "context"); var list = new FieldList(); if (item.ID == FolderId || (ControllerType.GetControllerType(ParentId, item.ID) != null)) { list.Add(FieldIDs.Icon, Themes.MapTheme("SoftwareV2/16x16/elements.png")); } else { var action = ControllerAction.GetControllerAction(ParentId, item.ID); if (action != null && HttpContext.Current != null) { //VirtualPathData vpd; //MvcActionHelper.GetRouteData(new HttpContextWrapper(HttpContext.Current), action.ActionName, action.ControllerType.ControllerName, null, false, out vpd); //list.Add(LayoutFieldIDs.Path, vpd.VirtualPath); list.Add(FieldIDs.Icon, Themes.MapTheme("SoftwareV2/16x16/element.png")); } } if (list.Count == 0) { return(base.GetItemFields(item, version, context)); } return(list); }
/// <summary> /// /// </summary> /// <param name="index"></param> /// <returns></returns> public Keys this[ControllerAction index] { get { switch (index) { case ControllerAction.Left: return _left; case ControllerAction.Right: return _right; case ControllerAction.Down: return _down; case ControllerAction.Hold: return _hold; case ControllerAction.Drop: return _drop; case ControllerAction.Time: return _time; case ControllerAction.RotateCCW: return _rotateLeft; case ControllerAction.RotateCW: return _rotateRight; default: return Keys.None; } } set { switch (index) { case ControllerAction.Left: _left = value; break; case ControllerAction.Right: _right = value; break; case ControllerAction.Down: _down = value; break; case ControllerAction.Hold: _hold = value; break; case ControllerAction.Drop: _drop = value; break; case ControllerAction.Time: _time = value; break; case ControllerAction.RotateCCW: _rotateLeft = value; break; case ControllerAction.RotateCW: _rotateRight = value; break; default: return; } } }
public ActionResult RoleAction(int id) { ViewBag.Title = "Role Action"; int roleID = id; IList <ControllerAction> list = new List <ControllerAction>(); var listController = BaseUtil.GetListController(); ViewBag.action_name = new List <SelectListItem>(); ViewBag.role_id = id; ViewBag.RoleName = db.ROLEs.Where(r => r.RoleId == id).FirstOrDefault().RoleName; foreach (var c in listController) { string controllerName = c.Value; var listAllAction = BaseUtil.GetListAllActionByController(controllerName); var listAssignedAction = BaseUtil.GetListActionAssignedByRoleAndController(roleID, controllerName); foreach (var aa in listAllAction) { ControllerAction ca = new ControllerAction(); ca.ControllerName = controllerName; ca.ActionName = aa.Text; ca.IsAssigned = listAssignedAction.Where(a => a.Text == aa.Text).Count() > 0 ? true : false; list.Add(ca); } } return(View(list)); }
public void Request(ControllerAction action) { if (action == ControllerAction.MOVE_LEFT) { moveLeftRequest = true; } else if (action == ControllerAction.MOVE_RIGHT) { moveRightRequest = true; } else if (action == ControllerAction.JUMP) { jumpRequest = true; } else if (action == ControllerAction.ROLL) { rollRequest = true; } else if (action == ControllerAction.CANCEL_JUMP) { cancelJumpRequest = true; } else if (action == ControllerAction.JETPACK) { jetpackRequest = true; } }
public void FindsActionWithMultipleMatchingComponents() { var basePathProvider = Mock.Of <IBasePathProvider>(); Mock.Get(basePathProvider).SetupGet(p => p.BasePath).Returns("basepath"); var action = new ControllerAction("action", null); var controller = new Controller("controller", null, action); var component = new Component("component", null, Enumerable.Empty <string>(), new List <Controller> { controller }, Enumerable.Empty <Script>(), Enumerable.Empty <Style>()); var decoyComponent = new Component("component", null, Enumerable.Empty <string>(), Enumerable.Empty <Controller>(), Enumerable.Empty <Script>(), Enumerable.Empty <Style>()); var componentRepository = Mock.Of <IComponentRepository>(); Mock.Get(componentRepository).Setup(r => r.GetAll()).Returns(new List <Component> { decoyComponent, component }); var result = new ControllerRouter(basePathProvider, componentRepository).Route("basepath/component/controller/action"); Assert.NotNull(result); Assert.Same(component, result.Component); Assert.Same(controller, result.Controller); Assert.Same(action, result.Action); }
public override string Generate(ControllerAction action) { string result = ""; result += $"$('#divid').load('{base.Generate(action)}',function (data){{\n\n}});"; return(result); }
public List <ControllerAction> GetList() { Assembly asm = Assembly.GetAssembly(typeof(DS.MvcApplication)); List <ControllerAction> ControllerActions = new List <ControllerAction>(); var CA = asm.GetTypes() .Where(type => typeof(System.Web.Mvc.Controller).IsAssignableFrom(type)) .SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public)) .Where(m => !m.GetCustomAttributes(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute), true).Any()) .Select(x => new { Controller = x.DeclaringType.Name, Action = x.Name, ReturnType = x.ReturnType.Name, Attributes = String.Join(",", x.GetCustomAttributes().Select(a => a.GetType().Name.Replace("Attribute", ""))) }) .OrderBy(x => x.Controller).ThenBy(x => x.Action).ToList(); int counter = 1; foreach (var item in CA) { ControllerAction aControllerActione = new ControllerAction(); aControllerActione.Controller = item.Controller.Substring(0, item.Controller.Length - 10); aControllerActione.Attributes = item.Attributes; aControllerActione.ReturnType = item.ReturnType; aControllerActione.Action = item.Action; aControllerActione.Id = counter++; ControllerActions.Add(aControllerActione); } List <ControllerAction> CAS = new List <ControllerAction>(); CAS = ControllerActions.GroupBy(x => x.Controller).Select(grp => grp.First()).ToList(); return(CAS); }
public override ItemDefinition GetItemDefinition(ID itemId, CallContext context) { Assert.ArgumentNotNull(itemId, "itemId"); Assert.ArgumentNotNull(context, "context"); if (itemId == FolderId) { return(new ItemDefinition(itemId, FolderName, FolderTemplateId, this.MasterId)); } var type = ControllerType.GetControllerType(ParentId, itemId); if (type != null) { return(new ItemDefinition(itemId, ItemUtil.ProposeValidItemName(type.Description), FolderTemplateId, this.MasterId)); } var action = ControllerAction.GetControllerAction(ParentId, itemId); if (action != null) { return(new ItemDefinition(itemId, action.Description, BaseTemplateId, this.MasterId)); } return(base.GetItemDefinition(itemId, context)); }
public static ControllerAction GetControllerAction(ControllerAction controllerAction) { using (DatabaseContext context = new DatabaseContext()) { return(sqlDatabase.ExecuteSprocAccessor <ControllerAction>(Procedure.spControllerAction_Get_ByNames, controllerAction.Controller, controllerAction.Action).FirstOrDefault()); } }
ActionTracker AddTracker(ControllerAction action) { ActionTracker tracker = new ActionTracker(action, this); current_actions[action] = tracker; return(tracker); }
private void OnButtonDown(ControllerAction action, ControllerSnapshot snapshot) { ActionTracker tracker = GetTracker(action); if (tracker.UpdateCurrentPoint()) { PointerEventData pevent = tracker.pevent; pevent.pressPosition = pevent.position; pevent.pointerPressRaycast = pevent.pointerCurrentRaycast; pevent.pointerPress = null; GameObject target = pevent.pointerPressRaycast.gameObject; tracker.current_pressed = ExecuteEvents.ExecuteHierarchy(target, pevent, ExecuteEvents.pointerDownHandler); if (tracker.current_pressed == null) { // some UI elements might only have click handler and not pointer down handler tracker.current_pressed = ExecuteEvents.ExecuteHierarchy(target, pevent, ExecuteEvents.pointerClickHandler); } else { // we want to do click on button down at same time, unlike regular mouse processing // which does click when mouse goes up over same object it went down on // reason to do this is head tracking might be jittery and this makes it easier to click buttons ExecuteEvents.Execute(tracker.current_pressed, pevent, ExecuteEvents.pointerClickHandler); } if (tracker.current_pressed != null) { ExecuteEvents.Execute(tracker.current_pressed, pevent, ExecuteEvents.beginDragHandler); pevent.pointerDrag = tracker.current_pressed; } } }
public void RaiseContorllerChanged(ControllerAction action) { if (ControllerChanged != null) { ControllerChanged(this, new ControllerChangedEventArgs(action)); } }
public JsonResult Actions(string id) { Assembly asm = Assembly.GetAssembly(typeof(DS.MvcApplication)); List <ControllerAction> ControllerActions = new List <ControllerAction>(); var CA = asm.GetTypes() .Where(type => typeof(System.Web.Mvc.Controller).IsAssignableFrom(type)) .SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public)) .Where(m => !m.GetCustomAttributes(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute), true).Any()) .Select(x => new { Controller = x.DeclaringType.Name, Action = x.Name, ReturnType = x.ReturnType.Name, Attributes = String.Join(",", x.GetCustomAttributes().Select(a => a.GetType().Name.Replace("Attribute", ""))) }) .OrderBy(x => x.Controller).ThenBy(x => x.Action).ToList(); int counter = 1; foreach (var item in CA) { ControllerAction aControllerActione = new ControllerAction(); aControllerActione.Controller = item.Controller.Substring(0, item.Controller.Length - 10); aControllerActione.Attributes = item.Attributes; aControllerActione.ReturnType = item.ReturnType; aControllerActione.Action = item.Action; aControllerActione.Id = counter++; ControllerActions.Add(aControllerActione); } List <string> Actions = new List <string>(); var actionlist = from p in ControllerActions where (p.Controller == id) select p.Action; //var ac = ControllerActions.Where(x =>x.Controller == "HomeController").Select(n=>n.Action); foreach (string aAciont in actionlist) { Actions.Add(aAciont); } return(Json(Actions, JsonRequestBehavior.AllowGet)); //return Actions; }
public ActionResult CompanyRoleAction(int id, string companyId = "") { ViewBag.Title = "Role Action"; int roleID = id; int company_id = Convert.ToInt32(companyId); IList <ControllerAction> list = new List <ControllerAction>(); var listController = STUtil.GetListController(); //Nedd to check data in respwct of ViewBag.action_name = new List <SelectListItem>(); ViewBag.role_id = id; ViewBag.RoleName = db.roles.Where(r => r.role_id == id && r.company_id == company_id).FirstOrDefault().role_name; foreach (var c in listController) { string controllerName = c.Value; var listAllAction = STUtil.GetListAllActionByController(controllerName); var listAssignedAction = STUtil.GetListActionAssignedByRoleAndController(roleID, controllerName); foreach (var aa in listAllAction) { ControllerAction ca = new ControllerAction(); ca.ControllerName = controllerName; ca.ActionName = aa.Text; ca.IsAssigned = listAssignedAction.Where(a => a.Text == aa.Text).Count() > 0 ? true : false; list.Add(ca); } } return(PartialView("_CompanyRoleAction", list)); }
private static void PostResolveRequestCache(object sender, EventArgs e) { HttpContext context = ((HttpApplication)sender).Context; HttpRequest request = context.Request; string appExecPath = request.AppRelativeCurrentExecutionFilePath; if (!appExecPath.EndsWith(WebAppConfig.Extension)) { return; } ControllerAction controllerAction = WebAppHelper.GetControllerAction(appExecPath, request.PathInfo); if (controllerAction != null) { string rawUrl = context.Request.RawUrl; IHttpHandler httpHandler = new PageHandler(new CPageHandler(controllerAction)); if (rawUrl.EndsWith("/")) { string filename = context.Request.ServerVariables["SCRIPT_FILENAME"]; rawUrl = string.Concat(rawUrl, Path.GetFileName(filename)); } context.Items[_contextItemKey] = new RequestData(UrlHelper.GetUrlWithoutPathInfo(rawUrl, request.PathInfo), httpHandler); context.RewritePath("~/MiniMVC.axd"); } }
/// <summary> /// Execute action and catch all potential errors. /// </summary> /// <param name="controllerAction">Action to perform</param> /// <returns>Result of action</returns> protected ActionResult Execute(ControllerAction controllerAction) { try { Log.Debug($"Invoke controller action"); return(controllerAction.Invoke()); } catch (PreValidationException preValidationException) { // validation of request fails Log.Warning(preValidationException, $"Prevalidation of request fails!"); return(BadRequest(preValidationException.Message)); } catch (UnsupportedContentTypeException unsupportedContentTypeException) { // unsupported content type detected Log.Warning(unsupportedContentTypeException, $"Requests includes content with unsupported media type!"); return(new UnsupportedMediaTypeResult()); } catch (Exception exc) { // unexpected error occures Log.Error(exc, $"Unexpected error occures while processing the request! Response will be http-500."); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
/// <summary> /// Converts a controller action expression to an instance of IControllerAction. This /// instance will contain all metadata needed to decompose captured parameter values from the /// caller into an invokable http request. /// </summary> /// <typeparam name="TController">The type of the controller.</typeparam> /// <param name="controllerActionExpression">The controller action expression.</param> /// <returns></returns> /// <exception cref="InvalidOperationException">You must supply an HttpMethod</exception> public static IControllerAction GetAction <TController, TResponse>(Expression <Func <TController, TResponse> > controllerActionExpression) { //get the controller type var controllerType = typeof(TController); //get the controller name. We assume conventions are used and all controllers end with Controllers suffix. var controllerName = controllerType.Name.Replace("Controller", string.Empty); //get all controller routeattributes. var controllerAttributes = controllerType.GetCustomAttributes <RouteAttribute>(true).Reverse().ToList(); //down cast to the appropriate expression var methodCallExpression = (MethodCallExpression)controllerActionExpression.Body; //grab the reflected methodInfo instance var methodInfo = methodCallExpression.Method; //the return type of the method var returnType = methodInfo.ReturnType; //grab the methodName var methodName = methodInfo.Name; //grab a list of method input parameters var methodInputParameters = methodInfo.GetParameters(); //all controller methods must have a derivative of HttpMethodAttribute var httpMethodAttribute = methodInfo.GetCustomAttribute <HttpMethodAttribute>(false); //get a route attribute applied to controller action var routeAttribute = methodInfo.GetCustomAttribute <RouteAttribute>(false); if (httpMethodAttribute == null) { //if no, method, we should throw an exception throw new InvalidOperationException("You must supply an HttpMethod"); } var controllerAction = new ControllerAction(controllerName, methodName, returnType, new HttpMethod(httpMethodAttribute.HttpMethods.FirstOrDefault())); for (int i = 0; i < methodCallExpression.Arguments.Count; i++) { var expr = methodCallExpression.Arguments[i]; var bindingSourceMetadataAttribute = GetBindingSourceAttribute(methodInputParameters[i]); controllerAction.ActionParameters.Add(new ControllerActionParameter(methodInputParameters[i].Name, Expression.Lambda(expr).Compile().DynamicInvoke(), bindingSourceMetadataAttribute, controllerAction)); } //if there are any controller scoped route attributes push them into our segment list foreach (var a in controllerAttributes) { controllerAction.AddRouteSegment(a.Template); } //process the template on the httpMethod attribute if (!string.IsNullOrEmpty(httpMethodAttribute.Template)) { controllerAction.AddRouteSegment(httpMethodAttribute.Template); } if (routeAttribute != null && !String.IsNullOrEmpty(routeAttribute.Template)) { controllerAction.AddRouteSegment(routeAttribute.Template); } return(controllerAction); }
private void btnExecute_Click(object sender, EventArgs e) { ControllerAction a = default(ControllerAction); APIResponse Result = default(APIResponse); string strPost = ""; string strURI = null; bool booImageResult = false; a = GetAction((System.Guid)tvwActions.SelectedNode.Tag); if (a.ActionResult == ControllerAction.ActionResultEnum.EskimoImage) { booImageResult = true; } //ensure the credentials are valid. this retrieves the access token, used for each query if (string.IsNullOrEmpty(m_strToken)) { if (!Token()) { return; } } strPost = PostString(a); txtRequestString.Text = strPost; if (a.ActionResult == ControllerAction.ActionResultEnum.ResponseMessage) { this.tabControl.SelectedTab = this.pgeRequest; Application.DoEvents(); } strURI = GetActionURI(a); Result = (APIResponse)Execute(strURI, a.Method, ContentTypeEnum.ApplicationJson, true, strPost, booImageResult); lblRowCount.Text = "No rows returned"; switch (Result.Code) { case HttpStatusCode.NoContent: MessageBox.Show("No content found", "Empty result set", MessageBoxButtons.OK, MessageBoxIcon.Error); break; case HttpStatusCode.OK: if (Result != null && Result.TextResponse != null) { txtResponse.Text = JsonPrettify(Result.TextResponse); } ProcessResults(a, Result.TextResponse, Result); return; default: MessageBox.Show("There was a problem executing this action: " + Environment.NewLine + Environment.NewLine + Result.ErrorMessage, string.Format("({0}) {1}", Convert.ToInt32(Result.Code), Result.Code), MessageBoxButtons.OK, MessageBoxIcon.Error); break; } }
private bool IsAxisMapped(ControllerAction action) { if (axisKeymap.ContainsKey(action) && axisKeymap[action] != null) { return true; } return false; }
/// <summary> /// Đăng ký một route mới, mỗi route ánh xạ một chuỗi truy vấn với một phương thức /// </summary> /// <param name="route"></param> /// <param name="action"></param> /// <param name="help"></param> public void Register(string route, ControllerAction action, string help = "") { // nếu _routingTable đã chứa route này thì bỏ qua if (!_routingTable.ContainsKey(route)) { _routingTable[route] = action; _helpTable[route] = help; } }
private bool IsActionMapped(ControllerAction action, out List<KeyCode> list) { if (buttonKeymap.ContainsKey(action) && (list = buttonKeymap[action]) != null) { return true; } list = null; return false; }
private void OnButtonDrag(ControllerAction action, ControllerSnapshot snapshot) { ActionTracker tracker = GetTracker(action); if (tracker.current_pressed != null && tracker.UpdateCurrentPoint(allow_out_of_bounds: true)) { ExecuteEvents.Execute(tracker.current_pressed, tracker.pevent, ExecuteEvents.dragHandler); } }
private string PostString(ControllerAction a) { string strPost = ""; if (a.Parameters != null) { strPost = Newtonsoft.Json.JsonConvert.SerializeObject(a.Parameters, Newtonsoft.Json.Formatting.Indented); } return(strPost); }
public ControllerActionViewModel(ControllerAction controllerAction, IDeviceManager deviceManager) { ControllerAction = controllerAction; var device = deviceManager.GetDeviceById(controllerAction.DeviceId); DeviceMissing = device == null; DeviceName = device != null ? device.Name : "Missing"; ChannelName = (device == null || device.DeviceType != DeviceType.Infrared) ? $"{controllerAction.Channel + 1}" : (controllerAction.Channel == 0 ? "Blue" : "Red"); InvertName = controllerAction.IsInvert ? "Inv" : string.Empty; }
public bool GetKeyUp(ControllerAction action) { TransformCrossControllerButton(ref action); #if DEBUG_CONTROL if (!IsActionMapped(action, out keyCodeList)) return false; return keyCodeList.Any(Input.GetKeyUp); #else return buttonKeymap[action].Any(Input.GetKeyUp); #endif }
private List <ControllerPathPattern> ExpandUrl(ExtendedRoute r, List <ControllerAction> controllers) { List <ControllerPathPattern> cpps = new List <ControllerPathPattern>(); if (r.Url.Contains("{controller}") && r.Url.Contains("{action}")) { cpps = controllers .SelectMany(c => c.Actions.Select(a => new { c.Controller, Action = a, c.SignificantRouteKeys })) .Select(ca => new ControllerPathPattern { PathPattern = BuildPathPattern(r.Url, ca.Controller, ca.Action, ca.SignificantRouteKeys), Controller = ca.Controller, Action = ca.Action }) .ToList(); } else if (r.Url.Contains("{controller}")) { cpps = controllers .Select(c => new ControllerPathPattern { PathPattern = BuildPathPattern(r.Url, c.Controller, "", c.SignificantRouteKeys), Controller = c.Controller, Action = r.Defaults["action"].ToString() }) .ToList(); } else if (r.Url.Contains("{action}")) { ControllerAction controllerAction = controllers .First(c => c.Controller == r.Defaults["controller"].ToString()); cpps = controllerAction .Actions .Select(a => new ControllerPathPattern { PathPattern = BuildPathPattern(r.Url, "", a, controllerAction.SignificantRouteKeys), Controller = r.Defaults["controller"].ToString(), Action = a }) .ToList(); } else { ControllerAction controllerAction = controllers .First(c => c.Controller == r.Defaults["controller"].ToString()); cpps.Add(new ControllerPathPattern { PathPattern = BuildPathPattern(r.Url, "", "", controllerAction.SignificantRouteKeys), Controller = r.Defaults["controller"].ToString(), Action = r.Defaults["action"].ToString() }); } return(cpps); }
/// <summary> /// Get or set the key used to control an action by action /// </summary> /// <param name="index"></param> /// <returns></returns> public Keys this[ControllerAction index] { get { switch (index) { case ControllerAction.Left: return _left; case ControllerAction.Right: return _right; case ControllerAction.Jump: return _jump; default: return Keys.None; } } set { switch (index) { case ControllerAction.Left: _left = value; break; case ControllerAction.Right: _right = value; break; case ControllerAction.Jump: _jump = value; break; default: return; } } }
public bool this[int playerno, ControllerAction action] { get { return (ControllerActions[playerno] & (1 << (int)action)) != 0; } set { if (!IgnoreInput) { if (value) { ControllerActions[playerno] |= (1 << (int)action); } else { ControllerActions[playerno] &= ~(1 << (int)action); } InputChanged = true; } } }
internal CPageHandler(ControllerAction controllerAction) { _controllerAction = controllerAction; }
protected virtual void AddActionFields(FieldList list, ControllerAction action) { list.Add(FieldIDs.Icon, Themes.MapTheme("SoftwareV2/16x16/element.png")); list.Add(FieldIDs.DisplayName, action.Description); list.Add(FieldIds.ControllerName, action.ControllerType.ControllerName); list.Add(FieldIds.ControllerAction, action.ActionName); var dataSourceTemplateAttribute = action.MethodInfo.GetCustomAttribute<DataSourceTemplateAttribute>(); if (dataSourceTemplateAttribute != null) { list.Add(FieldIds.DataSourceTemplate, dataSourceTemplateAttribute.DataSourceTemplate); } var dataSourceLocationAttribute = action.MethodInfo.GetCustomAttribute<DataSourceLocationAttribute>(); if (dataSourceLocationAttribute != null) { list.Add(FieldIds.DataSourceLocation, dataSourceLocationAttribute.DataSourceLocation); } var experienceEditorButtonsAttribute = action.MethodInfo.GetCustomAttribute<ExperienceEditorButtonsAttribute>(); if (experienceEditorButtonsAttribute != null) { list.Add(FieldIds.PageEditorButtons, experienceEditorButtonsAttribute.ExperienceEditorButtons); } }
/// <summary> /// Frame Renewal /// </summary> /// <param name="gameTime">Snapshot of timing values</param> public override void Update(GameTime gameTime) { base.Update(gameTime); Action = ControllerAction.None; if (!this.Enabled) return; if (_inputManager.Keyboard.IsKeyTriggerd(_left)) Action = ControllerAction.Left; else if (_inputManager.Keyboard.IsKeyTriggerd(_right)) Action = ControllerAction.Right; else if (_inputManager.Keyboard.IsKeyTriggerd(_down)) Action = ControllerAction.Down; else if (_inputManager.Keyboard.IsKeyTriggerd(_drop)) Action = ControllerAction.Drop; else if (_inputManager.Keyboard.IsKeyTriggerd(_rotateLeft)) Action = ControllerAction.RotateCCW; else if (_inputManager.Keyboard.IsKeyTriggerd(_rotateRight)) Action = ControllerAction.RotateCW; else if (_inputManager.Keyboard.IsKeyDown(_time)) Action = ControllerAction.Time; else if (_inputManager.Keyboard.IsKeyPressed(_hold)) Action = ControllerAction.Hold; }
void SetControllerActionState(int playerNo, ControllerAction action, bool value) { if (value) { _nextInputState[ControllerActionStateIndex + (playerNo & 3)] |= (1 << (int)action); } else { _nextInputState[ControllerActionStateIndex + (playerNo & 3)] &= ~(1 << (int)action); } }
public float GetAxis(ControllerAction action) { #if DEBUG_CONTROL if (!IsAxisMapped(action)) return 0; #endif List<string> keycodeList = axisKeymap[action]; foreach (var axisName in keycodeList) { float value = Input.GetAxisRaw(axisName); if (Mathf.Abs(value) > Mathf.Epsilon) { //Make triggers go from -1 to 1 if (controllerType == ControllerType.Playstation) { if (action == ControllerAction.L2 || action == ControllerAction.R2) { return (value + 1) / 2.0f; } } return value; } } return 0; }
private void TransformCrossControllerButton(ref ControllerAction action) { if (controllerType == ControllerType.Playstation) { switch (action) { case ControllerAction.A: action = ControllerAction.CROSS; break; case ControllerAction.B: action = ControllerAction.CIRCLE; break; case ControllerAction.X: action = ControllerAction.SQUARE; break; case ControllerAction.Y: action = ControllerAction.TRIANGLE; break; } } else if (controllerType == ControllerType.Playstation) { switch (action) { case ControllerAction.CIRCLE: action = ControllerAction.B; break; case ControllerAction.CROSS: action = ControllerAction.A; break; case ControllerAction.SQUARE: action = ControllerAction.X; break; case ControllerAction.TRIANGLE: action = ControllerAction.Y; break; } } }
private void AddButtonBinding(ControllerAction action, KeyCode keyCode) { List<KeyCode> list; if (!buttonKeymap.ContainsKey(action)) { list = new List<KeyCode>(); buttonKeymap.Add(action, list); } else { list = buttonKeymap[action]; } list.Add(keyCode); buttonKeymap[action] = list; }
private void AddAxisBinding(ControllerAction action, string axisName) { List<string> list; if (!axisKeymap.ContainsKey(action)) { list = new List<string>(); axisKeymap.Add(action, list); } else { list = axisKeymap[action]; } list.Add(axisName); axisKeymap[action] = list; }
internal bool SampleCapturedControllerActionState(int playerno, ControllerAction action) { _lagged = false; return (_inputState[ControllerActionStateIndex + (playerno & 3)] & (1 << (int)action)) != 0; }
/// <summary> /// Frame Renewal /// </summary> /// <param name="gameTime">Snapshot of timing values</param> public override void Update(GameTime gameTime) { base.Update(gameTime); Action = ControllerAction.None; if (!this.Enabled) return; if (_inputManager.Keyboard.IsKeyDown(_left)) Action |= ControllerAction.Left; if (_inputManager.Keyboard.IsKeyDown(_right)) Action |= ControllerAction.Right; if (_inputManager.Keyboard.IsKeyDown(_jump)) Action |= ControllerAction.Jump; }