SpecificationValue.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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.Controls;
  7. namespace HistoryDLL
  8. {
  9. /// <summary>
  10. /// 該歷史牆主要用於 n * 1 (n 最大為 3) 的螢幕
  11. /// 解析度為(1920 * 1080), (3840 * 1080), (5760 * 1080)
  12. /// 這部分將以上述解析度加上單位事件的寬度進行計算
  13. /// 得到各個常數項的值
  14. /// </summary>
  15. public partial class CyclicScroller : UserControl
  16. {
  17. private int MainEventHeight = 610;
  18. private int MainEventWidth = 460;
  19. private int YearEventHeight = 77;
  20. //螢幕解析度 (寬)
  21. private int ResolutionValueHeight = 0;
  22. private int ResolutionValueWidth = 0;
  23. //透過電視牆的寬度~及所設定的MainEventWidth, 取得該 scrollviewer 會有幾個 children
  24. private int ChildrenCount = 0;
  25. //除了 ChildrenCount 外在移動判斷上需再加上四, 以供在無限Scroll的時候判斷位置用
  26. private int TotalShowChildren = 0;
  27. //兩旁黑邊"沒出現"的範圍
  28. private int NoneUseRange = 0;
  29. private int FadeRate;
  30. private void SetSpecValue()
  31. {
  32. //設定 Scrollviewer 的高度~
  33. uxMyScroll.Height = MainEventHeight;
  34. ChildrenCount = GetChildrenCount();
  35. TotalShowChildren = ChildrenCount + 4;
  36. NoneUseRange = GetNoneUseRange();
  37. FadeRate = MainEventWidth / 2;
  38. }
  39. //兩旁黑邊"沒出現"的範圍
  40. private int GetNoneUseRange()
  41. {
  42. int result = 0;
  43. int buffer = 0;
  44. //一個螢幕的話可容納的個數
  45. if (CurrentMonitorCount.ncm == MonitorFlag.Monitor1_1)
  46. {
  47. //解析度1920 * 1080
  48. ResolutionValueWidth = 1920;
  49. ResolutionValueHeight = 1080;
  50. }
  51. else if (CurrentMonitorCount.ncm == MonitorFlag.Monitor2_1)
  52. {
  53. //解析度3840 * 1080
  54. ResolutionValueWidth = 3840;
  55. ResolutionValueHeight = 1080;
  56. }
  57. else if (CurrentMonitorCount.ncm == MonitorFlag.Monitor3_1)
  58. {
  59. //解析度5760 * 1080
  60. ResolutionValueWidth = 5760;
  61. ResolutionValueHeight = 1080;
  62. }
  63. else if (CurrentMonitorCount.ncm == MonitorFlag.Monitor4_1)
  64. {
  65. //解析度7680 * 1080
  66. ResolutionValueWidth = 7680;
  67. ResolutionValueHeight = 1080;
  68. }
  69. else if (CurrentMonitorCount.ncm == MonitorFlag.Monitor5_1)
  70. {
  71. //解析度9600 * 1080
  72. ResolutionValueWidth = 9600;
  73. ResolutionValueHeight = 1080;
  74. }
  75. else if (CurrentMonitorCount.ncm == MonitorFlag.Monitor6_1)
  76. {
  77. //解析度11520 * 1080
  78. ResolutionValueWidth = 11520;
  79. ResolutionValueHeight = 1080;
  80. }
  81. if (GlobalFunction.isSolutionUsing4K)
  82. {
  83. ResolutionValueHeight *= 2;
  84. }
  85. buffer = (ResolutionValueWidth - MainEventWidth) / MainEventWidth;
  86. result = MainEventWidth - (ResolutionValueWidth - (MainEventWidth * buffer)) / 2;
  87. return result;
  88. }
  89. /// <summary>
  90. /// 透過電視牆的寬度~及所設定的MainEventWidth, 取得該 scrollviewer 會有幾個 children
  91. /// </summary>
  92. /// <returns></returns>
  93. private int GetChildrenCount()
  94. {
  95. int result = 0;
  96. //一個螢幕的話可容納的個數
  97. if (CurrentMonitorCount.ncm == MonitorFlag.Monitor1_1)
  98. {
  99. //解析度1920 * 1080
  100. result = 1920 / MainEventWidth + 1;
  101. }
  102. else if (CurrentMonitorCount.ncm == MonitorFlag.Monitor2_1)
  103. {
  104. //解析度3840 * 1080
  105. result = 3840 / MainEventWidth + 1;
  106. }
  107. else if (CurrentMonitorCount.ncm == MonitorFlag.Monitor3_1)
  108. {
  109. //解析度5760 * 1080
  110. result = 5760 / MainEventWidth + 1;
  111. }
  112. else if (CurrentMonitorCount.ncm == MonitorFlag.Monitor4_1)
  113. {
  114. //解析度7680 * 1080
  115. result = 7680 / MainEventWidth + 1;
  116. }
  117. else if (CurrentMonitorCount.ncm == MonitorFlag.Monitor5_1)
  118. {
  119. //解析度9600 * 1080
  120. result = 9600 / MainEventWidth + 1;
  121. }
  122. else if (CurrentMonitorCount.ncm == MonitorFlag.Monitor6_1)
  123. {
  124. //解析度11520 * 1080
  125. result = 11520 / MainEventWidth + 1;
  126. }
  127. return result;
  128. }
  129. }
  130. }