Example #1
0
        private static void ConfigureAdDuplexInterstitalAd()
        {
            AdDuplex.InterstitialAd interstitialAd = null;
            WSANativeInterstitialAd._Request += (adType, adVariant, appId, adUnitId) =>
            {
                if (adType == WSAInterstitialAdType.AdDuplex)
                {
                    AppCallbacks.Instance.InvokeOnUIThread(async() =>
                    {
                        if (interstitialAd == null)
                        {
                            AdDuplex.AdDuplexClient.Initialize(appId);
                            await Task.Delay(500);
                            interstitialAd                 = new AdDuplex.InterstitialAd(adUnitId);
                            interstitialAd.AdLoaded       += (s, e) => { RaiseActionOnAppThread(WSANativeInterstitialAd.AdReady, WSAInterstitialAdType.AdDuplex); };
                            interstitialAd.AdClosed       += (s, e) => { RaiseActionOnAppThread(WSANativeInterstitialAd.Completed, WSAInterstitialAdType.AdDuplex); };
                            interstitialAd.AdLoadingError += (s, e) => { RaiseActionOnAppThread(WSANativeInterstitialAd.ErrorOccurred, WSAInterstitialAdType.AdDuplex, e.Error.Message); };
                            interstitialAd.NoAd           += (s, e) => { RaiseActionOnAppThread(WSANativeInterstitialAd.ErrorOccurred, WSAInterstitialAdType.AdDuplex, e.Message); };
                        }

                        await interstitialAd.LoadAdAsync();
                    }, false);
                }
            };
            WSANativeInterstitialAd._Show += (adType) =>
            {
                if (adType == WSAInterstitialAdType.AdDuplex && interstitialAd != null)
                {
                    AppCallbacks.Instance.InvokeOnUIThread(async() =>
                    {
                        await interstitialAd.ShowAdAsync();
                    }, false);
                }
            };
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="AdduplexAdUnitId"></param>
        /// <param name="AdduplexSDKKey"></param>
        /// <param name="PubcenterApplicationId"></param>
        /// <param name="PubcenterSDKKey"></param>
        /// <param name="PubcenterMobileApplicationId"></param>
        /// <param name="PubcenterMobileSDKKey"></param>
        public async void Initialize(string AdduplexAdUnitId, string AdduplexSDKKey,
                                     string PubcenterApplicationId, string PubcenterSDKKey,
                                     string PubcenterMobileApplicationId, string PubcenterMobileSDKKey)
        {
            // Initialize pubcenter
            interstitialAd_pubcenter                = new InterstitialAd();
            interstitialAd_pubcenter.AdReady       += InterstitialAdMain_AdReady;
            interstitialAd_pubcenter.ErrorOccurred += InterstitialAdMain_ErrorOccurred;
            interstitialAd_pubcenter.Completed     += InterstitialAdInterstitialAdMain_Completed;
            interstitialAd_pubcenter.Cancelled     += InterstitialAdInterstitialAdMain_Cancelled;

            interstitialAd_pubcenter.Keywords = tags;
            if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile")
            {
                interstitialAd_pubcenter.RequestAd(Microsoft.Advertising.WinRT.UI.AdType.Video, PubcenterMobileApplicationId, PubcenterMobileSDKKey);
            }
            else
            {
                interstitialAd_pubcenter.RequestAd(Microsoft.Advertising.WinRT.UI.AdType.Video, PubcenterApplicationId, PubcenterSDKKey);
            }

            // Initialize Adduplex
            AdDuplex.AdDuplexClient.Initialize(AdduplexSDKKey);
            interstitialAd_adduplex = new AdDuplex.InterstitialAd(AdduplexAdUnitId);

            interstitialAd_adduplex.NoAd           += InterstitialAd_adduplex_NoAd;
            interstitialAd_adduplex.AdClicked      += InterstitialAd_adduplex_AdClicked;
            interstitialAd_adduplex.AdClosed       += InterstitialAd_adduplex_AdClosed;
            interstitialAd_adduplex.AdLoadingError += InterstitialAd_adduplex_AdLoadingError;

            InterstitialAdInfo info = await interstitialAd_adduplex.LoadAdAsync();

            // Events
            HockeyClient.Current.TrackEvent("Ads requested");
        }
Example #3
0
 void InitializeInterstitialAd()
 {
     if (ad == null)
     {
         ad           = new AdDuplex.InterstitialAd("YOUR AdUnitId HERE");
         ad.AdClosed += ad_AdClosed;
     }
 }
Example #4
0
 protected async override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     Tracker myTracker = EasyTracker.GetTracker();
     myTracker.SendView("AboutPage");
     AdDuplex.InterstitialAd interstitialAd = new AdDuplex.InterstitialAd("180815");
     await interstitialAd.LoadAdAsync();
     await interstitialAd.ShowAdAsync();
 }
