Esempio n. 1
0
        public async Task <MobileServiceUser> Authenticate()
        {
            var message = string.Empty;

            try
            {//tipo de ddato con el que le vamos a dar autenticacion al usuario MobileServiceAuthenticationProvider
                usuario = await imagenes.DetailPageBD.Cliente.LoginAsync(UIApplication.SharedApplication.KeyWindow.RootViewController, MobileServiceAuthenticationProvider.MicrosoftAccount, "https://tesh.azurewebsites.net/.auth/login/microsoftaccount/callback");

                if (usuario != null)
                {
                    message = string.Format("usuario autenticado {0}.", usuario.UserId);
                    //await new MessageDialog(usuario.UserId, "Bienvenido").ShowAsync();
                    //await new MessageDialog(user.MobileServiceAuthenticationToken, "Token").ShowAsync();
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                //await new MessageDialog(ex.Message, "Error Message").ShowAsync();
            }
            IUIAlertViewDelegate iUIAlert = null;
            //UIAlertView avAlert = new UIAlertView("resultado de autenticacion", message, null, "ok", null);
            UIAlertView avAlert = new UIAlertView("resultado de autenticacion", message, iUIAlert, "ok", null);

            avAlert.Show();
            return(usuario);
        }
 void TextField_EditingDidBegin(object sender, EventArgs e)
 {
     (sender as UITextField).ResignFirstResponder();
     alertViewDelegate            = new AlertViewDelegate(pdfViewerControl);
     alertView                    = new UIAlertView("Go To Page", "Enter Page Number (1 - " + pdfViewerControl.PageCount.ToString() + ")", alertViewDelegate, "Cancel", "Okay");
     alertView.BackgroundColor    = UIColor.White;
     alertView.Layer.BorderWidth  = 1;
     alertView.Layer.BorderColor  = new CoreGraphics.CGColor(0.2f, 0.2f);
     alertView.Layer.CornerRadius = 10;
     alertView.AlertViewStyle     = UIAlertViewStyle.PlainTextInput;
     (alertView.GetTextField(0) as UITextField).KeyboardType = UIKeyboardType.NumberPad;
     (alertView.GetTextField(0) as UITextField).BecomeFirstResponder();
     (alertView.GetTextField(0) as UITextField).ShouldReturn += (textField) => {
         int pageNum = 0;
         if (int.TryParse(alertView.GetTextField(0).Text, out pageNum) && pageNum > 0 && pageNum <= pdfViewerControl.PageCount)
         {
             pdfViewerControl.PageNumber = pageNum;
             return(true);
         }
         else if (alertView.GetTextField(0).Text != "")
         {
             return(true);
         }
         else
         {
             return(false);
         }
     };
     alertView.Show();
 }
Esempio n. 3
0
        public async Task <MobileServiceUser> Authenticate()
        {
            var message = string.Empty;

            try
            {
                usuario = await Tareas.DataPage.Cliente.LoginAsync(UIApplication.SharedApplication.KeyWindow.RootViewController, MobileServiceAuthenticationProvider.MicrosoftAccount, "tesh.azurewebsites.net");

                if (usuario != null)
                {
                    message = string.Format("USUARIO AUTENTICADO {0}.", usuario.UserId);

                    //await new MessageDialog(usuario.MobileServiceAuthenticationToken, "Token").ShowAsync();
                }
            }

            catch (Exception ex)
            {
                message = ex.Message;
            }
            IUIAlertViewDelegate iUIAlert = null;
            UIAlertView          avAlert  = new UIAlertView("Resultado de Autenticacion", message, iUIAlert, "ok", null);

            avAlert.Show();
            return(usuario);
        }
Esempio n. 4
0
        public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path)
        {
            if (Url == null)
            {
                base.Selected(dvc, tableView, path);
                return;
            }

            tableView.DeselectRow(path, false);
            if (loading)
            {
                return;
            }
            var cell    = GetActiveCell();
            var spinner = StartSpinner(cell);

            loading = true;

            var wc = new WebClient();

            wc.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs e){
                dvc.BeginInvokeOnMainThread(delegate {
                    loading = false;
                    spinner.StopAnimating();
                    spinner.RemoveFromSuperview();
                    if (e.Result != null)
                    {
                        try {
                            var obj = JsonValue.Load(new StringReader(e.Result)) as JsonObject;
                            if (obj != null)
                            {
                                var root   = JsonElement.FromJson(obj);
                                var newDvc = new DialogViewController(root, true)
                                {
                                    Autorotate = true
                                };
                                PrepareDialogViewController(newDvc);
                                dvc.ActivateController(newDvc);
                                return;
                            }
                        } catch (Exception ee) {
                            Console.WriteLine(ee);
                        }
                    }
                    IUIAlertViewDelegate avd = null;
                    var alert = new UIAlertView("Error", "Unable to download data", avd, "OK", null);
                    alert.Show();
                });
            };
            wc.DownloadStringAsync(new Uri(Url));
        }
