Guest User

Untitled

a guest
Jan 16th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. public static void TabToNextField(this FrameworkElement i, FrameworkElement nextField)
  2. {
  3. i.KeyPress(Keys.Tab);
  4. var isNextFieldFocused = nextField.GetProperty<bool>("IsFocused");
  5.  
  6. if (!isNextFieldFocused)
  7. {
  8. //Taborder is incorrect. Next field wasn't focused!
  9. //This wont work since 'this' can't be used in a static context.
  10. var currentProcedure = this.GetType().Name;
  11. var fromField = i.AutomationId;
  12. var toField = nextField.AutomationId;
  13. //Log to file..
  14. }
  15. }
  16.  
  17. void Main()
  18. {
  19. "Test".Test();
  20. }
  21.  
  22. static class Extensions
  23. {
  24. public static void Test(this string s)
  25. {
  26. var method = new StackTrace().GetFrame(1).GetMethod();
  27. Console.WriteLine(String.Format("I was called from '{0}' of class '{1}'", method.Name, method.DeclaringType));
  28. }
  29. }
  30.  
  31. public static void TabToNextField(this FrameworkElement i, FrameworkElement nextField, [CallerMemberName] string memberName = "")
  32. {
  33. i.KeyPress(Keys.Tab);
  34. var isNextFieldFocused = nextField.GetProperty<bool>("IsFocused");
  35.  
  36. if (!isNextFieldFocused)
  37. {
  38. //Taborder is incorrect. Next field wasn't active!
  39. var currentProcedure = memberName;
  40. var fromField = i.AutomationId;
  41. var toField = nextField.AutomationId;
  42. }
  43. }
Add Comment
Please, Sign In to add comment