public void StopAnimatings()
 {
     _ai.StopAnimating();
     _alert.DismissWithClickedButtonIndex(0, true);
     _alert.Hidden        = true;
     _ai.HidesWhenStopped = true;
 }
 public void RefreshTable(UIAlertView loading = null)
 {
     if (NetworkAvailable())
     {
         _parser.UpdatePublications(publications => InvokeOnMainThread(() => {
             TableView.Source = new PublicationsViewSource(publications, NavigationController);
             TableView.ReloadData();
             if (loading != null)
             {
                 loading.DismissWithClickedButtonIndex(0, true);
             }
         }), state => InvokeOnMainThread(() => {
             var alert = new UIAlertView("Error".t(), "ErrorMessage".t(), null, "Ok", null);
             //alert.Clicked += (sender, e) => UIApplication.SharedApplication.PerformSelector(new Selector("terminateWithSuccess"), null, 0f);
             alert.Show();
         }));
     }
     else
     {
         var publications = _parser.Publications;
         TableView.Source = new PublicationsViewSource(publications, NavigationController);
         TableView.ReloadData();
         if (loading != null)
         {
             loading.DismissWithClickedButtonIndex(0, true);
         }
     }
     RefreshControl.EndRefreshing();
 }
Esempio n. 3
0
 public void dispose()
 {
     // dismiss with button clicked so if invoked on another thread we don't die for some reason
     myAlert.DismissWithClickedButtonIndex(0, true);
     myAlert.Dispose();
     myAlert = null;
 }
Esempio n. 4
0
		async Task<bool> SignIn()
		{
			var tcs = new TaskCompletionSource<bool> ();
			var alert = new UIAlertView ("Please sign in", "", null, "Cancel", "Ok");
			alert.AlertViewStyle = UIAlertViewStyle.SecureTextInput;
			var tb = alert.GetTextField(0);
			tb.ShouldReturn = (t)=>{

				alert.DismissWithClickedButtonIndex(1,true);
				signIn(tcs,tb.Text);
				return true;
			};

			alert.Clicked += async (object sender, UIButtonEventArgs e) => {
				if(e.ButtonIndex == 0)
				{
					tcs.TrySetResult(false);
					alert.Dispose();
					return;
				}

				var id = tb.Text;
				signIn(tcs,id);
			
			
			};
			alert.Show ();
			return await tcs.Task;
		}
Esempio n. 5
0
        private async void SaveButton_Click(object sender, EventArgs ea)
        {
            var waitingOverlay = new WaitingOverlay(UIScreen.MainScreen.Bounds, "Saving...");

            View.Add(waitingOverlay);

            Bindings.UpdateSourceForLastView();
            this.Model.ApplyEdit();
            try
            {
                //this.Model.GetBrokenRules();
                this.Model = await this.Model.SaveAsync();

                var alert = new UIAlertView();
                alert.Message = "Saved...";
                alert.AddButton("Close");
                alert.DismissWithClickedButtonIndex(0, false);
                alert.Show();
            }
            catch (Exception ex)
            {
                var alert = new UIAlertView();
                alert.Message = string.Format("the following error has occurred: {0}", ex.Message);
                alert.AddButton("Close");
                alert.DismissWithClickedButtonIndex(0, false);
                alert.Show();
            }
            finally
            {
                InitializeBindings(this.Model);
                waitingOverlay.Hide();
            }
        }
Esempio n. 6
0
        private async void DeleteButton_Click(object sender, EventArgs ea)
        {
            var waitingOverlay = new WaitingOverlay(UIScreen.MainScreen.Bounds, "Deleting...");

            View.Add(waitingOverlay);

            try
            {
                this.Model.Delete();
                this.Model.ApplyEdit();
                var returnModel = await this.Model.SaveAsync();

                InitializeBindings(returnModel);
            }
            catch (Exception ex)
            {
                var alert = new UIAlertView();
                alert.Message = string.Format("the following error has occurred: {0}", ex.Message);
                alert.AddButton("Close");
                alert.DismissWithClickedButtonIndex(0, false);
                alert.Show();
            }
            finally
            {
                waitingOverlay.Hide();
            }
        }
Esempio n. 7
0
        public static void ShowProgressDialog(string title, string message, Action action) {
            UIAlertView dialog = new UIAlertView(title, message, null, null);
            dialog.Show();
			_indicatorViewLeftCorner.Hidden = false;
            action();
            dialog.DismissWithClickedButtonIndex(0, true);
        }
Esempio n. 8
0
        partial void SaveItem(UIBarButtonItem sender)
        {
            var name = nameField.Text;

            if (string.IsNullOrEmpty(name))
            {
                var alert = new UIAlertView("Error", "Name can not be empty", null, "Dismiss", null);
                alert.DismissWithClickedButtonIndex(0, false);
                alert.Show();
                return;
            }
            var client = FHSyncClient.GetInstance();

            if (Item == null)
            {
                client.Create(RootViewController.DatasetId, new ShoppingItem(name));
            }
            else
            {
                Item.Name = name;
                client.Update(RootViewController.DatasetId, Item);
            }

            Navigate();
        }