Esempio n. 5
0
        public UIAlertView(string title, string message, IUIAlertViewDelegate del, string cancelButtonTitle, params string [] otherButtons)
            : this(title, message, del, cancelButtonTitle, otherButtons == null || otherButtons.Length == 0 ? IntPtr.Zero : new NSString(otherButtons [0]).Handle, IntPtr.Zero, IntPtr.Zero)
        {
            if (otherButtons == null)
            {
                return;
            }

            // first button, if present, was already added
            for (int i = 1; i < otherButtons.Length; i++)
            {
                AddButton(otherButtons [i]);
            }
        }
        private void ButtonCreateLocalAccount_TouchUpInside(object sender, EventArgs eArgs)
        {
            IUIAlertViewDelegate del = null;
            var alertView            = new UIAlertView(PowerPlannerResources.GetString("CreateAccountPage_String_WarningOfflineAccount"), PowerPlannerResources.GetString("CreateAccountPage_String_WarningOfflineAccountExplanation").Replace("Windows Phone", "other devices"), del, PowerPlannerResources.GetString("String_GoBack"), PowerPlannerResources.GetString("String_Create"));

            alertView.Clicked += (s, e) =>
            {
                if (e.ButtonIndex == 1)
                {
                    ViewModel.CreateLocalAccount();
                }
            };
            alertView.Show();
        }
Esempio n. 7
0
        public static void ConfirmDelete(string message, string title, Action deleteAction)
        {
            WeakReference <Action> weakAction = new WeakReference <Action>(deleteAction);
            IUIAlertViewDelegate   del        = null;
            var alertView = new UIAlertView(title, message, del, "Cancel", "Delete");

            alertView.Clicked += (s, e) =>
            {
                if (e.ButtonIndex == 1)
                {
                    // Use a weak reference otherwise the reference to the view model's delete action
                    // gets persisted and the view model doesn't dispose
                    if (weakAction.TryGetTarget(out Action delAction))
                    {
                        delAction();
                    }
                }
            };
            alertView.Show();
        }
