SlidContentPop.xaml.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 PDF_Office.CustomControl.CompositeControl
  16. {
  17. /// <summary>
  18. /// ThicknessContentPop.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class SlidContentPop : UserControl
  21. {
  22. public event EventHandler<double> OpacityValueChangedHandler;
  23. public bool isOpenLayout { get; private set; }
  24. public SlidContentPop()
  25. {
  26. InitializeComponent();
  27. }
  28. public void SetOpacity(double opacity)
  29. {
  30. bool changeFromDropBox = false;
  31. if(opacity == 0.25)
  32. {
  33. if (OpacityDropBox.SelectedIndex != 0)
  34. changeFromDropBox = true;
  35. OpacityDropBox.SelectedIndex = 0;
  36. }
  37. else if(opacity == 0.50)
  38. {
  39. if (OpacityDropBox.SelectedIndex != 1)
  40. changeFromDropBox = true;
  41. OpacityDropBox.SelectedIndex = 1;
  42. }
  43. else if(opacity == 0.75)
  44. {
  45. if (OpacityDropBox.SelectedIndex != 2)
  46. changeFromDropBox = true;
  47. OpacityDropBox.SelectedIndex = 2;
  48. }
  49. else if(opacity ==1)
  50. {
  51. if (OpacityDropBox.SelectedIndex != 3)
  52. changeFromDropBox = true;
  53. OpacityDropBox.SelectedIndex = 3;
  54. }
  55. if (changeFromDropBox == false)
  56. OpacitySlider.Value = opacity;
  57. }
  58. private void OpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
  59. {
  60. OpacityValueChangedHandler?.Invoke(this, e.NewValue);
  61. }
  62. private void OpacityDropBox_DropDownClosed(object sender, EventArgs e)
  63. {
  64. isOpenLayout = false;
  65. }
  66. private void OpacityDropBox_DropDownOpened(object sender, EventArgs e)
  67. {
  68. isOpenLayout = true;
  69. }
  70. private void OpacityDropBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  71. {
  72. switch(OpacityDropBox.SelectedIndex)
  73. {
  74. case 0:
  75. OpacitySlider.Value = 0.25;
  76. break;
  77. case 1:
  78. OpacitySlider.Value = 0.50;
  79. break;
  80. case 2:
  81. OpacitySlider.Value = 0.75;
  82. break;
  83. case 3:
  84. OpacitySlider.Value = 1;
  85. break;
  86. }
  87. }
  88. }
  89. }