Esempio n. 9
0
        public static void ShowProgressDialog(string title, string message, Action action, Action finalize)
        {
            UIAlertView dialog = new UIAlertView(title, message, null, null);

            dialog.Show();
            _indicatorViewLeftCorner.Hidden = false;

            ThreadPool.QueueUserWorkItem(delegate
            {
                // Run the given Async task
                action();

                // Run the completion handler on the UI thread and remove the spinner
                using (var pool = new NSAutoreleasePool())
                {
                    try
                    {
                        pool.InvokeOnMainThread(() =>
                        {
                            dialog.DismissWithClickedButtonIndex(0, true);

                            _indicatorViewLeftCorner.Hidden = true;
                            finalize();
                        });
                    }
                    catch (Exception ex) {
                        Insights.Report(ex);
                    }
                }
            });
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _client = new TwitterClient();

            var loading = new UIAlertView("Downloading Tweets", "Please wait...", null, null, null);
            loading.Show();

            var indicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge);
            indicator.Center = new System.Drawing.PointF(loading.Bounds.Width / 2, loading.Bounds.Size.Height - 40);
            indicator.StartAnimating();
            loading.AddSubview (indicator);

            _client.GetTweetsForUser ("OReillyMedia", tweets =>
            {
                InvokeOnMainThread(() =>
              	{
                    TableView.Source = new TwitterTableViewSource(tweets);
                    TableView.ReloadData();
                    loading.DismissWithClickedButtonIndex (0, true);
                });
            });

            _client.MentionReceived += (object sender, MentionEventArgs args) =>
            {
                InvokeOnMainThread(() =>
                    new UIAlertView("Mention Received", args.Tweet.Text,
                                    null, "Ok", null).Show());
            };
        }
Esempio n. 11
0
        public Task <string> PromptTextBox(string title, string message, string defaultValue, string okTitle)
        {
            var tcs   = new TaskCompletionSource <string>();
            var alert = new UIAlertView();

            alert.Title          = title;
            alert.Message        = message;
            alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
            var cancelButton = alert.AddButton("Cancel".t());
            var okButton     = alert.AddButton(okTitle);

            alert.CancelButtonIndex = cancelButton;
            alert.DismissWithClickedButtonIndex(cancelButton, true);
            alert.GetTextField(0).Text = defaultValue;
            alert.Clicked += (s, e) =>
            {
                if (e.ButtonIndex == okButton)
                {
                    tcs.SetResult(alert.GetTextField(0).Text);
                }
                else
                {
                    tcs.SetCanceled();
                }
            };
            alert.Show();
            return(tcs.Task);
        }
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            Title = PlayerOption == PlayerOption.Stream ? "Stream " : "Stream & Save";
            playPauseButton.TitleLabel.Text = "Pause";
            timeLabel.Text = string.Empty;

            // Create a shared intance session & check
            var session = AVAudioSession.SharedInstance();

            if (session == null)
            {
                var alert = new UIAlertView("Playback error", "Unable to playback stream", null, "Cancel");
                alert.Show();
                alert.Clicked += (object sender, UIButtonEventArgs e) => alert.DismissWithClickedButtonIndex(0, true);
            }
            else
            {
                StartPlayback();
                IsPlaying = true;

                // Set up the session for playback category
                NSError error;
                session.SetCategory(new NSString("AVAudioSessionCategoryPlayback"), AVAudioSessionCategoryOptions.DefaultToSpeaker, out error);
                session.OverrideOutputAudioPort(AVAudioSessionPortOverride.Speaker, out error);
            }
        }
Esempio n. 13
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _client = new TwitterClient();

            var loading = new UIAlertView("Downloading Tweets", "Please wait...", null, null, null);

            loading.Show();

            var indicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge);

            indicator.Center = new System.Drawing.PointF(loading.Bounds.Width / 2, loading.Bounds.Size.Height - 40);
            indicator.StartAnimating();
            loading.AddSubview(indicator);

            _client.GetTweetsForUser("OReillyMedia", tweets =>
            {
                InvokeOnMainThread(() =>
                {
                    TableView.Source = new TwitterTableViewSource(tweets);
                    TableView.ReloadData();
                    loading.DismissWithClickedButtonIndex(0, true);
                });
            });

            _client.MentionReceived += (object sender, MentionEventArgs args) =>
            {
                InvokeOnMainThread(() =>
                                   new UIAlertView("Mention Received", args.Tweet.Text,
                                                   null, "Ok", null).Show());
            };
        }
Esempio n. 14
0
        public static void ShowProgressDialog(string title, string message, Action action, Action finalize) {
            UIAlertView dialog = new UIAlertView(title, message, null, null);

            dialog.Show();
			_indicatorViewLeftCorner.Hidden = false;

            ThreadPool.QueueUserWorkItem(delegate
            {
                // Run the given Async task
                action();

                // Run the completion handler on the UI thread and remove the spinner
                using (var pool = new NSAutoreleasePool())
                {
                    try
                    {
                        pool.InvokeOnMainThread(() =>
                        {
                            dialog.DismissWithClickedButtonIndex(0, true);

							_indicatorViewLeftCorner.Hidden = true;
                            finalize();
                      });
                    }
					catch (Exception ex){
						Insights.Report(ex);
                    }
                }
            });

        }
Esempio n. 15
0
 public void RemoveAllAlerts()
 {
     if (_currentAlert != null)
     {
         _currentAlert.DismissWithClickedButtonIndex(_currentAlert.CancelButtonIndex, false);
     }
 }
Esempio n. 16
0
        async Task <bool> SignIn()
        {
            var tcs   = new TaskCompletionSource <bool> ();
            var alert = new UIAlertView("Please sign in", "", null, "Cancel", "Ok");

            alert.AlertViewStyle = UIAlertViewStyle.SecureTextInput;
            var tb = alert.GetTextField(0);

            tb.ShouldReturn = (t) => {
                alert.DismissWithClickedButtonIndex(1, true);
                signIn(tcs, tb.Text);
                return(true);
            };

            alert.Clicked += async(object sender, UIButtonEventArgs e) => {
                if (e.ButtonIndex == 0)
                {
                    tcs.TrySetResult(false);
                    alert.Dispose();
                    return;
                }

                var id = tb.Text;
                signIn(tcs, id);
            };
            alert.Show();
            return(await tcs.Task);
        }
