예제 #1
0
파일: Guide.cs 프로젝트: bjarkeeck/GCGJ
        public static Nullable <int> EndShowMessageBox(IAsyncResult result)
        {
#if WINDOWS_PHONE
            // Call the Microsoft implementation of EndShowMessageBox using an alias.
            return(MsXna_Guide.EndShowMessageBox(result));
#else
            return(((ShowMessageBoxDelegate)result.AsyncState).EndInvoke(result));
#endif
        }
예제 #2
0
파일: Guide.cs 프로젝트: bjarkeeck/GCGJ
        public static string EndShowKeyboardInput(IAsyncResult result)
        {
#if WINDOWS_PHONE
            // Call the Microsoft implementation of BeginShowKeyboardInput using an alias.
            return(MsXna_Guide.EndShowKeyboardInput(result));
#else
            ShowKeyboardInputDelegate ski = (ShowKeyboardInputDelegate)result.AsyncState;

            return(ski.EndInvoke(result));
#endif
        }
예제 #3
0
파일: Guide.cs 프로젝트: bjarkeeck/GCGJ
        public static void ShowMarketplace(PlayerIndex player)
        {
#if WINDOWS_PHONE
            // Call the Microsoft implementation of ShowMarketplace using an alias.
            MsXna_Guide.ShowMarketplace((MsXna_PlayerIndex)player);
#elif WINDOWS_STOREAPP
            _dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var uri = new Uri(@"ms-windows-store:PDP?PFN=" + Package.Current.Id.FamilyName);
                Launcher.LaunchUriAsync(uri).AsTask <bool>().Wait();
            }).AsTask();
#endif
        }
예제 #4
0
파일: Guide.cs 프로젝트: bjarkeeck/GCGJ
        public static IAsyncResult BeginShowKeyboardInput(
            PlayerIndex player,
            string title,
            string description,
            string defaultText,
            AsyncCallback callback,
            Object state)
        {
#if WINDOWS_PHONE
            // Call the Microsoft implementation of BeginShowKeyboardInput using an alias.
            return(MsXna_Guide.BeginShowKeyboardInput((MsXna_PlayerIndex)player, title, description, defaultText, callback, state));
#else
            return(BeginShowKeyboardInput(player, title, description, defaultText, callback, state, false));
#endif
        }
예제 #5
0
파일: Guide.cs 프로젝트: bjarkeeck/GCGJ
        public static IAsyncResult BeginShowMessageBox(
            PlayerIndex player,
            string title,
            string text,
            IEnumerable <string> buttons,
            int focusButton,
            MessageBoxIcon icon,
            AsyncCallback callback,
            Object state
            )
        {
#if WINDOWS_PHONE
            // Call the Microsoft implementation of BeginShowMessageBox using an alias.
            return(MsXna_Guide.BeginShowMessageBox(
                       (MsXna_PlayerIndex)player,
                       title, text,
                       buttons, focusButton,
                       (MsXna_MessageBoxIcon)icon,
                       callback, state));
#else
            // TODO: GuideAlreadyVisibleException
            if (IsVisible)
            {
                throw new Exception("The function cannot be completed at this time: the Guide UI is already active. Wait until Guide.IsVisible is false before issuing this call.");
            }

            if (player != PlayerIndex.One)
            {
                throw new ArgumentOutOfRangeException("player", "Specified argument was out of the range of valid values.");
            }
            if (title == null)
            {
                throw new ArgumentNullException("title", "This string cannot be null or empty, and must be less than 256 characters long.");
            }
            if (text == null)
            {
                throw new ArgumentNullException("text", "This string cannot be null or empty, and must be less than 256 characters long.");
            }
            if (buttons == null)
            {
                throw new ArgumentNullException("buttons", "Value can not be null.");
            }

            ShowMessageBoxDelegate smb = ShowMessageBox;

            return(smb.BeginInvoke(title, text, buttons, focusButton, icon, callback, smb));
#endif
        }