Example #5
0
        /// <summary>
        /// Cleanup
        /// </summary>
        public void Destroy()
        {
            if (interstitialAd_pubcenter != null)
            {
                interstitialAd_pubcenter.AdReady       -= InterstitialAdMain_AdReady;
                interstitialAd_pubcenter.ErrorOccurred -= InterstitialAdMain_ErrorOccurred;
                interstitialAd_pubcenter.Completed     -= InterstitialAdInterstitialAdMain_Completed;
                interstitialAd_pubcenter.Cancelled     -= InterstitialAdInterstitialAdMain_Cancelled;

                interstitialAd_pubcenter = null;
            }
            if (interstitialAd_adduplex != null)
            {
                interstitialAd_adduplex = null;
            }
        }
Example #6
0
        /// <summary>
        /// Uygulama son kullanıcı tarafından normal olarak başlatıldığında çağrılır. Diğer giriş noktaları
        /// uygulamanın belirli bir dosyayı açmak için çalıştırılması gibi durumlarda kullanılır.
        /// </summary>
        /// <param name="e">Başlatma isteği ve işlemi ile ilgili ayrıntılar.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            AdDuplex.AdDuplexClient.Initialize("e6df5edd-c3b0-46a3-90f8-c8673b6a60ee");
            AdDuplex.InterstitialAd interstitialAd = new AdDuplex.InterstitialAd("216335");
            await interstitialAd.ShowAdAsync();

            await interstitialAd.LoadAdAsync();

            // Pencerede içerik varken uygulama başlatmayı tekrarlamayın,
            // pencerenin etkin olduğundan emin olun
            if (rootFrame == null)
            {
                // Gezinti bağlamı olarak kullanılacak bir Çerçeve oluşturun ve ilk sayfaya gidin
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Önceki askıya alınmış uygulamadan durumu yükle
                }

                // Çerçeveyi geçerli Pencereye yerleştirin
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // Gezinme yığını geri yüklenmediğinde, ilk sayfaya gidin,
                    // gerekli bilgiyi gezinti parametresi olarak geçirerek
                    // oluşturun
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // Geçerli pencerenin etkin olduğundan emin olun
                Window.Current.Activate();
            }
        }
Example #7
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
           
           
            base.OnNavigatedTo(e);
            Tracker myTracker = EasyTracker.GetTracker();
            myTracker.SendView("HistoryPage");
            if(downloadList.Items.Count == 0)
            {
                nohistoryimage.Visibility = Visibility.Visible;
                nohistory.Visibility = Visibility.Visible;
            }
            else
            {
                nohistoryimage.Visibility = Visibility.Collapsed;
                nohistory.Visibility = Visibility.Collapsed;
            }
            AdDuplex.InterstitialAd interstitialAd = new AdDuplex.InterstitialAd("180815");
            await interstitialAd.LoadAdAsync();
            await interstitialAd.ShowAdAsync();

        }
