DocumentPage.xaml.cs 2.3 KB

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