public Menu(string name) : base(name) { this.Name = name; this.BackColor = Color.White; //FIX ME! (different color creates a minor bug on sub-sub menus) keyboad = new KeyboardHelper(); keyboad.OnKeyPress += Keyboard_OnPress; keyboad.OnKeyRelease += Keyboard_OnRelease; }
static void OnIsTabbingEnabledChanged(DependencyObject target, DependencyPropertyChangedEventArgs args) { FrameworkElement fe = target as FrameworkElement; if (fe == null) { keyboardHelper = null; } else { keyboardHelper = new KeyboardHelper(fe); fe.KeyDown += new KeyEventHandler(fe_KeyDown); } }
public override void Initialize() { Score = 0; Value = 0; Speed = 50; keyboard = new KeyboardHelper( Game ); keyboard.Configurate( Keys.Left, MeanOfKey.Mean1 ); keyboard.Configurate( Keys.Right, MeanOfKey.Mean2 ); scoreShows = new ScoreShowingManager( Game ); Game.Components.Add( keyboard ); Game.Components.Add( scoreShows ); base.Initialize(); }
public SubMenu(Form owner) : base(string.Empty) { this.Owner = owner; timer.Elapsed += new ElapsedEventHandler(Timer_Elapsed); BackColor = Color.White; ForeColor = Color.Black; if (owner != null) { BackColor = owner.BackColor; ForeColor = owner.ForeColor; } keyboard = new KeyboardHelper(); keyboard.OnKeyPress += Keyboard_OnPress; keyboard.OnKeyRelease += Keyboard_OnRelease; }
public void KeyboardTest() { using (var setup = new TestSetupHelper("TabView Tests")) { Log.Comment("Set focus inside the TabView"); UIObject tabContent = FindElement.ByName("FirstTabContent"); tabContent.SetFocus(); TabItem firstTab = FindElement.ByName <TabItem>("FirstTab"); TabItem secondTab = FindElement.ByName <TabItem>("SecondTab"); TabItem lastTab = FindElement.ByName <TabItem>("LastTab"); Button addButton = FindElement.ById <Button>("AddButton"); Verify.IsTrue(firstTab.IsSelected, "First Tab should be selected initially"); Button firstTabButton = FindElement.ByName <Button>("FirstTabButton"); Verify.IsTrue(firstTabButton.HasKeyboardFocus, "Focus should start in the First Tab"); // Ctrl+Tab to the second tab: KeyboardHelper.PressKey(Key.Tab, ModifierKey.Control); Verify.IsTrue(secondTab.IsSelected, "Ctrl+Tab should move selection to Second Tab"); Button secondTabButton = FindElement.ByName <Button>("SecondTabButton"); Verify.IsTrue(secondTabButton.HasKeyboardFocus, "Focus should move to the content of the Second Tab"); // Ctrl+Shift+Tab to the first tab: KeyboardHelper.PressKey(Key.Tab, ModifierKey.Control | ModifierKey.Shift); Verify.IsTrue(firstTab.IsSelected, "Ctrl+Shift+Tab should move selection to First Tab"); Verify.IsTrue(firstTabButton.HasKeyboardFocus, "Focus should move to the content of the First Tab"); // Ctrl+Shift+Tab to the last tab: KeyboardHelper.PressKey(Key.Tab, ModifierKey.Control | ModifierKey.Shift); Verify.IsTrue(lastTab.IsSelected, "Ctrl+Shift+Tab should move selection to Last Tab"); Verify.IsTrue(lastTab.HasKeyboardFocus, "Focus should move to the last tab (since it has no focusable content)"); // Ctrl+Tab to the first tab: KeyboardHelper.PressKey(Key.Tab, ModifierKey.Control); Verify.IsTrue(firstTab.IsSelected, "Ctrl+Tab should move selection to First Tab"); Verify.IsTrue(firstTab.HasKeyboardFocus, "Focus should move to the first tab"); KeyboardHelper.PressKey(Key.Up); Verify.IsTrue(firstTab.HasKeyboardFocus, "Up key should not move focus"); KeyboardHelper.PressKey(Key.Down); Verify.IsTrue(firstTab.HasKeyboardFocus, "Down key should not move focus"); KeyboardHelper.PressKey(Key.Right); Verify.IsTrue(secondTab.HasKeyboardFocus, "Right Key should move focus to the second tab"); KeyboardHelper.PressKey(Key.Left); Verify.IsTrue(firstTab.HasKeyboardFocus, "Left Key should move focus to the first tab"); addButton.SetFocus(); Verify.IsTrue(addButton.HasKeyboardFocus, "AddButton should have keyboard focus"); KeyboardHelper.PressKey(Key.Left); Verify.IsTrue(lastTab.HasKeyboardFocus, "Left Key from AddButton should move focus to last tab"); KeyboardHelper.PressKey(Key.Right); Verify.IsTrue(addButton.HasKeyboardFocus, "Right Key from Last Tab should move focus to Add Button"); firstTab.SetFocus(); // Ctrl+f4 to close the tab: Log.Comment("Verify that pressing ctrl-f4 closes the tab"); KeyboardHelper.PressKey(Key.F4, ModifierKey.Control); Wait.ForIdle(); VerifyElement.NotFound("FirstTab", FindBy.Name); // Move focus to the second tab content secondTabButton.SetFocus(); Wait.ForIdle(); } }
private void Cell_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { CalendarDayButton b = sender as CalendarDayButton; if (b == null) { return; } if (this.Owner == null || !(b.DataContext is DateTime)) { return; } if (b.IsBlackedOut) { this.Owner.HoverStart = null; } else { this._isDayPressed = true; Mouse.Capture(this, CaptureMode.SubTree); b.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)); bool ctrl, shift; KeyboardHelper.GetMetaKeyState(out ctrl, out shift); DateTime selectedDate = (DateTime)b.DataContext; Debug.Assert(selectedDate != null); switch (this.Owner.SelectionMode) { case CalendarSelectionMode.None: { break; } case CalendarSelectionMode.SingleDate: { this.Owner.DatePickerDisplayDateFlag = true; if (!ctrl) { this.Owner.SelectedDate = selectedDate; } else { this.Owner.SelectedDates.Toggle(selectedDate); } break; } case CalendarSelectionMode.SingleRange: { this.Owner.SelectedDates.ClearInternal(); if (shift) { if (!this.Owner.HoverStart.HasValue) { this.Owner.HoverStart = this.Owner.CurrentDate; } } else { this.Owner.HoverStart = selectedDate; } Mouse.Capture(this, CaptureMode.SubTree); break; } case CalendarSelectionMode.MultipleRange: { if (!ctrl) { this.Owner.SelectedDates.ClearInternal(); } if (shift) { if (!this.Owner.HoverStart.HasValue) { this.Owner.HoverStart = this.Owner.CurrentDate; } } else { this.Owner.HoverStart = selectedDate; } Mouse.Capture(this, CaptureMode.SubTree); break; } } this.Owner.CurrentDate = selectedDate; this.Owner.UpdateCellItems(); } }
public override void Update(GameTime gameTime) { if (OnlineGameClient != null) { OnlineGameClient.ExecuteDelayedScripts(); } if (OnlineCommunicationClient != null) { OnlineCommunicationClient.ExecuteDelayedScripts(); ChatHelper.UpdateChat(gameTime, OnlineCommunicationClient.Chat, ChatInput); } if (FMODSystem.sndActiveBGM != sndBGM) { sndBGM.PlayAsBGM(); } foreach (InteractiveButton ActiveButton in ArrayMenuButton) { ActiveButton.Update(gameTime); } MissionScrollbar.Update(gameTime); foreach (Player ActiveRobot in Room.ListRoomPlayer) { if (ActiveRobot.CharacterPreview != null) { ActiveRobot.CharacterPreview.Update(gameTime); ActiveRobot.CharacterPreview.UpdateAllWeaponsAngle(new Vector2(5, 0)); } } if (KeyboardHelper.KeyPressed(Microsoft.Xna.Framework.Input.Keys.F1)) { Player NewPlayer = new Player("", "", Player.PlayerTypes.Player, 0); Room.AddLocalPlayer(NewPlayer); NewPlayer.GameplayType = GameplayTypes.Controller1; } else if (KeyboardHelper.KeyPressed(Microsoft.Xna.Framework.Input.Keys.F2)) { Player NewPlayer = new Player("", "", Player.PlayerTypes.Player, 0); Room.AddLocalPlayer(NewPlayer); NewPlayer.GameplayType = GameplayTypes.Controller2; } else if (KeyboardHelper.KeyPressed(Microsoft.Xna.Framework.Input.Keys.F3)) { Player NewPlayer = new Player("", "", Player.PlayerTypes.Player, 0); Room.AddLocalPlayer(NewPlayer); NewPlayer.GameplayType = GameplayTypes.Controller3; } else if (KeyboardHelper.KeyPressed(Microsoft.Xna.Framework.Input.Keys.F4)) { Player NewPlayer = new Player("", "", Player.PlayerTypes.Player, 0); Room.AddLocalPlayer(NewPlayer); NewPlayer.GameplayType = GameplayTypes.Controller4; } if (MouseHelper.InputLeftButtonPressed() && IsHost) { for (int M = MissionInfoStartIndex, i = 0; M < ListMissionInfo.Count && i < 4; ++M, ++i) { Rectangle QuestButtonCollisionBox = new Rectangle(405 - (int)QuestButton.Origin.X, 140 - (int)QuestButton.Origin.Y + i * 64, QuestButton.SpriteWidth, QuestButton.SpriteHeight); if (QuestButtonCollisionBox.Contains(MouseHelper.MouseStateCurrent.X, MouseHelper.MouseStateCurrent.Y)) { UpdateSelectedMission(ListMissionInfo[M]); break; } } } }
public void UIAValuePatternTest() { using (var setup = new TestSetupHelper("RatingControl Tests")) // This literally clicks the button corresponding to the test page. { Log.Comment("Retrieve rating control as generic UIElement"); UIObject ratingUIObject = FindElement.ByName("TestRatingControl"); TextBlock textBlock = new TextBlock(FindElement.ByName("TestTextBlockControl")); Verify.IsNotNull(ratingUIObject, "Verifying that we found a UIElement called TestRatingControl"); Log.Comment("Verify the UIA Value before user clicks the control."); ratingUIObject.SetFocus(); // Setting focus just so we can use AE.FE below Wait.ForIdle(); AutomationElement ratingPeer = AutomationElement.FocusedElement; VerifyValue_ValueEqualsOnAutomationElement(ratingPeer, "Community Rating, 2.5 of 5"); if (PlatformConfiguration.IsOsVersionGreaterThan(OSVersion.Redstone2)) // engagement doesn't work pre RS3 { Log.Comment("Verify moving right 2 times with the gamepad sets the control to 3"); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadRight); GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadRight); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); Wait.ForIdle(); Verify.AreEqual("3", textBlock.DocumentText); Log.Comment("Verify rating of 3 sets UIA text to 3"); VerifyValue_ValueEqualsOnAutomationElement(ratingPeer, "Rating, 3 of 5"); // revert: Log.Comment("Resetting control to community rating"); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadLeft); GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadLeft); GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadLeft); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); VerifyValue_ValueEqualsOnAutomationElement(ratingPeer, "Community Rating, 2.5 of 5"); } Log.Comment("Verify more complex navigation"); KeyboardHelper.PressKey(ratingUIObject, Key.Right); KeyboardHelper.PressKey(ratingUIObject, Key.Right); KeyboardHelper.PressKey(ratingUIObject, Key.Right); KeyboardHelper.PressKey(ratingUIObject, Key.Left); VerifyValue_ValueEqualsOnAutomationElement(ratingPeer, "Rating, 2 of 5"); // Verify read an unset rating ratingUIObject = FindElement.ByName("RatingBindingSample"); Log.Comment("Verify the UIA Value of an unset Rating without a placeholder value"); ratingUIObject.SetFocus(); InputHelper.ScrollToElement(ratingUIObject); ratingPeer = AutomationElement.FocusedElement; VerifyValue_ValueEqualsOnAutomationElement(ratingPeer, "Rating Unset"); // Verify rounding: Log.Comment("Verifying Value_Value rounding"); UIObject round1 = FindElement.ById("ValuePatternRoundTest1"); round1.SetFocus(); AutomationElement roundAE1 = AutomationElement.FocusedElement; UIObject round2 = FindElement.ById("ValuePatternRoundTest2"); round2.SetFocus(); AutomationElement roundAE2 = AutomationElement.FocusedElement; UIObject round3 = FindElement.ById("ValuePatternRoundTest3"); round3.SetFocus(); AutomationElement roundAE3 = AutomationElement.FocusedElement; VerifyValue_ValueEqualsOnAutomationElement(roundAE1, "Rating, 1.5 of 5"); VerifyValue_ValueEqualsOnAutomationElement(roundAE2, "Rating, 1.55 of 5"); VerifyValue_ValueEqualsOnAutomationElement(roundAE3, "Rating, 1.5 of 5"); } }
private void listBox_PreviewKeyDown(object sender, KeyEventArgs e) { KeyboardHelper.ListBoxPreviewKeyDown(sender as ListBox, e); }
private void InitializeKeyCommands() { IgnoreCommand = new RelayCommand(_ => { }); EscCommand = new RelayCommand(_ => { if (!SelectedIsFromQueryResults()) { SelectedResults = Results; } else { MainWindowVisibility = Visibility.Collapsed; } }); SelectNextItemCommand = new RelayCommand(_ => { SelectedResults.SelectNextResult(); }); SelectPrevItemCommand = new RelayCommand(_ => { SelectedResults.SelectPrevResult(); }); SelectNextTabItemCommand = new RelayCommand(_ => { SelectedResults.SelectNextTabItem(); }); SelectPrevTabItemCommand = new RelayCommand(_ => { SelectedResults.SelectPrevTabItem(); }); SelectNextContextMenuItemCommand = new RelayCommand(_ => { SelectedResults.SelectNextContextMenuItem(); }); SelectPreviousContextMenuItemCommand = new RelayCommand(_ => { SelectedResults.SelectPreviousContextMenuItem(); }); SelectNextPageCommand = new RelayCommand(_ => { SelectedResults.SelectNextPage(); }); SelectPrevPageCommand = new RelayCommand(_ => { SelectedResults.SelectPrevPage(); }); SelectFirstResultCommand = new RelayCommand(_ => SelectedResults.SelectFirstResult()); StartHelpCommand = new RelayCommand(_ => { Process.Start("https://aka.ms/PowerToys/"); }); OpenResultCommand = new RelayCommand(index => { var results = SelectedResults; if (index != null) { results.SelectedIndex = int.Parse(index.ToString(), CultureInfo.InvariantCulture); } if (results.SelectedItem != null) { // If there is a context button selected fire the action for that button before the main command. bool didExecuteContextButton = results.SelectedItem.ExecuteSelectedContextButton(); if (!didExecuteContextButton) { var result = results.SelectedItem.Result; // SelectedItem returns null if selection is empty. if (result != null && result.Action != null) { MainWindowVisibility = Visibility.Collapsed; Application.Current.Dispatcher.Invoke(() => { result.Action(new ActionContext { SpecialKeyState = KeyboardHelper.CheckModifiers(), }); }); if (SelectedIsFromQueryResults()) { _userSelectedRecord.Add(result); _history.Add(result.OriginQuery.RawQuery); } else { SelectedResults = Results; } } } } }); LoadContextMenuCommand = new RelayCommand(_ => { if (SelectedIsFromQueryResults()) { SelectedResults = ContextMenu; } else { SelectedResults = Results; } }); LoadHistoryCommand = new RelayCommand(_ => { if (SelectedIsFromQueryResults()) { SelectedResults = History; History.SelectedIndex = _history.Items.Count - 1; } else { SelectedResults = Results; } }); ClearQueryCommand = new RelayCommand(_ => { if (!string.IsNullOrEmpty(QueryText)) { ChangeQueryText(string.Empty, true); // Push Event to UI SystemQuery has changed OnPropertyChanged(nameof(SystemQueryText)); } }); }
public void Update(List <OBJCollisionable> Obj) { RecPerso = new Rectangle((int)Position.X - 40, (int)Position.Y - 80, 80, 80); //Collision avec les obstacles if (Obj != null) { foreach (OBJCollisionable O in Obj) { O.Update(this); } } Vie.Update(this); Deplacement = false; Position += Speed; #region Controle //Peut se déplacer si pas entrain de respirer if (!Respire || !Transformation) { if (KeyboardHelper.KeyHold(Keys.Up) || KeyboardHelper.KeyHold(Keys.W)) { Position.Y -= 2; RecPerso.Y -= 4; Deplacement = true; } if (KeyboardHelper.KeyHold(Keys.Down) || KeyboardHelper.KeyHold(Keys.S)) { Position.Y += 2; RecPerso.Y += 4; Deplacement = true; } if (KeyboardHelper.KeyHold(Keys.Right) || KeyboardHelper.KeyHold(Keys.D)) { Position.X += 2; RecPerso.X += 4; flip = SpriteEffects.None; Deplacement = true; } if (KeyboardHelper.KeyHold(Keys.Left) || KeyboardHelper.KeyHold(Keys.A)) { Position.X -= 2; RecPerso.X -= 4; flip = SpriteEffects.FlipHorizontally; Deplacement = true; } //Deplacement de l'air if (EnnemiIn) { if (flipAir == SpriteEffects.None) { PositionAir.X += 3; } else { PositionAir.X -= 3; } } } #endregion #region GRAVITÉ Apres les saut et roulades if (Gravity) { float i = 1; Speed.Y += 0.15f * i; if (Speed.Y >= 3) { Speed.Y = 0; Gravity = false; JumpOne = false; } } #endregion #region Animation Selon les touche if (Deplacement) // si en deplacement { if (!Transform) // si n'est pas transformé { if (!EnnemiIn) //Si l'ennemi n'est pas avalé { if (Respire) { if (RespireContinue) { APJoueur.PlayAnimation(AspirationContinue); } else { APJoueur.PlayAnimation(Aspiration); } } else if (Jump) { APJoueur.PlayAnimation(Jumping); } else { APJoueur.PlayAnimation(Running); } } else // Si l'ennemi est avalé { if (Transformation) { APJoueur.PlayAnimation(Transforming); } else if (Launch) { APJoueur.PlayAnimation(Lauching); APAir.PlayAnimation(AirLunch); } else { APJoueur.PlayAnimation(RunningA); } } } else //Si transformé { if (Attack) { APJoueur.PlayAnimation(AttackT); } else if (Launch) { APJoueur.PlayAnimation(Lauching); APAir.PlayAnimation(AirLunch); } else { APJoueur.PlayAnimation(WalkingT); } } } else { if (!Transform) //si pas transformé { if (!EnnemiIn) //Si l'ennemi n'est pas avalé { if (Respire) { if (RespireContinue) { APJoueur.PlayAnimation(AspirationContinue); } else { APJoueur.PlayAnimation(Aspiration); } } else if (Jump) { APJoueur.PlayAnimation(Jumping); } else { APJoueur.PlayAnimation(Nothing); } } else // si l'ennemi est avalé { if (Transformation) { APJoueur.PlayAnimation(Transforming); } else if (Launch) { APJoueur.PlayAnimation(Lauching); APAir.PlayAnimation(AirLunch); } else { APJoueur.PlayAnimation(NothingA); } } } else // si transformé { if (Attack) { APJoueur.PlayAnimation(AttackT); } else if (Launch) { APJoueur.PlayAnimation(Lauching); APAir.PlayAnimation(AirLunch); } else { APJoueur.PlayAnimation(NothingT); } } } #endregion //Saut Et Attack #region Saut/Attack if (KeyboardHelper.KeyHold(Keys.Space)) { if (!EnnemiIn) { Jump = true; } else { Transformation = true; } if (Transform) { Attack = true; } if (!JumpOne && !Transform && !Transformation) { //Saut avec gravité Gravity = true; Position.Y -= 2; Speed.Y = -3; JumpOne = true; } } #endregion // if (KeyboardHelper.KeyPressed(Keys.I)) { if (EnnemiIn)EnnemiIn = false; else EnnemiIn = true; } // Activation de l'absorption et Tir #region Absorption et tir //Absorption if (KeyboardHelper.KeyHold(Keys.R) && !EnnemiIn) { Respire = true; Jump = false; } else { if (KeyboardHelper.KeyPressed(Keys.R)) { //Si a avalé un ennemi if (EnnemiIn || Transform) { Launch = true; //Regarde le jet d'air une fois if (!Tir) { Tir = true; if (flip == SpriteEffects.None) { PositionAir = new Vector2(Position.X + 40, Position.Y); } else { PositionAir = new Vector2(Position.X - 40, Position.Y); } flipAir = flip; } } } //Relachement de la respiration Respire = false; RespireContinue = false; } #endregion #region Deplacement du rectangle de l'air if (Tir) { RecAir = new Rectangle((int)PositionAir.X, (int)PositionAir.Y, 50, 50); //Deplacement if (flipAir == SpriteEffects.None) { PositionAir.X += 3f; } else { PositionAir.X -= 3f; } } #endregion // Arret des animation #region Arret if (APJoueur.Animation == Jumping && APJoueur.FrameIndex == 10) { Jump = false; } if (APJoueur.Animation == Aspiration && APJoueur.FrameIndex == 2) { RespireContinue = true; } if (APJoueur.Animation == Lauching && APJoueur.FrameIndex == 2) { Launch = false; EnnemiIn = false; APAir.PlayAnimation(null); Tir = false; Transform = false; Transformation = false; } if (APJoueur.Animation == Transforming && APJoueur.FrameIndex == 4) { Transform = true; Transformation = false; } if (APJoueur.Animation == AttackT && APJoueur.FrameIndex == 8) { Attack = false; } #endregion }
// When page is navigated to set data context to selected item in itemType protected override void OnNavigatedTo(NavigationEventArgs e) { // trace event TraceHelper.AddMessage("Item: OnNavigatedTo"); // check to make sure we haven't initialized yet if (isInitialized == true) return; // create the keyboard helper for tabbed navigation this.keyboardHelper = new KeyboardHelper(LayoutRoot); // reset the tab index tabIndex = 0; // render the folder field by default bool renderListInfo = false; // find the folder that this item would belong to string folderIDString = ""; if (NavigationContext.QueryString.TryGetValue("folderID", out folderIDString)) { Guid folderID = new Guid(folderIDString); if (folderID != Guid.Empty) { try { //folder = App.ViewModel.Folders.Single(folder => folder.ID == folderID); folder = App.ViewModel.LoadFolder(folderID); } catch (Exception) { folder = null; } } } // if we haven't found a folder, use the default one if (folder == null) { folder = App.ViewModel.DefaultFolder; renderListInfo = true; } string itemIDString = ""; // must have a item ID passed (either a valid GUID or "new") if (NavigationContext.QueryString.TryGetValue("ID", out itemIDString) == false) { // trace page navigation TraceHelper.StartMessage("Item: Navigate back"); NavigationService.GoBack(); return; } // the item page is used to construct a new item if (itemIDString == "new") { // remove the "actions" tab //ItemPagePivotControl.Items.RemoveAt(0); //((PivotItem)(ItemPagePivotControl.Items[0])).IsEnabled = false; itemCopy = new Item() { FolderID = folder.ID }; thisItem = null; RenderViewItem(itemCopy); RenderEditItem(itemCopy, renderListInfo); // navigate the pivot control to the "edit" view ItemPagePivotControl.SelectedIndex = 1; } else { // editing an existing item Guid id = new Guid(itemIDString); //thisItem = App.ViewModel.Items.Single(t => t.ID == id); //folder = App.ViewModel.Folders.Single(folder => folder.ID == thisItem.FolderID); thisItem = folder.Items.FirstOrDefault(t => t.ID == id); if (thisItem == null) { // trace page navigation TraceHelper.StartMessage("Item: Navigate back"); NavigationService.GoBack(); return; } // make a deep copy of the item for local binding itemCopy = new Item(thisItem); ItemPagePivotControl.DataContext = itemCopy; RenderViewItem(itemCopy); RenderEditItem(itemCopy, false /* don't render the list info as primray fields */); } // set the initialized flag isInitialized = true; }
public override void Update(GameTime gameTime) { Timer += (float)gameTime.ElapsedGameTime.TotalSeconds; //TRAITEMENT SELON LA PARTIE DU JEU OÙ ON EST RENDU switch (StateOfGame) { #region BeforeFight case GameState.BeforeFight: if (Timer >= 3) { Parole = "Bienvenue étranger,\nToi aussi il ta jeté \ndans la fosse. on\n va pouvoir enfin \n s'amuser !!"; } if (Timer >= 7) { Parole = "Han oui??\nQue voulez \nvous dire\n par là ?"; ParolePosition = new Vector2(Joueur.Position.X - 210, Joueur.Position.Y - 180); BullePosition = new Rectangle((int)(Joueur.Position.X - 130), (int)(Joueur.Position.Y - 250), GameResources.BulleParole.Width, GameResources.BulleParole.Height); RotationBulle = 20; CouleurParole = Color.Blue; } if (Timer >= 10) { Parole = "Nous allons te\ntester. Nous allons \nvoir si tu vaux la\n peine de devenir\n comme nous\n !DES NINJA!"; BullePosition = new Rectangle(40, 170, (int)(GameResources.BulleParole.Width * 1.5), (int)(GameResources.BulleParole.Height * 1.5)); ParolePosition = new Vector2(100, 230); CouleurParole = Color.DarkGreen; RotationBulle = 0; } if (Timer >= 15) { Parole = "Tu vas devoir\naffronter mes fils, \nUn apres l'autre\ndans un combat\nd'arene !!!"; AnimationPlayer.PlayAnimation(PresentationCombattants); } if (Timer >= 20) { Parole = " Est tu pret\n\n appuie sur Enter\n\nlorsque tu sera\n prêt"; if (KeyboardHelper.KeyPressed(Keys.Enter)) { StateOfGame = GameState.Raphael; Timer = 0; } } break; #endregion #region Fight case GameState.Raphael: if (!Presentationfinie) { AnimationPlayer.PlayAnimation(PresentationRaph); if (Timer >= 3) { Presentationfinie = true; //Vie = new HealthBars(RessourcesLoxi.HealtBarCombat, new Vector2(30, 50), false, null, false); //MechantVie = new HealthBars(RessourcesLoxi.HealtBarCombat, new Vector2(450, 50), false, null, true); Ennemi = new CombatIA(new Vector2(600, 480), 1, 70, GameResources.WalkingRaphAnimation, GameResources.RaphAttackAnimation); } } break; case GameState.Michelangelo: if (!Presentationfinie) { AnimationPlayer.PlayAnimation(PresentationMichelangelo); OpponentColor = Color.Yellow; OpponentName = "Michelangelo"; if (Timer >= 6) { Presentationfinie = true; Joueur.Position = new Vector2(200, 480); //Vie = new HealthBars(RessourcesLoxi.HealtBarCombat, new Vector2(30, 50), false, null, false); //MechantVie = new HealthBars(RessourcesLoxi.HealtBarCombat, new Vector2(450, 50), false, null, true); Ennemi = new CombatIA(new Vector2(600, 480), 2, 90, GameResources.WalkingMichAnimation, GameResources.MichAttackAnimation); } } break; case GameState.Donatello: if (!Presentationfinie) { AnimationPlayer.PlayAnimation(PresentationDonatello); OpponentColor = Color.Purple; OpponentName = "Donatello"; if (Timer >= 6) { Presentationfinie = true; Joueur.Position = new Vector2(200, 480); //Vie = new HealthBars(RessourcesLoxi.HealtBarCombat, new Vector2(30, 50), false, null, false); //MechantVie = new HealthBars(RessourcesLoxi.HealtBarCombat, new Vector2(450, 50), false, null, true); Ennemi = new CombatIA(new Vector2(600, 480), 3, 110, GameResources.WalkingDonAnimation, GameResources.DonAttackAnimation); } } break; case GameState.Leonardo: if (!Presentationfinie) { AnimationPlayer.PlayAnimation(PresentationLeonardo); OpponentColor = Color.Blue; OpponentName = "Leonardo"; if (Timer >= 6) { Presentationfinie = true; Joueur.Position = new Vector2(200, 480); //Vie = new HealthBars(RessourcesLoxi.HealtBarCombat, new Vector2(30, 50), false, null, false); //MechantVie = new HealthBars(RessourcesLoxi.HealtBarCombat, new Vector2(450, 50), false, null, true); Ennemi = new CombatIA(new Vector2(600, 480), 4, 120, GameResources.WalkingLeoAnimation, GameResources.LeoAttackAnimation); Parole = ""; } } break; #endregion #region AfterFight case GameState.AfterFight: if (Timer >= 1) { Parole = "Bravo étranger,\nTu as réussi a\nbattre tous mes\n fils je vais te\n récompenser!!"; BullePosition = new Rectangle(140, 20, (int)(GameResources.BulleParole.Width * 1.4), (int)(GameResources.BulleParole.Height * 1.4)); ParolePosition = new Vector2(20, 130); CouleurParole = Color.DarkGreen; RotationBulle = 20; } if (Timer >= 4) { Parole = " Je vais te \n Transformer\n comme nous...\n EN NINJA !!! \n Tiens toi pret"; AnimationPlayer.PlayAnimation(GameResources.DanseTransformation); } if (Timer >= 10 && !Joueur.LoxiTransformation) { Joueur.Transformation = true; } if (Timer >= 14) { Parole = "Maintenant tu \npourra peut être \nsortir de la fosse \n,avec ta force \n actuelle plus \n celle du \n ninja"; } if (Timer >= 18) { AddScreen(new cMovie3(m_ServiceProvider, m_GraphicsDeviceManager)); RemoveScreen(this); } break; #endregion } //CHANGEMENT DE NIVEAU SI MONSTRE MORT #region Traitement de Changement de niveau if (MechantVie != null && Presentationfinie && !ColorBackToNormal) { if (MechantVie.m_GameOver) { if (IniTimer == false) { Timer = 0; IniTimer = true; } if (Timer >= 3) { switch (StateOfGame) { case GameState.Raphael: StateOfGame = GameState.Michelangelo; break; case GameState.Michelangelo: StateOfGame = GameState.Donatello; break; case GameState.Donatello: StateOfGame = GameState.Leonardo; break; case GameState.Leonardo: Joueur.Position = new Vector2(200, 480); ColorBackToNormal = true; StateOfGame = GameState.AfterFight; Timer = 0; AP2.PlayAnimation(GameResources.MichAttenteAnimation); AP3.PlayAnimation(GameResources.LeoAttenteAnimation); AP4.PlayAnimation(GameResources.DonAttenteAnimation); AP5.PlayAnimation(GameResources.RaphAttenteAnimation); break; } if (ColorBackToNormal) { Presentationfinie = true; } else { Presentationfinie = false; } IniTimer = false; } } } #endregion Joueur.Update(null, GameResources.JumpEffect, GameResources.ShootEffect); #region Update Vie/Ennemi if (Ennemi != null && Vie != null && !ColorBackToNormal) { //Ennemi.Update(gameTime, Joueur); //Vie.Update(Ennemi.DamageYou,Ennemi.Force); if (Vie.m_GameOver && !MechantVie.m_GameOver) { TimerFin += (float)gameTime.ElapsedGameTime.TotalSeconds; if (Convert.ToInt32(TimerFin) == 3) { RemoveScreen(this); AddScreen(new cNivTortueNinja(m_ServiceProvider, m_GraphicsDeviceManager)); } } #endregion #region CheckBalle/UpdateMechantVie foreach (Bullets bullet in Joueur.bullets) { /* * if (bullet.m_Rectangle.Intersects(Ennemi.Rectangle)) * MechantVie.Update(true,1); * else * MechantVie.Update(false,1);*/ } #endregion } }
public bool InputLeftPressed() { return(KeyboardHelper.InputLeftPressed()); }
// When page is navigated to set data context to selected item in listType protected override void OnNavigatedTo(NavigationEventArgs e) { // trace event TraceHelper.AddMessage("Task: OnNavigatedTo"); // check to make sure we haven't initialized yet if (isInitialized == true) return; // create the keyboard helper for tabbed navigation this.keyboardHelper = new KeyboardHelper(LayoutRoot); // reset the tab index tabIndex = 0; // don't render the tasklist field by default bool renderTaskListField = false; // find the taskist that this task would belong to string taskListIDString = ""; if (NavigationContext.QueryString.TryGetValue("taskListID", out taskListIDString)) { Guid taskListID = new Guid(taskListIDString); if (taskListID != Guid.Empty) { try { //taskList = App.ViewModel.TaskLists.Single(tl => tl.ID == taskListID); taskList = App.ViewModel.LoadList(taskListID); } catch (Exception) { taskList = null; } } } // if we haven't found a tasklist, use the default one if (taskList == null) { taskList = App.ViewModel.DefaultTaskList; renderTaskListField = true; } string taskIDString = ""; // must have a task ID passed (either a valid GUID or "new") if (NavigationContext.QueryString.TryGetValue("ID", out taskIDString) == false) { // trace page navigation TraceHelper.StartMessage("Task: Navigate back"); NavigationService.GoBack(); return; } // the task page is used to construct a new item if (taskIDString == "new") { // remove the "actions" tab //TaskPagePivotControl.Items.RemoveAt(0); //((PivotItem)(TaskPagePivotControl.Items[0])).IsEnabled = false; taskCopy = new Task() { TaskListID = taskList.ID }; thisTask = null; RenderViewTask(taskCopy); RenderEditTask(taskCopy, renderTaskListField); // navigate the pivot control to the "edit" view TaskPagePivotControl.SelectedIndex = 1; } else { // editing an existing item Guid id = new Guid(taskIDString); //thisTask = App.ViewModel.Tasks.Single(t => t.ID == id); //taskList = App.ViewModel.TaskLists.Single(tl => tl.ID == thisTask.TaskListID); thisTask = taskList.Tasks.Single(t => t.ID == id); // make a deep copy of the task for local binding taskCopy = new Task(thisTask); DataContext = taskCopy; RenderViewTask(taskCopy); RenderEditTask(taskCopy, false); } // set the initialized flag isInitialized = true; }
internal InputManager() { Keyboard = new KeyboardHelper(); Mouse = new MouseHelper(); GamePads = new GamePadHelper(); }
void MainPage_Loaded(object sender, RoutedEventArgs e) { this.keyboardHelper = new KeyboardHelper(this, LayoutRoot); }
private void OpenResultsEvent(object index, bool isMouseClick) { var results = SelectedResults; if (index != null) { // Using InvariantCulture since this is internal results.SelectedIndex = int.Parse(index.ToString(), CultureInfo.InvariantCulture); } if (results.SelectedItem != null) { bool executeResultRequired = false; if (isMouseClick) { executeResultRequired = true; } else { // If there is a context button selected fire the action for that button instead, and the main command will not be executed executeResultRequired = !results.SelectedItem.ExecuteSelectedContextButton(); } if (executeResultRequired) { var result = results.SelectedItem.Result; // SelectedItem returns null if selection is empty. if (result != null && result.Action != null) { Hide(); Application.Current.Dispatcher.Invoke(() => { result.Action(new ActionContext { SpecialKeyState = KeyboardHelper.CheckModifiers(), }); }); if (SelectedIsFromQueryResults()) { // todo: revert _userSelectedRecordStorage.Save() and _historyItemsStorage.Save() after https://github.com/microsoft/PowerToys/issues/9164 is done _userSelectedRecord.Add(result); try { _userSelectedRecordStorage.Save(); } catch (UnauthorizedAccessException ex) { Log.Warn($"Failed to save file. ${ex.Message}", this.GetType()); } _history.Add(result.OriginQuery.RawQuery); try { _historyItemsStorage.Save(); } catch (UnauthorizedAccessException ex) { Log.Warn($"Failed to save file. ${ex.Message}", this.GetType()); } } else { SelectedResults = Results; } } } } }
public InputManager(Game game) : base(game) { PlayerControls = new Dictionary<PlayerIndex, Dictionary<string, InputMethod>>(); PlayerControls[PlayerIndex.One] = new Dictionary<string, InputMethod>(); PlayerControls[PlayerIndex.Two] = new Dictionary<string, InputMethod>(); PlayerControls[PlayerIndex.Three] = new Dictionary<string, InputMethod>(); PlayerControls[PlayerIndex.Four] = new Dictionary<string, InputMethod>(); GamePads = new Dictionary<PlayerIndex, Pad>(); GamePads[PlayerIndex.One] = new Pad(PlayerIndex.One); GamePads[PlayerIndex.Two] = new Pad(PlayerIndex.Two); GamePads[PlayerIndex.Three] = new Pad(PlayerIndex.Three); GamePads[PlayerIndex.Four] = new Pad(PlayerIndex.Four); _mouse = new MouseHelper(); _keyboard = new KeyboardHelper(); game.Components.Add(this); game.Services.AddService(typeof(IInputService), this); }
private void deviceChooserPanel_PreviewKeyDown(object sender, KeyEventArgs e) { KeyboardHelper.PopupPreviewKeyDown(sender as Popup, e); }
/// <summary> /// Allows the game component to update itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public override void Update(GameTime gameTime) { KeyboardHelper kHelper = new KeyboardHelper(); base.Update(gameTime); keyboardState = Keyboard.GetState(); if (keyboardState.IsKeyDown(Keys.Back) && oldKeyboardState.IsKeyUp(Keys.Back) && inputChars.Count > 0) inputChars.RemoveAt(inputChars.Count - 1); kHelper.ReturnDigitORNumberKeyAsChar(keyboardState, oldKeyboardState).ForEach(delegate(char c) { inputChars.Add(c); }); oldKeyboardState = keyboardState; }
public void DoUpdateEditor(GameTime gameTime) { if (MouseHelper.InputLeftButtonPressed()) { if (CursorPosition.X >= Constants.Width - 200 && CursorPosition.Y <= 30) { if (ListActionMenuChoice.HasMainPanel && !(ListActionMenuChoice.Last() is MagicElementSelectionPanel)) { ListActionMenuChoice.RemoveAllActionPanels(); } if (!ListActionMenuChoice.HasMainPanel) { ListActionMenuChoice.AddToPanelListAndSelect(new MagicElementSelectionPanel(this)); } else if (ListActionMenuChoice.HasMainPanel && ListActionMenuChoice.Last() is MagicElementSelectionPanel) { ListActionMenuChoice.RemoveAllActionPanels(); } } else if (CursorPosition.X >= Constants.Width - 400 && CursorPosition.Y <= 30) { ListActionMenuChoice.RemoveAllActionPanels(); ListActionMenuChoice.AddToPanelListAndSelect(new MagicPreviewerPanel(Content, ActiveMagicSpell, ListActionMenuChoice, GlobalProjectileContext, SharedParams)); } else { if (ListActionMenuChoice.HasMainPanel && CursorPosition.X >= Constants.Width - 200) { return; } if (ListActionMenuChoice.HasMainPanel && ListActionMenuChoice.Last() is MagicAttributesEditonPanel) { ListActionMenuChoice.RemoveAllActionPanels(); } foreach (MagicElement ActiveMagicElement in ListMagicElement) { if (Math.Sqrt(Math.Pow(CursorPosition.X - ActiveMagicElement.Position.X, 2) + Math.Pow(CursorPosition.Y - ActiveMagicElement.Position.Y, 2)) < ActiveMagicElement.Radius) { MagicElementSelected = ActiveMagicElement; ListActionMenuChoice.AddToPanelListAndSelect(new MagicAttributesEditonPanel(this, ActiveMagicElement)); break; } } } } else if (MouseHelper.InputLeftButtonReleased()) { MagicElementSelected = null; } else if (MouseHelper.InputLeftButtonHold()) { if (MagicElementSelected != null) { MagicElementSelected.Position = CursorPosition; MagicElementSelected.IsValid = true; //Unlink all Magic foreach (MagicElement ActiveMagicElement in ListMagicElement) { ActiveMagicElement.ListLinkedMagicElement.Remove(MagicElementSelected); if (ActiveMagicElement == MagicElementSelected) { continue; } double DistanceBetweenMagicElement = Math.Sqrt(Math.Pow(MagicElementSelected.Position.X - ActiveMagicElement.Position.X, 2) + Math.Pow(MagicElementSelected.Position.Y - ActiveMagicElement.Position.Y, 2)); float TotalRadius = MagicElementSelected.Radius + ActiveMagicElement.Radius; // Collision if (DistanceBetweenMagicElement <= TotalRadius) { MagicElementSelected.IsValid = false; return; } } //Recompute all Magic links foreach (MagicElement ActiveMagicElement in ListMagicElement) { if (ActiveMagicElement == MagicElementSelected) { continue; } double DistanceBetweenMagicElement = Math.Sqrt(Math.Pow(MagicElementSelected.Position.X - ActiveMagicElement.Position.X, 2) + Math.Pow(MagicElementSelected.Position.Y - ActiveMagicElement.Position.Y, 2)); float TotalRadius = MagicElementSelected.Radius + ActiveMagicElement.Radius; // Collision if (DistanceBetweenMagicElement > TotalRadius && DistanceBetweenMagicElement < TotalRadius + SelectionRadius) { ActiveMagicElement.ListLinkedMagicElement.Add(MagicElementSelected); break; } } } else if (KeyboardHelper.KeyHold(Microsoft.Xna.Framework.Input.Keys.LeftAlt)) { CameraOffset.X += MouseHelper.MouseStateCurrent.X - MouseHelper.MouseStateLast.X; CameraOffset.Y += MouseHelper.MouseStateCurrent.Y - MouseHelper.MouseStateLast.Y; ZoomLevel += (MouseHelper.MouseStateCurrent.ScrollWheelValue - MouseHelper.MouseStateLast.ScrollWheelValue) / 100; } } }
public void VerifyLightDismissDoesntSendDuplicateEvents() { var testScenarios = RegressionTestScenario.BuildLeftNavRegressionTestScenarios(); foreach (var testScenario in testScenarios) { using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName })) { if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone3)) { Log.Warning("Test is disabled on RS2 and older due to lack of SplitView events"); return; } CheckBox isPaneOpenCheckBox = new CheckBox(FindElement.ById("IsPaneOpenCheckBox")); Verify.AreEqual(ToggleState.On, isPaneOpenCheckBox.ToggleState, "IsPaneOpen expected to be True"); SetNavViewWidth(ControlWidth.Medium); WaitAndAssertPaneStatus(PaneOpenStatus.Closed); PaneOpenCloseTestCaseRetry(3, () => { // recover from the exception if needed if (isPaneOpenCheckBox.ToggleState != ToggleState.Off) { using (var waiter = isPaneOpenCheckBox.GetToggledWaiter()) { isPaneOpenCheckBox.Toggle(); waiter.Wait(); } WaitAndAssertPaneStatus(PaneOpenStatus.Closed); } Verify.AreEqual(ToggleState.Off, isPaneOpenCheckBox.ToggleState, "IsPaneOpen expected to be False"); Log.Comment("Reset the event count"); new Button(FindElement.ById("ClosingEventCountResetButton")).Invoke(); Wait.ForIdle(); Log.Comment("Open the pane"); using (var waiter = isPaneOpenCheckBox.GetToggledWaiter()) { isPaneOpenCheckBox.Toggle(); waiter.Wait(); } WaitAndAssertPaneStatus(PaneOpenStatus.Opened); Verify.AreEqual(ToggleState.On, isPaneOpenCheckBox.ToggleState, "IsPaneOpen expected to be True"); var closingCounts = new Edit(FindElement.ByName("ClosingEventCountTextBlock")); var expectedString = "1-1"; // trigger a light dismiss KeyboardHelper.PressKey(Key.Left, ModifierKey.Alt); Wait.ForIdle(); WaitAndAssertPaneStatus(PaneOpenStatus.Closed); Verify.AreEqual(ToggleState.Off, isPaneOpenCheckBox.ToggleState, "IsPaneOpen expected to be False"); Verify.AreEqual(expectedString, closingCounts.GetText()); }); } } }
/// <summary> /// Format a shortcut as a string. /// </summary> /// <param name="shortcut">Shortcut to format.</param> /// <returns>String format of shortcut.</returns> private string FormatShortcutString(Shortcut shortcut) { return(KeyboardHelper.FormatShortcutString(shortcut)); }
private void revertToDefaultKeyboardLayoutMenuItemClick(object sender, EventArgs e) { // Revert to default keyboard layout ChangeKeyboard(KeyboardHelper.GetKeyboardName()); Redraw(); }
internal void HandleKeyDown(KeyRoutedEventArgs e) { if (e == null || e.Handled) { return; } ItemInfo?info = null; switch (e.Key) { case VirtualKey.Escape: if (this.editService.IsEditing) { e.Handled = true; this.CancelEdit(ActionTrigger.Keyboard, e.Key); } break; case VirtualKey.F2: if (!this.editService.IsEditing) { e.Handled = true; this.BeginEdit(this.CurrentItem, ActionTrigger.Keyboard, e.Key); } break; case VirtualKey.Tab: if (e.OriginalSource is RadDataGrid) { if (!this.editService.IsEditing) { e.Handled = true; info = this.CurrencyService.CurrentItemInfo == null? this.model.FindFirstDataItemInView() : this.CurrencyService.CurrentItemInfo; #pragma warning disable CS4014 Dispatcher.RunAsync( Windows.UI.Core.CoreDispatcherPriority.Low, () => { var xamlVisualStateLayer = this.visualStateLayerCache as XamlVisualStateLayer; if (xamlVisualStateLayer != null) { var currencyVisual = xamlVisualStateLayer.CurrencyVisual as DataGridCurrencyControl; if (currencyVisual != null && currencyVisual.Visibility == Visibility.Visible) { currencyVisual.Focus(FocusState.Keyboard); this.RaiseCellPeerFocusChangedEvent(info); } } }); #pragma warning restore CS4014 } } break; case VirtualKey.Down: if (!this.editService.IsEditing) { e.Handled = true; info = this.model.FindPreviousOrNextDataItem(this.CurrentItem, true); } break; case VirtualKey.Up: if (!this.editService.IsEditing) { e.Handled = true; info = this.model.FindPreviousOrNextDataItem(this.CurrentItem, false); } break; case VirtualKey.PageDown: if (!this.editService.IsEditing) { e.Handled = true; info = this.model.FindPageUpOrDownDataItem(this.CurrentItem, true); } break; case VirtualKey.PageUp: if (!this.editService.IsEditing) { e.Handled = true; info = this.model.FindPageUpOrDownDataItem(this.CurrentItem, false); } break; case VirtualKey.Home: if (!this.editService.IsEditing && KeyboardHelper.IsModifierKeyDown(VirtualKey.Control)) { e.Handled = true; info = this.model.FindFirstDataItemInView(); } break; case VirtualKey.End: if (!this.editService.IsEditing && KeyboardHelper.IsModifierKeyDown(VirtualKey.Control)) { e.Handled = true; info = this.model.FindLastDataItemInView(); } break; case VirtualKey.Enter: e.Handled = true; if (this.editService.IsEditing) { this.CommitEdit(new DataGridCellInfo(this.CurrentItem, null), ActionTrigger.Keyboard, e.Key); } else { bool shiftPressed = KeyboardHelper.IsModifierKeyDown(VirtualKey.Shift); info = this.model.FindPreviousOrNextDataItem(this.CurrentItem, !shiftPressed); } break; case VirtualKey.Space: if (e.OriginalSource is RadDataGrid) { if (this.SelectionUnit == DataGridSelectionUnit.Row) { info = this.model.FindItemInfo(this.CurrentItem); if (info != null) { var cell = this.model.CellsController.GetCellsForRow(info.Value.Slot).First(); if (cell != null) { this.OnCellTap(new DataGridCellInfo(cell)); } } } } break; } if (info != null) { this.CurrencyService.ChangeCurrentItem(info.Value.Item, true, true); if (e.Key != VirtualKey.Tab) { this.RaiseCellPeerFocusChangedEvent(info); } } }
private void putKeyboardListOnClipboardToolStripMenuItemClick(object sender, EventArgs e) { KeyboardHelper.ShowKeyboardList(); }
public override void OnViewModelLoadedOverride() { FindViewById <Button>(Resource.Id.ButtonDate).Click += ButtonDate_Click; _spinnerClass = FindViewById <Spinner>(Resource.Id.SpinnerClass); _spinnerClass.Adapter = SpinnerClassesAdapter.Create(ViewModel.Classes); _spinnerClass.ItemSelected += _spinnerClass_ItemSelected; UpdateSelectedClass(); _spinnerWeight = FindViewById <Spinner>(Resource.Id.SpinnerWeightCategory); AssignWeightCategoriesAdapter(); _spinnerWeight.ItemSelected += _spinnerWeight_ItemSelected; UpdateSelectedWeight(); _spinnerTimeOption = FindViewById <Spinner>(Resource.Id.SpinnerTimeOption); AssignTimeOptionsAdapter(); _spinnerTimeOption.ItemSelected += _spinnerTimeOption_ItemSelected; switch (ViewModel.Type) { case AddHomeworkViewModel.ItemType.Homework: switch (ViewModel.State) { case AddHomeworkViewModel.OperationState.Adding: Title = PowerPlannerResources.GetString("String_AddTask").ToUpper(); break; case AddHomeworkViewModel.OperationState.Editing: Title = PowerPlannerResources.GetString("String_EditTask").ToUpper(); break; default: throw new NotImplementedException(); } break; case AddHomeworkViewModel.ItemType.Exam: switch (ViewModel.State) { case AddHomeworkViewModel.OperationState.Adding: Title = PowerPlannerResources.GetString("String_AddEvent").ToUpper(); break; case AddHomeworkViewModel.OperationState.Editing: Title = PowerPlannerResources.GetString("String_EditEvent").ToUpper(); break; default: throw new NotImplementedException(); } break; } FindViewById <Button>(Resource.Id.ButtonStartTime).Click += StartTime_Click; FindViewById <Button>(Resource.Id.ButtonEndTime).Click += EndTime_Click; FindViewById <EditingImageAttachmentsWrapGrid>(Resource.Id.EditingImageAttachmentsWrapGrid).RequestedAddImage += AddHomeworkView_RequestedAddImage; ViewModel.PropertyChanged += new WeakEventHandler <PropertyChangedEventArgs>(ViewModel_PropertyChanged).Handler; SetMenu(Resource.Menu.add_homework_menu); if (ViewModel.Name.Length == 0) { KeyboardHelper.FocusAndShow(FindViewById <EditText>(Resource.Id.EditTextName)); } }
/// <summary> /// Exposed for testing purposes. /// </summary> internal bool ProcessKeyDown(VirtualKey key) { if (!this.isCalendarViewFocused) { return(false); } bool handled = false; DateTime oldCurrentDate = this.CurrentDate; switch (key) { case VirtualKey.Left: { handled = this.CurrencyService.MoveCurrentToPrevious(KeyboardHelper.IsModifierKeyDown(VirtualKey.Control)); break; } case VirtualKey.Right: { handled = this.CurrencyService.MoveCurrentToNext(KeyboardHelper.IsModifierKeyDown(VirtualKey.Control)); break; } case VirtualKey.Up: { handled = this.CurrencyService.MoveCurrentUp(KeyboardHelper.IsModifierKeyDown(VirtualKey.Control)); break; } case VirtualKey.Down: { handled = this.CurrencyService.MoveCurrentDown(KeyboardHelper.IsModifierKeyDown(VirtualKey.Control)); break; } case VirtualKey.Home: { handled = this.CurrencyService.MoveCurrentToFirst(); break; } case VirtualKey.End: { handled = this.CurrencyService.MoveCurrentToLast(); break; } case VirtualKey.Enter: case VirtualKey.Space: { handled = this.CurrencyService.HandleCellTap(); break; } } // Shift Selection in Multiple SelectionMode. if (key != VirtualKey.Enter && key != VirtualKey.Space && KeyboardHelper.IsModifierKeyDown(VirtualKey.Shift) && !KeyboardHelper.IsModifierKeyDown(VirtualKey.Control) && oldCurrentDate != this.CurrentDate && this.SelectionMode == CalendarSelectionMode.Multiple) { CalendarCellModel oldCurrentModel = this.GetCellByDate(oldCurrentDate); CalendarCellModel newCurrentModel = this.GetCellByDate(this.CurrentDate); this.SelectionService.MakeRangeSelection(oldCurrentModel, newCurrentModel); } if (oldCurrentDate != this.CurrentDate) { this.FireAutomationFocusEvent(); } if (handled && this.FocusState != FocusState.Keyboard) { this.TryFocus(FocusState.Keyboard); } return(handled); }
private void dataGrid_PreviewKeyDown(object sender, KeyEventArgs e) { KeyboardHelper.DataGridPreviewKeyDown(sender as DataGrid, e); }
//TODO GroupSorting internal void ProcessSort(InputModifiers inputModifiers) { // if we can sort: // - DataConnection.AllowSort is true, and // - AllowUserToSortColumns and CanSort are true, and // - OwningColumn is bound, and // - SortDescriptionsCollection exists, and // - the column's data type is comparable // then try to sort if (OwningColumn != null && OwningGrid != null && OwningGrid.EditingRow == null && OwningColumn != OwningGrid.ColumnsInternal.FillerColumn && OwningGrid.DataConnection.AllowSort && OwningGrid.CanUserSortColumns && OwningColumn.CanUserSort && OwningGrid.DataConnection.SortDescriptions != null) { DataGrid owningGrid = OwningGrid; bool desending; AvaloniaSortDescription newSort; KeyboardHelper.GetMetaKeyState(inputModifiers, out bool ctrl, out bool shift); AvaloniaSortDescription sort = OwningColumn.GetSortDescription(); ICollectionView collectionView = owningGrid.DataConnection.CollectionView; Debug.Assert(collectionView != null); using (collectionView.DeferRefresh()) { // if shift is held down, we multi-sort, therefore if it isn't, we'll clear the sorts beforehand if (!shift || owningGrid.DataConnection.SortDescriptions.Count == 0) { /*if (collectionView.CanGroup && collectionView.GroupDescriptions != null) { // Make sure we sort by the GroupDescriptions first for (int i = 0; i < collectionView.GroupDescriptions.Count; i++) { PropertyGroupDescription groupDescription = collectionView.GroupDescriptions[i] as PropertyGroupDescription; if (groupDescription != null && collectionView.SortDescriptions.Count <= i || collectionView.SortDescriptions[i].PropertyName != groupDescription.PropertyName) { collectionView.SortDescriptions.Insert(Math.Min(i, collectionView.SortDescriptions.Count), new SortDescription(groupDescription.PropertyName, ListSortDirection.Ascending)); } } while (collectionView.SortDescriptions.Count > collectionView.GroupDescriptions.Count) { collectionView.SortDescriptions.RemoveAt(collectionView.GroupDescriptions.Count); } } else if (!shift) { owningGrid.DataConnection.SortDescriptions.Clear(); }*/ owningGrid.DataConnection.SortDescriptions.Clear(); } if (sort != null) { newSort = sort.SwitchSortDirection(); // changing direction should not affect sort order, so we replace this column's // sort description instead of just adding it to the end of the collection int oldIndex = owningGrid.DataConnection.SortDescriptions.IndexOf(sort); if (oldIndex >= 0) { owningGrid.DataConnection.SortDescriptions.Remove(sort); owningGrid.DataConnection.SortDescriptions.Insert(oldIndex, newSort); } else { owningGrid.DataConnection.SortDescriptions.Add(newSort); } } else { string propertyName = OwningColumn.GetSortPropertyName(); // no-opt if we couldn't find a property to sort on if (string.IsNullOrEmpty(propertyName)) { return; } newSort = AvaloniaSortDescription.FromPath(propertyName, culture: collectionView.Culture); owningGrid.DataConnection.SortDescriptions.Add(newSort); } } // We've completed the sort, so send the Invoked event for the column header's automation peer /*if (AutomationPeer.ListenerExists(AutomationEvents.InvokePatternOnInvoked)) { AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(this); if (peer != null) { peer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked); } }*/ } }
/// <summary> /// Verifica las teclas presinadas al cambio de ventana /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 07/04/2016 /// </history> private void Window_IsKeyboardFocusedChanged(object sender, DependencyPropertyChangedEventArgs e) { KeyboardHelper.CkeckKeysPress(StatusBarCap, Key.Capital); KeyboardHelper.CkeckKeysPress(StatusBarIns, Key.Insert); KeyboardHelper.CkeckKeysPress(StatusBarNum, Key.NumLock); }
public void PaneTabNavigationTest() { var testScenarios = RegressionTestScenario.BuildLeftNavRegressionTestScenarios(); foreach (var testScenario in testScenarios) { using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName })) { if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2)) { Log.Warning("Skipping: Correct pane tab navigation only works in RS2 and above"); return; } SetNavViewWidth(ControlWidth.Wide); Button togglePaneButton = new Button(FindElement.ById("TogglePaneButton")); UIObject firstItem = FindElement.ByName("Home"); UIObject settingsItem = FindElement.ByName("Settings"); UIObject nextTabTarget = FindElement.ByName("WidthComboBox"); CheckBox autoSuggestCheckBox = new CheckBox(FindElement.ByName("AutoSuggestCheckbox")); autoSuggestCheckBox.Uncheck(); Wait.ForIdle(); Log.Comment("Verify that in Expanded mode, tab navigation can leave the pane"); firstItem.SetFocus(); Wait.ForIdle(); KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 1); Wait.ForIdle(); Wait.RetryUntilEvalFuncSuccessOrTimeout( () => { return(togglePaneButton.HasKeyboardFocus); }, retryTimoutByMilliseconds: 3000 ); Log.Comment("Verify pressing shift-tab from the first menu item goes to the toggle button"); Verify.IsTrue(togglePaneButton.HasKeyboardFocus); settingsItem.SetFocus(); Wait.ForIdle(); KeyboardHelper.PressKey(Key.Tab); Wait.ForIdle(); Log.Comment("Verify pressing tab from settings goes to the first tab stop in the content area"); Verify.IsTrue(nextTabTarget.HasKeyboardFocus); SetNavViewWidth(ControlWidth.Medium); CheckBox isPaneOpenCheckBox = new CheckBox(FindElement.ById("IsPaneOpenCheckBox")); isPaneOpenCheckBox.Check(); Wait.ForIdle(); Log.Comment("Verify that in an overlay mode, tab navigation cannot leave the pane while the pane is open"); firstItem.SetFocus(); Wait.ForIdle(); KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 1); Wait.ForIdle(); Log.Comment("Verify pressing shift-tab from the first menu item goes to settings"); Verify.IsTrue(settingsItem.HasKeyboardFocus); settingsItem.SetFocus(); Wait.ForIdle(); KeyboardHelper.PressKey(Key.Tab); Wait.ForIdle(); Log.Comment("Verify pressing tab from settings goes to the first menu item"); Verify.IsTrue(firstItem.HasKeyboardFocus); } } }
public void BasicInteractionTest() { using (var setup = new TestSetupHelper("RatingControl Tests")) // This literally clicks the button corresponding to the test page. { Log.Comment("Retrieve rating control as generic UIElement"); UIObject ratingUIObject = FindElement.ByName("TestRatingControl"); Verify.IsNotNull(ratingUIObject, "Verifying that we found a UIElement called TestRatingControl"); Log.Comment("Retrieve the text block as a TextBlock"); TextBlock textBlock = new TextBlock(FindElement.ByName("TestTextBlockControl")); Log.Comment("Verify a tap on the third star sets Rating to 3"); InputHelper.Tap(ratingUIObject, 60, RATING_ITEM_HEIGHT / 2); Verify.AreEqual("3", textBlock.DocumentText); Log.Comment("Verify a tap on the third star sets Rating to 2.5 (placeholder value)"); InputHelper.Tap(ratingUIObject, 60, RATING_ITEM_HEIGHT / 2); Verify.AreEqual("!2.5", textBlock.DocumentText); Button phButton = new Button(FindElement.ByName("PHButton")); InputHelper.Tap(phButton); Log.Comment("Verify a tap on the first star sets Rating to 1"); InputHelper.Tap(ratingUIObject, 12, RATING_ITEM_HEIGHT / 2); Verify.AreEqual("1", textBlock.DocumentText); Log.Comment("Verify a swipe off the left sets Rating to NOTHING"); InputHelper.Pan(ratingUIObject, 200, Direction.West); Verify.AreEqual("!", textBlock.DocumentText); Log.Comment("Verify a right key on an unset Rating, sets rating to 1"); KeyboardHelper.PressKey(ratingUIObject, Key.Right); Verify.AreEqual("1", textBlock.DocumentText); Log.Comment("Verify a left key on an RTL rating increases the rating."); Button rtlbutton = new Button(FindElement.ByName("RTLButton")); rtlbutton.Invoke(); Wait.ForIdle(); KeyboardHelper.PressKey(ratingUIObject, Key.Left); Verify.AreEqual("2", textBlock.DocumentText); Log.Comment("Verify home/end keys in RTL"); KeyboardHelper.PressKey(ratingUIObject, Key.Home); Verify.AreEqual("!", textBlock.DocumentText); KeyboardHelper.PressKey(ratingUIObject, Key.End); Verify.AreEqual("5", textBlock.DocumentText); Log.Comment("Verify up down keys in RTL"); KeyboardHelper.PressKey(ratingUIObject, Key.Down); Verify.AreEqual("4", textBlock.DocumentText); KeyboardHelper.PressKey(ratingUIObject, Key.Up); Verify.AreEqual("5", textBlock.DocumentText); rtlbutton.Invoke(); Wait.ForIdle(); Log.Comment("Verify home/end keys in LTR"); KeyboardHelper.PressKey(ratingUIObject, Key.Home); Verify.AreEqual("!", textBlock.DocumentText); KeyboardHelper.PressKey(ratingUIObject, Key.End); Verify.AreEqual("5", textBlock.DocumentText); Log.Comment("Verify up down keys in LTR"); KeyboardHelper.PressKey(ratingUIObject, Key.Down); Verify.AreEqual("4", textBlock.DocumentText); KeyboardHelper.PressKey(ratingUIObject, Key.Up); Verify.AreEqual("5", textBlock.DocumentText); } }
//TODO GroupSorting internal void ProcessSort(KeyModifiers keyModifiers, ListSortDirection?forcedDirection = null) { // if we can sort: // - AllowUserToSortColumns and CanSort are true, and // - OwningColumn is bound // then try to sort if (OwningColumn != null && OwningGrid != null && OwningGrid.EditingRow == null && OwningColumn != OwningGrid.ColumnsInternal.FillerColumn && OwningGrid.CanUserSortColumns && OwningColumn.CanUserSort) { var ea = new DataGridColumnEventArgs(OwningColumn); OwningGrid.OnColumnSorting(ea); if (!ea.Handled && OwningGrid.DataConnection.AllowSort && OwningGrid.DataConnection.SortDescriptions != null) { // - DataConnection.AllowSort is true, and // - SortDescriptionsCollection exists, and // - the column's data type is comparable DataGrid owningGrid = OwningGrid; DataGridSortDescription newSort; KeyboardHelper.GetMetaKeyState(keyModifiers, out bool ctrl, out bool shift); DataGridSortDescription sort = OwningColumn.GetSortDescription(); IDataGridCollectionView collectionView = owningGrid.DataConnection.CollectionView; Debug.Assert(collectionView != null); using (collectionView.DeferRefresh()) { // if shift is held down, we multi-sort, therefore if it isn't, we'll clear the sorts beforehand if (!shift || owningGrid.DataConnection.SortDescriptions.Count == 0) { owningGrid.DataConnection.SortDescriptions.Clear(); } // if ctrl is held down, we only clear the sort directions if (!ctrl) { if (sort != null) { if (forcedDirection == null || sort.Direction != forcedDirection) { newSort = sort.SwitchSortDirection(); } else { newSort = sort; } // changing direction should not affect sort order, so we replace this column's // sort description instead of just adding it to the end of the collection int oldIndex = owningGrid.DataConnection.SortDescriptions.IndexOf(sort); if (oldIndex >= 0) { owningGrid.DataConnection.SortDescriptions.Remove(sort); owningGrid.DataConnection.SortDescriptions.Insert(oldIndex, newSort); } else { owningGrid.DataConnection.SortDescriptions.Add(newSort); } } else if (OwningColumn.CustomSortComparer != null) { newSort = forcedDirection != null? DataGridSortDescription.FromComparer(OwningColumn.CustomSortComparer, forcedDirection.Value) : DataGridSortDescription.FromComparer(OwningColumn.CustomSortComparer); owningGrid.DataConnection.SortDescriptions.Add(newSort); } else { string propertyName = OwningColumn.GetSortPropertyName(); // no-opt if we couldn't find a property to sort on if (string.IsNullOrEmpty(propertyName)) { return; } newSort = DataGridSortDescription.FromPath(propertyName, culture: collectionView.Culture); if (forcedDirection != null && newSort.Direction != forcedDirection) { newSort = newSort.SwitchSortDirection(); } owningGrid.DataConnection.SortDescriptions.Add(newSort); } } } } } }
private void Cell_Clicked(object sender, RoutedEventArgs e) { if (this.Owner == null) { return; } CalendarDayButton b = sender as CalendarDayButton; Debug.Assert(b != null); if (!(b.DataContext is DateTime)) { return; } // If the day is a blackout day selection is not allowed if (!b.IsBlackedOut) { DateTime clickedDate = (DateTime)b.DataContext; bool ctrl, shift; KeyboardHelper.GetMetaKeyState(out ctrl, out shift); switch (this.Owner.SelectionMode) { case CalendarSelectionMode.None: { break; } case CalendarSelectionMode.SingleDate: { if (!ctrl) { this.Owner.SelectedDate = clickedDate; } else { this.Owner.SelectedDates.Toggle(clickedDate); } break; } case CalendarSelectionMode.SingleRange: { DateTime?lastDate = this.Owner.CurrentDate; this.Owner.SelectedDates.Clear(); if (shift && lastDate.HasValue) { this.Owner.SelectedDates.AddRangeInternal(lastDate.Value, clickedDate); } else { this.Owner.SelectedDate = clickedDate; this.Owner.HoverStart = null; } break; } case CalendarSelectionMode.MultipleRange: { if (!ctrl) { this.Owner.SelectedDates.Clear(); } if (shift) { this.Owner.SelectedDates.AddRangeInternal(this.Owner.CurrentDate, clickedDate); } else { if (!ctrl) { this.Owner.SelectedDate = clickedDate; } else { this.Owner.SelectedDates.Toggle(clickedDate); this.Owner.HoverStart = null; } } break; } } this.Owner.OnDayClick(clickedDate); } }
public bool InputConfirmPressed(float MinX, float MinY, float MaxX, float MaxY) { return(KeyboardHelper.InputConfirmPressed() || (IsInZone(MinX, MinY, MaxX, MaxY) && MouseHelper.InputLeftButtonPressed())); }
private void Cell_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { CalendarDayButton b = sender as CalendarDayButton; if (b == null) { return; } if (this.Owner == null) { return; } if (!b.IsBlackedOut) { this.Owner.OnDayButtonMouseUp(e); } if (!(b.DataContext is DateTime)) { return; } bool ctrl, shift; KeyboardHelper.GetMetaKeyState(out ctrl, out shift); if (this.Owner.SelectionMode == CalendarSelectionMode.None || this.Owner.SelectionMode == CalendarSelectionMode.SingleDate) { this.Owner.OnDayClick((DateTime)b.DataContext); return; } if (this.Owner.HoverStart.HasValue) { switch (this.Owner.SelectionMode) { case CalendarSelectionMode.SingleRange: { // Update SelectedDates this.Owner.SelectedDates.ClearInternal(); EndDrag(ctrl, b); break; } case CalendarSelectionMode.MultipleRange: { // add the selection (either single day or SingleRange day) EndDrag(ctrl, b); break; } } } else { // If the day is blacked out but also a trailing day we should be able to switch months if (b.IsInactive && b.IsBlackedOut) { this.Owner.OnDayClick((DateTime)b.DataContext); } } }
public bool InputCancelPressed() { return(KeyboardHelper.InputCancelPressed() || (IsInZone(0, 0, Constants.Width, Constants.Height) && MouseHelper.InputRightButtonPressed())); }
public bool InputCommand2Pressed() { return(KeyboardHelper.InputCommand2Pressed()); }
public void Initialize() { UpdateScreenSettings(Settings.Instance); _keyboardHelper = new KeyboardHelper(Settings.FirstPlayer); _contentHelper = new ContentProvider(_game.Content); _debugHelper = new DebugHelper(this); Lifes = 3; StartLevel(1); }