protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			if (ScanActivity.appKey.Length != 43) {
				AlertDialog alert = new AlertDialog.Builder (this)
					.SetTitle ("App key not set")
						.SetMessage ("Please set the app key in the ScanActivity class.")
						.SetPositiveButton("OK", delegate {})
						.Create ();

				alert.Show ();
			}

			// Set our view from the "main" layout resource
			SetContentView (Resource.Layout.Main);

			// Get our button from the layout resource,
			// and attach an event to it
			Button button = FindViewById<Button> (Resource.Id.myButton);
			
			button.Click += delegate {
				// start the scanner
				StartActivity(typeof(ScanActivity));
			};
		}
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView ( Resource.Layout.Main );

            // Resources
            Button Button1 = FindViewById <Button> (Resource.Id.Button1);
            Button Button2 = FindViewById <Button> (Resource.Id.Button2);
            Button Button3 = FindViewById <Button> (Resource.Id.Button3);

            // Resource CallBacks
            Button1.Click += delegate {
                StartActivity ( typeof ( Game ) );
                Finish (); };

            Button2.Click += delegate {
                StartActivity ( typeof ( Instructions ) );
                Finish (); };

            Button3.Click += delegate {
                AlertDialog.Builder MessageBox = new AlertDialog.Builder ( this );
                MessageBox.SetNegativeButton ( "OK", delegate {} );
                MessageBox.SetMessage ("Xamarin Studio\n-Hussain Al-Homedawy.");
                MessageBox.Show (); };
        }
        public void Login(object sender, EventArgs e)
        {
            EditText Email = FindViewById<EditText>(Resource.Id.Email);
            EditText Password = FindViewById<EditText>(Resource.Id.Password);
            TextView tex1 = FindViewById<TextView>(Resource.Id.text1);
            TextView tex2 = FindViewById<TextView>(Resource.Id.text2);

            EmailSend = Email.Text;
            PasswordSend = Password.Text;
            ConnectDatabase data;

            string HashText = null;

            if (EmailSend == "" || PasswordSend == "" || EmailSend.Length < 5 || PasswordSend.Length < 5)
            {
                AlertDialog.Builder alert = new AlertDialog.Builder(this);
                alert.SetMessage("Invalid Username or Password");
                alert.SetTitle("Error");
                alert.SetCancelable(true);
                alert.SetPositiveButton("OK", (EventHandler<DialogClickEventArgs>)null);
                alert.Show();
            }
            else
            {
                StartActivity(typeof(StartPageActivity));
                data = new ConnectDatabase(EmailSend, PasswordSend);
                HashText = data.GetHash;
                tex1.Text = EmailSend;
                tex2.Text = HashText;

            }
        }
Example #4
0
		public bool Display (string body, string cancelButtonTitle, string acceptButtonTitle = "", Action action = null, bool negativeAction = false)
		{
			AlertDialog.Builder alert = new AlertDialog.Builder (Forms.Context);

			alert.SetTitle ("Alert");
			alert.SetMessage (body);
			alert.SetNeutralButton (cancelButtonTitle, (senderAlert, args) => {

			});


			if (acceptButtonTitle != "") {
				if (!negativeAction) {
					alert.SetPositiveButton (acceptButtonTitle, (senderAlert, args) => {
						if (action != null) {
							action.Invoke ();
						}
					});
				} else {
					alert.SetNegativeButton (acceptButtonTitle, (senderAlert, args) => {
						if (action != null) {
							action.Invoke ();
						}
					});
				}
			}

			((Activity)Forms.Context).RunOnUiThread (() => {
				alert.Show ();
			});
			return true;
		}
Example #5
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
                case Resource.Id.actionNew:
                    string default_game_name = "Game";
                    AlertDialog.Builder alert1 = new AlertDialog.Builder(this.Activity);
                    EditText input = new EditText(this.Activity);
                    input.Text = default_game_name;
                    alert1.SetTitle("Game Name");
                    alert1.SetView(input);
                    alert1.SetPositiveButton("OK", delegate { AddGame(input.Text); });
                    alert1.SetNegativeButton("Cancel", (s, e) => { });
                    alert1.Show();
                    _adapter.NotifyDataSetChanged();
                    return true;

                case Resource.Id.actionRefresh:
                    GameData.Service.RefreshCache();
                    _adapter.NotifyDataSetChanged();
                    return true;

                default:
                    return base.OnOptionsItemSelected(item);
            }
        }
