DocumentPage.xaml.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using netDxf.Units;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Linq;
  6. using System.Runtime.CompilerServices;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. namespace PRSDesktop.Panels.DataEntry
  19. {
  20. /// <summary>
  21. /// Interaction logic for DocumentPage.xaml
  22. /// </summary>
  23. public partial class DocumentPage : UserControl, INotifyPropertyChanged
  24. {
  25. public DocumentManipulationWindow.Page Page { get; set; }
  26. private static readonly Brush SelectedBorderBrush = new SolidColorBrush(Colors.LightBlue);
  27. private static readonly Brush SelectedBackgroundBrush = new SolidColorBrush(new Color
  28. {
  29. A = 128,
  30. R = Colors.LightBlue.R,
  31. G = Colors.LightBlue.G,
  32. B = Colors.LightBlue.B,
  33. });
  34. private static readonly Brush TransparentBrush = new SolidColorBrush(Colors.Transparent);
  35. public Brush SelectionBorder => Selected ? SelectedBorderBrush : TransparentBrush;
  36. public Brush SelectionBackground => Selected ? SelectedBackgroundBrush : TransparentBrush;
  37. private bool selected;
  38. public bool Selected
  39. {
  40. get => selected;
  41. set
  42. {
  43. selected = value;
  44. OnPropertyChanged(nameof(SelectionBorder));
  45. OnPropertyChanged(nameof(SelectionBackground));
  46. OnSelected?.Invoke(this, Selected);
  47. }
  48. }
  49. public delegate void OnSelectedHandler(DocumentPage page, bool selected);
  50. public event OnSelectedHandler? OnSelected;
  51. public DocumentPage(DocumentManipulationWindow.Page page)
  52. {
  53. Page = page;
  54. InitializeComponent();
  55. }
  56. public event PropertyChangedEventHandler? PropertyChanged;
  57. public void OnPropertyChanged([CallerMemberName] string name = "")
  58. {
  59. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
  60. }
  61. private void Border_MouseDown(object sender, MouseButtonEventArgs e)
  62. {
  63. Selected = !Selected;
  64. }
  65. }
  66. }