Example #8
0
        private async void downloadbutton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Tracker myTracker = EasyTracker.GetTracker();
              myTracker.SendEvent("Downloads", "Download Button Clicked", "Download Attempted",1);
                Uri source = new Uri("http://convertmyurl.net/?url=" + urltext.Text.Trim());
                ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
                StorageFolder folder;
                string pathname;
                object v = localSettings.Values["pathkey"];
                if (v != null)
                {
                    pathname = v.ToString();
                    try {
                        folder = await StorageFolder.GetFolderFromPathAsync(pathname);
                    }
                    catch(FileNotFoundException ex)
                    {
                        folder = await KnownFolders.PicturesLibrary.CreateFolderAsync("PDF Me", CreationCollisionOption.OpenIfExists);
                    }
                }
                else {
                     folder = await KnownFolders.PicturesLibrary.CreateFolderAsync("PDF Me", CreationCollisionOption.OpenIfExists);
                    
                }
                string filename;

                object value = localSettings.Values["filekey"];
                if (value != null)
                {
                   filename  = localSettings.Values["filekey"].ToString();
                    Debug.WriteLine("New filename");
                }
                else
                {
                    filename = "PDF Me.pdf";
                    Debug.WriteLine("Default filename");
                }
                char[] a = new char[25];
                StorageFile destinationFile;
                if (browserweb.DocumentTitle.Length > 60)
                {
                    destinationFile = await folder.CreateFileAsync(
                 "PDF Me.pdf", CreationCollisionOption.GenerateUniqueName);
                }
                else
                {
                    destinationFile = await folder.CreateFileAsync(
                browserweb.DocumentTitle+".pdf", CreationCollisionOption.GenerateUniqueName);
                }
                BackgroundDownloader downloader = new BackgroundDownloader();
                DownloadOperation download = downloader.CreateDownload(source, destinationFile);
                downloading.Visibility = Visibility.Visible;
                downloadprogress.Visibility = Visibility.Visible;
                downloadprogress.IsActive = true;
                await download.StartAsync();


                int progress = (int)(100 * (download.Progress.BytesReceived / (double)download.Progress.TotalBytesToReceive));
                if (progress >= 100)
                {
                    myTracker.SendEvent("Downloads", "Download Finished", "Download Successfull", 2);
                    downloading.Visibility = Visibility.Collapsed;
                    downloading.Text = "Downloading: ";
                    downloadprogress.Visibility = Visibility.Collapsed;
                    BasicProperties basic = await download.ResultFile.GetBasicPropertiesAsync();
                    string size;
                        double siz = basic.Size;
               //     ulong mb = ulong.Parse(1000000);
                    if (siz > 1000000)
                    {
                        double s = siz / 1000000;
                        size = s.ToString() + "MB";
                    }
                    else
                    {
                        double s = siz / 1000;
                        
                        size = s.ToString() + "KB";
                    }

                    DatabaseController.AddDownload(destinationFile.Name, download.ResultFile.Path,download.ResultFile.DateCreated.DateTime.ToString(),size);
                    AdDuplex.InterstitialAd interstitialAd = new AdDuplex.InterstitialAd("180815");
                    await interstitialAd.LoadAdAsync();
                    /* MessageDialog m = new MessageDialog(destinationFile.Name + " is saved in PDF Me folder.", "Download Completed");
                     m.Commands.Add(new UICommand("Open File", (command) =>
                     {
                          Launcher.LaunchFileAsync(download.ResultFile);
                     }
                     ));

                     m.Commands.Add(new UICommand("Close", (command) =>
                     {

                     }, 0));

                     m.CancelCommandIndex = 0;
                   await  m.ShowAsync();
                   */
                    string title = "Download Successful";
                    string content = destinationFile.Name + " is saved in PDF Me folder.";
                    ToastVisual visual = new ToastVisual()
                    {
                        TitleText = new ToastText()
                        {
                            Text = title
                        },

                        BodyTextLine1 = new ToastText()
                        {
                            Text = content
                        }
                    };
                    // In a real app, these would be initialized with actual data
                    int conversationId = 384928;

                    // Construct the actions for the toast (inputs and buttons)
                    ToastActionsCustom actions = new ToastActionsCustom()
                    {


                        Buttons =
    {
        new ToastButton("Open", new QueryString()
        {
            { "action", "open" },
            {"file",destinationFile.Path }

        }.ToString())
        {
            ActivationType = ToastActivationType.Foreground,
           
 
            // Reference the text box's ID in order to
            // place this button next to the text box
            
        },

        new ToastButton("Share", new QueryString()
        {
            { "action", "share" },
              {"file",destinationFile.Path }
        }.ToString())
        {
            ActivationType = ToastActivationType.Foreground
        }

       
    }
                    };
                    // Now we can construct the final toast content
                    ToastContent toastContent = new ToastContent()
                    {
                        Visual = visual,
                        Actions = actions,

                        // Arguments when the user taps body of toast
                        Launch = new QueryString()
{

{ "conversationId", conversationId.ToString() }

}.ToString()
                    };

                    // And create the toast notification
                    var toast = new ToastNotification(toastContent.GetXml());
                    toast.ExpirationTime = DateTime.Now.AddSeconds(10);
                    ToastNotificationManager.CreateToastNotifier().Show(toast);

                    await interstitialAd.LoadAdAsync();
                    await interstitialAd.ShowAdAsync();



                }
                else

                {
                    downloading.Visibility = Visibility.Collapsed;
                    downloadprogress.Visibility = Visibility.Collapsed;
                    BasicProperties basic = await download.ResultFile.GetBasicPropertiesAsync();

                    double siz = basic.Size;
                    if(siz == 0)
                    {
                      await  destinationFile.DeleteAsync();
                        myTracker.SendEvent("Downloads", "Download Failed due to Server Error", null, 3);
                        MessageDialog m = new MessageDialog("Server is down. Try again later","Fatal Error");
                        await   m.ShowAsync();
                    }
                }
                /*
                var authClient = new LiveAuthClient();
                var authResult = await authClient.LoginAsync(new string[] { "wl.skydrive", "wl.skydrive_update" });
                if (authResult.Session == null)
                {
                    throw new InvalidOperationException("You need to sign in and give consent to the app.");
                }

                var liveConnectClient = new LiveConnectClient(authResult.Session);

                string skyDriveFolder = await CreateDirectoryAsync(liveConnectClient, "PDF Me - Saved PDFs", "me/skydrive");
            */
            }
            catch (Exception ex)
            {
               
                Tracker myTracker = EasyTracker.GetTracker();      // Get a reference to tracker.
                myTracker.SendException(ex.Message, false);
                MessageDialog m = new MessageDialog(ex.ToString());
                m.ShowAsync();
            }
        }