Example #6
0
		public MainApp(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
		{
			// Catch unhandled exceptions
			// Found at http://xandroid4net.blogspot.de/2013/11/how-to-capture-unhandled-exceptions.html
			// Add an exception handler for all uncaught exceptions.
			AndroidEnvironment.UnhandledExceptionRaiser += AndroidUnhandledExceptionHandler;
			AppDomain.CurrentDomain.UnhandledException += ApplicationUnhandledExceptionHandler;

			// Save prefernces instance
			Main.Prefs = new PreferenceValues(PreferenceManager.GetDefaultSharedPreferences(this));

			// Get path from preferences or default path
			string path = Main.Prefs.GetString("filepath", Path.Combine(global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "WF.Player"));

			try {
				if (!Directory.Exists (path))
					Directory.CreateDirectory (path);
			}
			catch {
			}

			if (!Directory.Exists (path))
			{
				AlertDialog.Builder builder = new AlertDialog.Builder (this);
				builder.SetTitle (GetString (Resource.String.main_error));
				builder.SetMessage(String.Format(GetString(Resource.String.main_error_directory_not_found), path));
				builder.SetCancelable (true);
				builder.SetNeutralButton(Resource.String.ok,(obj,arg) => { });
				builder.Show ();
			} else {
				Main.Path = path;
				Main.Prefs.SetString("filepath", path);
			}
		}
Example #7
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.GetMain);

            Button back = FindViewById<Button>(Resource.Id.GetMian_cancel);
            ListView list = FindViewById<ListView>(Resource.Id.GetMian_items);
            Button save = FindViewById<Button>(Resource.Id.GetMian_save);
            OnBind();
            save.Click += delegate 
            {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.SetTitle("提示:");
                builder.SetMessage("确认同步订单吗?");
                builder.SetNegativeButton("确定", delegate 
                {
                    string msg = Sync.syncOrder();
                    AlertDialog.Builder bd = new AlertDialog.Builder(this);
                    bd.SetTitle("提示:");
                    bd.SetMessage(msg);
                    bd.SetNegativeButton("确定", delegate { });
                    bd.Show();
                });
                builder.Show();
            };
            back.Click += delegate 
            {
                Intent intent = new Intent();
                intent.SetClass(this, typeof(Index));
                StartActivity(intent);
                Finish();
            };
            new Core.Menu(this);
        }
Example #8
0
        public static void MsgBox(Context context,
			string msg, 
			string Titolo = "Vegetha", 
			string PositiveText = "OK", 
			Action PositiveAction = null, 
			string NegativeText ="",
			Action NegativeAction = null)
        {
            AlertDialog.Builder d = new AlertDialog.Builder (context);
            d.SetTitle(Titolo);
            d.SetMessage (msg);
            if (PositiveAction != null) {
                d.SetPositiveButton (PositiveText, (sender, e) => {
                    PositiveAction.Invoke();
                });
            } else {
                d.SetPositiveButton (PositiveText, (sender, e) => {

                });
            }

            if (NegativeAction != null) {
                d.SetNegativeButton (NegativeText, (sender, e) => {
                    NegativeAction.Invoke ();
                });
            }
            d.Show ();
        }