Esempio n. 17
0
 private static void PlatformCancel(int?result)
 {
     tcs.SetResult(result);
     UIApplication.SharedApplication.InvokeOnMainThread(delegate
     {
         alert.DismissWithClickedButtonIndex(0, true);
     });
 }
Esempio n. 18
0
 public void Dispose()
 {
     alertController?.Dispose();
     alertView?.DismissWithClickedButtonIndex(alertView.CancelButtonIndex, true);
     alertView?.Dispose();
     tcs?.TrySetCanceled();
     tcs = null;
 }
Esempio n. 19
0
 public void InviteDidCancel(Twilio.Conversations.TwilioConversationsClient conversationsClient, Twilio.Conversations.IncomingInvite invite)
 {
     if (alertView != null)
     {
         alertView.DismissWithClickedButtonIndex(alertView.CancelButtonIndex, true);
         incomingInvite = null;
     }
 }
Esempio n. 20
0
        public async override void DisplayToast(MessageDisplayParams messageParams, bool quick)
        {
            var alert = new UIAlertView(string.Empty, messageParams.Message, null, null, null);
            alert.Show();

            await Task.Delay(quick ? ShortToastDuration : LongToastDuration);
            alert.DismissWithClickedButtonIndex(0, true);
        }
Esempio n. 21
0
 public void StopListening()
 {
     pocketSphinxController.StopListening();
     UIApplication.SharedApplication.InvokeOnMainThread(() =>
     {
         _questionAlert?.DismissWithClickedButtonIndex(0, true);
     });
 }
 protected void StopActivityAnimation()
 {
     if (activityAlert != null)
     {
         activityAlert.DismissWithClickedButtonIndex(0, true);
         activityAlert = null;
     }
 }
Esempio n. 23
0
        /*public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
         * {
         *      ProcessNotification(userInfo, false);
         * }*/

        void ProcessNotification(NSDictionary options, bool fromFinishedLaunching, UIApplicationState appState)
        {
            // Check to see if the dictionary has the aps key.  This is the notification payload you would have sent
            if (null != options && options.ContainsKey(new NSString("aps")))
            {
                //Get the aps dictionary
                NSDictionary aps = options.ObjectForKey(new NSString("aps")) as NSDictionary;

                string alert = string.Empty;

                //Extract the alert text
                //NOTE: If you're using the simple alert by just specifying "  aps:{alert:"alert msg here"}  "
                //this will work fine.  But if you're using a complex alert with Localization keys, etc.,
                //your "alert" object from the aps dictionary will be another NSDictionary... Basically the
                //json gets dumped right into a NSDictionary, so keep that in mind
                if (aps.ContainsKey(new NSString("alert")))
                {
                    alert = (aps [new NSString("alert")] as NSString).ToString();

                    int tripid = -1;
                    if (aps.ContainsKey(new NSString("tripid")))
                    {
                        tripid = (aps [new NSString("tripid")] as NSNumber).IntValue;
                    }


                    //If this came from the ReceivedRemoteNotification while the app was running,
                    // we of course need to manually process things like the sound, badge, and alert.
                    if (!fromFinishedLaunching)
                    {
                        //Manually show an alert
                        if (!string.IsNullOrEmpty(alert))
                        {
                            if (NotificationAlertView != null)
                            {
                                NotificationAlertView.DismissWithClickedButtonIndex(0, false);
                            }

                            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("app_action", "notifications", "alert", null).Build());

                            NotificationAlertView = new UIAlertView("Notification", alert, null, "OK", null);
                            NotificationAlertView.Show();
                        }
                    }
                }

                if (aps.ContainsKey(new NSString("content-available")))
                {
                    GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("app_action", "notifications", "content-available", null).Build());
                    //TODO get list of times to send location
                    //backgroundTaskId = UIApplication.SharedApplication.BeginBackgroundTask( () => {});
                    DurationToSendLocation_Sec = (aps [new NSString("content-available")] as NSNumber).IntValue;
                    //NSTimer locationTimer = NSTimer.CreateScheduledTimer (TimeSpan.FromSeconds (60), delegate {
                    MonitorLocation(appState);
                    //});
                }
            }
        }
Esempio n. 24
0
        private void DownloadCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            UIApplication.SharedApplication.BeginInvokeOnMainThread(() => {
                UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;

                mAlert.DismissWithClickedButtonIndex(0, true);

                if (e.Error != null)
                {
                    DisplayError("Warning", "The rss feed could not be downloaded: " + e.Error.Message);
                }
                else
                {
                    try
                    {
                        //clear the selected items
                        this.GridView.ClearSelectedItems();

                        //Clear the rows
                        mDatasource.ClearRows();
                        mDatasource.Apps.Clear();

                        foreach (var v in RssParser.Parse(e.Result))
                        {
                            mDatasource.Apps.Add(v);
                        }

                        mAlert = new UIAlertView("Fetching Icons...", "", null, null, null);
                        mAlert.Show();
                        UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;

                        Task.Run(() => {
                            foreach (var anApp in mDatasource.Apps)
                            {
                                byte[] data = null;

                                using (var c = new GzipWebClient())
                                {
                                    data = c.DownloadData(anApp.ImageUrl);
                                }


                                anApp.Image = UIImage.LoadFromData(NSData.FromArray(data));
                            }
                        }).ContinueWith(prevTask => {
                            mAlert.DismissWithClickedButtonIndex(0, true);
                            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;

                            GridView.ReloadData();
                        }, CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.FromCurrentSynchronizationContext());
                    }
                    catch
                    {
                        DisplayError("Warning", "Malformed Xml was found in the Rss Feed.");
                    }
                }
            });
        }
