RecordSelectionDialog.xaml.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System.Windows;
  2. using InABox.Core;
  3. using InABox.Wpf;
  4. namespace PRSDesktop
  5. {
  6. /// <summary>
  7. /// Interaction logic for RecordSelectionDialog.xaml
  8. /// </summary>
  9. public partial class RecordSelectionDialog : ThemableWindow
  10. {
  11. public RecordSelectionDialog()
  12. {
  13. Selection = Selection.None;
  14. InitializeComponent();
  15. CenterWindowOnScreen();
  16. }
  17. public Selection Selection { get; set; }
  18. private void CenterWindowOnScreen()
  19. {
  20. var screenleft = Application.Current.MainWindow.Left;
  21. var screentop = Application.Current.MainWindow.Top;
  22. var screenWidth = Application.Current.MainWindow.Width;
  23. var screenHeight = Application.Current.MainWindow.Height;
  24. var windowWidth = Width;
  25. var windowHeight = Height;
  26. Left = screenleft + screenWidth / 2 - windowWidth / 2;
  27. Top = screentop + screenHeight / 2 - windowHeight / 2;
  28. }
  29. public static Selection Execute()
  30. {
  31. var form = new RecordSelectionDialog();
  32. if (form.ShowDialog() == true)
  33. return form.Selection;
  34. return Selection.None;
  35. }
  36. private void All_Click(object sender, RoutedEventArgs e)
  37. {
  38. Selection = Selection.All;
  39. DialogResult = true;
  40. Close();
  41. }
  42. private void Sel_Click(object sender, RoutedEventArgs e)
  43. {
  44. Selection = Selection.Selected;
  45. DialogResult = true;
  46. Close();
  47. }
  48. }
  49. }