コード例 #1
0
        /*<Summary>
         * AdMob overload
         * </Summery>*/
        public void CreateAd(string adUnit, AD_FORMATS format, HORIZONTAL_ALIGNMENT horizontalAlign, VERTICAL_ALIGNMENT vertAlign, double width, double height, bool testAd)
        {
#if WINDOWS_PHONE
            Dispatcher.InvokeOnUIThread(() =>
            {
                BuildAd(adUnit, format, horizontalAlign, vertAlign, width, height, testAd);
            });
#endif
        }
コード例 #2
0
        /*<Summary>
         * Builds an admob ad
         * </Summery>*/
        private void BuildAd(string adUnit, AD_FORMATS format, HORIZONTAL_ALIGNMENT horizontalAlign, VERTICAL_ALIGNMENT vertAlign, double width, double height, bool testAd)
        {
#if WINDOWS_PHONE
            if (_ad_Google != null)
            {
                return;
            }

            if (!HasGrid())
            {
                _isBuilt      = false;
                _errorMessage = "Missing grid to attach ad to";
            }

            try
            {
                _ad_Google = new AdView
                {
                    Format   = ConvertAdFormat(format),
                    AdUnitID = adUnit
                };

                if (format != AD_FORMATS.SMART_BANNER)
                {
                    _ad_Google.Width  = width;
                    _ad_Google.Height = height;
                    _ad_Google.HorizontalAlignment = ConvertHorizontalAlignment(horizontalAlign);
                }

                _ad_Google.VerticalAlignment = ConvertVerticalAlignment(vertAlign);

                _ad_Google.ReceivedAd        += OnAdReceived;
                _ad_Google.FailedToReceiveAd += OnFailedToReceiveAd;


                baseGrid.Children.Add(_ad_Google);
                if (baseGrid.Children.Count > 0)
                {
                    _adIndex = baseGrid.Children.Count - 1;
                }

                if (testAd)
                {
                    AdRequest adRequest = new AdRequest();
                    adRequest.ForceTesting = true;
                    _ad_Google.LoadAd(adRequest);
                }

                _isBuilt = true;
            }
            catch (Exception e)
            {
                _errorMessage = "AdMob Error: " + e.Message;
                _isBuilt      = false;
            }
#endif
        }
コード例 #3
0
        public TableCell(AngleSharp.Dom.IElement element = null)
        {
            Text = "";
            HorizontalAlignment = HORIZONTAL_ALIGNMENT.UNKNOWN;
            Indentation         = 0.0;
            IndentationLevel    = 0;
            Bold = false;

            if (element != null)
            {
                Initialize(element);
            }
        }
コード例 #4
0
        /// <summary>
        /// Used to create an AdMob ad
        /// Pass in your ad mob unit id, the format, height/width, position and whether its a test ad or not
        /// The testAd bool is important, it allows us to test an admob ad
        /// </summary>
        public void CreateAd(string adUnit, AD_FORMATS format, HORIZONTAL_ALIGNMENT hAlign, VERTICAL_ALIGNMENT vAlign, bool testAd)
        {
#if WINDOWS_PHONE
            if (Dispatcher.InvokeOnUIThread == null && Messenger != null)
            {
                Messenger("Dispatcher Error: UI Thread not set up");
                return;
            }

            Dispatcher.InvokeOnUIThread(() =>
            {
                BuildAd(adUnit, format, hAlign, vAlign, testAd);
            });
#endif
        }
コード例 #5
0
        /*<Summary>
         * Just our own converter for the  alignment enumerations
         * </Summery>*/
        private HorizontalAlignment ConvertHorizontalAlignment(HORIZONTAL_ALIGNMENT f)
        {
            switch (f)
            {
            case HORIZONTAL_ALIGNMENT.LEFT:
                return(HorizontalAlignment.Left);

            case HORIZONTAL_ALIGNMENT.RIGHT:
                return(HorizontalAlignment.Right);

            case HORIZONTAL_ALIGNMENT.CENTER:
                return(HorizontalAlignment.Center);

            default:
                return(HorizontalAlignment.Center);
            }
        }
