private void MainBorder_PreviewKeyDown(object sender, KeyEventArgs e) { // キー情報取得 if (e.ImeProcessedKey != Key.None) // Ime有効な場合の対処 { this.Key = e.ImeProcessedKey; } else if (e.Key == Key.System) // システムキーが押された場合 { this.Key = e.SystemKey; } else { this.Key = e.Key; } this.Modifiers = Keyboard.Modifiers; this.KeyText.Text = GetKeyString(); e.Handled = true; // キー割り当て完了通知 if (IsValidKey()) { KeyAssigned?.Invoke(this, new EventArgs()); } }
public async Task key_is_assigned_repeatedly() { var config = new SimpleProperties(); var testOptions = TestOptions <SimpleProperties>( async r => { var idxValue = r.Request.Query["index"]; var idx = string.IsNullOrEmpty(idxValue) ? 0 : int.Parse(idxValue); idx++; await Task.Delay(TimeSpan.FromSeconds(1)); await r.Response(200, idx, $"[ {KV("/keystring", $"http{idx}")} ]"); }); Structure updater = null; int assignments = 0; testOptions.Events.KeyValueAssigned = (path, value) => { if (++assignments >= 2) { updater.Stop(); KeyAssigned.SetResult(true); } }; updater = Structure.Start(config, testOptions); var result = await Task.WhenAny(KeyAssigned.Task, Task.Delay(TimeSpan.FromMinutes(1))); assignments.ShouldBe(2); result.ShouldBe(KeyAssigned.Task, "Assignment timed out"); config.KeyString.ShouldBe("http2"); await updater.Stop(); }
public override void Update(GameTime gameTime) { if (!Active) { base.Update(gameTime); } DoubleActivationProtectionTimer++; ActiveTimer++; if (!Active || ActiveTimer < 3) { return; } var i = game1.Input.RecentInput(Filter); if (i.Type != InputTypes.None) { if (i.Key == Keys.Escape) { //Input = Input; } else { //Input = i; game1.Input.SetKeybind(i, Action); KeyAssigned.Invoke(null, new EventArgs()); } SetInactive(); } }