Esempio n. 25
0
        public async void showRecordingToast(string recordingMessage)
        {
            UIAlertView messageBox = new UIAlertView(recordingMessage, null, null, null);

            messageBox.Show();
            await Task.Delay(TimeSpan.FromSeconds(1));

            messageBox.DismissWithClickedButtonIndex(0, true);
        }
Esempio n. 26
0
        public static void ShowAlert(string title, string message)
        {
            var alert = new UIAlertView {
                Title = title, Message = message
            };

            alert.DismissWithClickedButtonIndex(alert.AddButton("Ok"), true);
            alert.Show();
        }
Esempio n. 27
0
 public static void HideBlockingProgressDialog()
 {
     if (blockingDialog != null)
     {
         blockingDialog.DismissWithClickedButtonIndex(0, true);
         blockingDialog = null;
     }
     _indicatorViewLeftCorner.Hidden = true;
 }
Esempio n. 28
0
        private void CancelAlert()
        {
            if (_Alert == null)
            {
                return;
            }

            Utilities.Dispatch(() => _Alert.DismissWithClickedButtonIndex(-1, true));
        }
Esempio n. 29
0
        public static void ShowProgressDialog(string title, string message, Action action)
        {
            UIAlertView dialog = new UIAlertView(title, message, null, null);

            dialog.Show();
            _indicatorViewLeftCorner.Hidden = false;
            action();
            dialog.DismissWithClickedButtonIndex(0, true);
        }
Esempio n. 30
0
        private static void PlatformCancel(string result)
        {
            if (!tcs.Task.IsCompleted)
            {
                tcs.SetResult(result);
            }

            UIApplication.SharedApplication.InvokeOnMainThread(delegate
            {
                alert.DismissWithClickedButtonIndex(0, true);
            });
        }
Esempio n. 31
0
        public static void ShowAlert(string title, string message, Action dismissed = null)
        {
            var alert = new UIAlertView {
                Title = title, Message = message
            };

            alert.DismissWithClickedButtonIndex(alert.AddButton("Ok".t()), true);
            if (dismissed != null)
            {
                alert.Dismissed += (sender, e) => dismissed();
            }
            alert.Show();
        }
		public void CheckResult(IList<string> matches)
		{
			var answer = MappingService.DetectAnswer(matches);

			_error.DismissWithClickedButtonIndex(0, true);
			                                                   
			if (answer != AnswerType.Unknown)
			{
				TextToSpeechService.Speak($"Your answer is {answer.ToString()}", false).ConfigureAwait(false);
				_recognitionTask.TrySetResult(answer == AnswerType.Positive);
			}
			else
                AskQuestionMethod(Question);
		}
Esempio n. 33
0
        public static void Show(string message, int timeout)
        {
            var timer = new System.Timers.Timer (timeout);
            var alert = new UIAlertView{ Message = message };

            timer.Elapsed += delegate {
                timer.Stop ();
                alert.InvokeOnMainThread (delegate {
                    alert.DismissWithClickedButtonIndex (0, animated:true);
                });
            };
            alert.Show ();
            timer.Start ();
        }
Esempio n. 34
0
 public void Confirm(string title, string text, Action<int> callback, string button1 = "Отмена", string button2 = "ОК")
 {
     UIAlertView alert = new UIAlertView(title, text, null,
         NSBundle.MainBundle.LocalizedString (button1, button1),
         NSBundle.MainBundle.LocalizedString (button2, button2));
     alert.Show ();
     alert.Clicked += (sender, buttonArgs) =>  {
         if(buttonArgs.ButtonIndex == 0)
         {
             alert.DismissWithClickedButtonIndex(0, false);
         }
         callback.Invoke((int)(buttonArgs.ButtonIndex));
     };
 }
Esempio n. 35
0
        void prepareAudioUnit()
        {
            // Updated for deprecated AudioSession
            var     session = AVAudioSession.SharedInstance();
            NSError error;

            if (session == null)
            {
                var alert = new UIAlertView("Session error", "Unable to create audio session", null, "Cancel");
                alert.Show();
                alert.Clicked += delegate
                {
                    alert.DismissWithClickedButtonIndex(0, true);
                    return;
                };
            }
            session.SetActive(true);
            session.SetCategory(AVAudioSessionCategory.PlayAndRecord);
            session.SetPreferredIOBufferDuration(0.005, out error);

            // Getting AudioComponent Remote output
            _audioComponent = AudioComponent.FindComponent(AudioTypeOutput.Remote);

            // creating an audio unit instance
            _audioUnit = new AudioUnit(_audioComponent);

            // turning on microphone
            _audioUnit.SetEnableIO(true,
                                   AudioUnitScopeType.Input,
                                   1 // Remote Input
                                   );

            // setting audio format
            _audioUnit.SetAudioFormat(_dstFormat,
                                      AudioUnitScopeType.Input,
                                      0 // Remote Output
                                      );

            var format = AudioStreamBasicDescription.CreateLinearPCM(_sampleRate, bitsPerChannel: 32);

            format.FormatFlags = AudioStreamBasicDescription.AudioFormatFlagsNativeFloat;
            _audioUnit.SetAudioFormat(format, AudioUnitScopeType.Output, 1);

            // setting callback method
            _audioUnit.SetRenderCallback(_audioUnit_RenderCallback, AudioUnitScopeType.Global);

            _audioUnit.Initialize();
            _audioUnit.Start();
        }