예제 #6
0
        private static Task <int?> PlatformShow(string title, string description, List <string> buttons)
        {
            tcs = new TaskCompletionSource <int?>();
            MsXna_Guide.BeginShowMessageBox(MsXna_PlayerIndex.One, title, description, buttons, 0, MsXna_MessageBoxIcon.None,
                                            ar =>
            {
                var result = MsXna_Guide.EndShowMessageBox(ar);

                if (!tcs.Task.IsCompleted)
                {
                    tcs.SetResult(result);
                }
            },
                                            null);

            return(tcs.Task);
        }
예제 #7
0
파일: Guide.cs 프로젝트: bjarkeeck/GCGJ
        public static IAsyncResult BeginShowKeyboardInput(
            PlayerIndex player,
            string title,
            string description,
            string defaultText,
            AsyncCallback callback,
            Object state,
            bool usePasswordMode)
        {
#if WINDOWS_PHONE
            // Call the Microsoft implementation of BeginShowKeyboardInput using an alias.
            return(MsXna_Guide.BeginShowKeyboardInput((MsXna_PlayerIndex)player, title, description, defaultText, callback, state, usePasswordMode));
#else
            ShowKeyboardInputDelegate ski = ShowKeyboardInput;

            return(ski.BeginInvoke(player, title, description, defaultText, usePasswordMode, callback, ski));
#endif
        }
예제 #8
0
        private static Task <string> PlatformShow(string title, string description, string defaultText, bool usePasswordMode)
        {
            tcs = new TaskCompletionSource <string>();
            MsXna_Guide.BeginShowKeyboardInput(MsXna_PlayerIndex.One, title, description, defaultText,
                                               ar =>
            {
                var result = MsXna_Guide.EndShowKeyboardInput(ar);

                if (!tcs.Task.IsCompleted)
                {
                    tcs.SetResult(result);
                }
            },
                                               null,
                                               usePasswordMode);

            return(tcs.Task);
        }
예제 #9
0
        public static IAsyncResult BeginShowMessageBox(
            MGXna_Framework.PlayerIndex player,
            string title,
            string text,
            IEnumerable <string> buttons,
            int focusButton,
            MessageBoxIcon icon,
            AsyncCallback callback,
            Object state
            )
        {
#if WINDOWS_PHONE
            // Call the Microsoft implementation of BeginShowMessageBox using an alias.
            return(MsXna_Guide.BeginShowMessageBox(
                       (MsXna_PlayerIndex)player,
                       title, text,
                       buttons, focusButton,
                       (MsXna_MessageBoxIcon)icon,
                       callback, state));
#elif !WINDOWS_UAP
            // TODO: GuideAlreadyVisibleException
            if (IsVisible)
            {
                throw new Exception("The function cannot be completed at this time: the Guide UI is already active. Wait until Guide.IsVisible is false before issuing this call.");
            }

            if (player != PlayerIndex.One)
            {
                throw new ArgumentOutOfRangeException("player", "Specified argument was out of the range of valid values.");
            }
            if (title == null)
            {
                throw new ArgumentNullException("title", "This string cannot be null or empty, and must be less than 256 characters long.");
            }
            if (text == null)
            {
                throw new ArgumentNullException("text", "This string cannot be null or empty, and must be less than 256 characters long.");
            }
            if (buttons == null)
            {
                throw new ArgumentNullException("buttons", "Value can not be null.");
            }

            ShowMessageBoxDelegate smb = ShowMessageBox;

            return(smb.BeginInvoke(title, text, buttons, focusButton, icon, callback, smb));
#else
            var tcs  = new TaskCompletionSource <int?>(state);
            var task = Task.Run <int?>(() => ShowMessageBox(title, text, buttons, focusButton, icon));
            task.ContinueWith(t =>
            {
                // Copy the task result into the returned task.
                if (t.IsFaulted)
                {
                    tcs.TrySetException(t.Exception.InnerExceptions);
                }
                else if (t.IsCanceled)
                {
                    tcs.TrySetCanceled();
                }
                else
                {
                    tcs.TrySetResult(t.Result);
                }

                // Invoke the user callback if necessary.
                if (callback != null)
                {
                    callback(tcs.Task);
                }
            });
            return(tcs.Task);
#endif
        }