Beispiel #1
0
        private void ConsoleCommand()
        {
            AlertDialog commandDialog = null;
            Button      btnSend       = null;
            Button      btnCancel     = null;

            Android.OS.Handler dialogHandler = new Android.OS.Handler(m => { throw new Java.Lang.RuntimeException(); });

            AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);

            View content = LayoutInflater.From(this).Inflate(Resource.Layout.edit_option_dialog, null);

            EditText edtKey = content.FindViewById <EditText>(Resource.Id.key);

            edtKey.Text = "";

            btnSend   = content.FindViewById <Button>(Resource.Id.btn_ok);
            btnCancel = content.FindViewById <Button>(Resource.Id.btn_cancel);

            btnSend.Text = Resources.GetString(Resource.String.send);

            btnSend.Enabled   = true;
            btnCancel.Enabled = true;

            btnSend.Click += delegate
            {
                string commandResult = SendConsoleCommand(edtKey.Text);

                if (!commandResult.Equals(""))
                {
                    EddieLogger.Debug(commandResult);

                    logEntry = GetCurrentLog(FormatType.HTML, LogTime.LOCAL);

                    if (logEntry == null)
                    {
                        return;
                    }

                    if (viewMode == ViewMode.ListView)
                    {
                        logListAdapter.DataSet(GetSpannedLog());
                    }
                    else
                    {
                        LoadLogWebView();
                    }
                }

                commandDialog.Dismiss();

                dialogHandler.SendMessage(dialogHandler.ObtainMessage());
            };

            btnCancel.Click += delegate
            {
                commandDialog.Dismiss();

                dialogHandler.SendMessage(dialogHandler.ObtainMessage());
            };

            dialogBuilder.SetTitle(Resources.GetString(Resource.String.console_command_title));
            dialogBuilder.SetView(content);

            commandDialog = dialogBuilder.Create();
            commandDialog.Show();

            try
            {
                Looper.Loop();
            }
            catch (Java.Lang.RuntimeException)
            {
            }
        }