123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- using PDF_Master.Helper;
- using PDF_Master.Properties;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace PDF_Master.Views.HomePanel
- {
- /// <summary>
- /// PromotionContent.xaml 的交互逻辑
- /// </summary>
- public partial class PromotionContent : UserControl
- {
- private ObservableCollection<PromotionBanner> PDFProPromotion = new ObservableCollection<PromotionBanner>();
- private ObservableCollection<PromotionBanner> OthersPromotion = new ObservableCollection<PromotionBanner>();
- /// <summary>
- /// 活动链接
- /// </summary>
- public string ActiveUri = Settings.Default.ADDate.advertisement_BlackFridaylinkURLen;
- public string iPad = Settings.Default.ADDate.RecommondPDFPro_iPadlinkURLen;
- public string Mac = Settings.Default.ADDate.RecommondPDFPro_MaclinkURLen;
- public string Android = Settings.Default.ADDate.RecommondPDFPro_AndroidlinkURLen;
- public string ComPDFKit = Settings.Default.ADDate.RecommondOther_ComPDFKitlinkURLen;
- public string ComVideoKit = Settings.Default.ADDate.RecommondOther_ComVideoKitlinkURLen;
- public string SignFlow = Settings.Default.ADDate.RecommondOther_SignFlowlinkURLen;
- public string FilmageEditor = Settings.Default.ADDate.RecommondOther_FilmageEditorlinkURLen;
- public string FilmageScreen = Settings.Default.ADDate.RecommondOther_FilmageScreenlinkURLen;
- public string FreePDFTemplates = Settings.Default.ADDate.RecommondOther_FreePDFTemplateslinkURLen;
- public PromotionContent()
- {
- InitializeComponent();
- InitPromotionBanner();
- ADDispaly();
- }
- private void InitPromotionBanner()
- {
- try
- {
- Text_PDFPro.Text = Settings.Default.ADDate.RecommondContentPDFPro_nameen;
- Text_Others.Text = Settings.Default.ADDate.RecommondContentOther_nameen;
- if (ServiceHelper.IsConnectInternet() == false)
- {
- PDFProPromotion.Add(new PromotionBanner("pack://application:,,,/Resources/PromotionIcon/Mac.png", Settings.Default.ADDate.RecommondPDFPro_Macnameen, Mac));
- PDFProPromotion.Add(new PromotionBanner("pack://application:,,,/Resources/PromotionIcon/IPhoneiPad.png", Settings.Default.ADDate.RecommondPDFPro_iPadnameen, iPad));
- PDFProPromotion.Add(new PromotionBanner("pack://application:,,,/Resources/PromotionIcon/Android.png", Settings.Default.ADDate.RecommondPDFPro_Androidnameen, Android));
- PDFProListview.ItemsSource = PDFProPromotion;
- OthersPromotion.Add(new PromotionBanner("pack://application:,,,/Resources/PromotionIcon/ComPDFKit.png", Settings.Default.ADDate.RecommondOther_ComPDFKitnameen, ComPDFKit));
- //OthersPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "ComVideoKit" + ".png", Settings.Default.ADDate.RecommondOther_ComVideoKitnameen, ComVideoKit));
- OthersPromotion.Add(new PromotionBanner("pack://application:,,,/Resources/PromotionIcon/SignFlow.png", Settings.Default.ADDate.RecommondOther_SignFlownameen, SignFlow));
- OthersPromotion.Add(new PromotionBanner("pack://application:,,,/Resources/PromotionIcon/FilmageEditor.png", Settings.Default.ADDate.RecommondOther_FilmageEditornameen, FilmageEditor));
- OthersPromotion.Add(new PromotionBanner("pack://application:,,,/Resources/PromotionIcon/FilmageScreen.png", Settings.Default.ADDate.RecommondOther_FilmageScreennameen, FilmageScreen));
- OthersPromotion.Add(new PromotionBanner("pack://application:,,,/Resources/PromotionIcon/FreePDFTemplates.png", Settings.Default.ADDate.RecommondOther_FreePDFTemplatesnameen, FreePDFTemplates));
- OthersListview.ItemsSource = OthersPromotion;
- }
- else
- {
- PDFProPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "Mac" + ".png", Settings.Default.ADDate.RecommondPDFPro_Macnameen, Mac));
- PDFProPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "iPad" + ".png", Settings.Default.ADDate.RecommondPDFPro_iPadnameen, iPad));
- PDFProPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "Android" + ".png", Settings.Default.ADDate.RecommondPDFPro_Androidnameen, Android));
- PDFProListview.ItemsSource = PDFProPromotion;
- OthersPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "ComPDFKit" + ".png", Settings.Default.ADDate.RecommondOther_ComPDFKitnameen, ComPDFKit));
- //OthersPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "ComVideoKit" + ".png", Settings.Default.ADDate.RecommondOther_ComVideoKitnameen, ComVideoKit));
- OthersPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "SignFlow" + ".png", Settings.Default.ADDate.RecommondOther_SignFlownameen, SignFlow));
- OthersPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "FilmageEditor" + ".png", Settings.Default.ADDate.RecommondOther_FilmageEditornameen, FilmageEditor));
- OthersPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "FilmageScreen" + ".png", Settings.Default.ADDate.RecommondOther_FilmageScreennameen, FilmageScreen));
- OthersPromotion.Add(new PromotionBanner(App.CachePath.ADFilePath + "\\" + "FreePDFTemplates" + ".png", Settings.Default.ADDate.RecommondOther_FreePDFTemplatesnameen, FreePDFTemplates));
- OthersListview.ItemsSource = OthersPromotion;
- }
-
- }
- catch { };
- }
- private void ADDispaly()
- {
- try
- {
- ImgeActivity.Source = new BitmapImage(new Uri(App.CachePath.ADFilePath + "\\" + "advertisement" + ".png"));
- DateTime targetstartTime = DateTimeOffset.FromUnixTimeMilliseconds(Settings.Default.ADDate.advertisement_BlackFridaystartTime).DateTime;
- DateTime targetendTime = DateTimeOffset.FromUnixTimeMilliseconds(Settings.Default.ADDate.advertisement_BlackFridayendTime).DateTime;
- TimeZoneInfo chinaTimeZone = TimeZoneInfo.FindSystemTimeZoneById("China Standard Time");
- DateTime beijingTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, chinaTimeZone);
- if (beijingTime < targetendTime && beijingTime > targetstartTime)
- {
- ImgeActivity.Visibility = Visibility.Visible;
- }
- else
- {
- ImgeActivity.Visibility = Visibility.Collapsed;
- }
- }
- catch { };
- }
- private void LoadPromotionContents()
- {
- if(ImgeActivity.Visibility == Visibility.Visible)
- {
- }
- else
- {
- PDFProSeriesExpander.IsExpanded = false;
- OthersExpander.IsExpanded = false;
- }
- }
- private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
- {
- }
- private void FrameworkElement_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- var item = sender as ListViewItem;
- if(item!=null)
- {
- if(!string.IsNullOrEmpty((item.DataContext as PromotionBanner).Uri))
- {
- GotoURI((item.DataContext as PromotionBanner).Uri);
- }
- }
- }
- private void ImgeActivity_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- try
- {
- GotoURI(Settings.Default.ADDate.advertisement_BlackFridaylinkURLen);
- }
- catch
- {
- }
- }
- /// <summary>
- /// 跳转到链接
- /// </summary>
- /// <param name="uri"></param>
- private void GotoURI(string uri)
- {
- try
- {
- System.Diagnostics.Process.Start(uri);
- }
- catch { }
- }
- }
- }
|