Esempio n. 36
0
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();

            if (Initialized)
            {
                return;
            }
            Initialized = true;

            this.View = new MainView();

            // create binding manager
            Bindings = new BindingManager(this.View);

            ((MainView)this.View).btnSave.TouchUpInside          += SaveButton_Click;
            ((MainView)this.View).btnCancel.TouchUpInside        += CancelButton_Click;
            ((MainView)this.View).btnMarkForDelete.TouchUpInside += DeleteButton_Click;

            ((MainView)this.View).txtName.ShouldReturn += (textField) =>
            {
                textField.ResignFirstResponder();
                return(true);
            };

            var waitingOverlay = new WaitingOverlay(UIScreen.MainScreen.Bounds, "Loading...");

            View.Add(waitingOverlay);

            try
            {
                this.Model = await CustomerEdit.GetCustomerEditAsync(1);

                InitializeBindings(this.Model);
            }
            catch (Exception ex)
            {
                var alert = new UIAlertView();
                alert.Message = string.Format("the following error has occurred: {0}", ex.Message);
                alert.AddButton("Close");
                alert.DismissWithClickedButtonIndex(0, false);
                alert.Show();
            }
            finally
            {
                waitingOverlay.Hide();
            }
        }
Esempio n. 37
0
 public static void Hide()
 {
     if (alert != null)
     {
         try
         {
             alert.Dismissed -= HandleDismissed;
             alert.DismissWithClickedButtonIndex(0, true);
             alert = null;
         }
         catch (Exception ex)
         {
             Logger.WriteLineDebugging("eBriefingViewController - LoadingView: {0}", ex.ToString());
         }
     }
 }
Esempio n. 38
0
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();

            if (Initialized) return;
            Initialized = true;

            this.View = new MainView();

            // create binding manager
            Bindings = new BindingManager(this.View);

            ((MainView)this.View).btnSave.TouchUpInside += SaveButton_Click;
            ((MainView)this.View).btnCancel.TouchUpInside += CancelButton_Click;
            ((MainView)this.View).btnMarkForDelete.TouchUpInside += DeleteButton_Click;

            ((MainView)this.View).txtName.ShouldReturn += (textField) =>
            {
              textField.ResignFirstResponder();
              return true;
            };

            var waitingOverlay = new WaitingOverlay(UIScreen.MainScreen.Bounds, "Loading...");
            View.Add(waitingOverlay);

            try
            {
                this.Model = await CustomerEdit.GetCustomerEditAsync(1);
                InitializeBindings(this.Model);
            }
            catch (Exception ex)
            {
                var alert = new UIAlertView();
                alert.Message = string.Format("the following error has occurred: {0}", ex.Message);
                alert.AddButton("Close");
                alert.DismissWithClickedButtonIndex(0, false);
                alert.Show();
            }
            finally
            {
                waitingOverlay.Hide();
            }
        }
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear (animated);

            _client = new RemoteDataRepository (_baseUrl);

            var loading = new UIAlertView ("Downloading Session", "Please wait...", null, null, null);

            loading.Show ();

            var indicator = new UIActivityIndicatorView (UIActivityIndicatorViewStyle.WhiteLarge);
            indicator.Center = new System.Drawing.PointF (loading.Bounds.Width / 2, loading.Bounds.Size.Height - 40);
            indicator.StartAnimating ();
            loading.AddSubview (indicator);

            _client.GetSession ("CodeMash-2012", this.SessionSlug, session =>
            {
                InvokeOnMainThread (() =>
                {
                    //new UIAlertView ("Session", session.title, null, "Ok", null).Show ();
                    this.sessionTitleLabel.Text = session.title;
                    this.sessionEndLabel.Text = session.end.ToString ();
                    this.sessionStartLabel.Text = session.start.ToString();
                    this.sessionTwitterHashTagLabel.Text = session.twitterHashTag;
                    loading.DismissWithClickedButtonIndex (0, true);
                }
                );
            }
            );

            // Perform any additional setup after loading the view, typically from a nib.

            //this.TableView.Source = new DataSource (this);

            //			if (!UserInterfaceIdiomIsPhone) {
            //				this.TableView.SelectRow (
            //					NSIndexPath.FromRowSection (0, 0),
            //					false,
            //					UITableViewScrollPosition.Middle
            //				);
            //			}
        }
 public Task<string> PromptTextBox(string title, string message, string defaultValue, string okTitle)
 {
     var tcs = new TaskCompletionSource<string>();
     var alert = new UIAlertView();
     alert.Title = title;
     alert.Message = message;
     alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
     var cancelButton = alert.AddButton("Cancel".t());
     var okButton = alert.AddButton(okTitle);
     alert.CancelButtonIndex = cancelButton;
     alert.DismissWithClickedButtonIndex(cancelButton, true);
     alert.GetTextField(0).Text = defaultValue;
     alert.Clicked += (s, e) =>
     {
         if (e.ButtonIndex == okButton)
             tcs.SetResult(alert.GetTextField(0).Text);
         else
             tcs.SetCanceled();
     };
     alert.Show();
     return tcs.Task;
 }
		public override void ViewWillAppear (bool animated)
		{
			base.ViewWillAppear (animated);
			Title = PlayerOption == PlayerOption.Stream ? "Stream " : "Stream & Save";
			playPauseButton.TitleLabel.Text = "Pause";
			timeLabel.Text = string.Empty;

			// Create a shared intance session & check
			var session = AVAudioSession.SharedInstance ();
			if (session == null) {
				var alert = new UIAlertView ("Playback error", "Unable to playback stream", null, "Cancel");
				alert.Show ();
				alert.Clicked += (object sender, UIButtonEventArgs e) => alert.DismissWithClickedButtonIndex (0, true);
			} else {
				StartPlayback ();
				IsPlaying = true;

				// Set up the session for playback category
				NSError error;
				session.SetCategory (AVAudioSessionCategory.Playback, AVAudioSessionCategoryOptions.DefaultToSpeaker);
				session.OverrideOutputAudioPort (AVAudioSessionPortOverride.Speaker, out error);
			}
		}
        public void PlayAudio(byte[] audioRecording, string fileExtension)
        {
            if (_player != null)
            {
                _player.Dispose();
                _player = null;
            }
            var session = AVAudioSession.SharedInstance();
            if (session == null || audioRecording == null)
            {
                var alert = new UIAlertView("Playback error", "Unable to playback stream", null, "Cancel");
                alert.Show();
                alert.Clicked += (object senderObj, UIButtonEventArgs arg) => alert.DismissWithClickedButtonIndex(0, true);
            }
            else
            {
                NSError error;
                ObjCRuntime.Class.ThrowOnInitFailure = false;
                session.SetCategory(AVAudioSessionCategory.Playback);
                session.SetActive(true, out error);
                var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                var temp = Path.Combine(documents, "..", "tmp");
                _tempAudioFile = Path.Combine(temp, Guid.NewGuid() + fileExtension);
                File.WriteAllBytes(_tempAudioFile, audioRecording);
                using (var url = new NSUrl(_tempAudioFile))
                {
                    _player = AVAudioPlayer.FromUrl(url, out error);
                }

                _player.Volume = 1.0f;
                _player.NumberOfLoops = 0;
                _player.FinishedPlaying += player_FinishedPlaying;
                _player.PrepareToPlay();
                _player.Play();
            }
        }