Example #9
0
 /// <summary>
 ///     Shows a dialog with title and message. Contains only an OK button.
 /// </summary>
 /// <param name="title">Title to display.</param>
 /// <param name="message">Text to display.</param>
 public async Task ShowMessage(string title, string message)
 {
     var builder = new AlertDialog.Builder(CurrentActivity);
     builder.SetTitle(title);
     builder.SetMessage(message);
     builder.Show();
 }
		private void initListeners()
		{
			create.Click += delegate 
			{
				if(!validdateForm()) return;
				create.Enabled = false;
				var task = Task<TournamentModel>.Factory.StartNew(() => ServerData.createTournament(name.Text, Session.Instance().CurrentUser.Id));
				task.ContinueWith(x =>     
				{
					create.Enabled = true;
					try 
					{
						if (x.Exception != null) throw x.Exception.InnerException;
						// Success
						Session.Instance().selectedTournament = task.Result;
						StartActivity(typeof(TournamentDetails));
						Finish();
					}
					catch (WebException e)
					{
						var builder = new AlertDialog.Builder(this);
						builder.SetMessage("Er is iets mis met de verbinding, probeer het later opnieuw.");
						builder.SetCancelable(false);
						builder.SetPositiveButton("OK", delegate { });
						builder.Show();
					}
				},
				TaskScheduler.FromCurrentSynchronizationContext());
			};
		}
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource.
            SetContentView (Resource.Layout.Main);

            // Get our UI controls from the loaded layout:
            EditText phoneNumberText = FindViewById<EditText>(Resource.Id.PhoneNumberText);
            Button translateButton = FindViewById<Button>(Resource.Id.TranslateButton);
            Button callButton = FindViewById<Button>(Resource.Id.CallButton);
            Button callHistoryButton = FindViewById<Button> (Resource.Id.CallHistoryButton);

            // Disable the "Call" button.
            callButton.Enabled = false;

            // Add code to translate number.
            string translatedNumber = string.Empty;

            translateButton.Click += (object sender, EventArgs e) => {
                // Translate user's alphanumeric phone number to numeric.
                translatedNumber = Core.PhonewordTranslator.ToNumber(phoneNumberText.Text);

                if (String.IsNullOrWhiteSpace(translatedNumber)) {
                    callButton.Text = "Call";
                    callButton.Enabled = false;
                } else {
                    callButton.Text = "Call " + translatedNumber;
                    callButton.Enabled = true;
                }
            };

            callButton.Click += (object sender, EventArgs e) => {
                // On "Call" button click, try to dial phone number.
                var callDialog = new AlertDialog.Builder(this);
                callDialog.SetMessage("Call " + translatedNumber + "?");
                callDialog.SetNeutralButton("Call", delegate {
                    // Add dialed number to list of called numbers.
                    phoneNumbers.Add(translatedNumber);

                    // Enable the Call History button.
                    callHistoryButton.Enabled = true;

                    // Create intent to dial phone.
                    var callIntent = new Intent(Intent.ActionCall);
                    callIntent.SetData(Android.Net.Uri.Parse("tel:" + translatedNumber));
                    StartActivity(callIntent);
                });
                callDialog.SetNegativeButton("Cancel", delegate {});

                // Show the alert dialog to the user and wait for response.
                callDialog.Show();
            };

            callHistoryButton.Click += (sender, e) => {
                var intent = new Intent(this, typeof(CallHistoryActivity));
                intent.PutStringArrayListExtra("phone_numbers", phoneNumbers);
                StartActivity(intent);
            };
        }
		/**
	     * Show End User License Agreement.
	     *
	     * @param accepted True IFF user has accepted license already, which means it can be dismissed.
	     *                 If the user hasn't accepted, then the EULA must be accepted or the program
	     *                 exits.
	     * @param activity Activity started from.
	     */
		public static void ShowEula(bool accepted, Activity activity)
		{
			AlertDialog.Builder eula = new AlertDialog.Builder(activity)
				.SetTitle(Resource.String.eula_title)
				.SetIcon(Android.Resource.Drawable.IcDialogInfo)
				.SetMessage(Resource.String.eula_text)
				.SetCancelable(accepted);
			
			if (accepted) 
			{
				eula.SetPositiveButton(Android.Resource.String.Ok, (object dialog, DialogClickEventArgs which) => {
					(dialog as IDialogInterface).Dismiss();	
				});
			} else {
				eula.SetPositiveButton(Resource.String.accept,(object dialog, DialogClickEventArgs which) => {
					SetAcceptedEula(activity);
					(dialog as IDialogInterface).Dismiss();
				})
				.SetNegativeButton(Resource.String.decline, (object dialog, DialogClickEventArgs which) => { 
					(dialog as IDialogInterface).Cancel();
					activity.Finish();
				});
			}
			eula.Show();
		}
