/// <summary>
        /// Shows alert dialog.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: private void showAlertDialog(String message, final boolean finishActivity)
        private void showAlertDialog(string message, bool finishActivity)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.app.AlertDialog.Builder dialog = new android.app.AlertDialog.Builder(this);
            AlertDialog.Builder dialog = new AlertDialog.Builder(this);
            dialog.setMessage(message).setIcon(android.R.drawable.ic_dialog_alert).setTitle("Alert").setPositiveButton([email protected], new OnClickListenerAnonymousInnerClassHelper(this, finishActivity, dialog))
            .Cancelable = false;

            runOnUiThread(() =>
            {
                dialog.show();
            });
        }
Пример #2
0
        public override bool onOptionsItemSelected(MenuItem item)
        {
            int id = item.ItemId;

            switch (id)
            {
            case R.id.action_new_thing:
                renderNewThingPopup();
                break;

            case R.id.change_floor:
                renderChangeCarpetPopup();
                break;

            case R.id.action_rotate:
                if (mSelectedThing != null)
                {
                    int rotation = mSelectedThing.Rotation;

                    if (rotation >= 270)
                    {
                        mSelectedThing.Rotation = 0;
                    }
                    else
                    {
                        mSelectedThing.Rotation = rotation + 90;
                    }
                    updateOfficeThing(mSelectedThing.Key, mSelectedThing);
                }
                break;

            case R.id.action_delete:
                deleteOfficeThing(mSelectedThing.Key, mSelectedThing);
                break;

            case R.id.action_edit:
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.widget.EditText entry = new android.widget.EditText(this);
                EditText entry = new EditText(this);

                builder.setMessage(getString([email protected]_desk_name_description)).setTitle(getString([email protected]_desk_name_title)).setView(entry);

                builder.setPositiveButton(getString([email protected]_desk_name_save), new OnClickListenerAnonymousInnerClassHelper(this, id, entry));
                builder.show();
                break;
            }
            return(base.onOptionsItemSelected(item));
        }
Пример #3
0
		/// <summary>
		/// Shows alert dialog.
		/// </summary>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: private void showAlertDialog(String message, final boolean finishActivity)
		private void showAlertDialog(string message, bool finishActivity)
		{

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.app.AlertDialog.Builder dialog = new android.app.AlertDialog.Builder(this);
			AlertDialog.Builder dialog = new AlertDialog.Builder(this);
			dialog.setMessage(message).setIcon(android.R.drawable.ic_dialog_alert).setTitle("Alert").setPositiveButton([email protected], new OnClickListenerAnonymousInnerClassHelper(this, finishActivity, dialog))
				   .Cancelable = false;

			runOnUiThread(() =>
			{
				dialog.show();
			});
		}
		public override bool onOptionsItemSelected(MenuItem item)
		{
			int id = item.ItemId;
			switch (id)
			{
				case R.id.action_new_thing:
					renderNewThingPopup();
					break;
				case R.id.change_floor:
					renderChangeCarpetPopup();
					break;
				case R.id.action_rotate:
					if (mSelectedThing != null)
					{
						int rotation = mSelectedThing.Rotation;

						if (rotation >= 270)
						{
							mSelectedThing.Rotation = 0;
						}
						else
						{
							mSelectedThing.Rotation = rotation + 90;
						}
						updateOfficeThing(mSelectedThing.Key, mSelectedThing);
					}
					break;
				case R.id.action_delete:
					deleteOfficeThing(mSelectedThing.Key, mSelectedThing);
					break;
				case R.id.action_edit:
					AlertDialog.Builder builder = new AlertDialog.Builder(this);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.widget.EditText entry = new android.widget.EditText(this);
					EditText entry = new EditText(this);

					builder.setMessage(getString([email protected]_desk_name_description)).setTitle(getString([email protected]_desk_name_title)).setView(entry);

					builder.setPositiveButton(getString([email protected]_desk_name_save), new OnClickListenerAnonymousInnerClassHelper(this, id, entry));
					builder.show();
					break;
			}
			return base.onOptionsItemSelected(item);
		}
