CBButtonControls.xaml.cs 2.1 KB

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