Example #13
0
        public async void Register(View view)
        {
            ProgressDialog dialog = DialogHelper.CreateProgressDialog("Registering...", this);
            dialog.Show();

            RegisterRequest request = new RegisterRequest
            {
                FirstName = FindViewById<EditText>(Resource.Id.registerFirstName).Text,
                LastName = FindViewById<EditText>(Resource.Id.registerLastName).Text,
                StudentId = FindViewById<EditText>(Resource.Id.registerStudentId).Text,
                Password = FindViewById<EditText>(Resource.Id.registerPassword).Text
            };
            
            GenericResponse Response = await Services.Auth.Register(request);
            dialog.Hide();

            if (Response.Success)
            {
                AlertDialog.Builder builder = new AlertDialog.Builder(this, Resource.Style.LightDialog);
                builder.SetTitle("Successfully Registered");
                builder.SetMessage("Please check your UTS email for instructions to confirm your account");
                builder.SetCancelable(false);
                builder.SetPositiveButton("OK", delegate { Finish(); });
                builder.Show();
            }
            else
            {
                DialogHelper.ShowDialog(this, Response.Message, Response.Title);
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);
            button = FindViewById<Button> (Resource.Id.button);

            button.Click += (o, e) =>  {
                // use an array adapter to populate a spinner item from our string array
                ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                    Android.Resource.Layout.SimpleSpinnerItem, villains);

                // create the spinner and populate it with our items
                Spinner spinner = new Spinner(this);
                spinner.LayoutParameters = new LinearLayout.LayoutParams (ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                spinner.Adapter = adapter;

                // handle item selection
                spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (ItemSelected);

                // build the alert dialog
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.SetView(spinner);
                builder.SetNeutralButton("OK", delegate {});
                builder.Show();
            };
        }
Example #15
0
        public List<Game> GetFavoriteGameList(Context Context, string AccountIdentifier)
        {
            XmlDocument doc = new XmlDocument ();
            List<Game> gamesList = new List<Game>();

            try
            {
                doc.Load("http://thegamesdb.net/api/User_Favorites.php?=accountid=" + AccountIdentifier);

                XmlNodeList nodes = doc.DocumentElement.SelectNodes("/Favorites");

                foreach (XmlNode node in nodes)
                {
                    if(node.SelectSingleNode("Game") != null)
                    {
                        gamesList.Add(GetGame(Context, node.SelectSingleNode("Game").Value));
                    }
                }

                return gamesList;
            }
            catch
            {
                var errorDialog = new AlertDialog.Builder(Context).SetTitle("Oops!").SetMessage("There was a problem getting Favorites, please try again later.").SetPositiveButton("Okay", (sender1, e1) =>
                {

                }).Create();
                errorDialog.Show();

                return gamesList;
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Page_Dialog);

            var yesNoDialogbutton = FindViewById<Button>(Resource.Id.YesNoDialogButton);
            yesNoDialogbutton.Click += delegate
                                {
                                    var builder = new AlertDialog.Builder(this);
                                    builder.SetMessage(Resource.String.knigts_dialog_title);
                                    builder.SetPositiveButton(Resource.String.yes, (s, e) => { });
                                    builder.SetNegativeButton(Resource.String.no, (s, e) => { }).Create();
                                    builder.Show();
                                };

            var alertDialogButton = FindViewById<Button>(Resource.Id.AlertDialogButton);
            alertDialogButton.Click += delegate { ShowDialog(AlertDialog); };

            var listDialogButton = FindViewById<Button>(Resource.Id.ListDialogButton);
            listDialogButton.Click += delegate { ShowDialog(ListDialog); };

            var multiChoiceDialogButton = FindViewById<Button>(Resource.Id.MultiChoiceDialogButton);
            multiChoiceDialogButton.Click += delegate { ShowDialog(MultiChoiceDialog); };

            var customViewDialogButton = FindViewById<Button>(Resource.Id.CustomViewDialogButton);
            customViewDialogButton.Click += delegate { ShowDialog(CustomViewDialog); };

            var fragmentDialogsButton = FindViewById<Button>(Resource.Id.FragmentDialogsButton);
            fragmentDialogsButton.Click += delegate
                                               {
                                                   var intent = new Intent(this, typeof (DialogFragmentActivity));
                                                   intent.AddFlags(ActivityFlags.ClearTop);
                                                   StartActivity(intent);
                                               };
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button> (Resource.Id.loginButton);

            button.Click += delegate {
                //set alert for executing the task
                var alert = new AlertDialog.Builder (this);

                alert.SetTitle ("Login Popup");

                alert.SetPositiveButton ("OK", (senderAlert, args) => {

                });

                alert.SetMessage ("Logged In");

                //run the alert in UI thread to display in the screen
                RunOnUiThread (() => {
                    alert.Show ();
                });
            };
        }
		protected void CreateChatRooms(){
			chatroomsAdapter = new ChatRoomsAdapter (this);
			var chatRoomsListView = FindViewById<ListView> (Resource.Id.chatroomsListView);
			chatRoomsListView.Adapter = chatroomsAdapter;
			chatRoomsListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
				ChatRoom currChatRoom = chatroomsAdapter.GetChatRoomAt(e.Position);
				var intent = new Intent(this, typeof(ChatRoomActivity));
				intent.PutExtra("chatroom", currChatRoom.webID);
				StartActivity(intent);
			};
			chatRoomsListView.ItemLongClick += async (object sender, AdapterView.ItemLongClickEventArgs e) => {
				AlertDialog.Builder alert = new AlertDialog.Builder(this);
				alert.SetTitle("Do you want to delete this chatroom?");
				alert.SetPositiveButton("Yes", (senderAlert, args) => {
					ChatRoom currChatRoom = chatroomsAdapter.GetChatRoomAt(e.Position);
					ParsePush.UnsubscribeAsync (currChatRoom.webID);
					ChatRoomUser cru = DatabaseAccessors.ChatRoomDatabaseAccessor.DeleteChatRoomUser(DatabaseAccessors.CurrentUser().webID, currChatRoom.webID);
					DatabaseAccessors.ChatRoomDatabaseAccessor.DeleteChatRoom(currChatRoom.webID);
					ParseChatRoomDatabase pcrd = new ParseChatRoomDatabase();
					pcrd.DeleteChatRoomUserAsync(cru);
					Console.WriteLine("ERASED");
					chatroomsAdapter.NotifyDataSetChanged();

				});
				alert.SetNegativeButton("No", (senderAlert, args) => {
				});	
				alert.Show();
			};
		}
