Esempio n. 1
0
        /// <summary>
        /// WP8适配WP8.1,UWP手机等比例放大
        /// </summary>
        /// <param name="gamePage">Page类</param>
        /// <param name="xnaSurface">XnaSurface</param>
        public static void SetupScreenAutoScaling(Microsoft.Phone.Controls.PhoneApplicationPage gamePage, System.Windows.Controls.DrawingSurface xnaSurface)
        {
            if (Instance != null)
            {
                throw new InvalidOperationException("There can be only one GamePage object!");
            }

            Instance = gamePage;
            // Get the screen’s WVGA ''ScaleFactor'' via reflection.  scaleFactor will be 100 (WVGA), 160 (WXGA), or 150 (WXGA).
            int?scaleFactor         = null;
            var content             = System.Windows.Application.Current.Host.Content;
            var scaleFactorProperty = content.GetType().GetProperty("ScaleFactor");

            if (scaleFactorProperty != null)
            {
                scaleFactor = scaleFactorProperty.GetValue(content, null) as int?;
            }

            if (scaleFactor == null)
            {
                scaleFactor = 100;
            }

            double scale = ((double)scaleFactor) / 100.0;



            System.Windows.Media.ScaleTransform scaleTransform = new System.Windows.Media.ScaleTransform();
            scaleTransform.ScaleX      = scaleTransform.ScaleY = scale;
            xnaSurface.RenderTransform = scaleTransform;
        }
        private void Authenticate(Xamarin.Auth.ProviderSamples.Helpers.OAuth1 oauth1)
        {
            OAuth1Authenticator auth = new OAuth1Authenticator
                                       (
                consumerKey: oauth1.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer,
                consumerSecret: oauth1.OAuth1_SecretKey_ConsumerSecret_APISecret,
                requestTokenUrl: oauth1.OAuth1_UriRequestToken,
                authorizeUrl: oauth1.OAuth_UriAuthorization,
                accessTokenUrl: oauth1.OAuth_UriAccessToken_UriRequestToken,
                callbackUrl: oauth1.OAuth_UriCallbackAKARedirect
                                       );

            auth.AllowCancel = oauth1.AllowCancel;

            // If authorization succeeds or is canceled, .Completed will be fired.
            auth.Completed         += Auth_Completed;
            auth.Error             += Auth_Error;
            auth.BrowsingCompleted += Auth_BrowsingCompleted;

            Uri uri = auth.GetUI();

            // For Xamarin.Forms refactoring
            Microsoft.Phone.Controls.PhoneApplicationPage this_page = this;
            this.NavigationService.Navigate(uri);

            return;
        }
Esempio n. 3
0
 private static void OnSetCommandParameterCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
 {
     Microsoft.Phone.Controls.PhoneApplicationPage buttonBase = dependencyObject as Microsoft.Phone.Controls.PhoneApplicationPage;
     if (buttonBase != null)
     {
         PhoneApplicationPageBackKeyPressCommandBehavior behavior = GetOrCreateBehavior(buttonBase);
         behavior.CommandParameter = e.NewValue;
     }
 }
Esempio n. 4
0
        /// <summary>
        /// WP8适配WP8.1,UWP手机等比例放大
        /// </summary>
        /// <param name="gamePage">Page类</param>
        /// <param name="xnaSurface">XnaSurface</param>
        /// <param name="thickness">设置游戏屏幕与手机屏幕边缘的距离</param>
        public static void SetupScreenAutoScaling(Microsoft.Phone.Controls.PhoneApplicationPage gamePage, System.Windows.Controls.DrawingSurface xnaSurface, ViewportMargin viewportMargin)
        {
            if (Instance != null)
            {
                throw new InvalidOperationException("There can be only one GamePage object!");
            }

            Instance = gamePage;

            int?scaleFactor         = null;
            var content             = System.Windows.Application.Current.Host.Content;
            var scaleFactorProperty = content.GetType().GetProperty("ScaleFactor");

            if (scaleFactorProperty != null)
            {
                scaleFactor = scaleFactorProperty.GetValue(content, null) as int?;
            }

            if (scaleFactor == null)
            {
                scaleFactor = 100;
            }

            double scale = ((double)scaleFactor) / 100.0;



            if (scaleFactor == 150)
            {
                // Centered letterboxing - move Margin.Left to the right by ((1280-1200)/2)/scale
                if (viewportMargin == ViewportMargin.Top)
                {
                    xnaSurface.Margin = new System.Windows.Thickness(0, 40 / scale, 0, 0);
                }
                else if (viewportMargin == ViewportMargin.Left)
                {
                    xnaSurface.Margin = new System.Windows.Thickness(40 / scale, 0, 0, 0);
                }
                else if (viewportMargin == ViewportMargin.Right)
                {
                    xnaSurface.Margin = new System.Windows.Thickness(0, 0, 40 / scale, 0);
                }
                else if (viewportMargin == ViewportMargin.Right)
                {
                    xnaSurface.Margin = new System.Windows.Thickness(0, 0, 0, 40 / scale);
                }
            }

            // Scale the XnaSurface:

            System.Windows.Media.ScaleTransform scaleTransform = new System.Windows.Media.ScaleTransform();
            scaleTransform.ScaleX      = scaleTransform.ScaleY = scale;
            xnaSurface.RenderTransform = scaleTransform;
        }