Пример #5
0
        public static global::System.Windows.Forms.DialogResult Show(string text, string caption)
        {
            // or are we called on a background thread?
            // for java, we can block a worker thread until ui is shown. for javascript cannot do it without async?
            // assume we are activity based..
            var context = ScriptCoreLib.Android.ThreadLocalContextReference.CurrentContext as Activity;
            var ui      = context.getMainLooper() == Looper.myLooper();

            Console.WriteLine("enter MessageBox.Show " + new { ui });

            var value   = default(global::System.Windows.Forms.DialogResult);
            var thread0 = Thread.CurrentThread;
            var sync    = new AutoResetEvent(false);

            context.runOnUiThread(
                a =>
            {
                //thread0 = Thread.CurrentThread;
                //sync0ui.Set();

                // X:\jsc.svn\examples\java\android\forms\FormsMessageBox\FormsMessageBox\Library\ApplicationControl.cs
                // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201410/20141025
                // X:\jsc.svn\examples\java\android\Test\TestAlertDialog\TestAlertDialog\ApplicationActivity.cs


                var alertDialog = new AlertDialog.Builder(context);

                alertDialog.setTitle(caption);

                if (!string.IsNullOrEmpty(caption))
                {
                    alertDialog.setMessage(text);
                }

                // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201410/20141026


                alertDialog.setPositiveButton("OK",
                                              new xDialogInterface_OnClickListener
                {
                    yield = delegate
                    {
                        Console.WriteLine(" alertDialog.setPositiveButton");
                        value = global::System.Windows.Forms.DialogResult.OK;
                        //sync.Set();
                    }
                }
                                              );

                // skip icons?
                //alertDialog.setIcon(android.R.drawable.star_off);
                var dialog = alertDialog.create();

                dialog.setOnDismissListener(
                    new xDialogInterface_OnDismissListener
                {
                    yield = delegate
                    {
                        Console.WriteLine("  dialog.setOnDismissListener");
                        sync.Set();

                        if (ui)
                        {
                            throw null;
                        }
                    }
                }
                    );

                dialog.show();


                // http://stackoverflow.com/questions/13974661/runonuithread-vs-looper-getmainlooper-post-in-android
                // http://developer.android.com/reference/android/os/Looper.html



                //sync.Set();
            }
                );



            // need to poll? discard?


            if (ui)
            {
                try
                {
                    // loop until we throw null
                    // where is it thrown?
                    android.os.Looper.loop();
                }
                catch
                {
                }
            }
            else
            {
                sync.WaitOne();
            }

            Console.WriteLine("exit MessageBox.Show " + new { ui, value });
            return(value);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            // http://stackoverflow.com/questions/2028697/dialogs-alertdialogs-how-to-block-execution-while-dialog-is-up-net-style
            // http://mindfiremobile.wordpress.com/2014/04/21/displaying-alert-dialog-in-android-using-xamarin/

            //button1.Text = "Clicked!";

            // X:\jsc.svn\examples\java\android\forms\FormsMessageBox\FormsMessageBox\ApplicationActivity.cs
            // X:\jsc.svn\examples\java\android\Test\TestAlertDialog\TestAlertDialog\ApplicationActivity.cs
            var alertDialog = new AlertDialog.Builder(ScriptCoreLib.Android.ThreadLocalContextReference.CurrentContext);

            alertDialog.setTitle("Reset...");
            alertDialog.setMessage("Are you sure?");

            alertDialog.setOnDismissListener(
                new xDialogInterface_OnDismissListener
            {
                yield = delegate
                {
                    throw null;
                }
            }
                );

            alertDialog.setPositiveButton("OK",
                                          new xOnClickListener
            {
                yield = delegate
                {
                    button1.Text = "clicked! " + new
                    {
                        Thread.CurrentThread.ManagedThreadId
                    };
                }
            }

                                          );

            // skip icons?
            //alertDialog.setIcon(android.R.drawable.star_off);

            // can we do async yet?
            alertDialog.create().show();

            // http://stackoverflow.com/questions/13974661/runonuithread-vs-looper-getmainlooper-post-in-android

            //android.os.Looper.getMainLooper().loop();

            // http://developer.android.com/reference/android/os/Looper.html

            try
            {
                // loop until we throw null
                android.os.Looper.loop();
            }
            catch
            {
            }

            button1.Text = "clicked! after looper " + new
            {
                Thread.CurrentThread.ManagedThreadId
            };

            //alertDialog.create().show();
        }
        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // cmd /K c:\util\android-sdk-windows\platform-tools\adb.exe logcat
            // Camera PTP

            // http://developer.android.com/guide/topics/ui/notifiers/notifications.html

            base.onCreate(savedInstanceState);

            ScrollView sv = new ScrollView(this);

            LinearLayout ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);

            sv.addView(ll);


            Button b = new Button(this);

            b.setText("AlertDialog! " + new { id = Thread.currentThread().getId() });
            int counter = 0;

            // ScriptCoreLib.Ultra ?
            b.AtClick(
                delegate
            {
                counter++;

                // http://www.tomswebdesign.net/Articles/Android/number-pad-input-class.html
                // https://android.googlesource.com/platform/frameworks/base/+/b896b9f/packages/Keyguard/src/com/android/keyguard/KeyguardSimPinView.java
                // http://xmlstackoverflow.blogspot.com/2014/07/how-to-use-alertdialog-to-prompt-for-pin.html
                // http://incidencias-ctt.administracionelectronica.gob.es/websvn/filedetails.php?repname=clienteafirma&path=%2Fproject%2Fafirma-mobile%2Fafirma-android%2Ftrunk%2Fafirma-ui-android%2Fsrc%2Fes%2Fgob%2Fafirma%2Fandroid%2Fgui%2FPinDialog.java&peg=4040

                // X:\jsc.svn\examples\java\android\forms\FormsMessageBox\FormsMessageBox\ApplicationActivity.cs
                // X:\jsc.svn\examples\java\android\Test\TestAlertDialog\TestAlertDialog\ApplicationActivity.cs
                AlertDialog alertDialog = new AlertDialog.Builder(this).create();

                alertDialog.setTitle("Reset...");
                alertDialog.setMessage("Are you sure?");
                alertDialog.setButton("OK",
                                      new xOnClickListener
                {
                    yield = delegate
                    {
                        b.setText("clicked! " + new { id = Thread.currentThread().getId() });
                    }
                }

                                      );

                // skip icons?
                //alertDialog.setIcon(android.R.drawable.star_off);

                // can we do async yet?
                alertDialog.show();
            }
                );

            ll.addView(b);

            this.setContentView(sv);

            // X:\jsc.svn\examples\java\android\HelloOpenGLES20Activity\HelloOpenGLES20Activity\ScriptCoreLib.Android\Shader.cs

            // Error	1	'TestAlertDialog.Activities.ApplicationActivity' does not contain a definition for 'ShowLongToast' and no extension method 'ShowLongToast' accepting a first argument of type 'TestAlertDialog.Activities.ApplicationActivity' could be found (are you missing a using directive or an assembly reference?)	X:\jsc.svn\examples\java\android\TestAlertDialog\TestAlertDialog\ApplicationActivity.cs	80	18	TestAlertDialog
            //this.ShowLongToast("http://jsc-solutions.net");
            //this.ShowToast("http://jsc-solutions.net");
        }