Example #19
0
        public static AlertDialog ShowQuestion(this Activity activity, string title, string message, string positiveButton, string negativeButton, Action positive, Action negative)
        {
            AlertDialog dialog = null;

            var builder = new AlertDialog.Builder(activity);
            builder.SetTitle(title);
            builder.SetMessage(message);
            builder.SetPositiveButton(positiveButton, (s, e) =>
            {
                dialog.Cancel();
                dialog.Dismiss();

                if (positive != null)
                    positive();
            });

            builder.SetNegativeButton(negativeButton, (s, e) =>
            {
                dialog.Cancel();
                dialog.Dismiss();

                if (negative != null)
                    negative();
            });

            dialog = builder.Show();

            return dialog;
        }
Example #20
0
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);

			SetContentView (Resource.Layout.activity_events);

			base.debugTextView = (EditText)FindViewById (Resource.Id.debug_output_field_events);
			selectEventButton = (Button)FindViewById (Resource.Id.select_event_button);
			sendEventButton = (Button)FindViewById (Resource.Id.send_event_button);

			EventHandler<DialogClickEventArgs> handler = (s, o) => {
				// save off selected event
				selectEventButton.Text = items [o.Which];
				lastSelectedEvent = items [o.Which];
				sendEventButton.Enabled = true;
			};

			selectEventButton.Click += (sender, e) => {
				AlertDialog.Builder builder = new AlertDialog.Builder (this);
				builder.SetTitle ("Select Event");
				builder.SetItems (items, handler);
				builder.Show();
			};
				

			// set up click listener for when event is sent
			sendEventButton.Click += (sender, e) => {
				tapjoyEvent = new TJEvent(this, lastSelectedEvent, null, eventCallback);
				tapjoyEvent.EnableAutoPresent(true);
				tapjoyEvent.Send();
			};

		}
Example #21
0
 private void OnLogin(bool p_isLogedIn)
 {
     if (p_isLogedIn == false)
     {
         RunOnUiThread(() => {
             AlertDialog.Builder l_alert = new AlertDialog.Builder(this);
             l_alert.SetMessage("Connection failed...");
             l_alert.SetNegativeButton("Cancel", delegate { });
             Console.WriteLine("Failed to connect");
             l_alert.Show();
         });
     }
     else
     {
         if (m_checkBox.Checked == true)
         {
             m_dataManager.StoreData<string>("login", m_login.Text);
             m_dataManager.StoreData<string>("password", m_password.Text);
         }
         else
         {
             m_dataManager.RemoveData("login");
             m_dataManager.RemoveData("password");
         }
         m_dataManager.StoreData<bool>("loginCheckBox", m_checkBox.Checked);
         Console.WriteLine("success to connect");
         StartActivity(typeof(ChatActivity));
     }
 }
