PromotionContent.xaml.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. using PDF_Master.Helper;
  2. using PDF_Master.Properties;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Collections.ObjectModel;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. namespace PDF_Master.Views.HomePanel
  19. {
  20. /// <summary>
  21. /// PromotionContent.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class PromotionContent : UserControl
  24. {
  25. private ObservableCollection<PromotionBanner> PDFProPromotion = new ObservableCollection<PromotionBanner>();
  26. private ObservableCollection<PromotionBanner> OthersPromotion = new ObservableCollection<PromotionBanner>();
  27. /// <summary>
  28. /// 活动链接
  29. /// </summary>
  30. public string ActiveUri = Settings.Default.ADDate.advertisement_BlackFridaylinkURLen;
  31. public string iPad = Settings.Default.ADDate.RecommondPDFPro_iPadlinkURLen;
  32. public string Mac = Settings.Default.ADDate.RecommondPDFPro_MaclinkURLen;
  33. public string Android = Settings.Default.ADDate.RecommondPDFPro_AndroidlinkURLen;
  34. public string ComPDFKit = Settings.Default.ADDate.RecommondOther_ComPDFKitlinkURLen;
  35. public string ComVideoKit = Settings.Default.ADDate.RecommondOther_ComVideoKitlinkURLen;
  36. public string SignFlow = Settings.Default.ADDate.RecommondOther_SignFlowlinkURLen;
  37. public string FilmageEditor = Settings.Default.ADDate.RecommondOther_FilmageEditorlinkURLen;
  38. public string FilmageScreen = Settings.Default.ADDate.RecommondOther_FilmageScreenlinkURLen;
  39. public string FreePDFTemplates = Settings.Default.ADDate.RecommondOther_FreePDFTemplateslinkURLen;
  40. public PromotionContent()
  41. {
  42. InitializeComponent();
  43. InitPromotionBanner();
  44. ADDispaly();
  45. }
  46. private void InitPromotionBanner()
  47. {
  48. try
  49. {
  50. Text_PDFPro.Text = Settings.Default.ADDate.RecommondContentPDFPro_nameen;
  51. Text_Others.Text = Settings.Default.ADDate.RecommondContentOther_nameen;
  52. if (ServiceHelper.IsConnectInternet() == false)
  53. {
  54. PDFProPromotion.Add(new PromotionBanner("pack://application:,,,/Resources/PromotionIcon/Mac.png", Settings.Default.ADDate.RecommondPDFPro_Macnameen, Mac));
  55. PDFProPromotion.Add(new PromotionBanner("pack://application:,,,/Resources/PromotionIcon/IPhoneiPad.png", Settings.Default.ADDate.RecommondPDFPro_iPadnameen, iPad));
  56. PDFProPromotion.Add(new PromotionBanner("pack://application:,,,/Resources/PromotionIcon/Android.png", Settings.Default.ADDate.RecommondPDFPro_Androidnameen, Android));
  57. PDFProListview.ItemsSource = PDFProPromotion;
  58. OthersPromotion.Add(new PromotionBanner("pack://application:,,,/Resources/PromotionIcon/ComPDFKit.png", Settings.Default.ADDate.RecommondOther_ComPDFKitnameen, ComPDFKit));
  59. //OthersPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "ComVideoKit" + ".png", Settings.Default.ADDate.RecommondOther_ComVideoKitnameen, ComVideoKit));
  60. OthersPromotion.Add(new PromotionBanner("pack://application:,,,/Resources/PromotionIcon/SignFlow.png", Settings.Default.ADDate.RecommondOther_SignFlownameen, SignFlow));
  61. OthersPromotion.Add(new PromotionBanner("pack://application:,,,/Resources/PromotionIcon/FilmageEditor.png", Settings.Default.ADDate.RecommondOther_FilmageEditornameen, FilmageEditor));
  62. OthersPromotion.Add(new PromotionBanner("pack://application:,,,/Resources/PromotionIcon/FilmageScreen.png", Settings.Default.ADDate.RecommondOther_FilmageScreennameen, FilmageScreen));
  63. OthersPromotion.Add(new PromotionBanner("pack://application:,,,/Resources/PromotionIcon/FreePDFTemplates.png", Settings.Default.ADDate.RecommondOther_FreePDFTemplatesnameen, FreePDFTemplates));
  64. OthersListview.ItemsSource = OthersPromotion;
  65. }
  66. else
  67. {
  68. PDFProPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "Mac" + ".png", Settings.Default.ADDate.RecommondPDFPro_Macnameen, Mac));
  69. PDFProPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "iPad" + ".png", Settings.Default.ADDate.RecommondPDFPro_iPadnameen, iPad));
  70. PDFProPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "Android" + ".png", Settings.Default.ADDate.RecommondPDFPro_Androidnameen, Android));
  71. PDFProListview.ItemsSource = PDFProPromotion;
  72. OthersPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "ComPDFKit" + ".png", Settings.Default.ADDate.RecommondOther_ComPDFKitnameen, ComPDFKit));
  73. //OthersPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "ComVideoKit" + ".png", Settings.Default.ADDate.RecommondOther_ComVideoKitnameen, ComVideoKit));
  74. OthersPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "SignFlow" + ".png", Settings.Default.ADDate.RecommondOther_SignFlownameen, SignFlow));
  75. OthersPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "FilmageEditor" + ".png", Settings.Default.ADDate.RecommondOther_FilmageEditornameen, FilmageEditor));
  76. OthersPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "FilmageScreen" + ".png", Settings.Default.ADDate.RecommondOther_FilmageScreennameen, FilmageScreen));
  77. OthersPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "FreePDFTemplates" + ".png", Settings.Default.ADDate.RecommondOther_FreePDFTemplatesnameen, FreePDFTemplates));
  78. OthersListview.ItemsSource = OthersPromotion;
  79. }
  80. }
  81. catch { };
  82. }
  83. private void ADDispaly()
  84. {
  85. try
  86. {
  87. ImgeActivity.Source = new BitmapImage(new Uri(App.CachePath.ADFilePath + "\\" + "advertisement" + ".png"));
  88. DateTime targetstartTime = DateTimeOffset.FromUnixTimeMilliseconds(Settings.Default.ADDate.advertisement_BlackFridaystartTime).DateTime;
  89. DateTime targetendTime = DateTimeOffset.FromUnixTimeMilliseconds(Settings.Default.ADDate.advertisement_BlackFridayendTime).DateTime;
  90. TimeZoneInfo chinaTimeZone = TimeZoneInfo.FindSystemTimeZoneById("China Standard Time");
  91. DateTime beijingTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, chinaTimeZone);
  92. if (beijingTime < targetendTime && beijingTime > targetstartTime)
  93. {
  94. ImgeActivity.Visibility = Visibility.Visible;
  95. }
  96. else
  97. {
  98. ImgeActivity.Visibility = Visibility.Collapsed;
  99. }
  100. }
  101. catch { };
  102. }
  103. private void LoadPromotionContents()
  104. {
  105. if(ImgeActivity.Visibility == Visibility.Visible)
  106. {
  107. }
  108. else
  109. {
  110. PDFProSeriesExpander.IsExpanded = false;
  111. OthersExpander.IsExpanded = false;
  112. }
  113. }
  114. private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
  115. {
  116. }
  117. private void FrameworkElement_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  118. {
  119. var item = sender as ListViewItem;
  120. if(item!=null)
  121. {
  122. if(!string.IsNullOrEmpty((item.DataContext as PromotionBanner).Uri))
  123. {
  124. GotoURI((item.DataContext as PromotionBanner).Uri);
  125. }
  126. }
  127. }
  128. private void ImgeActivity_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  129. {
  130. try
  131. {
  132. GotoURI(Settings.Default.ADDate.advertisement_BlackFridaylinkURLen);
  133. }
  134. catch
  135. {
  136. }
  137. }
  138. /// <summary>
  139. /// 跳转到链接
  140. /// </summary>
  141. /// <param name="uri"></param>
  142. private void GotoURI(string uri)
  143. {
  144. try
  145. {
  146. System.Diagnostics.Process.Start(uri);
  147. }
  148. catch { }
  149. }
  150. }
  151. }