コード例 #6
0
        private void Initialize(AngleSharp.Dom.IElement element)
        {
            if (Text.Length == 0)       // Only take text from the first element that offers it.
            {
                // Replace an <br>'s with spaces.
                while (element.InnerHtml.Contains("<br>") || element.InnerHtml.Contains("<BR>"))
                {
                    element.InnerHtml = element.InnerHtml.Replace("<br>", " ").Replace("<BR>", " ");
                }

                Text = element.TextContent.Trim().Replace('\u00A0', ' ');       // Transform nbsp to regular space...
            }

            // Take other attributes from deepest last-sibling element that offers it.


            if (element.GetAttribute(AngleSharp.Html.AttributeNames.Align) == "left" || element.Style.TextAlign.ToLower() == "left")
            {
                HorizontalAlignment = HORIZONTAL_ALIGNMENT.LEFT;
            }
            else if (element.GetAttribute(AngleSharp.Html.AttributeNames.Align) == "center" || element.Style.TextAlign.ToLower() == "center")
            {
                HorizontalAlignment = HORIZONTAL_ALIGNMENT.CENTER;
            }
            else if (element.GetAttribute(AngleSharp.Html.AttributeNames.Align) == "right" || element.Style.TextAlign.ToLower() == "right")
            {
                HorizontalAlignment = HORIZONTAL_ALIGNMENT.RIGHT;
            }

            if (element.Style.FontWeight.ToLower() == "bold")
            {
                Bold = true;
            }

            // Questionable assumption: html authors don't mix px and pt dimensions in the same page...
            if (element.Style.PaddingLeft.Length > 0)
            {
                double leftPad = 0;
                Double.TryParse(element.Style.PaddingLeft.Replace("px", "").Replace("pt", ""), out leftPad);
                this.Indentation += leftPad;
            }
            if (element.Style.MarginLeft.Length > 0)
            {
                double leftMargin = 0;
                Double.TryParse(element.Style.MarginLeft.Replace("px", "").Replace("pt", ""), out leftMargin);
                this.Indentation += leftMargin;
            }
            if (element.Style.TextIndent.Length > 0)
            {
                double textIndent = 0;
                Double.TryParse(element.Style.TextIndent.Replace("px", "").Replace("pt", ""), out textIndent);
                this.Indentation += textIndent;
            }

            // Eliminate "meaningless" indentation diffs.  MAKE THE SENSITIVITY OF THIS OVERRIDEABLE THROUGH CONFIG PARAMS.
            const int INDENTATION_GRANULARITY = 2;

            this.Indentation = (double)((((int)this.Indentation) / INDENTATION_GRANULARITY) * INDENTATION_GRANULARITY);

            // Iterate over this element's children, recursing down the branches of each.
            //  Recursion bounded by leaf elements having no children.
            foreach (var childElement in element.Children)
            {
                this.Initialize(childElement);
            }
        }
コード例 #7
0
        private void BuildAd(string adUnit, AD_FORMATS format, HORIZONTAL_ALIGNMENT hAlign, VERTICAL_ALIGNMENT vAlign, bool testAd)
        {
#if WINDOWS_PHONE
            //Check if an AdMob ad has already been created
            //If so we return, and display a message to the user
            if (_AdMobAd != null)
            {
                if (Messenger != null)
                {
                    Messenger("AdMob Ad already present");
                }
                return;
            }

            //Next we check if we have a grid
            if (_baseGrid == null)
            {
                _isAMAd = false;
                if (Messenger != null)
                {
                    Messenger("Missing grid");
                }
                return;
            }

            try
            {
                _AdMobAd = new AdView
                {
                    Format   = ConvertAdFormat(format),
                    AdUnitID = adUnit
                };

                if (format != AD_FORMATS.SMART_BANNER)
                {
                }

                _AdMobAd.VerticalAlignment = ConvertVerticalAlignment(vAlign);

                _AdMobAd.ReceivedAd        += OnAdReceived;
                _AdMobAd.FailedToReceiveAd += OnError;


                _baseGrid.Children.Add(_AdMobAd);
                //if (_baseGrid.Children.Count > 0)
                //    _adIndex = _baseGrid.Children.Count - 1;

                if (testAd)
                {
                    AdRequest adRequest = new AdRequest();
                    adRequest.ForceTesting = true;
                    _AdMobAd.LoadAd(adRequest);
                }


                //Finally add it to our grid
                _baseGrid.Children.Add(_AdMobAd);

                _isAMAd = true;
            }
            catch (Exception e)
            {
                if (Messenger != null)
                {
                    Messenger("AdMob Error: " + e.Message);
                }
                _isAMAd = false;
            }
#endif
        }