Example #22
0
		protected override async void OnResume()
		{
			base.OnResume ();

			Title = DataHolder.Current.CurrentCity.Name;

			// Load pollutions
			pollutionService = new PollutionService(Settings.ApiBaseUrl);
			var pollutions = await pollutionService.GetPollutionForCity(DataHolder.Current.CurrentCity.Zip);
			if (pollutions == null) 
			{
				// An error occured
				var builder = new AlertDialog.Builder(this);
				builder.SetTitle(GetString(Resource.String.error_header));
				builder.SetMessage(GetString(Resource.String.pollution_error_body));
				builder.SetPositiveButton (GetString (Android.Resource.String.Ok), (senderAlert, args) => {});
				builder.Show();
			} else {
				DataHolder.Current.CurrentPollutions = pollutions;
			}				

			// Initialize tabs
			AddPollutionDayTab(Resources.GetString(Resource.String.tab_today), 0);
			AddPollutionDayTab(Resources.GetString(Resource.String.tab_tomorrow), 1);
			AddPollutionDayTab(Resources.GetString(Resource.String.tab_aftertomorrow), 2);

			// Hide loading indicator
			var loading = FindViewById<ProgressBar> (Resource.Id.pbLoading);
			loading.Visibility = ViewStates.Gone;
		}
Example #23
0
        public static AlertDialog ShowInformation(this Activity activity, string title, string message, string buttonText, Action button = null)
        {
            AlertDialog dialog = null;

            var builder = new AlertDialog.Builder(activity);
            builder.SetTitle(title);
            builder.SetMessage(message);

            builder.SetNegativeButton(buttonText, (s, e) =>
            {
                if (dialog == null)
                {
                    return;
                }

                dialog.Cancel();
                dialog.Dismiss();

                if (button != null)
                {
                    button();
                }
            });

            dialog = builder.Show();

            return dialog;
        }
Example #24
0
		protected override void OnStart ()
		{
			base.OnStart ();
			InitService ();

			var button1 = FindViewById<Button> (Resource.Id.buttonCalc);
			button1.Click += (sender, e) => {
				if (IsBound) {
					var text1 = FindViewById<EditText> (Resource.Id.value1);
					var text2 = FindViewById<EditText> (Resource.Id.value2);
					var result = FindViewById<TextView> (Resource.Id.result);

					int v1;
					int v2;
					int v3;

					if(Int32.TryParse (text2.Text, out v2) && Int32.TryParse (text1.Text, out v1)) {
						v3 = Service.Add (v1, v2);
					} else {
						v3 = 0;
						var builder = new AlertDialog.Builder(this);
						builder.SetMessage("Spaces or special character are not allowed");
						builder.SetNeutralButton("OK", (source, eventArgs) => {});
						builder.Show();
					}

					result.Text = v3.ToString ();
				} else {
					Log.Warn (Tag, "The AdditionService is not bound");
				}

			};

		}
		private void refreshRanking()
		{
			var task = Task<List<TournamentRankingModel>>.Factory.StartNew(() => ServerData.getTournamentRanking(Session.Instance().selectedTournament.Id));
			task.ContinueWith(x =>     
			{
				try 
				{
					if (x.Exception != null) throw x.Exception.InnerException;
					ranking = task.Result;
					if(ranking.Count > 0)
					{
						notStarted.Visibility = ViewStates.Gone;
						Session.Instance().selectedTournament.Open = false;
						populateTable ();
					}
				} 
				catch (WebException e)
				{
					var builder = new AlertDialog.Builder(this);
					builder.SetMessage("Er is iets mis met de verbinding, probeer het later opnieuw.");
					builder.SetCancelable(false);
					builder.SetPositiveButton("OK", delegate { });
					builder.Show();
				}
			},
			TaskScheduler.FromCurrentSynchronizationContext());
		}
        public async void ForgotPassword(View view)
        {
            ProgressDialog dialog = DialogHelper.CreateProgressDialog("Please wait...", this);
            dialog.Show();

            EditText StudentId = FindViewById<EditText>(Resource.Id.forgotStudentId);
            AuthService ForgotPasswordService = new AuthService();
            GenericResponse Response = await ForgotPasswordService.ForgotPassword(StudentId.Text);
            dialog.Hide();

            if (Response.Success)
            {

                AlertDialog.Builder builder = new AlertDialog.Builder(this, Resource.Style.LightDialog);
                builder.SetTitle("Password Reset Sent");
                builder.SetMessage("Please check your emails to reset your password");
                builder.SetCancelable(false);
                builder.SetPositiveButton("OK", delegate { Finish(); });
                builder.Show();
            }
            else
            {
                DialogHelper.ShowDialog(this, Response.Message, Response.Title);
            }
        }
		public void Display (string body, string title, GoalsAvailable availableGoal, string cancelButtonTitle, string acceptButtonTitle = "", Action<GoalsAvailable, int> action = null)
		{
			EditText goalTextBox = new EditText (Forms.Context);
			AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder (Forms.Context);
			alertDialogBuilder.SetTitle (title);
			alertDialogBuilder.SetMessage (body);
			alertDialogBuilder.SetView (goalTextBox);

			goalTextBox.InputType = Android.Text.InputTypes.NumberFlagSigned;

			var inputFilter = new Android.Text.InputFilterLengthFilter (7);
			var filters = new Android.Text.IInputFilter[1];

			filters [0] = inputFilter;

			goalTextBox.SetFilters (filters);
			goalTextBox.InputType = Android.Text.InputTypes.ClassNumber;

			alertDialogBuilder.SetPositiveButton ("OK", (senderAlert, args) => {
				if(action != null)
				{
					int goalValue;
					int.TryParse(goalTextBox.Text, out goalValue);
					action.Invoke(availableGoal, goalValue);
				}

			} );
			alertDialogBuilder.SetNeutralButton ("CANCEL", (senderAlert, args) => {

			} );

			alertDialogBuilder.Show ();

		}
