PromotionContent.xaml.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. DateTime localTime = DateTime.Now;
  91. if (localTime < targetendTime && localTime > targetstartTime)
  92. {
  93. ImgeActivity.Visibility = Visibility.Visible;
  94. }
  95. else
  96. {
  97. ImgeActivity.Visibility = Visibility.Collapsed;
  98. }
  99. }
  100. catch { };
  101. }
  102. private void LoadPromotionContents()
  103. {
  104. if(ImgeActivity.Visibility == Visibility.Visible)
  105. {
  106. }
  107. else
  108. {
  109. PDFProSeriesExpander.IsExpanded = false;
  110. OthersExpander.IsExpanded = false;
  111. }
  112. }
  113. private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
  114. {
  115. }
  116. private void FrameworkElement_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  117. {
  118. var item = sender as ListViewItem;
  119. if(item!=null)
  120. {
  121. if(!string.IsNullOrEmpty((item.DataContext as PromotionBanner).Uri))
  122. {
  123. GotoURI((item.DataContext as PromotionBanner).Uri);
  124. }
  125. }
  126. }
  127. private void ImgeActivity_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  128. {
  129. try
  130. {
  131. GotoURI(Settings.Default.ADDate.advertisement_BlackFridaylinkURLen);
  132. }
  133. catch
  134. {
  135. }
  136. }
  137. /// <summary>
  138. /// 跳转到链接
  139. /// </summary>
  140. /// <param name="uri"></param>
  141. private void GotoURI(string uri)
  142. {
  143. try
  144. {
  145. System.Diagnostics.Process.Start(uri);
  146. }
  147. catch { }
  148. }
  149. }
  150. }