コード例 #8
0
        /// <summary>
        /// Actually goes and does the hard work of building the Pubcenter Ad
        /// </summary>
        private void BuildAd(string apID, string unitId, double height, double width, bool autoRefresh, HORIZONTAL_ALIGNMENT hAlign, VERTICAL_ALIGNMENT vAlign)
        {
#if WINDOWS_PHONE_APP || WINDOWS_APP || WINDOWS_PHONE
            //if the ad already exists we return
            if (_Ad != null)
            {
                if (Messenger != null)
                {
                    Messenger("PubCenter Ad already created");
                }
                return;
            }

            if (BaseGrid == null)
            {
                _isPCAd = false;
                if (Messenger != null)
                {
                    Messenger("Missing grid");
                }
                return;
            }

            try
            {
                //Create the AdControl object
                _Ad = new AdControl();
                _Ad.ApplicationId        = apID;                              //Set the ap id
                _Ad.AdUnitId             = unitId;                            //Set the unit id
                _Ad.IsAutoRefreshEnabled = autoRefresh;                       //Set the autorefresh property

                _Ad.Width  = width;                                           //Set its width
                _Ad.Height = height;                                          //Set its height

                _Ad.VerticalAlignment   = ConvertVerticalAlignment(vAlign);   //Set its vertical position
                _Ad.HorizontalAlignment = ConvertHorizontalAlignment(hAlign); //Set its horizontal position


                //On error and on refreshed
                _Ad.ErrorOccurred += OnError;
                _Ad.AdRefreshed   += OnRefreshed;

                _isPCAd = true;


                //Finally add it to our grid
                _baseGrid.Children.Add(_Ad);

                if (Messenger != null)
                {
                    Messenger("PubCenter Ad Successfully Created");
                }
            }
            catch (Exception e)
            {
                if (Messenger != null)
                {
                    Messenger("Pubcenter Error: " + e.Message);
                }
                _isPCAd = false;
            }
#endif
        }
コード例 #9
0
        /// <summary>
        /// Used to create a pubcenter ad
        /// Pass in your apId, unitId, height/width, position and whether its a test ad or not
        /// The testAd bool is important, it allows us to test an admob ad
        /// </summary>
        public void CreateAd(string apID, string unitId, double height, double width, bool autoRefresh, HORIZONTAL_ALIGNMENT hAlign, VERTICAL_ALIGNMENT vAlign)
        {
#if WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE
            if (Dispatcher.InvokeOnUIThread == null)
            {
                return;
            }

            Dispatcher.InvokeOnUIThread(() =>
            {
                BuildAd(apID, unitId, height, width, autoRefresh, hAlign, vAlign);
            });
#endif
        }
コード例 #10
0
        //This function is public and called from Unity
        //It then uses the dispatcher to invoke on the UI thread

        /*<Summary>
         * Windows ad service overload
         * </Summery>*/
        public void CreateAd(string apId, string unitId, double height, double width, bool autoRefresh, HORIZONTAL_ALIGNMENT horizontalAlign, VERTICAL_ALIGNMENT vertAlign)
        {
#if WINDOWS_PHONE || NETFX_CORE
            Dispatcher.InvokeOnUIThread(() =>
            {
                BuildAd(apId, unitId, height, width, autoRefresh, horizontalAlign, vertAlign);
            });
#endif
        }