Esempio n. 5
0
        internal static NavigationEvent FromCancelEventArgs(Microsoft.Phone.Controls.PhoneApplicationPage phoneApplicationPage, System.ComponentModel.CancelEventArgs e)
        {
            var evnt = new NavigationEvent()
            {
                IsCancelable          = true,
                IsNavigationInitiator = true,
                NavigationMode        = NavigationMode.Back,
                FromUri           = null,
                ToUri             = null,
                NavigationContext = null
            };

            return(evnt);
        }
        public void Login(Authenticator authenticator)
        {
            authenticator.Completed += AuthenticatorCompleted;

            //rootViewController = UIKit.UIApplication.SharedApplication.KeyWindow.RootViewController;
            //rootViewController.PresentViewController(authenticator.GetUI(), true, null);

            System.Uri uri = authenticator.GetUI();
            // this == Microsoft.Phone.Controls.PhoneApplicationPage
            Microsoft.Phone.Controls.PhoneApplicationPage this_page = null;
            this_page.NavigationService.Navigate(uri);

            return;
        }
        private void Authenticate(Xamarin.Auth.ProviderSamples.Helpers.OAuth2 oauth2)
        {
            OAuth2Authenticator auth = null;

            if (oauth2.OAuth_UriAccessToken_UriRequestToken == null || string.IsNullOrEmpty(oauth2.OAuth_SecretKey_ConsumerSecret_APISecret))
            {
                auth = new OAuth2Authenticator
                       (
                    clientId: oauth2.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer,
                    scope: oauth2.OAuth2_Scope,
                    authorizeUrl: oauth2.OAuth_UriAuthorization,
                    redirectUrl: oauth2.OAuth_UriCallbackAKARedirect
                       );
            }
            else
            {
                auth = new OAuth2Authenticator
                       (
                    clientId: oauth2.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer,
                    clientSecret: "93e7f486b09bd1af4c38913cfaacbf8a384a50d2",
                    scope: oauth2.OAuth2_Scope,
                    authorizeUrl: oauth2.OAuth_UriAuthorization,
                    redirectUrl: oauth2.OAuth_UriCallbackAKARedirect,
                    accessTokenUrl: oauth2.OAuth_UriAccessToken_UriRequestToken
                       );
            }

            auth.AllowCancel = oauth2.AllowCancel;

            // If authorization succeeds or is canceled, .Completed will be fired.
            auth.Completed         += Auth_Completed;
            auth.Error             += Auth_Error;
            auth.BrowsingCompleted += Auth_BrowsingCompleted;

            Uri uri = auth.GetUI();

            // For Xamarin.Forms refactoring
            Microsoft.Phone.Controls.PhoneApplicationPage this_page = this;
            this_page.NavigationService.Navigate(uri);

            return;
        }
Esempio n. 8
0
        private LSilverlightPlus(Microsoft.Phone.Controls.PhoneApplicationPage page, Microsoft.Xna.Framework.Content.ContentManager c, OnMainEvent main)
            : base()
        {
            isClose   = false;
            numformat = new NumberFormatInfo();
            numformat.NumberDecimalSeparator = ".";

            GamePage = page;

            try
            {
                Microsoft.Phone.Shell.SystemTray.IsVisible = false;
            }
            catch (Exception)
            {
            }

            content = c;
            content.RootDirectory = "";

            TargetElapsedTime = new GameTimer();
            TargetElapsedTime.UpdateInterval = TimeSpan.FromTicks(333333);
            TargetElapsedTime.Update        += OnUpdate;
            TargetElapsedTime.Draw          += OnDraw;

            if (useXNAListener)
            {
                sl_listener.Create(GamePage);
            }

            log.I("LGame 2D Engine Start");
            Initialize();
            XNA_Graphics_Loading();
            if (main != null)
            {
                main(this);
            }
        }
