コード例 #1
0
 private void _showHUD(string text, bool isBgHidden)
 {
     checkCanvas();
     if (_canvas != null)
     {
         if (_currentWaitingHUD == null)
         {
             _currentWaitingHUD = GameObject.Instantiate(WaittingHUDPrefab);
             _currentWaitingHUD.transform.SetParent(_canvas.transform, false);
         }
         ProgressHUD hud = _currentWaitingHUD.GetComponent <ProgressHUD>();
         hud.isBackgroundHidden = isBgHidden;
         hud.setMsgText(text);
     }
     _canvas = null;
 }
コード例 #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            NavigationController.SetNavigationBarHidden(false, true);

            #region UI Settings

            if (!DeviceHelper.IsPad)
            {
                AdjustFontSize(this.View);
            }

            //SetBackButtonTitle("Back");

            this.AutomaticallyAdjustsScrollViewInsets = false;

            #endregion


            mToastToken = Mvx.Resolve <IMvxMessenger>().SubscribeOnMainThread <ToastMessage>((ToastMessage message) =>
            {
                if (message.Sender != ViewModel)
                {
                    return;
                }

                if (!string.IsNullOrEmpty(message.Message))
                {
                    var progressHud = new ProgressHUD()
                    {
                        ForceiOS6LookAndFeel = true
                    };

                    progressHud.ShowToast(message.Message, ProgressHUD.MaskType.None, ProgressHUD.ToastPosition.Bottom, 1500);

                    progressHud.Dispose();
                    progressHud = null;
                }
            });

            mProgressToken = Mvx.Resolve <IMvxMessenger>().SubscribeOnMainThread <ProgressMessage>(message =>
            {
                if (message.Sender != ViewModel)
                {
                    return;
                }

                if (message.IsShow)
                {
                    if (mProgressHud == null)
                    {
                        mProgressHud = new ProgressHUD()
                        {
                            ForceiOS6LookAndFeel = true
                        }
                    }
                    ;

                    mProgressHud.Show(message.Message, -1, message.IsAllowInteraction ? ProgressHUD.MaskType.None : ProgressHUD.MaskType.Clear);
                }
                else
                {
                    if (mProgressHud != null)
                    {
                        mProgressHud.Dismiss();
                        mProgressHud.Dispose();
                        mProgressHud = null;
                    }
                }
            });

            mAlertToken = Mvx.Resolve <IMvxMessenger>().SubscribeOnMainThread <AlertMessage>(message =>
            {
                if (message.Sender != ViewModel)
                {
                    return;
                }

                //TODO : use UIAlertView in iOS 7.x
                if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
                {
                    //  show alert view with more than 1 buttons (e.g OK and Cancel )
                    if (message.OtherTitles != null && message.OtherActions != null)
                    {
                        if (mAlertView == null)
                        {
                            mAlertView = new UIAlertView(message.Title, message.Message, null, message.CancelTitle);
                        }

                        if (message.OtherTitles.Length == message.OtherActions.Length)
                        {
                            foreach (var title in message.OtherTitles)
                            {
                                mAlertView.AddButton(title);
                            }
                        }
                        else
                        {
                            Console.WriteLine("Please check your message constructor");
                            return;
                        }

                        mAlertView.Clicked += (object sender, UIButtonEventArgs e) =>
                        {
                            if (e.ButtonIndex != 0)
                            {
                                message.OtherActions[(int)e.ButtonIndex - 1]();
                            }
                            else
                            {
                                if (message.CancelAction != null)
                                {
                                    message.CancelAction();
                                }
                            }
                        };

                        mAlertView.Dismissed += (object sender, UIButtonEventArgs e) =>
                        {
                            if (mAlertView != null)
                            {
                                mAlertView.Dispose();
                                mAlertView = null;
                            }
                        };

                        mAlertView.Show();
                    }
                    //this is just a normal alert view :)
                    else
                    {
                        if (mAlertView == null)
                        {
                            mAlertView = new UIAlertView(message.Title, message.Message, null, message.CancelTitle);
                        }

                        mAlertView.Clicked += (object sender, UIButtonEventArgs e) =>
                        {
                            if (message.CancelAction != null)
                            {
                                message.CancelAction();
                            }
                        };

                        mAlertView.Dismissed += (object sender, UIButtonEventArgs e) =>
                        {
                            if (mAlertView != null)
                            {
                                mAlertView.Dispose();
                                mAlertView = null;
                            }
                        };

                        mAlertView.Show();
                    }
                }
                else
                {
                    //show alert view with more than 1 buttons (e.g OK and Cancel )
                    if (message.OtherTitles != null && message.OtherActions != null)
                    {
                        UIAlertController alertController = UIAlertController.Create(message.Title, message.Message, UIAlertControllerStyle.Alert);
                        UIAlertAction cancelAction        = UIAlertAction.Create(message.CancelTitle, UIAlertActionStyle.Cancel,
                                                                                 action =>
                        {
                            if (message.CancelAction != null)
                            {
                                message.CancelAction();
                            }
                        });
                        alertController.AddAction(cancelAction);

                        if (message.OtherTitles.Length == message.OtherActions.Length)
                        {
                            for (int i = 0; i < message.OtherTitles.Length; i++)
                            {
                                UIAlertAction alertAction = UIAlertAction.Create(message.OtherTitles[i], UIAlertActionStyle.Default,
                                                                                 action =>
                                {
                                    if ((i - 1 >= 0) && (message.OtherActions[i - 1] != null))
                                    {
                                        message.OtherActions[i - 1]();
                                    }
                                });
                                alertController.AddAction(alertAction);
                            }
                        }
                        else
                        {
                            Console.WriteLine("Please check your message constructor");
                            return;
                        }

                        PresentViewController(alertController, true, null);
                    }
                    //this is just a normal alert view :)
                    else
                    {
                        UIAlertController alertController = UIAlertController.Create(message.Title, message.Message, UIAlertControllerStyle.Alert);
                        UIAlertAction cancelAction        = UIAlertAction.Create(message.CancelTitle, UIAlertActionStyle.Cancel,
                                                                                 action =>
                        {
                            if (message.CancelAction != null)
                            {
                                message.CancelAction();
                            }
                        });

                        alertController.AddAction(cancelAction);

                        PresentViewController(alertController, true, null);
                    }
                }
            });
        }
コード例 #3
0
 public override void ViewDidLoad()
 {
     base.ViewDidLoad();
     // Perform any additional setup after loading the view, typically from a nib.
     ProgressHUD.ShowHUDAddedTo(this.View, true);
 }