Esempio n. 8
0
        public async Task<MobileServiceUser> Authenticate()
        {
            var message = string.Empty;
            try
            {
                usuario = await LithoFormas.Login.cliente.LoginAsync(UIApplication.SharedApplication.KeyWindow.RootViewController, MobileServiceAuthenticationProvider.MicrosoftAccount, "lithoformas.azurewebsites.net");
                if(usuario != null)
                {
                    message = string.Format("Iniciando sesion {0].", usuario.UserId);
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            IUIAlertViewDelegate iUAlert = null;
            UIAlertView avAlert = new UIAlertView("Resultado de autenticacion", message, iUAlert, null, "OK", null);
            avAlert.Show();
            return usuario;

        }
        private IOSMessageDialog(PortableMessageDialog dialog)
        {
            IUIAlertViewDelegate del = null;

            _alertView = new UIAlertView(dialog.Title, dialog.Content, del, "Ok", null);
        }
 public void ShowPopUp(string title, string message, IUIAlertViewDelegate del, string cancelButtonTitle, string[] otherButton)
 {
     alert = new UIAlertView(title, message, del, cancelButtonTitle, otherButton);
     alert.Show();
 }
Esempio n. 11
0
    private void ShowAlertBox()
    {
        IsDisplayed   = false;
        buttonClicked = -1;
        alert         = null;
        string cancelButton = "Cancel";

        string[] otherButtons = null;
        switch (button)
        {
        case MessageBoxButton.OK:
            cancelButton    = "";
            otherButtons    = new string[1];
            otherButtons[0] = "OK";
            break;

        case MessageBoxButton.OKCancel:
            otherButtons    = new string[1];
            otherButtons[0] = "OK";
            break;

        case MessageBoxButton.YesNo:
            cancelButton    = "";
            otherButtons    = new string[2];
            otherButtons[0] = "Yes";
            otherButtons[1] = "No";
            break;

        case MessageBoxButton.YesNoCancel:
            otherButtons    = new string[2];
            otherButtons[0] = "Yes";
            otherButtons[1] = "No";
            break;
        }
        IUIAlertViewDelegate d = null;

        if (cancelButton.Length > 0)
        {
            alert = new UIAlertView(caption, messageBoxText, d, cancelButton, otherButtons);
        }
        else
        {
            alert = new UIAlertView(caption, messageBoxText, d, null, otherButtons);
        }
        if (messageBoxText.Contains("\r\n"))
        {
            foreach (UIView v in alert.Subviews)
            {
                try
                {
                    UILabel l = (UILabel)v;
                    if (l.Text == messageBoxText)
                    {
                        l.TextAlignment = UITextAlignment.Left;
                    }
                }
                catch
                {
                    // Do nothing
                }
            }
        }
        alert.BackgroundColor = UIColor.FromWhiteAlpha(0f, 0.8f);
        alert.Canceled       += Canceled_Click;
        alert.Clicked        += Clicked_Click;
        alert.Dismissed      += Dismissed_Click;
        alert.Show();
        IsDisplayed = true;
    }
Esempio n. 12
0
 public override void GetLocation(Action <bool> action, bool isRefresh = false)
 {
     Actions.Add(action);
     if (!isRefresh && (!LastLatitude.Equals(0) || !LastLongitude.Equals(0)))
     {
         RaiseAppOnLocationChanged(true);
     }
     else
     {
         if (CLLocationManager.Status == CLAuthorizationStatus.Denied)
         {
             string title   = AppResources.LocationServicesOff;
             string message = AppResources.TurnOnLocationMessage;
             IUIAlertViewDelegate alertViewDelegate = null;
             UIAlertView          uiAlertView       = new UIAlertView(title, message, alertViewDelegate, AppResources.Cancel, new[] { AppResources.Settings });
             uiAlertView.Clicked += (sender, e) =>
             {
                 if (e.ButtonIndex == 1)
                 {
                     var settingsString = UIKit.UIApplication.OpenSettingsUrlString;
                     var url            = new NSUrl(settingsString);
                     UIApplication.SharedApplication.OpenUrl(url);
                 }
                 else
                 {
                     if (action != null)
                     {
                         action.Invoke(false);
                     }
                 }
             };
             uiAlertView.Show();
         }
         else
         {
             CLLocationManager locMgr = new CLLocationManager();
             locMgr.PausesLocationUpdatesAutomatically = false;
             if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
             {
                 locMgr.RequestAlwaysAuthorization();
             }
             if (UIDevice.CurrentDevice.CheckSystemVersion(9, 0))
             {
                 locMgr.AllowsBackgroundLocationUpdates = true;
             }
             if (CLLocationManager.LocationServicesEnabled)
             {
                 locMgr.DistanceFilter    = 5;
                 locMgr.LocationsUpdated += (object sender2, CLLocationsUpdatedEventArgs e2) =>
                 {
                     var location = e2.Locations.FirstOrDefault();
                     if (location != null)
                     {
                         this.LastLongitude = location.Coordinate.Longitude;
                         this.LastLatitude  = location.Coordinate.Latitude;
                         RaiseAppOnLocationChanged(true);
                     }
                 };
                 locMgr.StartUpdatingLocation();
             }
         }
     }
 }