public bool OnPressed(PlatformAction action) { switch (action.ActionType) { case PlatformActionType.Cut: Cut(); return(true); case PlatformActionType.Copy: Copy(); return(true); case PlatformActionType.Paste: Paste(); return(true); case PlatformActionType.Undo: Undo(); return(true); case PlatformActionType.Redo: Redo(); return(true); case PlatformActionType.Save: Save(); return(true); } return(false); }
public PlatformAction GetAsPlatformAction() { PlatformAction platformAction = new PlatformAction(this); foreach (ActInputValue aiv in this.InputValues) { string ValueforDriver = aiv.ValueForDriver; if (!platformAction.InputParams.ContainsKey(aiv.Param) && !String.IsNullOrEmpty(ValueforDriver)) { platformAction.InputParams.Add(aiv.Param, ValueforDriver); } } Dictionary <string, string> Locators = new Dictionary <string, string>(); Locators.Add(ElementLocateBy.ToString(), ElementLocateValueForDriver); platformAction.InputParams.Add("Locators", Locators); return(platformAction); }
/// <summary> /// Returns <c>true</c> if this <paramref name="platformAction"/> is a common text editing <see cref="PlatformAction"/>. /// </summary> /// <remarks> /// Common text editing actions are those used for text editing in a text box, /// and/or are used by an platform-native IME for internal text editing purposes. /// </remarks> public static bool IsCommonTextEditingAction(this PlatformAction platformAction) { switch (platformAction) { case PlatformAction.Cut: case PlatformAction.Copy: case PlatformAction.Paste: case PlatformAction.SelectAll: case PlatformAction.MoveBackwardChar: case PlatformAction.MoveForwardChar: case PlatformAction.MoveBackwardWord: case PlatformAction.MoveForwardWord: case PlatformAction.MoveBackwardLine: case PlatformAction.MoveForwardLine: case PlatformAction.DeleteBackwardChar: case PlatformAction.DeleteForwardChar: case PlatformAction.DeleteBackwardWord: case PlatformAction.DeleteForwardWord: case PlatformAction.DeleteBackwardLine: case PlatformAction.DeleteForwardLine: case PlatformAction.SelectBackwardChar: case PlatformAction.SelectForwardChar: case PlatformAction.SelectBackwardWord: case PlatformAction.SelectForwardWord: case PlatformAction.SelectBackwardLine: case PlatformAction.SelectForwardLine: return(true); default: return(false); } }
protected override void OnEnable() { base.OnEnable(); m_PlatformAction = (PlatformAction)m_Action; m_DistanceProp = serializedObject.FindProperty("m_Distance"); }
public async Task <GamificationAction> GetByAction(PlatformAction action) { FilterDefinition <GamificationAction> filter = Builders <GamificationAction> .Filter.Eq(x => x.Action, action); GamificationAction result = await DbSet.Find(filter).FirstOrDefaultAsync(); return(result); }
public bool OnPressed(PlatformAction action) { switch (action.ActionType) { case PlatformActionType.SelectAll: SelectAll(); return(true); } return(false); }
public bool OnPressed(PlatformAction action) { switch (action.ActionMethod) { case PlatformActionMethod.Delete: DeleteSelected(); return(true); } return(false); }
public virtual bool OnPressed(PlatformAction action) { switch (action.ActionType) { case PlatformActionType.Exit: Host.Window?.Close(); return(true); } return(false); }
public int ProcessAction(Guid userId, PlatformAction action) { int scoreValue = 5; GamificationAction actionToProcess = Task.Run(async() => await gamificationActionRepository.GetByAction(action)).Result; if (actionToProcess != null) { scoreValue = actionToProcess.ScoreValue; } Task <IEnumerable <Gamification> > userGamificationTask = gamificationRepository.GetByUserId(userId); userGamificationTask.Wait(); Gamification userGamification = userGamificationTask.Result.FirstOrDefault(); if (userGamification == null) { GamificationLevel newLevel = Task.Run(async() => await gamificationLevelRepository.GetByNumber(1)).Result; userGamification = GenerateNewGamification(userId); userGamification.XpCurrentLevel += scoreValue; userGamification.XpTotal += scoreValue; userGamification.XpToNextLevel = (newLevel.XpToAchieve - scoreValue); gamificationRepository.Add(userGamification); } else { userGamification.XpCurrentLevel += scoreValue; userGamification.XpTotal += scoreValue; userGamification.XpToNextLevel -= scoreValue; if (userGamification.XpToNextLevel <= 0) { GamificationLevel currentLevel = Task.Run(async() => await gamificationLevelRepository.GetByNumber(userGamification.CurrentLevelNumber)).Result; GamificationLevel newLevel = Task.Run(async() => await gamificationLevelRepository.GetByNumber(userGamification.CurrentLevelNumber + 1)).Result; if (newLevel != null) { userGamification.CurrentLevelNumber = newLevel.Number; userGamification.XpCurrentLevel = (userGamification.XpCurrentLevel - currentLevel.XpToAchieve); userGamification.XpToNextLevel = (newLevel.XpToAchieve - userGamification.XpCurrentLevel); } } gamificationRepository.Update(userGamification); } return(scoreValue); }
public override bool OnPressed(PlatformAction action) { // Shift+delete is handled via PlatformAction on macOS. this is not so useful in the context of a SearchTextBox // as we do not allow arrow key navigation in the first place (ie. the care should always be at the end of text) // Avoid handling it here to allow other components to potentially consume the shortcut. if (action.ActionType == PlatformActionType.CharNext && action.ActionMethod == PlatformActionMethod.Delete) { return(false); } return(base.OnPressed(action)); }
public PlatformAction GetAsPlatformAction() { PlatformAction platformAction = new PlatformAction(this); foreach (ActInputValue aiv in this.InputValues) { string ValueforDriver = aiv.ValueForDriver; if (!platformAction.InputParams.ContainsKey(aiv.Param) && !String.IsNullOrEmpty(ValueforDriver)) { platformAction.InputParams.Add(aiv.Param, ValueforDriver); } } if (platformAction.InputParams.ContainsKey("RequestBody")) { platformAction.InputParams["RequestBody"] = GetCalulatedRequestBodyString(); } Dictionary <string, string> sHttpHeaders = new Dictionary <string, string>(); foreach (ActInputValue header in this.HttpHeaders) { sHttpHeaders.Add(header.Param, header.ValueForDriver); } platformAction.InputParams.Add("Headers", sHttpHeaders); List <WebAPiKeyValue> WebAPiKeyValues = new List <WebAPiKeyValue>(); foreach (WebAPIKeyBodyValues WKBV in this.RequestKeyValues) { WebAPiKeyValue wakv = new WebAPiKeyValue(); wakv.Param = WKBV.Param; wakv.Value = WKBV.ValueForDriver; wakv.ValueType = WKBV.ValueType; if (WKBV.ValueType == WebAPIKeyBodyValues.eValueType.File) { wakv.FileBytes = File.ReadAllBytes(WKBV.ValueForDriver); } WebAPiKeyValues.Add(wakv); } platformAction.InputParams.Add("RequestKeyValues", WebAPiKeyValues); return(platformAction); }
private void performPlatformAction(PlatformAction action, PlatformActionContainer platformActionContainer, Drawable drawable) { var tempIsHovered = drawable.IsHovered; var tempHasFocus = drawable.HasFocus; drawable.IsHovered = true; drawable.HasFocus = true; platformActionContainer.TriggerPressed(action); platformActionContainer.TriggerReleased(action); drawable.IsHovered = tempIsHovered; drawable.HasFocus = tempHasFocus; }
public override bool OnPressed(PlatformAction action) { switch (action) { case PlatformAction.MoveBackwardLine: case PlatformAction.MoveForwardLine: // Shift+delete is handled via PlatformAction on macOS. this is not so useful in the context of a SearchTextBox // as we do not allow arrow key navigation in the first place (ie. the caret should always be at the end of text) // Avoid handling it here to allow other components to potentially consume the shortcut. case PlatformAction.DeleteForwardChar: return(false); } return(base.OnPressed(action)); }
public PlatformAction GetAsPlatformAction() { PlatformAction platformAction = new PlatformAction(this); foreach (ActInputValue aiv in this.InputValues) { string ValueforDriver = aiv.ValueForDriver; if (!platformAction.InputParams.ContainsKey(aiv.Param) && !String.IsNullOrEmpty(ValueforDriver)) { platformAction.InputParams.Add(aiv.Param, ValueforDriver); } } return(platformAction); }
public bool OnPressed(PlatformAction action) { if (IsSwitchable) { switch (action.ActionType) { case PlatformActionType.DocumentNext: SwitchTab(1); return(true); case PlatformActionType.DocumentPrevious: SwitchTab(-1); return(true); } } return(false); }
public PlatformAction GetAsPlatformAction() { PlatformAction platformAction = new PlatformAction(this); foreach (ActInputValue aiv in this.InputValues) { if (!platformAction.InputParams.ContainsKey(aiv.Param)) { platformAction.InputParams.Add(aiv.Param, aiv.ValueForDriver); } } return(platformAction); }
public bool OnPressed(PlatformAction action) { switch (action.ActionType) { case PlatformActionType.Undo: Undo(); return(true); case PlatformActionType.Redo: Redo(); return(true); case PlatformActionType.Save: saveBeatmap(); return(true); } return(false); }
private void assertKeyEventsNotConsumedForAction(PlatformAction action) { AddAssert("KeyDown events not consumed", () => { // mirrored from ManualInputManager.Keys(PlatformAction) var binding = host.PlatformKeyBindings.First(b => (PlatformAction)b.Action == action); for (int i = 0; i < binding.KeyCombination.Keys.Length; i++) { // fail if consumed if (textBox.KeyDownQueue.Dequeue()) { return(false); } } return(textBox.KeyDownQueue.Count == 0); }); AddAssert("PlatformAction event consumed", () => textBox.PlatformActionQueue.Dequeue() && textBox.PlatformActionQueue.Count == 0); }
public PlatformAction GetAsPlatformAction() { PlatformAction platformAction = new PlatformAction(this); string SoapAction = this.GetInputParamCalculatedValue(Fields.SOAPAction); foreach (ActInputValue aiv in this.InputValues) { string ValueforDriver = aiv.ValueForDriver; if (!platformAction.InputParams.ContainsKey(aiv.Param) && !String.IsNullOrEmpty(ValueforDriver)) { platformAction.InputParams.Add(aiv.Param, ValueforDriver); } } if (platformAction.InputParams.ContainsKey("RequestBody")) { platformAction.InputParams["RequestBody"] = GetCalulatedRequestBodyString(); } else { platformAction.InputParams.Add("RequestBody", GetCalulatedRequestBodyString()); } Dictionary <string, string> sHttpHeaders = new Dictionary <string, string>(); sHttpHeaders.Add("SOAPAction", SoapAction); foreach (ActInputValue header in this.HttpHeaders) { sHttpHeaders.Add(header.Param, header.ValueForDriver); } platformAction.InputParams.Add("Headers", sHttpHeaders); return(platformAction); }
public void OnReleased(PlatformAction action) { }
private bool handleAction(PlatformAction action) { int?amount = null; if (!HandleLeftRightArrows && action.ActionMethod == PlatformActionMethod.Move && (action.ActionType == PlatformActionType.CharNext || action.ActionType == PlatformActionType.CharPrevious)) { return(false); } switch (action.ActionType) { // Clipboard case PlatformActionType.Cut: case PlatformActionType.Copy: if (string.IsNullOrEmpty(SelectedText) || !AllowClipboardExport) { return(true); } clipboard?.SetText(SelectedText); if (action.ActionType == PlatformActionType.Cut) { removeCharacterOrSelection(); } return(true); case PlatformActionType.Paste: //the text may get pasted into the hidden textbox, so we don't need any direct clipboard interaction here. string pending = textInput?.GetPendingText(); if (string.IsNullOrEmpty(pending)) { pending = clipboard?.GetText(); } insertString(pending); return(true); case PlatformActionType.SelectAll: selectionStart = 0; selectionEnd = text.Length; cursorAndLayout.Invalidate(); return(true); // Cursor Manipulation case PlatformActionType.CharNext: amount = 1; break; case PlatformActionType.CharPrevious: amount = -1; break; case PlatformActionType.LineEnd: amount = text.Length; break; case PlatformActionType.LineStart: amount = -text.Length; break; case PlatformActionType.WordNext: if (!AllowWordNavigation) { amount = 1; } else { int searchNext = MathHelper.Clamp(selectionEnd, 0, Text.Length - 1); while (searchNext < Text.Length && text[searchNext] == ' ') { searchNext++; } int nextSpace = text.IndexOf(' ', searchNext); amount = (nextSpace >= 0 ? nextSpace : text.Length) - selectionEnd; } break; case PlatformActionType.WordPrevious: if (!AllowWordNavigation) { amount = -1; } else { int searchPrev = MathHelper.Clamp(selectionEnd - 2, 0, Text.Length - 1); while (searchPrev > 0 && text[searchPrev] == ' ') { searchPrev--; } int lastSpace = text.LastIndexOf(' ', searchPrev); amount = lastSpace > 0 ? -(selectionEnd - lastSpace - 1) : -selectionEnd; } break; } if (amount.HasValue) { switch (action.ActionMethod) { case PlatformActionMethod.Move: resetSelection(); moveSelection(amount.Value, false); break; case PlatformActionMethod.Select: moveSelection(amount.Value, true); break; case PlatformActionMethod.Delete: if (selectionLength == 0) { selectionEnd = MathHelper.Clamp(selectionStart + amount.Value, 0, text.Length); } if (selectionLength > 0) { removeCharacterOrSelection(); } break; } return(true); } return(false); }
public bool OnReleased(PlatformAction action) => false;
public virtual bool OnReleased(PlatformAction action) => false;
static NewPayLoad GeneratePlatformActionPayload(IActPluginExecution ACT, Agent agent) { PlatformAction platformAction = ACT.GetAsPlatformAction(); if (ACT is ActUIElement actUi) { if (actUi.ElementLocateBy == eLocateBy.POMElement) { AddPOMLocators(ref platformAction, ref actUi, agent.ProjEnvironment, agent.BusinessFlow); } } // TODO: calculate VE ??!! NewPayLoad payload = new NewPayLoad("RunPlatformAction"); payload.AddJSONValue <PlatformAction>(platformAction); payload.ClosePackage(); // TODO: Process Valuefordriver!!!! return(payload); void AddPOMLocators(ref PlatformAction PlatformAction, ref ActUIElement UIElementAction, ProjEnvironment projEnvironment, BusinessFlow businessFlow) { Dictionary <string, string> Locators = new Dictionary <string, string>(); List <string> Frames = new List <string>(); string[] pOMandElementGUIDs = UIElementAction.ElementLocateValue.ToString().Split('_'); Guid selectedPOMGUID = new Guid(pOMandElementGUIDs[0]); ApplicationPOMModel currentPOM = amdocs.ginger.GingerCoreNET.WorkSpace.Instance.SolutionRepository.GetRepositoryItemByGuid <ApplicationPOMModel>(selectedPOMGUID); if (currentPOM == null) { UIElementAction.ExInfo = string.Format("Failed to find the mapped element Page Objects Model with GUID '{0}'", selectedPOMGUID.ToString()); return; } Guid selectedPOMElementGUID = new Guid(pOMandElementGUIDs[1]); ElementInfo selectedPOMElement = (ElementInfo)currentPOM.MappedUIElements.Where(z => z.Guid == selectedPOMElementGUID).FirstOrDefault(); if (selectedPOMElement == null) { UIElementAction.ExInfo = string.Format("Failed to find the mapped element with GUID '{0}' inside the Page Objects Model", selectedPOMElement.ToString()); return; } else { List <NewPayLoad> switchframpayload = new List <NewPayLoad>(); if (selectedPOMElement.Path != null) { string[] spliter = new string[] { "," }; string[] iframesPathes = selectedPOMElement.Path.Split(spliter, StringSplitOptions.RemoveEmptyEntries); foreach (string iframePath in iframesPathes) { Frames.Add(iframePath); } } PlatformAction.InputParams.Add("Frames", Frames); //adding all locators from POM foreach (ElementLocator locator in selectedPOMElement.Locators.Where(x => x.Active == true).ToList()) { string locateValue; if (locator.IsAutoLearned) { locateValue = locator.LocateValue; } else { ElementLocator evaluatedLocator = locator.CreateInstance() as ElementLocator; GingerCore.ValueExpression VE = new GingerCore.ValueExpression(projEnvironment, businessFlow); locateValue = VE.Calculate(evaluatedLocator.LocateValue); } Locators.Add(locator.LocateBy.ToString(), locateValue); } if (PlatformAction.InputParams.ContainsKey("Locators")) { PlatformAction.InputParams["Locators"] = Locators; } else { PlatformAction.InputParams.Add("Locators", Locators); } } } }
public OperationResultVo <Guid> Save(Guid currentUserId, UserContentViewModel viewModel) { try { int pointsEarned = 0; UserContent model; bool isSpam = CheckSpam(viewModel.Id, viewModel.Content); bool isNew = viewModel.Id == Guid.Empty; if (isSpam) { return(new OperationResultVo <Guid>("Calm down! You cannot post the same content twice in a row.")); } string youtubePattern = @"(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+"; viewModel.Content = Regex.Replace(viewModel.Content, youtubePattern, delegate(Match match) { string v = match.ToString(); if (match.Index == 0 && String.IsNullOrWhiteSpace(viewModel.FeaturedImage)) { viewModel.FeaturedImage = v; } return(v); }); UserContent existing = userContentDomainService.GetById(viewModel.Id); if (existing != null) { model = mapper.Map(viewModel, existing); } else { model = mapper.Map <UserContent>(viewModel); } if (model.PublishDate == DateTime.MinValue) { model.PublishDate = model.CreateDate; } if (isNew) { userContentDomainService.Add(model); PlatformAction action = viewModel.IsComplex ? PlatformAction.ComplexPost : PlatformAction.SimplePost; pointsEarned += gamificationDomainService.ProcessAction(viewModel.UserId, action); unitOfWork.Commit().Wait(); viewModel.Id = model.Id; if (viewModel.Poll != null && viewModel.Poll.PollOptions != null && viewModel.Poll.PollOptions.Any()) { CreatePoll(viewModel); pointsEarned += gamificationDomainService.ProcessAction(viewModel.UserId, PlatformAction.PollPost); } } else { userContentDomainService.Update(model); } unitOfWork.Commit().Wait(); return(new OperationResultVo <Guid>(model.Id, pointsEarned)); } catch (Exception ex) { return(new OperationResultVo <Guid>(ex.Message)); } }