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 { /// /// PromotionContent.xaml 的交互逻辑 /// public partial class PromotionContent : UserControl { private ObservableCollection PDFProPromotion = new ObservableCollection(); private ObservableCollection OthersPromotion = new ObservableCollection(); /// /// 活动链接 /// 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 { } } /// /// 跳转到链接 /// /// private void GotoURI(string uri) { try { System.Diagnostics.Process.Start(uri); } catch { } } } }