private void MethodClick(object sender, EventArgs e) { // MethodClick is what executes when the user clicks on addition, substraction, multiplication, or division Button button = (Button)sender; if (endValue != 0) { EnterKey.PerformClick(); methodExecuted = button.Text; endValue = Double.Parse(TxtResult.Text); ismethodExecuted = true; LblOperation.Text = endValue + " " + methodExecuted; } else // Statement if the endValue is equal to 0 { methodExecuted = button.Text; endValue = Double.Parse(TxtResult.Text); ismethodExecuted = true; LblOperation.Text = endValue + " " + methodExecuted; } }
private void AddSpecialKey(SpecialKey specialKey) { KeyControl key; switch (specialKey.KeyType) { case SpecialKeyType.Shift: key = new ShiftKey(); break; case SpecialKeyType.Win: key = new WindowsKey(); break; case SpecialKeyType.Tab: key = new TabKey(); break; case SpecialKeyType.Captial: key = new CapsKey(); break; case SpecialKeyType.Return: key = new EnterKey(); break; case SpecialKeyType.Back: key = new BackKey(); break; default: return; } key.IsPressed = specialKey.IsDown; _currentKeyItem.InlineCollection.Add(key); }
private void UpdateView(List <KeyLogEntry> keyLogEntries) { var newContent = new List <KeyItem>(); if (keyLogEntries == null) { KeyLogContent = new ObservableCollection <KeyItem>(); OnPropertyChanged(nameof(KeyLogContent)); return; } var currentKeyItem = new KeyItem(); var placeholderText = Application.Current.Resources["NoKeyInputs"]; foreach (var keyLogEntry in keyLogEntries) { var normalTextEntry = keyLogEntry as NormalText; if (normalTextEntry != null) { if (!string.IsNullOrEmpty(normalTextEntry.Text)) { currentKeyItem.InlineCollection.Add(normalTextEntry.Text); } continue; } var specialKey = keyLogEntry as SpecialKey; if (specialKey != null) { KeyControl key; switch (specialKey.KeyType) { case SpecialKeyType.Shift: key = new ShiftKey(); break; case SpecialKeyType.Win: key = new WindowsKey(); break; case SpecialKeyType.Tab: key = new TabKey(); break; case SpecialKeyType.Captial: key = new CapsKey(); break; case SpecialKeyType.Return: key = new EnterKey(); break; case SpecialKeyType.Back: key = new BackKey(); break; default: continue; } if (HideReleaseKeyState && !specialKey.IsDown) { continue; } key.IsPressed = specialKey.IsDown; currentKeyItem.InlineCollection.Add(key); continue; } var standardKey = keyLogEntry as StandardKey; if (standardKey != null) { if (HideReleaseKeyState && !standardKey.IsDown) { continue; } string text; switch (standardKey.Key) { case Keys.Alt: text = "Alt"; break; case Keys.RMenu: text = "Alt Gr"; break; case Keys.Delete: text = "Del"; break; case Keys.Control: case Keys.LControlKey: text = "Ctrl"; break; default: text = standardKey.ToString(); break; } currentKeyItem.InlineCollection.Add(new ViewModels.KeyLog.StandardKey(text) { IsPressed = standardKey.IsDown }); continue; } var windowChanged = keyLogEntry as WindowChanged; if (windowChanged != null) { if (currentKeyItem.InlineCollection.Count == 0) { if (HideEmptyWindows) { newContent.Remove(currentKeyItem); } else { currentKeyItem.InlineCollection.Add( new Italic(new Run("(" + placeholderText + ")") { Foreground = (Brush)Application.Current.Resources["BlackBrush"] })); } } currentKeyItem = new KeyItem { ApplicationName = windowChanged.WindowTitle, Timestamp = windowChanged.Timestamp }; newContent.Add(currentKeyItem); } } KeyLogContent = new ObservableCollection <KeyItem>(newContent); OnPropertyChanged(nameof(KeyLogContent)); }
public void Test_EnterKey_Method() { EnterKey ek = new EnterKey(); Assert.IsTrue(ek.IsUnitTest); }