Esempio n. 43
0
 public static void ShowAlert(string title, string message, Action dismissed = null)
 {
     var alert = new UIAlertView {Title = title, Message = message};
     alert.DismissWithClickedButtonIndex(alert.AddButton("Ok".t()), true);
     if (dismissed != null)
         alert.Dismissed += (sender, e) => dismissed();
     alert.Show();
 }
Esempio n. 44
0
 public static void ShowAlert(string title, string message)
 {
     var alert = new UIAlertView {Title = title, Message = message};
     alert.DismissWithClickedButtonIndex(alert.AddButton("Ok"), true);
     alert.Show();
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            var backgroundImage = UIImage.FromBundle(@"images/appview/bg");
            //this.View.BackgroundColor = UIColor.FromPatternImage(backgroundImage);

            _client = new RemoteDataRepository (_baseUrl);

            var loading = new UIAlertView (" Downloading Sessions", "Please wait...", null, null, null);

            loading.Show ();

            var indicator = new UIActivityIndicatorView (UIActivityIndicatorViewStyle.WhiteLarge);
            indicator.Center = new System.Drawing.PointF (loading.Bounds.Width / 2, loading.Bounds.Size.Height - 40);
            indicator.StartAnimating ();
            loading.AddSubview (indicator);

            //			_client.GetFullConference("CodeMash-2012", conference => {
            //				var connectionString = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments), "conferences.db");
            //				var localDatabase = new LocalDatabase(connectionString);
            //				localDatabase.CreateDatabase();
            //
            //				var conferenceMapper = new ConferenceDtoToConferenceEntityMapper();
            //				var conferenceEntity = conferenceMapper.Map(conference);
            //
            //				var sessionMapper = new SessionDtoToSessionEntityMapper();
            //				var sessions = sessionMapper.MapAll(conferenceEntity.Id, conference.sessions.AsEnumerable());
            //				//localDatabase.SaveSessions(sessions);
            //
            //				var speakersMapper = new SessionDtoToSessionEntityMapper();
            //				var speakerEntities = speakersMapper.MapAll(conferenceEntity.Id, conference.speakers.AsEnumerable());
            //				localDatabase.SaveConference(conferenceEntity, sessions, speakers);
            //
            //			});
            _client.GetSessions ("CodeMash-2012", sessions =>
            {
                InvokeOnMainThread (() =>
                {
                    TableView.Source = new SessionsTableViewSource (this, sessions);
                    TableView.ReloadData ();
                    loading.DismissWithClickedButtonIndex (0, true);
                });
            }
            );

            // Perform any additional setup after loading the view, typically from a nib.

            //this.TableView.Source = new DataSource (this);

            if (!UserInterfaceIdiomIsPhone)
                this.TableView.SelectRow (
                    NSIndexPath.FromRowSection (0, 0),
                    false,
                    UITableViewScrollPosition.Middle
                );
        }
        void prepareAudioUnit()
        {
            // Updated for deprecated AudioSession
            var session = AVAudioSession.SharedInstance();
            NSError error;

            if (session == null)
            {
                var alert = new UIAlertView("Session error", "Unable to create audio session", null, "Cancel");
                alert.Show();
                alert.Clicked += delegate
                {
                    alert.DismissWithClickedButtonIndex(0, true);
                    return;
                };
            }
            session.SetActive(true);
            session.SetCategory(AVAudioSessionCategory.PlayAndRecord);
            session.SetPreferredIOBufferDuration(0.005, out error);    

            // Getting AudioComponent Remote output 
            _audioComponent = AudioComponent.FindComponent(AudioTypeOutput.Remote);

            // creating an audio unit instance
            _audioUnit = new AudioUnit(_audioComponent);

            // turning on microphone
            _audioUnit.SetEnableIO(true,
                AudioUnitScopeType.Input,
                1 // Remote Input
            );

            // setting audio format
            _audioUnit.SetAudioFormat(_dstFormat, 
                AudioUnitScopeType.Input, 
                0 // Remote Output
            );  

            var format = AudioStreamBasicDescription.CreateLinearPCM(_sampleRate, bitsPerChannel: 32);
            format.FormatFlags = AudioStreamBasicDescription.AudioFormatFlagsNativeFloat;
            _audioUnit.SetAudioFormat(format, AudioUnitScopeType.Output, 1);

            // setting callback method
            _audioUnit.SetRenderCallback(_audioUnit_RenderCallback, AudioUnitScopeType.Global);

            _audioUnit.Initialize();
            _audioUnit.Start();
        }
