ValueScaleDisplayCollection.xaml.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. using System.Windows.Input;
  4. namespace MuchInfo.Chart.WPF.Controls.ValueScaling
  5. {
  6. /// <summary>
  7. /// ValueScaleDisplayCollection.xaml 的交互逻辑
  8. /// </summary>
  9. public partial class ValueScaleDisplayCollection : UserControl
  10. {
  11. #region Fields
  12. private bool ValueScaleDisplayCollection_1984;
  13. #endregion Fields
  14. #region Constructors
  15. public ValueScaleDisplayCollection()
  16. {
  17. this.SelectedIndexXml = -1;
  18. this.ValueScaleDisplayCollection_1984 = false;
  19. this.InitializeComponent();
  20. this.borderControls.Visibility = Visibility.Collapsed;
  21. }
  22. #endregion Constructors
  23. #region Properties
  24. #region Public Properties
  25. public int SelectedIndexXml
  26. {
  27. get;
  28. set;
  29. }
  30. #endregion Public Properties
  31. #endregion Properties
  32. #region Methods
  33. #region Public Methods
  34. public object AddScale(FrameworkElement aScale)
  35. {
  36. this.stackMain.Children.Add(aScale);
  37. this.ValueScaleDisplayCollection_5629();
  38. return null;
  39. }
  40. public object DoPending()
  41. {
  42. bool flag = !this.ValueScaleDisplayCollection_1984;
  43. if (flag)
  44. {
  45. this.ValueScaleDisplayCollection_1984 = true;
  46. this.ValueScaleDisplayCollection_5631();
  47. }
  48. object result = null;
  49. return result;
  50. }
  51. public object RemoveScale(FrameworkElement aScale)
  52. {
  53. bool flag = this.stackMain.Children.Contains(aScale);
  54. if (flag)
  55. {
  56. this.stackMain.Children.Remove(aScale);
  57. this.ValueScaleDisplayCollection_5629();
  58. }
  59. object result = null;
  60. return result;
  61. }
  62. #endregion Public Methods
  63. #region Internal Methods
  64. internal FrameworkElement ValueScaleDisplayCollection_5630()
  65. {
  66. bool flag = this.borderControls.Visibility == Visibility.Visible;
  67. FrameworkElement result;
  68. if (flag)
  69. {
  70. result = this.borderRight;
  71. }
  72. else
  73. {
  74. result = null;
  75. }
  76. return result;
  77. }
  78. internal void ValueScaleDisplayCollection_5631()
  79. {
  80. bool flag = this.SelectedIndexXml >= 0 && this.SelectedIndexXml < this.stackMain.Children.Count;
  81. checked
  82. {
  83. if (flag)
  84. {
  85. int num = 0;
  86. try
  87. {
  88. var enumerator = this.stackMain.Children.GetEnumerator();
  89. while (enumerator.MoveNext())
  90. {
  91. var current = enumerator.Current as UIElement;
  92. flag = (num == this.SelectedIndexXml);
  93. if (flag)
  94. {
  95. current.Visibility = Visibility.Visible;// Visibility.Visible;
  96. }
  97. else
  98. {
  99. current.Visibility = Visibility.Collapsed;//Visibility.Collapsed;
  100. }
  101. num++;
  102. }
  103. }
  104. finally
  105. {
  106. //IEnumerator<UIElement> enumerator;
  107. //flag = (enumerator != null);
  108. //if (flag)
  109. //{
  110. // enumerator.Dispose();
  111. //}
  112. }
  113. }
  114. else
  115. {
  116. this.SelectedIndexXml = -1;
  117. try
  118. {
  119. var enumerator2 = this.stackMain.Children.GetEnumerator();
  120. while (enumerator2.MoveNext())
  121. {
  122. var current2 = enumerator2.Current as UIElement;
  123. current2.Visibility = Visibility.Visible;
  124. }
  125. }
  126. finally
  127. {
  128. //IEnumerator<UIElement> enumerator2;
  129. //flag = (enumerator2 != null);
  130. //if (flag)
  131. //{
  132. // enumerator2.Dispose();
  133. //}
  134. }
  135. }
  136. }
  137. }
  138. #endregion Internal Methods
  139. #region Private Methods
  140. private void borderControls_MouseEnter(object sender, MouseEventArgs e)
  141. {
  142. this.borderRight.Opacity = (1.0);
  143. }
  144. private void borderControls_MouseLeave(object sender, MouseEventArgs e)
  145. {
  146. this.borderRight.Opacity = (0.5);
  147. }
  148. private void borderRight_MouseEnter(object sender, MouseEventArgs e)
  149. {
  150. //ChartToolTip.ShowTip(this.borderRight, e, "Toggle Scale Display");
  151. }
  152. private void borderRight_MouseLeave(object sender, MouseEventArgs e)
  153. {
  154. //ChartToolTip.HideTip(this.borderRight);
  155. }
  156. private void borderRight_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  157. {
  158. this.ValueScaleDisplayCollection_5632();
  159. //TutorialActions.RaiseTutorialAction(TutorialActions.eTutorialAction.MultiScaleToggle);
  160. }
  161. /// <summary>
  162. /// 若stackMain中有Element则显示,否则隐藏初始内容
  163. /// </summary>
  164. private void ValueScaleDisplayCollection_5629()
  165. {
  166. bool flag = this.stackMain.Children.Count > 1;
  167. if (flag)
  168. {
  169. this.borderControls.Visibility = Visibility.Visible;//Visibility.Visible;
  170. }
  171. else
  172. {
  173. this.borderControls.Visibility = Visibility.Collapsed;// Visibility.Collapsed;
  174. this.SelectedIndexXml = 0;
  175. }
  176. this.ValueScaleDisplayCollection_5631();
  177. }
  178. private void ValueScaleDisplayCollection_5632()
  179. {
  180. checked
  181. {
  182. this.SelectedIndexXml++;
  183. this.ValueScaleDisplayCollection_5631();
  184. }
  185. }
  186. #endregion Private Methods
  187. #endregion Methods
  188. }
  189. }