CBButtonControls.xaml.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. namespace CollaborativePlatformProject.FormLibrary.CheckboxButton
  16. {
  17. /// <summary>
  18. /// CBButtonControls.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class CBButtonControls : UserControl
  21. {
  22. public CBButtonControlsData CbButtonControls;
  23. public CBButtonControls(CBButtonControlsData cbButtonControls)
  24. {
  25. InitializeComponent();
  26. CbButtonControls = cbButtonControls;
  27. tb_name.Text = CbButtonControls.BtnName;
  28. cb_check.IsChecked = CbButtonControls.CbIsCheck;
  29. }
  30. private void UIElement_OnPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  31. {
  32. if ((bool)cb_check.IsChecked)
  33. {
  34. cb_check.IsChecked = false;
  35. }
  36. else
  37. {
  38. cb_check.IsChecked = true;
  39. }
  40. CbButtonControls.CbIsCheck = (bool)cb_check.IsChecked;
  41. }
  42. private void Cb_check_OnClick(object sender, RoutedEventArgs e)
  43. {
  44. if ((bool)cb_check.IsChecked)
  45. {
  46. cb_check.IsChecked = false;
  47. }
  48. else
  49. {
  50. cb_check.IsChecked = true;
  51. }
  52. CbButtonControls.CbIsCheck = (bool)cb_check.IsChecked;
  53. }
  54. }
  55. public class CBButtonControlsData
  56. {
  57. public CBButtonControlsData(string btnName, bool cbIsCheck, string imgPath)
  58. {
  59. BtnName = btnName;
  60. CbIsCheck = cbIsCheck;
  61. ImgPath = imgPath;
  62. Guid = System.Guid.NewGuid().ToString();
  63. }
  64. public string Guid { get; set; }
  65. public string BtnName { get; set; }
  66. public bool CbIsCheck { get; set; } = false;
  67. public string ImgPath { get; set; }
  68. }
  69. }