Esempio n. 47
0
        private async void SaveButton_Click(object sender, EventArgs ea)
        {
            var waitingOverlay = new WaitingOverlay(UIScreen.MainScreen.Bounds, "Saving...");
            View.Add(waitingOverlay);

            Bindings.UpdateSourceForLastView();
            this.Model.ApplyEdit();
            try
            {
                //this.Model.GetBrokenRules();
                this.Model = await this.Model.SaveAsync();
                
                var alert = new UIAlertView();
                alert.Message = "Saved...";
                alert.AddButton("Close");
                alert.DismissWithClickedButtonIndex(0, false);
                alert.Show();
            }
            catch (Exception ex)
            {
                var alert = new UIAlertView();
                alert.Message = string.Format("the following error has occurred: {0}", ex.Message);
                alert.AddButton("Close");
                alert.DismissWithClickedButtonIndex(0, false);
                alert.Show();
            }
            finally
            {
                InitializeBindings(this.Model);
                waitingOverlay.Hide();
            }
        }
Esempio n. 48
0
        private async void DeleteButton_Click(object sender, EventArgs ea)
        {
            var waitingOverlay = new WaitingOverlay(UIScreen.MainScreen.Bounds, "Deleting...");
            View.Add(waitingOverlay);

            try
            {
                this.Model.Delete();
                this.Model.ApplyEdit();
                var returnModel = await this.Model.SaveAsync();
                InitializeBindings(returnModel);
            }
            catch (Exception ex)
            {
                var alert = new UIAlertView();
                alert.Message = string.Format("the following error has occurred: {0}", ex.Message);
                alert.AddButton("Close");
                alert.DismissWithClickedButtonIndex(0, false);
                alert.Show();
            }
            finally
            {
                waitingOverlay.Hide();
            }
        }
		private void AttachSocketEvents (UIAlertView alert)
		{
			// Whenever the server emits "login", log the login message
			socket.On ("login", data => {
				if (alert != null) {
					InvokeOnMainThread (() => alert.DismissWithClickedButtonIndex (0, true));
					alert = null;
				}

				var d = Data.FromData (data);
				connected = true;
				// Display the welcome message
				AddMessage ("Welcome to Socket.IO Chat – ", true);
				AddParticipantsMessage (d.numUsers);
			});
			// Whenever the server emits "new message", update the chat body
			socket.On ("new message", data => {
				var d = Data.FromData (data);
				AddMessage (d.message, username: d.username);
			});
			// Whenever the server emits "user joined", log it in the chat body
			socket.On ("user joined", data => {
				var d = Data.FromData (data);
				AddMessage (d.username + " joined");
				AddParticipantsMessage (d.numUsers);
			});
			// Whenever the server emits "user left", log it in the chat body
			socket.On ("user left", data => {
				var d = Data.FromData (data);
				AddMessage (d.username + " left");
				AddParticipantsMessage (d.numUsers);
				UpdateChatTyping (d.username, true);
			});
			// Whenever the server emits "typing", show the typing message
			socket.On ("typing", data => {
				var d = Data.FromData (data);
				UpdateChatTyping (d.username, false);
			});
			// Whenever the server emits "stop typing", kill the typing message
			socket.On ("stop typing", data => {
				var d = Data.FromData (data);
				UpdateChatTyping (d.username, true);
			});
		}
