PromotionContent.xaml.cs 6.4 KB

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