コード例 #11
0
        /*<Summary>
         * Builds a windows ad service ad
         * </Summery>*/
        private void BuildAd(string apId, string unitId, double height, double width, bool autoRefresh, HORIZONTAL_ALIGNMENT horizontalAlign, VERTICAL_ALIGNMENT vertAlign)
        {
#if WINDOWS_PHONE || NETFX_CORE
            //Phone implementation
            //If the basegrid object is null it will just return, just a safety check
            //Creates the adControl object
            //Sets its height, width, appid, unitid and such and then uses the margin to position it on screen
            //Finally its added to the children of the basegrid

            //A check to make sure we do not get duplicate ads
            if (_ad != null)
            {
                return;
            }

            //This should be called prior to calling this function but just in case...
            //Lets check if the grid/panel exists
            if (!HasGrid())
            {
                _isBuilt      = false;
                _errorMessage = "Missing grid to attach ad to";
            }
            try
            {
                _ad = new AdControl();
                _ad.ApplicationId        = apId;
                _ad.AdUnitId             = unitId;
                _ad.IsAutoRefreshEnabled = autoRefresh;

                _ad.Width  = width;
                _ad.Height = height;

                _ad.VerticalAlignment   = ConvertVerticalAlignment(vertAlign);
                _ad.HorizontalAlignment = ConvertHorizontalAlignment(horizontalAlign);


#if WINDOWS_PHONE
                baseGrid.Children.Add(_ad);

                if (baseGrid.Children.Count > 0)
                {
                    _adIndex = baseGrid.Children.Count - 1;
                }
#elif NETFX_CORE
                backPanel.Children.Add(_ad);

                if (backPanel.Children.Count > 0)
                {
                    _adIndex = backPanel.Children.Count - 1;
                }
#endif
                _ad.ErrorOccurred += OnAdError_ErrorOccurred;

                _ad.AdRefreshed += OnAdRefreshed;

                _isBuilt = true;
                return;
            }
            catch (Exception e)
            {
                _errorMessage = "PubCenter Error: " + e.Message;
                _isBuilt      = false;
            }
#else
            //function will return and do nothing if its in Unity editor
            _isBuilt = false;
#endif
        }
コード例 #12
0
 /*<Summary>
 * Just our own converter for the  alignment enumerations
 </Summery>*/
 private HorizontalAlignment ConvertHorizontalAlignment(HORIZONTAL_ALIGNMENT f)
 {
     switch (f)
     {
         case HORIZONTAL_ALIGNMENT.LEFT:
             return HorizontalAlignment.Left;
         case HORIZONTAL_ALIGNMENT.RIGHT:
             return HorizontalAlignment.Right;
         case HORIZONTAL_ALIGNMENT.CENTER:
             return HorizontalAlignment.Center;
         default:
             return HorizontalAlignment.Center;
     }
 }
コード例 #13
0
        /*<Summary>
         * Builds an admob ad
        </Summery>*/
        private void BuildAd(string adUnit, AD_FORMATS format, HORIZONTAL_ALIGNMENT horizontalAlign, VERTICAL_ALIGNMENT vertAlign, double width, double height, bool testAd)
        {
#if WINDOWS_PHONE
           if(_ad_Google != null)
            return;

           if (!HasGrid())
           {
               _isBuilt = false;
               _errorMessage = "Missing grid to attach ad to";
           }

            try
            {
                _ad_Google = new AdView
                {
                    Format = ConvertAdFormat(format),
                    AdUnitID = adUnit
                };
                
                if (format != AD_FORMATS.SMART_BANNER)
                {
                    _ad_Google.Width = width;
                    _ad_Google.Height = height;
                    _ad_Google.HorizontalAlignment = ConvertHorizontalAlignment(horizontalAlign);
                }
   
                _ad_Google.VerticalAlignment = ConvertVerticalAlignment(vertAlign);
            
                _ad_Google.ReceivedAd += OnAdReceived;
                _ad_Google.FailedToReceiveAd += OnFailedToReceiveAd;


                baseGrid.Children.Add(_ad_Google);
                if (baseGrid.Children.Count > 0)
                    _adIndex = baseGrid.Children.Count - 1;

                if (testAd)
                {
                    AdRequest adRequest = new AdRequest();
                    adRequest.ForceTesting = true;
                    _ad_Google.LoadAd(adRequest);
                }
                
                _isBuilt = true;
            }
            catch(Exception e)
            {
                _errorMessage = "AdMob Error: " + e.Message;
                _isBuilt = false;
            }
#endif
        }