Esempio n. 50
0
        private void PromptForWikiPage()
        {
            var alert = new UIAlertView
            {
                Title = "Goto Wiki Page",
                Message = "What is the title of the Wiki page you'd like to goto?",
                AlertViewStyle = UIAlertViewStyle.PlainTextInput
            };

            alert.CancelButtonIndex = alert.AddButton("Cancel");
            alert.DismissWithClickedButtonIndex(alert.CancelButtonIndex, true);
            var gotoButton = alert.AddButton("Go");
            alert.Dismissed += (sender, e) =>
            {
                if (e.ButtonIndex == gotoButton)
                {
                    GoToPage(alert.GetTextField(0).Text);
                    //ViewModel.GoToPageCommand.Execute(alert.GetTextField(0).Text);
                }
            };
            alert.Show();
        }
		public override void LoadView ()
		{
			base.LoadView ();

			var versionElement = new StringElement ("Version", FlurryAgent.GetFlurryAgentVersion ());

			var errorElement = new StringElement ("Throw & Log Exception", () => {
				try {
					throw new Exception ("Thar be dragons!");
				} catch (Exception ex) {
					FlurryAgent.LogError (ex.GetType ().Name, ex.Message, new NSError (NSError.CocoaErrorDomain, 3584));

					Debug.WriteLine ("Logged exception.");
				}
			});

			var shortEventElement = new StringElement ("Single Event", () => {
				FlurryAgent.LogEvent ("SingleEvent");

				Debug.WriteLine ("Logged event.");
			});

			var shortParameterEventElement = new StringElement ("Single Event with Parameters", () => {
				FlurryAgent.LogEvent ("SingleEventWithParameter", GetParameter ());

				Debug.WriteLine ("Logged event with parameter.");
			});

			var timedEventElement = new StringElement ("Timed Event", () => {
				FlurryAgent.LogEvent ("TimedEvent", true);
				var alert = new UIAlertView ("Please Wait", "Doing a longer running operation...", null, null);
				alert.Show ();
				Thread.Sleep (1000);
				FlurryAgent.EndTimedEvent ("TimedEvent");
				alert.DismissWithClickedButtonIndex (-1, true);

				Debug.WriteLine ("Logged timed event.");
			});

			var timedParameterEventElement = new StringElement ("Timed Event with Parameters", () => {
				FlurryAgent.LogEvent ("TimedEventWithParameter", GetParameter (), true);
				var alert = new UIAlertView ("Please Wait", "Doing a longer running operation...", null, null);
				alert.Show ();
				Thread.Sleep (1000);
				FlurryAgent.EndTimedEvent ("TimedEventWithParameter");
				alert.DismissWithClickedButtonIndex (-1, true);

				Debug.WriteLine ("Logged timed event with parameter.");
			});

			var idElement = new EntryElement ("User ID: ", "enter user id", "");
			idElement.Changed += (sender, e) => {
				FlurryAgent.SetUserId (((EntryElement)sender).Value);

				Debug.WriteLine ("Logged user id.");
			};
			
			var ageElement = new EntryElement ("Age: ", "enter age", "");
			ageElement.Changed += (sender, e) => {
				int age;
				var element = (EntryElement)sender;
				if (int.TryParse (element.Value, out age)) {
					FlurryAgent.SetAge (age);

					Debug.WriteLine ("Logged age.");
				}
			};

			var genderElement = new RootElement ("Gender: ", new RadioGroup (0)) {
				new Section () {
					new SelectableRadioElement ("Unknown", (sender, e) => {
						FlurryAgent.SetGender (Gender.Unknown);

						Debug.WriteLine ("Logged gender.");
					}),
					new SelectableRadioElement ("Male", (sender, e) => {
						FlurryAgent.SetGender (Gender.Male);

						Debug.WriteLine ("Logged gender.");
					}),
					new SelectableRadioElement ("Female", (sender, e) => {
						FlurryAgent.SetGender (Gender.Female);

						Debug.WriteLine ("Logged gender.");
					})
				}
			};
			
			this.Root.Add (new Section[] {
				new Section ("About Flurry Analytics") {
					versionElement
				}, 
				new Section ("Track Errors") {
					errorElement
				}, 
				new Section ("Track Events") {
					shortEventElement,
					shortParameterEventElement,
					timedEventElement,
					timedParameterEventElement
				}, 
				new Section ("Track Demographics") {
					idElement,
					ageElement,	
					genderElement,
				} 
			});
		}
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            var backgroundImage = UIImage.FromBundle(@"images/appview/bg");
            //this.View.BackgroundColor = UIColor.FromPatternImage(backgroundImage);

            _client = new RemoteDataRepository (_baseUrl);

            var loading = new UIAlertView (" Downloading Speakers", "Please wait...", null, null, null);

            loading.Show ();

            var indicator = new UIActivityIndicatorView (UIActivityIndicatorViewStyle.WhiteLarge);
            indicator.Center = new System.Drawing.PointF (loading.Bounds.Width / 2, loading.Bounds.Size.Height - 40);
            indicator.StartAnimating ();
            loading.AddSubview (indicator);

            _client.GetSpeakers ("CodeMash-2012", speakers =>
            {
                InvokeOnMainThread (() =>
                {
                    TableView.Source = new SpeakersTableViewSource (this, speakers);
                    TableView.ReloadData ();
                    loading.DismissWithClickedButtonIndex (0, true);
                }
                );
            }
            );

            // Perform any additional setup after loading the view, typically from a nib.

            //this.TableView.Source = new DataSource (this);

            if (!UserInterfaceIdiomIsPhone)
                this.TableView.SelectRow (
                    NSIndexPath.FromRowSection (0, 0),
                    false,
                    UITableViewScrollPosition.Middle
                );
        }
		private void DownloadCompleted (object sender, DownloadStringCompletedEventArgs e)
		{
			UIApplication.SharedApplication.BeginInvokeOnMainThread (() => {

				UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;

				mAlert.DismissWithClickedButtonIndex (0, true);

				if (e.Error != null)
				{
					DisplayError ("Warning", "The rss feed could not be downloaded: " + e.Error.Message);
				}
				else
				{
					try
					{
						//clear the selected items
						this.GridView.ClearSelectedItems();

						//Clear the rows
						mDatasource.ClearRows();
						mDatasource.Apps.Clear ();

						foreach (var v in RssParser.Parse (e.Result))
							mDatasource.Apps.Add (v);

						mAlert = new UIAlertView ("Fetching Icons...", "", null, null, null);
						mAlert.Show ();
						UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;

						Task.Run (() => {

							foreach (var anApp in mDatasource.Apps)
							{
								byte[] data = null;

								using (var c = new GzipWebClient ())
								{
									data = c.DownloadData (anApp.ImageUrl);
								}


								anApp.Image = UIImage.LoadFromData (NSData.FromArray (data));
							}


						}).ContinueWith (prevTask => {

							mAlert.DismissWithClickedButtonIndex (0, true);
							UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;

							GridView.ReloadData ();

						}, CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.FromCurrentSynchronizationContext ());

					}
					catch
					{
						DisplayError ("Warning", "Malformed Xml was found in the Rss Feed.");
					}
				}
			});

		}