protected override void OnKeyDown(KeyEventArgs e) { if (e.Key == Key.Up && _increaseButton.IsEnabled) { _increaseButtonAutomationPeer ??= new RepeatButtonAutomationPeer(_increaseButton); var invokeProv = _increaseButtonAutomationPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; invokeProv?.Invoke(); return; } if (e.Key == Key.Down && _decreaseButton.IsEnabled) { _decreaseButtonAutomationPeer ??= new RepeatButtonAutomationPeer(_decreaseButton); var invokeProv = _decreaseButtonAutomationPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; invokeProv?.Invoke(); return; } }
public override void GetPattern() { RepeatButtonAutomationPeer rbap = new RepeatButtonAutomationPeer(new RepeatButton()); Assert.AreEqual(AutomationControlType.Button, rbap.GetAutomationControlType(), "GetAutomationControlType"); Assert.AreEqual("RepeatButton", rbap.GetClassName(), "GetClassName"); Assert.IsNull(rbap.GetPattern(PatternInterface.Dock), "Dock"); Assert.IsNull(rbap.GetPattern(PatternInterface.ExpandCollapse), "ExpandCollapse"); Assert.IsNull(rbap.GetPattern(PatternInterface.Grid), "Grid"); Assert.IsNull(rbap.GetPattern(PatternInterface.GridItem), "GridItem"); Assert.IsTrue(Object.ReferenceEquals(rbap, rbap.GetPattern(PatternInterface.Invoke)), "Invoke"); Assert.IsNull(rbap.GetPattern(PatternInterface.MultipleView), "MultipleView"); Assert.IsNull(rbap.GetPattern(PatternInterface.RangeValue), "RangeValue"); Assert.IsNull(rbap.GetPattern(PatternInterface.Scroll), "Scroll"); Assert.IsNull(rbap.GetPattern(PatternInterface.ScrollItem), "ScrollItem"); Assert.IsNull(rbap.GetPattern(PatternInterface.Selection), "Selection"); Assert.IsNull(rbap.GetPattern(PatternInterface.SelectionItem), "SelectionItem"); Assert.IsNull(rbap.GetPattern(PatternInterface.Table), "Table"); Assert.IsNull(rbap.GetPattern(PatternInterface.TableItem), "TableItem"); Assert.IsNull(rbap.GetPattern(PatternInterface.Toggle), "Toggle"); Assert.IsNull(rbap.GetPattern(PatternInterface.Transform), "Transform"); Assert.IsNull(rbap.GetPattern(PatternInterface.Value), "Value"); Assert.IsNull(rbap.GetPattern(PatternInterface.Window), "Window"); Assert.IsNotNull(rbap.GetPattern(PatternInterface.Invoke), "Invoke #1"); }