コード例 #14
0
        /*<Summary>
         * AdMob overload
        </Summery>*/
        public void CreateAd(string adUnit, AD_FORMATS format, HORIZONTAL_ALIGNMENT horizontalAlign, VERTICAL_ALIGNMENT vertAlign, double width, double height, bool testAd)
        {
#if WINDOWS_PHONE
            Dispatcher.InvokeOnUIThread(() =>
            {
                BuildAd(adUnit, format,horizontalAlign,vertAlign,width,height,testAd);
            });
#endif
        }
コード例 #15
0
        /*<Summary>
         * Builds a windows ad service ad
        </Summery>*/
        private void BuildAd(string apId, string unitId, double height, double width, bool autoRefresh, HORIZONTAL_ALIGNMENT horizontalAlign, VERTICAL_ALIGNMENT vertAlign)
        {
#if WINDOWS_PHONE || NETFX_CORE
           //Phone implementation
           //If the basegrid object is null it will just return, just a safety check
           //Creates the adControl object
           //Sets its height, width, appid, unitid and such and then uses the margin to position it on screen
           //Finally its added to the children of the basegrid

           //A check to make sure we do not get duplicate ads
           if(_ad != null)
            return;

           //This should be called prior to calling this function but just in case...
           //Lets check if the grid/panel exists
           if (!HasGrid())
           {
               _isBuilt = false;
               _errorMessage = "Missing grid to attach ad to";
           }
           try
           {
               _ad = new AdControl();
               _ad.ApplicationId = apId;
               _ad.AdUnitId = unitId;
               _ad.IsAutoRefreshEnabled = autoRefresh;

               _ad.Width = width;
               _ad.Height = height;

               _ad.VerticalAlignment = ConvertVerticalAlignment(vertAlign);
               _ad.HorizontalAlignment = ConvertHorizontalAlignment(horizontalAlign);


#if WINDOWS_PHONE

               baseGrid.Children.Add(_ad);

               if(baseGrid.Children.Count >0)
                    _adIndex = baseGrid.Children.Count - 1;
               

#elif NETFX_CORE
               backPanel.Children.Add(_ad);

               if (backPanel.Children.Count > 0)
                   _adIndex = backPanel.Children.Count - 1;
           
#endif
               _ad.ErrorOccurred += OnAdError_ErrorOccurred;

               _ad.AdRefreshed += OnAdRefreshed;

               _isBuilt = true;
               return;
           }
           catch (Exception e)
           {
               _errorMessage = "PubCenter Error: " + e.Message;
               _isBuilt = false;
           }
#else
            //function will return and do nothing if its in Unity editor
            _isBuilt = false;
#endif
        }
コード例 #16
0
        //This function is public and called from Unity
        //It then uses the dispatcher to invoke on the UI thread

        /*<Summary>
         * Windows ad service overload
        </Summery>*/
        public void CreateAd(string apId, string unitId, double height, double width, bool autoRefresh, HORIZONTAL_ALIGNMENT horizontalAlign, VERTICAL_ALIGNMENT vertAlign)
        {
#if WINDOWS_PHONE || NETFX_CORE
            Dispatcher.InvokeOnUIThread(() =>
                {
                   BuildAd(apId, unitId, height, width, autoRefresh,horizontalAlign,vertAlign);
                });
#endif
        }