You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2 KiB

1 month ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Forms;
  7. namespace ShenTun.Camera.AForgeL
  8. {
  9. public class Photo : AForge.Controls.PictureBox
  10. {
  11. public string PhotoId { get; set; }
  12. private bool _Selected;
  13. public bool Selected
  14. {
  15. get { return _Selected; }
  16. set
  17. {
  18. _Selected = value;
  19. this.BorderStyle = _Selected ? BorderStyle.Fixed3D : BorderStyle.None;
  20. }
  21. }
  22. #region 委托事件
  23. public delegate void SelectedPhoto(string photoId);
  24. public event SelectedPhoto SelecPhotoInfo;
  25. #endregion
  26. public Photo():base()
  27. {
  28. SetStyle(ControlStyles.DoubleBuffer, true);
  29. Selected = false;
  30. if (string.IsNullOrEmpty(PhotoId)) PhotoId = Guid.NewGuid().ToString();
  31. SizeMode = PictureBoxSizeMode.StretchImage;
  32. Click+=Photo_Click;
  33. }
  34. private void Photo_Click(object sender, EventArgs e)
  35. {
  36. Selected = !Selected;
  37. SelecPhotoInfo(this.PhotoId);
  38. this.Refresh();
  39. }
  40. }
  41. }