Esempio n. 9
0
 public static object GetCommandParameter(Microsoft.Phone.Controls.PhoneApplicationPage buttonBase)
 {
     return(buttonBase.GetValue(CommandParameterProperty));
 }
 public static void SetApplicationBar(Microsoft.Phone.Controls.PhoneApplicationPage obj, ApplicationBar value)
 {
     obj.SetValue(ApplicationBarProperty, value);
 }
Esempio n. 11
0
 public static ICommand GetCommand(Microsoft.Phone.Controls.PhoneApplicationPage buttonBase)
 {
     return(buttonBase.GetValue(CommandProperty) as ICommand);
 }
Esempio n. 12
0
 public static void SetCommand(Microsoft.Phone.Controls.PhoneApplicationPage buttonBase, ICommand command)
 {
     buttonBase.SetValue(CommandProperty, command);
 }
Esempio n. 13
0
        private static PhoneApplicationPageBackKeyPressCommandBehavior GetOrCreateBehavior(Microsoft.Phone.Controls.PhoneApplicationPage buttonBase)
        {
            PhoneApplicationPageBackKeyPressCommandBehavior behavior = buttonBase.GetValue(BackKeyPressCommandBehaviorProperty) as PhoneApplicationPageBackKeyPressCommandBehavior;

            if (behavior == null)
            {
                behavior = new PhoneApplicationPageBackKeyPressCommandBehavior(buttonBase);
                buttonBase.SetValue(BackKeyPressCommandBehaviorProperty, behavior);
            }

            return(behavior);
        }
Esempio n. 14
0
 public static LSilverlightPlus Load(Microsoft.Phone.Controls.PhoneApplicationPage page, Microsoft.Xna.Framework.Content.ContentManager c, OnMainEvent main)
 {
     return(new LSilverlightPlus(page, c, main));
 }
 public static ApplicationBar GetApplicationBar(Microsoft.Phone.Controls.PhoneApplicationPage obj)
 {
     return((ApplicationBar)obj.GetValue(ApplicationBarProperty));
 }
Esempio n. 16
0
 public static void SetCommandParameter(Microsoft.Phone.Controls.PhoneApplicationPage buttonBase, object parameter)
 {
     buttonBase.SetValue(CommandParameterProperty, parameter);
 }
        protected override async void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Page> e)
        {
            try
            {
                base.OnElementChanged(e);

                System.Diagnostics.Debug.WriteLine("AuthenticatorPageRenderer.OnElementChanged");

                if (e == null)
                {
                    System.Diagnostics.Debug.WriteLine("AuthenticatorPageRenderer: e = {null}");
                }
                else
                {
                    if (e.NewElement == null)
                    {
                        System.Diagnostics.Debug.WriteLine("AuthenticatorPageRenderer: e.NewElement = {null}");
                    }
                    if (e.OldElement == null)
                    {
                        System.Diagnostics.Debug.WriteLine("AuthenticatorPageRenderer: e.OldElement = {null}");
                    }
                }

                if (Element == null)
                {
                    System.Diagnostics.Debug.WriteLine("AuthenticatorPageRenderer: Element is {null}");
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("AuthenticatorPageRenderer: Element is " + Element);
                }

                if (Control == null)
                {
                    System.Diagnostics.Debug.WriteLine("AuthenticatorPageRenderer: Control is {null}");
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("AuthenticatorPageRenderer: Control is " + Control);
                }

                if (Control == null)
                {
                    authenticator_page = (AuthenticatorPage)base.Element;

                    Authenticator.Completed -= Authenticator_Completed;
                    Authenticator.Completed += Authenticator_Completed;
                    Authenticator.Error     -= Authenticator_Error;
                    Authenticator.Error     += Authenticator_Error;

                    Uri page_uri = Authenticator.GetUI();
                    Microsoft.Phone.Controls.PhoneApplicationPage this_page = null;
                    this_page.NavigationService.Navigate(page_uri);
                }
            }
            catch (Exception ex)
            {
                throw new Xamarin.Auth._MobileServices.AuthException("WindowsPhone OnElementChanged");
            }

            return;
        }
Esempio n. 18
0
 /// <summary>
 ///  <para>Create a new adapter which does not initially reference a page.</para>
 ///  <para>The caller is expected to assign this adapter a page reference via its "Page" property after creation.</para>
 /// </summary>
 public DotNetPageAdapter()
 {
     fPage = null;
 }