public void ChangeMode(InputMode mode) { var member = GetType().GetField(string.Format("_{0}Dict", mode.ToString().ToLower()), BindingFlags.NonPublic | BindingFlags.Instance); if (member == null) throw new Exception(mode + " does not have a dictionary set up"); _currentDict = (SequencedDictionary<Key, Message>)member.GetValue(this); InputMode = mode; }
public CharacterMapKeysAttribute(InputMode mode, string charList, int width, params Key[] keys) { _mode = mode; _charList = charList; _width = width; _keys = keys; }
/// <summary> /// Specifies the input mode on a Smartphone. /// </summary> public static void SetInputMode(Control control, InputMode mode) { int msg; //only certain controls are supported if(control is TextBox) { msg = EM_SETINPUTMODE; } else if(control is ComboBox) { msg = LB_SETINPUTMODE; } else { return; } //get the handle to the child (native) control control.Capture = true; IntPtr hwnd = Win32Window.GetWindow(Win32Window.GetCapture(), GW.CHILD); control.Capture = false; //send message IntPtr result = Win32Window.SendMessage(hwnd, msg, IntPtr.Zero, (int)mode); }
internal RawStylusInputReport( InputMode mode, int timestamp, PresentationSource inputSource, PenContext penContext, RawStylusActions actions, int tabletDeviceId, int stylusDeviceId, int[] data) : base(inputSource, InputType.Stylus, mode, timestamp) { // Validate parameters if (!RawStylusActionsHelper.IsValid(actions)) { throw new InvalidEnumArgumentException(SR.Get(SRID.Enum_Invalid, "actions")); } if (data == null && actions != RawStylusActions.InRange) { throw new ArgumentNullException("data"); } _penContext = new SecurityCriticalDataClass<PenContext>(penContext); _actions = actions; _tabletDeviceId = tabletDeviceId; _stylusDeviceId = stylusDeviceId; _data = data; _isSynchronize = false; }
void getMove() { move = false; if (Input.GetKeyDown(KeyCode.M)){ input = "M"; move = true; mode = InputMode.getRoom; } if (Input.GetKeyDown(KeyCode.S)){ input = "S"; move = true; mode = InputMode.getArrowPath; } if (Input.GetKeyDown(KeyCode.Q)){ input = "Q"; move = true; } //clear everything if (move){ selectedRoom = null; arrowPath = null; tempPath.Clear(); move = false; } }
public InputHelper(InputMode inputDevice = InputMode.KeyMouse) { this.inputDevice = inputDevice; currentControlerState = GamePad.GetState(PlayerIndex.One); currentKeyboardState = Keyboard.GetState(); currentMouseState = Mouse.GetState(); }
public void ActivateAttackModifier() { Debug.Log("attc md activated"); m_InputMode = InputMode.attack; attackModifier = true; Cursor.SetCursor(attackCursorTexture, Vector2.zero, CursorMode.Auto); Input.ResetInputAxes(); }
public InputController() { m_Mode = InputMode.Player1; m_oldState = new KeyboardState(); m_newState = new KeyboardState(); m_oldControllerState = new GamePadState[NUM_SUPPORTED_PLAYERS]; m_newControllerState = new GamePadState[NUM_SUPPORTED_PLAYERS]; }
protected UIMapControlInputHandler(InputMode setInputMode, UIMapControl setUIMapControl) { mapUnitOrder = MapUnitOrder.None; IsSpanningRectangle = false; selectionRectangle = RectangleF.Empty; MapControl = setUIMapControl; InputMode = setInputMode; }
public InputController(InputMode mode) { m_Mode = mode; m_oldState = new KeyboardState(); m_newState = new KeyboardState(); m_oldControllerState = new GamePadState[NUM_SUPPORTED_PLAYERS]; m_newControllerState = new GamePadState[NUM_SUPPORTED_PLAYERS]; }
void Update() { if (Input.GetButtonDown ("Fire1")) { RaycastManager.RaycastControl (); } if (GameManager.CellControlled == null) { mode = InputMode.Default; return; } if (GameManager.CellControlled.GetComponent<AgentLife> ().isInfected) { DeselectAll(); return; } if (Input.GetButtonDown ("Fire2")) { playerTarget = RaycastManager.RaycastAttackEnemy (); GameManager.CellControlled.GetComponent<AgentMovement> ().enabled = false; GameManager.CellControlled.GetComponent<MoveToPoint> ().DefineNewDestination (Camera.main.ScreenToWorldPoint (Input.mousePosition)); if (playerTarget != null) { mode = InputMode.Attacking; } else { mode = InputMode.Controlling; } } switch (mode) { case (InputMode.Attacking): if(playerTarget == null) { //GameManager.CellControlled.GetComponent<AgentMovement> ().enabled = true; mode = InputMode.Controlling; break; } GameManager.CellControlled.GetComponent<MoveToPoint> ().DefineNewDestination (playerTarget.transform.position); if (Vector2.Distance (GameManager.CellControlled.transform.position, playerTarget.transform.position) < 10) { GameManager.CellControlled.GetComponent<AgentMovement> ().enabled = true; GameManager.CellControlled.GetComponent<MoveToPoint> ().enabled = false; } break; //case (InputMode.Attacking) } }
public HexagonyEnv(string source, string input, HexagonySettings settings) { if (source.StartsWith("❢")) _linearCode = source.Substring(1); else { _grid = Grid.Parse(source); _ips = Ut.NewArray( new PointAxial(0, -_grid.Size + 1), new PointAxial(_grid.Size - 1, -_grid.Size + 1), new PointAxial(_grid.Size - 1, 0), new PointAxial(0, _grid.Size - 1), new PointAxial(-_grid.Size + 1, _grid.Size - 1), new PointAxial(-_grid.Size + 1, 0)); _ipDirs = Ut.NewArray( Direction.East, Direction.SouthEast, Direction.SouthWest, Direction.West, Direction.NorthWest, Direction.NorthEast); } switch (_inputMode = settings.InputMode) { case InputMode.Utf8: _input = input.ToUtf8(); break; case InputMode.Utf16: _input = input.ToUtf16(); break; case InputMode.Numbers: var m = Regex.Match(input, @"\A(\s*\d+\s*)*\Z", RegexOptions.Singleline); if (!m.Success) throw new InvalidOperationException("The input provided is not a whitespace-separated list of numbers."); _input = m.Groups[1].Captures.Cast<Capture>().Select(c => { byte b; if (!byte.TryParse(c.Value.Trim(), out b)) throw new InvalidOperationException("The number {0} in the input string does not fit in a byte.".Fmt(c.Value.Trim())); return b; }).ToArray(); break; default: throw new InvalidOperationException("Please choose an input mode from the “Input semantics” menu."); } _inputIndex = 0; _settings = settings; if (!settings.MemoryAnnotations.ContainsKey(settings.LastMemoryAnnotationSet)) settings.MemoryAnnotations[settings.LastMemoryAnnotationSet] = new Dictionary<Direction, Dictionary<PointAxial, string>>(); _memory = new Memory(settings.MemoryAnnotations[settings.LastMemoryAnnotationSet]); }
/// <summary> /// Constructs ad instance of the RawAppCommandInputReport class. /// </summary> /// <param name="inputSource"> /// The input source that provided this input. /// </param> /// <param name="mode"> /// The mode in which the input is being provided. /// </param> /// <param name="timestamp"> /// The time when the input occured. /// </param> /// <param name="appCommand"> /// The Application Command associated. /// </param> /// <param name="device"> /// The device that generated the app command. /// </param> /// <param name="inputType">the input device that generated the input event</param> internal RawAppCommandInputReport( PresentationSource inputSource, InputMode mode, int timestamp, int appCommand, InputType device, InputType inputType) : base(inputSource, inputType, mode, timestamp) { _appCommand = appCommand; _device = device; }
public static IEnumerator DelayInputModeSwitch(InputMode switchTo) { float elapsedTime = 0; while (elapsedTime <= GameConstants.DELAYED_INPUT_SWITCH_DURATION) { elapsedTime += Time.unscaledDeltaTime; yield return null; } mode = switchTo; DelayedSwitch = null; }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } if (_animator.ReadyInQueue) { _animator.Start(null); } InputMode mode = _input.Update(this, _camera.Projection, _camera.View); if (mode == InputMode.Select) { //Ray ray = CreateRayFrom2D(_input.Selected); //_rubikscube.SelectCubicle(ray); } /* * else if (mode == InputMode.Drag) * { * Vector2 d = _input.DragTo - _input.DragFrom; * if (Math.Abs(d.X) > 5 || Math.Abs(d.Y) > 5) * { * Ray from = XNAUtils.CreateRayFrom2D(GraphicsDevice, _input.DragFrom, _camera.Projection, _camera.View, Matrix.Identity); * Cubicle fromCubicle; float fromDistance; * bool fromIntersected = _rubikscube.SelectCubicle(from, out fromCubicle, out fromDistance); * Ray to = XNAUtils.CreateRayFrom2D(GraphicsDevice, _input.DragTo, _camera.Projection, _camera.View, Matrix.Identity); * Cubicle toCubicle; float toDistance; * bool toIntersected = _rubikscube.SelectCubicle(to, out toCubicle, out toDistance); * * if (fromIntersected && toIntersected) * { * Vector3 fromPoint = from.Position + from.Direction * fromDistance; * Vector3 toPoint = to.Position + to.Direction * toDistance; * Position fromPos = new Position(fromPoint.X, fromPoint.Y, fromPoint.Z); * Position toPos = new Position(toPoint.X, toPoint.Y, toPoint.Z); * string op = CubeOperation.GetOp(_rubikscube.SelectedBasicOp, fromPos, toPos); * if (!string.IsNullOrEmpty(op)) * _rubikscube.Rotate(op, 500, false); * } * } * } * */ _camera.Rotate(-_input.Pan, -_input.Tilt, -_input.Pan); _input.Reset(); _animator.Update(); base.Update(gameTime); }
static void Main(string[] args) { args = new string[] { "bg", "PlainText", @"E:\AnalysInfo\Bulgarian\articles", @"E:\AnalysInfo\BulgarianResultPlain.txt" }; /* * Arg0 - short IETF language code * Arg1 - InputMode - Xml or plain text parsing * Arg2 - data source path * Arg3 - path for result * Arg4 - (optional)SpeedMode - Normal or Fast */ try { if (args.Length < 4) { throw new Exception("Wrong arguments"); } string language_code = args[0]; InputMode input_mode = (InputMode)Enum.Parse(typeof(InputMode), args[1]); string from_path = args[2]; string to_path = args[3]; SpeedMode speed_mode = SpeedMode.Normal; if (args.Length > 4) { speed_mode = (SpeedMode)Enum.Parse(typeof(SpeedMode), args[4]); } List <char> chars = new List <char>(); switch (language_code) { case "en": case "fr": case "de": chars = LatinCharacters.Concat(StandartPunctuationsCharacters).ToList(); break; case "ru": case "bg": chars = CyrillicCharacters.Concat(StandartPunctuationsCharacters).ToList(); break; } LanguageAnalizer analizer = new LanguageAnalizer(chars, from_path, to_path, InputMode.PlainText, SpeedMode.Normal); analizer.Analize(); } catch (Exception ex) { Console.WriteLine("Exception - {}", ex.Message); } }
private void SynchronizeState(InputMode inputMode, InputMethodState state) { try { _synchronizingSettings = true; SetState(inputMode, state); } finally { _synchronizingSettings = false; } }
/// <summary> /// There is a proscription against using Enum.IsDefined(). (it is slow) /// so we write these PRIVATE validate routines instead. /// </summary> private void Validate_InputMode(InputMode mode) { switch (mode) { case InputMode.Foreground: case InputMode.Sink: break; default: throw new System.ComponentModel.InvalidEnumArgumentException("mode", (int)mode, typeof(InputMode)); } }
// Update is called once per frame void Update() { // None -> Hold // Hold -> Tap, or Drag // Tap, Drag -> None // Get data we will need // We only care about clicks if they are not over a UI element leftButtonDown = Input.GetMouseButton(0) && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject(); Vector2 currentPosition = Input.mousePosition; switch (currentInputMode) { case InputMode.None: // If we are in the default mode, we can only enter Hold mode if (leftButtonDown) { currentInputMode = InputMode.Hold; lastPosition = currentPosition; } break; case InputMode.Hold: // If we are holding, we have to check position (transforming to Drag) // and releaseing the click (transforming to Tap) if (GetFastDistance(currentPosition, lastPosition) < 10 && framesSinceLastClick < 5) { // Tap if (!leftButtonDown) { currentInputMode = InputMode.Tap; eventPosition = currentPosition; } } else { // Drag currentInputMode = InputMode.Drag; eventPosition = currentPosition; } break; case InputMode.Tap: currentInputMode = InputMode.None; break; case InputMode.Drag: if (leftButtonDown) { framesSinceLastClick++; lastPosition = eventPosition; eventPosition = currentPosition; } else { framesSinceLastClick = 0; currentInputMode = InputMode.None; } break; } }
private void OnInputModeRelatedEvent(IVimBuffer vimBuffer) { var oldInputMode = _inputMode; var newInputMode = GetInputMode(vimBuffer); _inputMode = newInputMode; if (oldInputMode != newInputMode) { AdjustImeState(oldInputMode, newInputMode); } }
internal ImeCoordinator(IVim vim) { _vim = vim; _globalSettings = _vim.GlobalSettings; _inputModeState = new InputModeState(_vim.GlobalSettings); _inputMode = InputMode.None; _vim.GlobalSettings.SettingChanged += OnSettingChanged; AdjustImeState(_inputMode, _inputMode); }
// Token: 0x06000E4F RID: 3663 RVA: 0x003E95F4 File Offset: 0x003E77F4 private void CopyKeysFrom(PlayerInputProfile profile, InputMode mode, string[] keysToCopy) { for (int i = 0; i < keysToCopy.Length; i++) { List<string> collection; if (profile.InputModes[mode].KeyStatus.TryGetValue(keysToCopy[i], out collection)) { this.InputModes[mode].KeyStatus[keysToCopy[i]].Clear(); this.InputModes[mode].KeyStatus[keysToCopy[i]].AddRange(collection); } } }
public FtExtension(int extensionId) { ExtensionId = extensionId; InputValues = new short[TxtInterface.UniversalInputs]; InputModes = new InputMode[TxtInterface.UniversalInputs]; InputIsDigital = new bool[TxtInterface.UniversalInputs]; OutputValues = new int[TxtInterface.PwmOutputs]; OutputModes = new bool[TxtInterface.MotorOutputs]; MotorDirections = new MotorDirection[TxtInterface.MotorOutputs]; }
private void CopyKeysFrom(PlayerInputProfile profile, InputMode mode, string[] keysToCopy) { for (int index = 0; index < keysToCopy.Length; ++index) { List <string> stringList; if (profile.InputModes[mode].KeyStatus.TryGetValue(keysToCopy[index], out stringList)) { this.InputModes[mode].KeyStatus[keysToCopy[index]].Clear(); this.InputModes[mode].KeyStatus[keysToCopy[index]].AddRange((IEnumerable <string>)stringList); } } }
internal override void SendString(string text, byte messageEnumerator, bool isIdMessage = false, bool suppressEthernetHeader = false) { _messageEnumerator = messageEnumerator; _suppressEthernetHeader = suppressEthernetHeader; if (objectDisposed) { throw new ObjectDisposedException(""); } receivedBuffer = new byte[0]; inputMode = InputMode.ASCII; lock (lockObj) { messageReceived = false; } if (!Connected) { return; } byte[] messageBuffer = strToByteArray(text.Replace(" ", "")); byte[] ethernetCommand; if (_suppressEthernetHeader) { ethernetCommand = messageBuffer; } else { ethernetCommand = getTcpCommand(messageBuffer, isIdMessage); } ethernetHeader = ethernetCommand.Take(4).ToArray(); try { worker.Send(ethernetCommand); } catch { throw; } finally { transactionIdentifier++; if (transactionIdentifier == 0x2f2f) { transactionIdentifier++; } transactionIdentifier = transactionIdentifier % 0xFFFF; } }
private void Reset() { AllowMultipleClicks = ALLOW_MULTIPLE_CLICKS_DEFAULT_VALUE; DeselectButtonAfterClick = DESELECT_BUTTON_AFTER_CLICK_DEFAULT_VALUE; DisableButtonBetweenClicksInterval = BETWEEN_CLICKS_DISABLE_INTERVAL_DEFAULT_VALUE; EnableAlternateInputs = InputData.DEFAULT_ENABLE_ALTERNATE_INPUTS; InputMode = InputData.DEFAULT_INPUT_MODE; KeyCode = InputData.DEFAULT_ON_CLICK_KEY_CODE; KeyCodeAlt = InputData.DEFAULT_ON_CLICK_KEY_CODE_ALT; VirtualButtonName = InputData.DEFAULT_ON_CLICK_VIRTUAL_BUTTON_NAME; VirtualButtonNameAlt = InputData.DEFAULT_ON_CLICK_VIRTUAL_BUTTON_NAME_ALT; }
void Start() { UpdateAreaLimits(); if (GameOptions.inputModeSelected == GameOptions.InputMode.OnlyGesture) { inputMode = InputMode.OnlyGesture; } else { inputMode = InputMode.OnlyKeyboard; } }
private InputIconSO GetIconSet(InputMode mode) { for (int i = 0; i < ModeIcons.Length; i++) { InputIconSO so = ModeIcons[i]; if (so.inputMode == mode) { return(so); } } return(null); }
private void Update() { if (_prevMode != _mode) { _prevMode = _mode; _material.SetTexture("_MainTex", GetTexture()); } var accel = SenselMaster.Acceleration; _accel = new Vector3((int)accel.x, (int)accel.y, (int)accel.z).normalized; }
protected InputReport(PresentationSource inputSource, InputType type, InputMode mode, int timestamp) { if (inputSource == null) throw new ArgumentNullException("inputSource"); Validate_InputType( type ); Validate_InputMode( mode ); _inputSource= new SecurityCriticalData<PresentationSource>(inputSource); _type = type; _mode = mode; _timestamp = timestamp; }
public Solution(string input, InputMode mode) { if (mode == InputMode.File) { ParseInput(input); } else { Input = input; ParseInput(); } }
public void ConfigureInputMode(int inputIndex, InputMode inputMode, bool digital, int extension = 0) { if (extension > 0) { throw new NotImplementedException("More than one extension is not implemented right now"); } ThrowWhenNotConnected(); _masterInterface.SetInputMode(inputIndex, inputMode, digital); _configurationChanged = true; }
private void TickTargetPosition(Dungeon.Dungeon dungeon) { if (_itemPendingUseFromTargetPosition == null) { _mode = InputMode.Character; //_targetGameObject?.SetActive(false); if (_targetGameObject != null) { GameObject.Destroy(_targetGameObject); } return; } if (Input.GetKeyDown(KeyCode.Escape)) { _mode = InputMode.Character; _itemPendingUseFromTargetPosition = null; //_targetGameObject?.SetActive(false); if (_targetGameObject != null) { GameObject.Destroy(_targetGameObject); } return; } if (Input.GetKeyDown(KeyCode.E)) { _mode = InputMode.Character; if (Character.TryCastSpell(_itemPendingUseFromTargetPosition, _targetPosition)) { SpendTurn(dungeon); } _itemPendingUseFromTargetPosition = null; //_targetGameObject?.SetActive(false); if (_targetGameObject != null) { GameObject.Destroy(_targetGameObject); } return; } MoveResult result = MoveResult.None; MoveDirection dir = CheckMoveInput(); var move = DirectionToVec(dir); _targetPosition += move; if (_targetGameObject != null) { _targetGameObject.transform.position = new Vector3(_targetPosition.x, _targetPosition.y, 0); } }
void Update() { if (Input.GetKeyUp(KeyCode.Tab)) { Mode = (Mode == InputMode.UIMode) ? InputMode.GameMode : InputMode.UIMode; UIManager.instance.UpdateInputMode(Mode); } if (Input.GetKeyUp(KeyCode.Space)) { UIManager.instance.ShowHideUI(); } switch (Mode) { case InputMode.GameMode: { float forwardValue = 0f; float rightValue = 0f; float yaw = CameraSpeed * Input.GetAxis("Mouse X"); float pitch = CameraSpeed * Input.GetAxis("Mouse Y"); if (Input.GetKey(KeyCode.W)) { forwardValue += CameraSpeed; } else if (Input.GetKey(KeyCode.S)) { forwardValue -= CameraSpeed; } if (Input.GetKey(KeyCode.D)) { rightValue += CameraSpeed; } else if (Input.GetKey(KeyCode.A)) { rightValue -= CameraSpeed; } Camera.MoveCam(forwardValue, rightValue); Camera.RotateCam(yaw, pitch); } break; case InputMode.UIMode: { } break; } }
public void SwapP2Input() { switch (P2Mode) { case InputMode.Keyboard: P2Mode = InputMode.Gamepad; break; case InputMode.Gamepad: P2Mode = InputMode.Disconnected; break; case InputMode.Disconnected: P2Mode = InputMode.Keyboard; break; } PlayerSettings.Setup(PlayerID.Player2, P2Mode); }
void HandleDefaultInput() { if (Input.GetButtonDown("Y")) { m_Machine.ChangeState(PlayerStateId.Jetpack); } else if (Input.GetButtonDown("X")) { MessageManager.Instance.Send(MessageId.MSG__UI__SHOW_BUILDING_PANEL); MessageManager.Instance.Send(MessageId.MSG__UI__SHOW_BUILDING_SELECTION_CONTROL); m_InputMode = InputMode.BuildingSelection; } }
public static IEnumerable <string> GetInputLines(InputMode mode, string input, char[] splitOn = null) { if (splitOn == null) { splitOn = new char[] { '\r', '\n' } } ; var rawInput = GetInput(mode, input); return(rawInput.Split(splitOn, StringSplitOptions.RemoveEmptyEntries)); } }
/// <summary> /// 入力モードを設定します。 /// </summary> /// <param name="mode">設定する入力モード。</param> public static void SetInputMode(InputMode mode) { var current = GetInputMode(); if (current == mode) { return; } // 現時点では、単に「半角/全角|漢字」キーを押すだけにする。 // 入力モードが「半角英数」(_A) になる場合については、現時点では処理しないことにする。 InputKey(VirtualKeyCode.Kanji); }
private void HandleMouseDown(CanvasData canvasData, Point clickCoordinates) { InputMode inputMode = InputMode.SingleLeftClick; if ((ModifierKeys == Keys.Control)) { inputMode = InputMode.CtrlPressed; } canvasData = GetBehaviorAndCanvasData(canvasData, clickCoordinates, inputMode); CommandsList.GetCommand(canvasData).Change(canvasData); this.canvasData = canvasData; }
internal void BeginMoveMode(Window win) { try { CanFocus = true; _inputMode = InputMode.Moving; win.SetFocus(this); } finally { CanFocus = false; } }
internal static void SetInputMode(Control ctrl, InputMode mode) { try { if (Environment.OSVersion.Platform == PlatformID.WinCE) { SendMessageW(ctrl.Handle, 0xde, 0, (uint)mode); } } catch { } }
public void CopyMapSettingsFrom(PlayerInputProfile profile, InputMode mode) { string[] keysToCopy = new string[6] { "MapZoomIn", "MapZoomOut", "MapAlphaUp", "MapAlphaDown", "MapFull", "MapStyle" }; this.CopyKeysFrom(profile, mode, keysToCopy); }
/// <summary> /// Handles the input mode changed event. It sets the proper tooltip active or inactive, alternating the tooltips. /// </summary> /// <param name="newInputMode"></param> private void OnInputModeChange(InputMode newInputMode) { if (newInputMode == InputMode.MANIPULATION) { teleportTooltip.SetActive(false); manipulationTooltip.SetActive(true); } else if (newInputMode == InputMode.TELEPORT) { teleportTooltip.SetActive(true); manipulationTooltip.SetActive(false); } }
private bool AddEntityModeProcessKey(KeyEvent keyEvent) { switch (keyEvent.Key) { case Key.CursorUp: if (Focus.Y > 0) { MoveFocus(0, -1); } SetNeedsDisplay(); return(true); case Key.CursorDown: if (Focus.Y + _entityToAddMaxY < (Frame.Bottom - 1)) { MoveFocus(0, 1); } SetNeedsDisplay(); return(true); case Key.CursorLeft: if (Focus.X > 0) { MoveFocus(-1, 0); } SetNeedsDisplay(); return(true); case Key.CursorRight: if (Focus.X + _entityToAddMaxX < (Frame.Right - 1)) { MoveFocus(1, 0); } SetNeedsDisplay(); return(true); case Key.Space: foreach (var pt in _entityToAdd) { _game.Add(pt.X + Focus.X - _offset.X, pt.Y + Focus.Y - _offset.Y); } _inputMode = InputMode.None; FocusNext(); SetNeedsDisplay(); return(true); default: return(false); } }
protected InputReport(PresentationSource inputSource, InputType type, InputMode mode, int timestamp) { if (inputSource == null) { throw new ArgumentNullException("inputSource"); } Validate_InputType(type); Validate_InputMode(mode); _inputSource = new SecurityCriticalData <PresentationSource>(inputSource); _type = type; _mode = mode; _timestamp = timestamp; }
public void CopyGamepadAdvancedSettingsFrom(PlayerInputProfile profile, InputMode mode) { this.TriggersDeadzone = profile.TriggersDeadzone; this.InterfaceDeadzoneX = profile.InterfaceDeadzoneX; this.LeftThumbstickDeadzoneX = profile.LeftThumbstickDeadzoneX; this.LeftThumbstickDeadzoneY = profile.LeftThumbstickDeadzoneY; this.RightThumbstickDeadzoneX = profile.RightThumbstickDeadzoneX; this.RightThumbstickDeadzoneY = profile.RightThumbstickDeadzoneY; this.LeftThumbstickInvertX = profile.LeftThumbstickInvertX; this.LeftThumbstickInvertY = profile.LeftThumbstickInvertY; this.RightThumbstickInvertX = profile.RightThumbstickInvertX; this.RightThumbstickInvertY = profile.RightThumbstickInvertY; this.InventoryMoveCD = profile.InventoryMoveCD; }
/// <summary> /// Constructs ad instance of the RawKeyboardInputReport class. /// </summary> /// <param name="inputSource"> /// The input source that provided this input. /// </param> /// <param name="mode"> /// The mode in which the input is being provided. /// </param> /// <param name="timestamp"> /// The time when the input occured. /// </param> /// <param name="isDeadCharacter"> /// True if the char code is a dead char. /// </param> /// <param name="isSystemCharacter"> /// True if the char code is a system char. /// </param> /// <param name="isControlCharacter"> /// True if the char code is a control char. /// </param> /// <param name="characterCode"> /// The character code. /// </param> public RawTextInputReport( PresentationSource inputSource, InputMode mode, int timestamp, bool isDeadCharacter, bool isSystemCharacter, bool isControlCharacter, char characterCode) : base(inputSource, InputType.Text, mode, timestamp) { _isDeadCharacter = isDeadCharacter; _isSystemCharacter = isSystemCharacter; _isControlCharacter = isControlCharacter; _characterCode = characterCode; }
public RawUIStateInputReport( PresentationSource inputSource, InputMode mode, int timestamp, RawUIStateActions action, RawUIStateTargets targets) : base(inputSource, InputType.Keyboard, mode, timestamp) { if (!IsValidRawUIStateAction(action)) throw new System.ComponentModel.InvalidEnumArgumentException("action", (int)action, typeof(RawUIStateActions)); if (!IsValidRawUIStateTargets(targets)) throw new System.ComponentModel.InvalidEnumArgumentException("targets", (int)targets, typeof(RawUIStateTargets)); _action = action; _targets = targets; }
public RawMouseInputReport( InputMode mode, int timestamp, PresentationSource inputSource, RawMouseActions actions, int x, int y, int wheel, IntPtr extraInformation) : base(inputSource, InputType.Mouse, mode, timestamp) { if (!IsValidRawMouseActions(actions)) throw new System.ComponentModel.InvalidEnumArgumentException("actions", (int)actions, typeof(RawMouseActions)); /* we pass a null state from MouseDevice.PreProcessorInput, so null is valid value for state */ _actions = actions; _x = x; _y = y; _wheel = wheel; _extraInformation = new SecurityCriticalData<IntPtr>(extraInformation); }
public RawKeyboardInputReport( PresentationSource inputSource, InputMode mode, int timestamp, RawKeyboardActions actions, int scanCode, bool isExtendedKey, bool isSystemKey, int virtualKey, IntPtr extraInformation) : base(inputSource, InputType.Keyboard, mode, timestamp) { if (!IsValidRawKeyboardActions(actions)) throw new System.ComponentModel.InvalidEnumArgumentException("actions", (int)actions, typeof(RawKeyboardActions)); _actions = actions; _scanCode = scanCode; _isExtendedKey = isExtendedKey; _isSystemKey = isSystemKey; _virtualKey = virtualKey; _extraInformation = new SecurityCriticalData<IntPtr>(extraInformation); }
/// <summary> /// Refresh the text displayed in the text box. /// </summary> /// <returns> /// Status of update. /// </returns> private bool ValidateAndUpdateValue() { NhsTime result; bool status = true; bool containedPM = this.ISPMContained(); this.SetValid(); this.recentSelectionStart = this.txtInput.SelectionStart; this.recentSelectionLength = this.txtInput.SelectionLength; // for null index nothing to be done as index is updated while setting. if (this.EditingTimeType != TimeType.NullIndex) { if (NhsTime.IsAddValid(this.txtInput.Text)) { this.Value.Add(this.txtInput.Text); this.RefreshDisplayText(); this.ResetFields(); return status; } else if (NhsTime.TryParseExact(this.txtInput.Text, out result, CultureInfo.CurrentCulture)) { // Handles an exception case, TryParse always returns the text in am no matter // input contains am or pm. if (containedPM && result.TimeValue.Hour < 12) { result.TimeValue = result.TimeValue.AddHours(12); } this.Value = result; this.invalidFormat = false; } else { this.SetInvalid(ref status); } } this.allowTimeTypeChange = true; this.currentValue = this.Value; this.EditingTimeType = this.TimeType; this.currentMode = InputMode.Simple; this.txtInput.SelectionStart = this.txtInput.TextLength; this.txtInput.SelectionLength = 0; return status; }
static void Test2(InputMode pIM) { string filePath = null; System.IO.StreamReader sR = null; Console.WriteLine(); if (pIM == InputMode.CLI) { Console.WriteLine("Please enter your query in the form of:"); Console.WriteLine("\t>: number n of cities in the graph (beginning at 0)"); Console.WriteLine("\t>: number m of unidirectinal prexisting roads"); Console.WriteLine("\t>: NEXT M LINES: <city1>:<city2>:<road length>"); Console.WriteLine("\t>: number k of optional unidirectional roads"); Console.WriteLine("\t>: NEXT K LINES: <city1>:<city2>:<road length>"); Console.WriteLine("\t>: s (source city)"); Console.WriteLine("\t>: t (target city)"); } else { Console.WriteLine("Please enter the path of the file to pull input from."); filePath = Console.ReadLine(); while (!File.Exists(filePath)) { Console.WriteLine("That file appears to not exist. Try again."); filePath = Console.ReadLine(); } while (IsFileinUse(filePath)) { Console.WriteLine("File is currently in use. Please close it and press enter."); Console.ReadLine(); } sR = new System.IO.StreamReader(filePath); } AdjacencyGraph<string, Edge<string>> graph = new AdjacencyGraph<string, Edge<string>>(true); // Transpose graph AdjacencyGraph<string, Edge<string>> tGraph = new AdjacencyGraph<string, Edge<string>>(true); Dictionary<Edge<string>, double> edgeCost = new Dictionary<Edge<string>, double>(); Dictionary<Edge<string>, double> tEdgeCost = new Dictionary<Edge<string>, double>(); int n = Convert.ToInt32((pIM == InputMode.CLI) ? Console.ReadLine() : sR.ReadLine()); for (int i = 0; i < n; i++) { AddNodeToBoth(graph, tGraph, ""+i); } int m = Convert.ToInt32((pIM == InputMode.CLI) ? Console.ReadLine() : sR.ReadLine()); char[] splitChars = {':'}; string[] theParts; for (int i = 0; i < m; i++) { theParts = ((pIM == InputMode.CLI) ? Console.ReadLine() : sR.ReadLine()).Replace(" ", "").Replace("\t", "").Split(splitChars); AddEdgeToBoth(graph, tGraph, edgeCost, tEdgeCost, theParts[0], theParts[1], Convert.ToInt32(theParts[2])); } int k = Convert.ToInt32(((pIM == InputMode.CLI) ? Console.ReadLine() : sR.ReadLine())); Stack<string[]> optionalEdgeStack = new Stack<string[]>(); for (int i = 0; i < k; i++) { optionalEdgeStack.Push(((pIM == InputMode.CLI) ? Console.ReadLine() : sR.ReadLine()).Replace(" ", "").Replace("\t", "").Split(splitChars)); } string source = ((pIM == InputMode.CLI) ? Console.ReadLine() : sR.ReadLine()); string target = ((pIM == InputMode.CLI) ? Console.ReadLine() : sR.ReadLine()); System.Func<Edge<String>, double> EdgeCostFunct = (QuickGraph.Edge<string> input) => { return (edgeCost.ContainsKey(input)) ? edgeCost[input] : 1000.0; }; System.Func<Edge<String>, double> EdgeCostFunct2 = (QuickGraph.Edge<string> input) => { return (tEdgeCost.ContainsKey(input)) ? tEdgeCost[input] : 1000.0; }; //FORWARD SEARCH // We want to use Dijkstra on this graph DijkstraShortestPathAlgorithm<string, Edge<string>> dijkstra = new DijkstraShortestPathAlgorithm<string, Edge<string>>(graph, EdgeCostFunct); // attach a distance observer to give us the shortest path distances VertexDistanceRecorderObserver<string, Edge<string>> distObserver = new VertexDistanceRecorderObserver<string, Edge<string>>(EdgeCostFunct); distObserver.Attach(dijkstra); // Attach a Vertex Predecessor Recorder Observer to give us the paths VertexPredecessorRecorderObserver<string, Edge<string>> predecessorObserver = new VertexPredecessorRecorderObserver<string, Edge<string>>(); predecessorObserver.Attach(dijkstra); //BACKWARD SEARCH // We want to use Dijkstra on this graph DijkstraShortestPathAlgorithm<string, Edge<string>> dijkstra2 = new DijkstraShortestPathAlgorithm<string, Edge<string>>(tGraph, EdgeCostFunct2); // attach a distance observer to give us the shortest path distances VertexDistanceRecorderObserver<string, Edge<string>> distObserver2 = new VertexDistanceRecorderObserver<string, Edge<string>>(EdgeCostFunct2); distObserver2.Attach(dijkstra2); // Attach a Vertex Predecessor Recorder Observer to give us the paths VertexPredecessorRecorderObserver<string, Edge<string>> predecessorObserver2 = new VertexPredecessorRecorderObserver<string, Edge<string>>(); predecessorObserver2.Attach(dijkstra2); // Run the algorithm with starname set to be the source dijkstra.Compute(source); if (distObserver.Distances.ContainsKey(target) == false) { Console.WriteLine(target + " is unreachable"); } else { dijkstra2.Compute(target); double initialPathLength = distObserver.Distances[target]; Stack<string> viablePathAdditions = new Stack<string>(); string currentMinEdgeAddition = ""; double currentMinEdgeWeight = -1.0; while (optionalEdgeStack.Count > 0) { string[] triple = optionalEdgeStack.Pop(); if (distObserver.Distances.ContainsKey(triple[0]) && distObserver2.Distances.ContainsKey(triple[1])) { double total = distObserver.Distances[triple[0]] + distObserver2.Distances[triple[1]] + (double)Int32.Parse(triple[2]); if (total < initialPathLength) { viablePathAdditions.Push(triple[0] + ':' + triple[1]); if (currentMinEdgeWeight < 0 || total < currentMinEdgeWeight) { currentMinEdgeWeight = total; currentMinEdgeAddition = triple[0] + ':' + triple[1]; } } } } if (viablePathAdditions.Count > 0) { Console.WriteLine("Additions that would lower path length."); while (viablePathAdditions.Count > 0) { Console.WriteLine(viablePathAdditions.Pop()); } Console.WriteLine("The cost-minimizing addition is:"); Console.WriteLine(currentMinEdgeAddition); } else { Console.WriteLine("There are no additions that would minimize path length."); } } Console.WriteLine(""); Console.WriteLine("Press enter to return to the main menu."); Console.ReadLine(); if (sR != null) sR.Close(); }
protected override void PrepareInputProcessors(InputManager input) { PlayerIndex inputIndex = GameResources.PlaySession.LocalPlayers[PlayerId]; InputMode newMode = mInputMode; // TODO: P3: This needs a real state system to manage transitions: // Compute next mode: if (mInputMode == InputMode.Aiming && !(input.CheckForBinaryInput(mPlayerInputMap, BinaryControlActions.Aim, inputIndex))) { newMode = InputMode.Aloof; } else if (mInputMode == InputMode.Aloof && input.CheckForBinaryInput(mPlayerInputMap, BinaryControlActions.Aim, inputIndex)) { newMode = InputMode.Aiming; } // Take some special actions if there is a mode change: if (newMode != mInputMode) { // Exiting mode tasks: switch (mInputMode) { case InputMode.Aiming: Actor avatar = GameResources.ActorManager.GetActorById(ActorId); BipedControllerComponent bipedControl = avatar.GetComponent<BipedControllerComponent>( ActorComponent.ComponentType.Control); bipedControl.Controller.ViewDirection = bipedControl.Controller.HorizontalViewDirection; mMmoCameraDesc.Pitch = -MathHelper.Pi / 12.0f; mMmoCameraDesc.Yaw = (float)(Math.Atan2(-bipedControl.Controller.HorizontalViewDirection.X, -bipedControl.Controller.HorizontalViewDirection.Z)); DrawSegment.MainWindow.UIElements.Remove(UIElementDepth.CROSSHAIRS); break; default: break; } // Entering mode tasks: switch (newMode) { case InputMode.Aiming: DrawSegment.MainWindow.UIElements.Add(UIElementDepth.CROSSHAIRS, mCrosshairs); break; default: break; } } mInputMode = newMode; // Handle some misc input functions: // Inventory window: if (input.CheckForNewBinaryInput(mPlayerInputMap, BinaryControlActions.OpenInventory, inputIndex)) { DrawSegment.AddWindow(mInventoryPanel, inputIndex); mInventoryPanel.RefreshItems(); } // TODO: P2: Remove nonessential/debug functionality: PlayerIndex dummyPlayerIndex; if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.V, inputIndex, out dummyPlayerIndex)) { mShadowViewMode = !mShadowViewMode; DrawSegment.MainWindow.UIElements.Clear(); if (mShadowViewMode) { DrawSegment.MainWindow.UIElements.Add(UIElementDepth.DEBUG_SHADOW_MAP, new ShadowMapVisual()); } else { DrawSegment.MainWindow.UIElements.Add(UIElementDepth.STANDARD_3D_PERSP, new Standard3dPerspective()); } } if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.P, inputIndex, out dummyPlayerIndex)) { Debugger.Break(); } if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.U, inputIndex, out dummyPlayerIndex)) { mBright += 0.01f; } if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.J, inputIndex, out dummyPlayerIndex)) { mBright -= 0.01f; } if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.I, inputIndex, out dummyPlayerIndex)) { mContrast += 0.1f; } if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.K, inputIndex, out dummyPlayerIndex)) { mContrast -= 0.1f; } //mBrightParam.SetValue(mBright); //mContrastParam.SetValue(mContrast); }
internal RawStylusSystemGestureInputReport( InputMode mode, int timestamp, PresentationSource inputSource, PenContext penContext, int tabletId, int stylusDeviceId, SystemGesture systemGesture, int gestureX, int gestureY, int buttonState) : base( mode, timestamp, inputSource, penContext, RawStylusActions.SystemGesture, tabletId, stylusDeviceId, new int[] {}) { if (!RawStylusSystemGestureInputReport.IsValidSystemGesture(systemGesture, true, true)) { throw new InvalidEnumArgumentException(SR.Get( SRID.Enum_Invalid, "systemGesture")); } _id = systemGesture; _gestureX = gestureX; _gestureY = gestureY; _buttonState = buttonState; }
public QuestionMutliOrSingelInputViewModel(object question, InputMode inputMode) : base(question, inputMode) { }
public QuestionMultiInputViewModel(object question, InputMode inputMode) : base(question, inputMode) { AddInputCommand = new DelegateCommand(AddInput, CanAddInput); RemoveSelectedInputCommand = new DelegateCommand(RemoveSelectedInput, CanRemoveSelectedInput); }
/// <summary> /// Handles the text changed event of the child textbox /// </summary> /// <param name="sender">Object calling the event</param> /// <param name="e">Event arguments</param> private void TextBox1_TextChanged(object sender, EventArgs e) { if (this.selectedPaste) { this.selectedPaste = false; return; } if (this.inlineEditing) { return; } if (this.txtInput.TextLength == 0) { this.currentMode = InputMode.Simple; this.invalidFormat = false; this.editingTimeType = TimeType.Null; } if (this.acceptedKey) { this.acceptedKey = false; return; } if (!this.IsCorrectFormat()) { this.invalidFormat = true; } else { this.invalidFormat = false; if (this.editingTimeType == TimeType.Exact || this.editingTimeType == TimeType.Approximate) { this.HandleAmPmDisplay(); } } }
/// <summary> /// Resets the control's state fields to their default value. /// </summary> private void ResetFields() { this.currentField = Field.Hours; this.currentMode = InputMode.Simple; this.allowTimeTypeChange = true; this.currentValue = this.Value; this.EditingTimeType = this.TimeType; this.invalidFormat = false; this.LoadResources(); this.SelectCurrentField(); }
/// <summary> /// Identifies if the key pressed in the txtInput is valid for arithmetic mode. /// </summary> /// <param name="e">Keypress event argument</param> /// <returns>True if the Key Pressed belongs to arithmetic mode, else false</returns> private bool IsArithmeticMode(KeyPressEventArgs e) { if (this.editingTimeType == TimeType.NullIndex || this.invalidFormat || this.Functionality == TimeFunctionality.Simple) { return false; } String currentInputTillSelection = this.txtInput.Text.Substring(0, this.txtInput.SelectionStart) + e.KeyChar.ToString(CultureInfo.CurrentCulture); bool startsWithSpecialChar = false; int maxLength = 3; this.acceptedKey = false; if (this.currentMode == InputMode.Arithmetic) { if (e.KeyChar == '+' || e.KeyChar == '-') { e.Handled = true; return true; } if (this.txtInput.Text.StartsWith("+", StringComparison.CurrentCultureIgnoreCase) || this.txtInput.Text.StartsWith("-", StringComparison.CurrentCultureIgnoreCase)) { startsWithSpecialChar = true; maxLength = 4; } this.HandleKeyInputInArithmeticMode(startsWithSpecialChar, maxLength, e); e.Handled = !this.acceptedKey; return true; } else { if (NhsTime.IsAddValid(currentInputTillSelection) || (e.KeyChar == '+' || e.KeyChar == '-')) { this.currentMode = InputMode.Arithmetic; this.txtInput.Text = (e.KeyChar == '+' || e.KeyChar == '-') ? e.KeyChar.ToString() : currentInputTillSelection; this.txtInput.SelectionStart = this.txtInput.TextLength; e.Handled = true; return true; } return false; } }
/// <summary> /// Validates the format of string in txtInput. /// </summary> /// <remarks> /// Cut/Paste can change the pattern of input string, however, TimeType remains same. This /// function is called to validate the string format in txtInput for specified TimeType. /// </remarks> /// <returns>True if pattern is correct, else false.</returns> private bool IsCorrectFormat() { this.txtInput.Text = this.txtInput.Text.Trim(); // Simple functionality if (this.Functionality == TimeFunctionality.Simple) { return this.IsCorrectFormatForExactTime(); } // Complex functionality else { int index; index = this.GetNullIndexExact(this.txtInput.Text); if (index >= 0) { this.NullIndex = index; this.EditingTimeType = TimeType.NullIndex; this.allowTimeTypeChange = false; this.TimeType = TimeType.NullIndex; this.currentMode = InputMode.Simple; return true; } if (this.IsArithmeticModeFormat()) { this.currentMode = InputMode.Arithmetic; return true; } if (this.IsCorrectFormatForExactTime()) { this.EditingTimeType = this.chkApprox.Checked ? TimeType.Approximate : TimeType.Exact; return true; } return false; } }