Example #28
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            this.Window.AddFlags(WindowManagerFlags.Fullscreen);

            // Create your application here
            ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
            SetContentView(Resource.Layout.MainTabLayout);

            AddTab(Resource.String.tabMain, new MainTabFragment(this));
            AddTab(Resource.String.tabCreate, new CreateTabFragment(this));
            AddTab(Resource.String.tabSettings, new SettingsTabFragment(this));

            //testing tab for layouts - not used
            //AddTab(Resource.String.tabSettings, new TestTabFragment(this));

            LoadPreferences();
            if (gVar.apiKey_ == "")
            {
                var dlgNoApi = new AlertDialog.Builder(this);
                dlgNoApi.SetMessage(Resource.String.noAPI);
                dlgNoApi.SetNegativeButton(Resource.String.ok, delegate
                    {
                        ActionBar.SetSelectedNavigationItem(2);
                    });
                dlgNoApi.Show();
            }	
        }
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // shows a spinner while it gets polls from database
            var progressDialog = new ProgressDialog(this);
            progressDialog.Show();
            {
                try
                {
                    // gets all the polls from the database
                    polls = await VotingService.MobileService.GetTable<Poll>().ToListAsync();
                }
                catch (Exception exc)
                {
                    // error dialog that shows if something goes wrong
                    var errorDialog = new AlertDialog.Builder(this).SetTitle("Oops!").SetMessage("Something went wrong " + exc.ToString()).SetPositiveButton("Okay", (sender1, e1) =>
                    {

                    }).Create();
                    errorDialog.Show();
                }
            };
            // ends spinner on completion
            progressDialog.Dismiss();

            // created table for polls
            ListAdapter = new ArrayAdapter<Poll>(this, Android.Resource.Layout.SimpleListItem1, polls);
        }
Example #30
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            FindViewById<EditText>(Resource.Id.modemPassword).RequestFocus();

            FindViewById<Button>(Resource.Id.next).Click += (s,e) => {
                if(ModemPassword=="")
                {
                    var diag=new AlertDialog.Builder(this);
                    diag.SetTitle("Device Access Code Required!");
                    diag.SetMessage("A password or Device Access Code is required! It is usually a 10-digit number printed on your modem");
                    diag.SetIcon(Android.Resource.Drawable.IcDialogAlert);
                    diag.SetNeutralButton("Ok", new EventHandler<DialogClickEventArgs>((s2, e2) => {} ));
                    diag.Show();
                    return;
                }
                var controller = new Intent(this, typeof(ControllerActivity));
                controller.PutExtra("address", ModemAddress);
                controller.PutExtra("password", ModemPassword);
                StartActivity(controller);
            };
            // Get our button from the layout resource,
            // and attach an event to it
            //must get address and password in this context because it can change later, but other threads can't access it
        }