private void GameNameTextBox_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Space) { e.Handled = !InputChecker.IsValidInput(sender as TextBox, " "); } }
static void Main() { const int numberOfConverters = 4; delegateConvertTemperature[] converters = new delegateConvertTemperature[numberOfConverters]; converters[(int)Temperature.CToF] = StaticTempConverters.CelciusToFahrenheit; converters[(int)Temperature.CToK] = StaticTempConverters.CelciusToKelvin; converters[(int)Temperature.CToRa] = StaticTempConverters.CelciusToRankine; converters[(int)Temperature.CToRe] = StaticTempConverters.CelciusToReaumur; do { Console.Clear(); double temperature = InputChecker.InputVar <double>("temperature in Celcius"); Console.WriteLine($"Celcius: {temperature:F3}"); for (int i = 0; i < numberOfConverters; ++i) { Console.WriteLine($"{converters[i].Method.Name}: {converters[i](temperature):F3}"); } Console.WriteLine("Press Esc to exit. Press any other key to continue."); } while (Console.ReadKey(true).Key != ConsoleKey.Escape); }
/// <summary> /// Coroutine che fa virbrare il joystick per la potenza e il tempo indicato /// </summary> /// <param name="_leftMotorIntensity"></param> /// <param name="_rightMotorIntensity"></param> /// <param name="_duration"></param> /// <returns></returns> private IEnumerator RumbleCoroutine(float _leftMotorIntensity, float _rightMotorIntensity, float _duration) { GamePad.SetVibration(InputChecker.GetJoystickPlayerIndex(), _leftMotorIntensity, _rightMotorIntensity); yield return(new WaitForSecondsRealtime(_duration)); GamePad.SetVibration(InputChecker.GetJoystickPlayerIndex(), 0f, 0f); }
public IActionResult LoginCheck(InputChecker Data_get) { LoginUser userSubmission = Data_get.LoginUser; if (ModelState.IsValid) { var userInDb = dbContext.Users.FirstOrDefault(u => u.Email == userSubmission.Email); if (userInDb == null) { ModelState.AddModelError("LoginUser.Email", "Invalid Email"); return(View("Index")); } var hasher = new PasswordHasher <LoginUser>(); var result = hasher.VerifyHashedPassword(userSubmission, userInDb.Password, userSubmission.Password); if (result == 0) { ModelState.AddModelError("LoginUser.Password", "Password Incorrect!"); return(View("Index")); } else { HttpContext.Session.SetInt32("UserId", userInDb.UserId); return(RedirectToAction("MainMenu")); } } else { return(View("Index")); } }
protected void MarketplaceAddButton_Click(object sender, EventArgs e) { ErrorMessagePanel.Visible = false; SuccMessagePanel.Visible = false; if (Member.IsLogged && Page.IsValid) { try { NewProduct.SellerId = user.Id; NewProduct.Title = InputChecker.HtmlEncode(MarketplaceAddTitle.Text, MarketplaceAddTitle.MaxLength, L1.TITLE); NewProduct.Description = InputChecker.HtmlEncode(MarketplaceAddDescription.Text, MarketplaceAddDescription.MaxLength, L1.DESCRIPTION); NewProduct.Price = Money.Parse(MarketplaceAddPrice.Text); NewProduct.Quantity = Convert.ToInt32(MarketplaceAddQuantity.Text); NewProduct.Contact = InputChecker.HtmlEncode(MarketplaceAddContact.Text, MarketplaceAddContact.MaxLength, L1.CONTACT); NewProduct.Status = UniversalStatus.Active; NewProduct.CategoryId = Convert.ToInt32(MarketplaceAddCategoriesList.SelectedValue); if (GeolocationCheckBox.Checked) { var validCountries = GeolocationUtils.GeoCountData.Keys; var countryNames = new StringBuilder(); foreach (ListItem item in GeoCountries.Items) { if (validCountries.Contains <string>(item.Value)) { countryNames.Append(item.Value); countryNames.Append("#"); } } var minAge = Convert.ToInt32(GeoAgeMin.Text); var maxAge = Convert.ToInt32(GeoAgeMax.Text); var gender = (Gender)Convert.ToInt32(GeoGenderList.SelectedValue); var countryCodes = GeolocationUnit.ParseFromCountriesString(countryNames.ToString()); var cities = string.Empty; NewProduct.AddGeolocation(new GeolocationUnit(countryCodes, cities, minAge, maxAge, gender)); } NewProduct.Save(); ClearAll(); BuildMarketplaceGrid(); SuccMessagePanel.Visible = true; SuccMessage.Text = U5006.MARKETPLACEADDED; } catch (MsgException ex) { ErrorMessagePanel.Visible = true; ErrorMessage.Text = ex.Message; } catch (Exception ex) { ErrorLogger.Log(ex); throw ex; } } }
public void TestKeyAvailable() { FakeIInput fakeConsole = new FakeIInput(Input.Left); InputChecker inputChecker = new InputChecker(fakeConsole); Assert.AreEqual(inputChecker.InputAvailable, true); }
public IActionResult Registration(InputChecker Data_get) { User the_user = Data_get.User; if (ModelState.IsValid) { if (dbContext.Users.Any(u => u.Email == the_user.Email)) { ModelState.AddModelError("User.Email", "Email already in use!"); return(View("Index")); } else { PasswordHasher <User> Hasher = new PasswordHasher <User>(); the_user.Password = Hasher.HashPassword(the_user, the_user.Password); dbContext.Add(the_user); dbContext.SaveChanges(); User this_user = dbContext.Users.FirstOrDefault(user => user.Email == the_user.Email); HttpContext.Session.SetInt32("UserId", this_user.UserId); return(RedirectToAction("MainMenu")); } } else { return(View("Index")); } }
protected void SupportTicketButton_Click(object sender, EventArgs e) { try { if (Member.IsLogged) { var ticket = new SupportTicket(Convert.ToInt32(Request.QueryString["ticketId"])); var InText = InputChecker.HtmlEncode(SupportTicketTextBox.Text, SupportTicketTextBox.MaxLength, U5004.MESSAGE); ticket.ReplyFromMember(InText); ticket.IsSolved = false; ticket.Date = DateTime.Now; ticket.Save(); SuccMessage.Text = U3501.SUPPSENT; TicketLiteral.Text = SupportTicketReply.GetAllTicketRepliesHtml(ticket.Id, Member.Current, true); //Clear the fields ErrorMessagePanel.Visible = false; SupportTicketTextBox.Text = ""; } } catch (MsgException ex) { ErrorMessagePanel.Visible = true; ErrorMessage.Text = ex.Message; } catch (Exception ex) { ErrorLogger.Log(ex); } }
protected void ArticlesGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var article = new Article(Convert.ToInt32(e.Row.Cells[0].Text)); e.Row.Cells[1].Text = InputChecker.HtmlPartialDecode(article.Title); e.Row.Cells[2].Text = article.GetCategory().Text; e.Row.Cells[4].Text = String.Format("<img src='Images/Flags/{0}.png'/> {1}", article.Geolocation.ToLower(), CountryManager.GetCountryName(article.Geolocation)); e.Row.Cells[6].Text = Money.Parse(e.Row.Cells[6].Text).ToString(); e.Row.Cells[7].Text = HtmlCreator.GetColoredStatus(article.Status); if (article.Status != AdvertStatus.Paused) { e.Row.Cells[8].Text = " "; } if (article.Status != AdvertStatus.Active) { e.Row.Cells[9].Text = " "; } //Edit button ((LinkButton)e.Row.Cells[11].FindControl("ImageButton4")).ToolTip = U5007.EDIT; } else if (e.Row.RowType == DataControlRowType.Header) { e.Row.Cells[5].Text = U6012.READS; e.Row.Cells[6].Text = U6012.MONEYCREDITED; } }
public void SetKeySignature() { Random randomNumber = new Random(); //create randomNumber object Menus.DisplayKeyMenu(); keyNumber = InputChecker.IntegerCheck("\n Please choose a key signature from the " + "display above. ", 1, 27); // calculate keyNumber variable for random selections if (keyNumber == 25) { keyNumber = randomNumber.Next(1, 12); //random Major key } else if (keyNumber == 26) { keyNumber = randomNumber.Next(13, 24); //random minor key } else if (keyNumber == 27) { keyNumber = randomNumber.Next(1, 24); //random all keys } SetKeyName(keyNumber); //set the keyLabel value //append the keyType value if (keyNumber <= 12) { keyLabel += " Major"; } else { keyLabel += " minor"; } }
public IActionResult Registration(InputChecker Data_get) { User the_user = Data_get.User; if (ModelState.IsValid) { if (dbContext.Users.Any(u => u.Email == the_user.Email)) { ModelState.AddModelError("User.Email", "Email already in use!"); return(View("Index")); } else { if (Regex.IsMatch(the_user.Password, @"^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{8,}$")) { PasswordHasher <User> Hasher = new PasswordHasher <User>(); the_user.Password = Hasher.HashPassword(the_user, the_user.Password); dbContext.Add(the_user); dbContext.SaveChanges(); User this_user = dbContext.Users.FirstOrDefault(user => user.Email == the_user.Email); HttpContext.Session.SetInt32("UserId", this_user.UserId); return(RedirectToAction("MainMenu")); } else { ModelState.AddModelError("User.Password", "Must contain at least 1 number, letter, and a special character!"); return(View("Index")); } } } else { return(View("Index")); } }
public override void Update(GameTime gameTime) { Vector2 inputVector = InputChecker.GetInputVector(Acceleration); Vector2 adjustedVector = ApplyMovementRules(inputVector); Body.ApplyLinearImpulse(adjustedVector); base.Update(gameTime); }
private void Awake() { if (instance == null) { instance = this; StartCoroutine(CheckInputTypeCoroutine()); } }
private void SetTutorialActive(Mechanic mechanic) { _currentInputDevice = InputChecker.GetInputType(); _keyboardMove.SetActive(mechanic == Mechanic.Move && _currentInputDevice == InputChecker.InputType.MouseKeyboard); _gamePadMove.SetActive(mechanic == Mechanic.Move && _currentInputDevice == InputChecker.InputType.Controller); _keyboardDash.SetActive(mechanic == Mechanic.Dash && _currentInputDevice == InputChecker.InputType.MouseKeyboard); _gamePadDash.SetActive(mechanic == Mechanic.Dash && _currentInputDevice == InputChecker.InputType.Controller); }
private void HandleTutorialTriggerEnter(TutorialTrigger _triggerTriggered) { tutorialTriggered = _triggerTriggered; enemyMng.SetCanAddTollerance(false); player.GetHealthController().SetCanLoseHealth(false); tutorialText.text = tutorialTriggered.GetTextToShow(InputChecker.GetCurrentInputType()); tutorialText.gameObject.SetActive(true); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { InputChecker inputChecker = new InputChecker(this); #region GetDataFromCanvas List <Curve> inCurves = new List <Curve>(); bool canGetCurves = DA.GetDataList <Curve>(0, inCurves); inputChecker.StopIfConversionIsFailed(canGetCurves); List <int> inCurvesDegree = new List <int>(); bool canGetCrvDegrees = DA.GetDataList <int>(1, inCurvesDegree); inputChecker.StopIfConversionIsFailed(canGetCrvDegrees); ValuesAllocator.MatchLists(inCurves, inCurvesDegree); List <double> inRebuildFactors = new List <double>(); bool canGetFactors = DA.GetDataList <double>(2, inRebuildFactors); inputChecker.StopIfConversionIsFailed(canGetFactors); ValuesAllocator.MatchLists(inCurves, inRebuildFactors); List <bool> inPreserveTan = new List <bool>(); bool canGetPreserveTan = DA.GetDataList <bool>(3, inPreserveTan); inputChecker.StopIfConversionIsFailed(canGetPreserveTan); ValuesAllocator.MatchLists(inCurves, inPreserveTan); bool useParallel = false; DA.GetData <bool>(4, ref useParallel); #endregion Curve[] curves = inCurves.ToArray(); int[] curvesDegree = inCurvesDegree.ToArray(); double[] rebuildFactors = inRebuildFactors.ToArray(); bool[] preserveTan = inPreserveTan.ToArray(); ConcurrentDictionary <int, Curve> rebuildedCurves = new ConcurrentDictionary <int, Curve>(); if (!useParallel) { this.Message = Constants.Constants.SERIAL_MESSAGE; for (int i = 0; i < (int)curves.Length; i++) { CurvesOptimizer.RebuildProportionally(i, curves, curvesDegree, rebuildFactors, preserveTan, rebuildedCurves); } } else { this.Message = Constants.Constants.PARALLEL_MESSAGE; this.AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, Constants.Constants.PARALLEL_WARNING); int processorCount = Environment.ProcessorCount - 1;; Parallel.For(0, curves.Length, new ParallelOptions { MaxDegreeOfParallelism = processorCount }, i => CurvesOptimizer.RebuildProportionally(i, curves, curvesDegree, rebuildFactors, preserveTan, rebuildedCurves) ); } List <Curve> curves1 = new List <Curve>(); curves1.AddRange(rebuildedCurves.Values); DA.SetDataList(0, curves1); }
public override void Update(GameTime gameTime) { Vector2 inputVector = InputChecker.GetInputVector(Acceleration); SetVelocityBasedOnInputVector(gameTime, inputVector); UpdateAnimationFrame(gameTime); SetDirectionBasedOnInputVector(inputVector); base.Update(gameTime); }
protected void DepositViaRepresentativeButton_Click(object sender, EventArgs e) { ErrorMessagePanel.Visible = false; SuccMessagePanel.Visible = false; string amount = Request.Form["price"].ToString(); Money Amount; try { Amount = Money.Parse(amount).FromMulticurrency(); //Anti-Injection Fix if (Amount <= new Money(0)) { throw new MsgException(L1.ERROR); } if (Amount < AppSettings.Payments.MinimumTransferAmount) { throw new MsgException(U3000.ITSLOWERTHANMINIMUM); } if (string.IsNullOrEmpty(RepresentativeMessage.Text) || String.IsNullOrWhiteSpace(RepresentativeMessage.Text)) { throw new MsgException(L1.REQ_TEXT); } string Message = InputChecker.HtmlEncode(RepresentativeMessage.Text, RepresentativeMessage.MaxLength, U5004.MESSAGE); var SelectedRepresentative = new Representative(Convert.ToInt32(AvaibleRepresentativeList.SelectedValue)); if (ConversationMessage.CheckIfThisUserHavePendingActions(user.Id)) { throw new MsgException(U6010.YOUHAVEPENDINGACTION); } if (Amount > new Member(SelectedRepresentative.UserId).CashBalance) { throw new MsgException(U6010.REPRESENTATIVENOFUNDS); } RepresentativesTransferManager representativesTransferManager = new RepresentativesTransferManager(Member.CurrentId, SelectedRepresentative.UserId); representativesTransferManager.InvokeDeposit(Amount, Message); Response.Redirect("~/user/network/messenger.aspx"); } catch (MsgException ex) { ShowErrorMessage(ex.Message); } catch (Exception ex) { ErrorLogger.Log(ex); ShowErrorMessage(ex.Message); } }
public void GenderCheckMaleInput() { bool CorrectGender = false; string testString = "Male"; CorrectGender = InputChecker.GenderCheck(testString); Assert.IsTrue(CorrectGender); }
public void GenderCheckWrongInput() { bool CorrectGender = false; string testString = "test"; CorrectGender = InputChecker.GenderCheck(testString); Assert.IsFalse(CorrectGender); }
public void MailFormatCheckRightInput() { bool CorrectMailAddress = false; string testString = "[email protected]"; CorrectMailAddress = InputChecker.MailFormatCheck(testString); Assert.IsTrue(CorrectMailAddress); }
public void NoEmptyInputCheckNullInput() { bool NoEmptyInput = false; string testString = null; NoEmptyInput = InputChecker.NoEmptyInputCheck(testString); Assert.IsFalse(NoEmptyInput); }
public void GenderCheckNullInput() { bool CorrectGender = false; string testString = null; CorrectGender = InputChecker.GenderCheck(testString); Assert.IsFalse(CorrectGender); }
protected void CreateOrEditButton_Click(object sender, EventArgs e) { ErrorMessagePanel.Visible = false; SuccMessagePanel.Visible = false; if (Page.IsValid) { try { var user = Member.Current; string ImageURL = VideoImage.DescriptionUrl; string VideoURL = VideoURLHiddenLabel.Text; if (PageRequest == RequestType.Create && String.IsNullOrEmpty(ImageURL) && String.IsNullOrEmpty(VideoURL)) { throw new MsgException(U6012.MUSTUPLOADIMAGEORVIDEO); } string title = InputChecker.HtmlEncode(TitleTextBox.Text, Article.TitleMaxCharacters, L1.TITLE); string description = InputChecker.HtmlEncode(DescriptionTextBox.Text, 150, U6012.SUBTITLE); string text = InputChecker.HtmlEncode(Request.Form[TextCKEditor.UniqueID], 2000000000, L1.TEXT); List <string> keywords = KeywordsTextBox.Text.Replace(" ", string.Empty) .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(tag => InputChecker.HtmlEncode(tag, 20, U6002.TAG)) .ToList(); string keywordsString = InputChecker.HtmlEncode(String.Join(",", keywords.ToArray()), 5000, U6012.KEYWORDS); if (PageRequest == RequestType.Create) { Article.Add(title, text, description, keywordsString, Member.CurrentId, CountriesList.SelectedValue, Convert.ToInt32(CategoriesList.SelectedValue), ImageURL, VideoURL); SuccMessage.Text = U6012.ARTICLECREATED + ". " + L1.YOUWILLREDIRECT; } else { Article.Edit(Convert.ToInt32(ViewState["editid"]), title, text, description, keywordsString, Member.CurrentId, CountriesList.SelectedValue, Convert.ToInt32(CategoriesList.SelectedValue), ImageURL, VideoURL); SuccMessage.Text = U6013.ARTICLESAVEDANDSENT + " " + L1.YOUWILLREDIRECT; } SuccMessagePanel.Visible = true; ViewState["editid"] = null; Response.AddHeader("REFRESH", "3;URL=writing.aspx"); } catch (MsgException ex) { ErrorMessagePanel.Visible = true; ErrorMessage.Text = ex.Message; } catch (Exception ex) { ErrorLogger.Log(ex); } } }
public void MailFormatCheckEmptyStringInput() { bool CorrectMailAddress = false; string testString = ""; CorrectMailAddress = InputChecker.MailFormatCheck(testString); Assert.IsFalse(CorrectMailAddress); }
public void SetUp() { var inputArray = new[] { "1721", "1", "366", "299", "675", "1456" }; var mockPuzzleInput = new Mock <IPuzzleInput>(); mockPuzzleInput.Setup(p => p.GetPuzzleInputAsArray(It.IsAny <string>())).Returns(inputArray); _sut = new InputChecker(mockPuzzleInput.Object); }
public void SetUp() { var inputArray = new[] { "1-3 a: abcde", "1-3 b: cdefg", "2-9 c: ccccccccc" }; var mockPuzzleInput = new Mock <IPuzzleInput>(); mockPuzzleInput.Setup(p => p.GetPuzzleInputAsArray(It.IsAny <string>())).Returns(inputArray); _sut = new InputChecker(mockPuzzleInput.Object); }
public void WhenNoKeyboardKeyIsPushed_AnyButtonIsCurrentlyPressed_ReturnsFalse() { var inputChecker = new InputChecker(); var inputConnectorMock = new InputConnectorMock(); var gameSettings = new GameSettings(); inputChecker.SetInputConnector(inputConnectorMock); inputConnectorMock.ManipulateKeyboardState = new KeyboardState(new Keys[] {}); Assert.IsFalse(inputChecker.AnyButtonIsCurrentlyPressed(gameSettings)); }
private void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; } }
public void Then_output_value_for_part2_is_correct(string input, string result) { _input = new[] { string.Empty, input }; var mockPuzzleInput = new Mock <IPuzzleInput>(); mockPuzzleInput.Setup(p => p.GetPuzzleInputAsArray(It.IsAny <string>())).Returns(_input); _sut = new InputChecker(mockPuzzleInput.Object); Assert.That(_sut.CheckInputToGetAnswerPart2(), Is.EqualTo(result)); }
public SimpleGestureDetector( InputChecker parent ) { Parent = parent; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { // Currently in a layout without a container, so no reason to create our view. return null; } //The navbar should basically be a background with logo and a springboard reveal button in the upper left. Navbar = inflater.Inflate(Resource.Layout.navbar, container, false) as RelativeLayout; Navbar.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TopNavToolbar_BackgroundColor ) ); // create the springboard reveal button CreateSpringboardButton( Navbar ); DropShadowXOffset = 15; DropShadowView = Activity.FindViewById<FrameLayout>(Resource.Id.dropShadowView) as FrameLayout; InputViewChecker = new InputChecker( Rock.Mobile.PlatformSpecific.Android.Core.Context ); InputViewChecker.NavParent = this; if ( _ActiveTaskFrame != null ) { _ActiveTaskFrame.AddView( InputViewChecker ); } return Navbar; }