Пример #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            SetContentView (Resource.Layout.dialog);

            // Normal Dialog
            Button mbtnAlert = FindViewById<Button> (Resource.Id.btnDialog);
            mbtnAlert.Click += delegate
            {
                new AlertDialog.Builder(this)
                    .SetTitle("Alert!")
                        .SetMessage("This is the content of the alert")
                        .SetPositiveButton("Ok", delegate
                                           {
                            Toast.MakeText(this, "Clicked ok", ToastLength.Short).Show();
                        })
                        .SetNegativeButton("Cancel", delegate
                                           {
                            Toast
                                .MakeText(this, "Clicked cancel", ToastLength.Short)
                                    .Show();
                        })
                        .Show();
            };

            //Progress Dialog
            Button mbtnProgress = FindViewById<Button>(Resource.Id.btnProgress);
            mbtnProgress.Click += delegate
            {
                ProgressDialog progressDialog = ProgressDialog.Show(this, "Running", "Please wait...", true);

                new Thread(new ThreadStart(delegate
                                           {
                    Thread.Sleep(5000);

                    RunOnUiThread(() => progressDialog.Hide());
                })).Start();
            };

            //Custom Dialog
            Button mbtnCustom = FindViewById<Button> (Resource.Id.btnCustom);
            mbtnCustom.Click += delegate
            {
                Dialog dialog = new Dialog(this);
                dialog.SetContentView(Resource.Layout.custom_dialog);
                dialog.SetTitle("This is a custom dialog");
                dialog.SetCancelable(true);
                EditText input = (EditText) dialog.FindViewById (Resource.Id.editTextD);
                TextView txtv = (TextView)dialog.FindViewById(Resource.Id.textView1);
                Button btnOk = (Button)dialog.FindViewById(Resource.Id.btnOk);
                btnOk.Click += delegate
                {
                    if (input.Text.Length>0){
                        Toast.MakeText(this, input.Text, ToastLength.Short).Show();
                    } else {
                        Toast.MakeText(this, "Clicked ok", ToastLength.Short).Show();
                    }

                    dialog.Cancel();
                };
                Button btnCancel = (Button)dialog.FindViewById(Resource.Id.btnCancel);
                btnCancel.Click += delegate
                {
                    dialog.Cancel();
                };

                dialog.Show();
            };

            Button mbackBtn = FindViewById<Button> (Resource.Id.BackBtn5);
            mbackBtn.Click += delegate
            {
                Finish();
            };
        }
Пример #2
0
        private void DisplayDialogOkey()
        {
            //Close Keyboard
            InputMethodManager inputMgr = GetSystemService(InputMethodService) as InputMethodManager;
            if (CurrentFocus != null)
                inputMgr.HideSoftInputFromWindow(CurrentFocus.WindowToken, 0);

            //Open Connect Dialog!
            //set the content view to the dialogwindow content
            //outside this contentview we are unable to find our resources
            SetContentView(Resource.Layout.DialogWindow);

            //create a new dialog
            dialog = new Dialog(this);
            dialog.SetContentView(Resource.Layout.DialogWindow);
            dialog.SetTitle("OML");
            dialog.SetCancelable(true);

            //set the dialog text
            dialogTxt = FindViewById<TextView>(Resource.Id.dialogText);

            //set the buttons
            okButton = FindViewById<Button>(Resource.Id.okButton);
            cancelButton = FindViewById<Button>(Resource.Id.cancelButton);

            //Hide Cancel buttom, Only Okey needed
            cancelButton.Visibility = ViewStates.Invisible;

            okButton.Click += delegate
            {
                //change the background, close the dialog and set the contentview back to the live / connection screen
                //so we can continue with our activity
                //Draw Click
                okButton.SetBackgroundResource(Resource.Drawable.okbutton_pressed);
                //Close Dialog
                dialog.Cancel();
                this.OnCreate(bundle);
            };//end delegate
        }
Пример #3
0
        void MultiChoice(object sender, EventArgs e)
        {
            var dialog = new Dialog (this);
            dialog.RequestWindowFeature(1);
            dialog.SetContentView (Resource.Layout.multichoice);
            dialog.Window.SetBackgroundDrawableResource (Resource.Drawable.station_sign_background);
            dialog.Window.SetFeatureInt (WindowFeatures.NoTitle,0);
            dialog.SetCancelable (true);

            var title = (TextView) dialog.FindViewById (Resource.Id.titleDialog);
            title.Typeface = kalingab;

            var listView = (ListView) dialog.FindViewById (Resource.Id.multiListView);
            listView.Clickable = true;
            listView.ChoiceMode = ChoiceMode.Multiple;
            listView.ItemClick += (object s, AdapterView.ItemClickEventArgs ev) => {
                var conn = connections [ev.Position];
                conn.Save = !conn.Save;
                Console.WriteLine ("item clicked {0}", ev.Position);
                ((XListViewAdapter) listView.Adapter).NotifyDataSetChanged ();
            };

            var listAdapter = new XListViewAdapter (this, connections);
            listView.Adapter = listAdapter;
            //XListViewAdapter.CheckHandler += RadioClicked;
            var btnOk = (Button)dialog.FindViewById(Resource.Id.bOk);
            btnOk.Click += delegate {
                foreach (var connection in connections) {
                    if (connection.Save) {
                        Console.WriteLine ("id: {0} Save?:{1}", connection.ID, connection.Save);
                    }
                }
                //cCommand.AddConnection (connection);
                var cCommand = new ConnectionCommands (this);
                cCommand.Close ();
                dialog.Cancel ();
            };

            var btnCancel = (Button)dialog.FindViewById(Resource.Id.bCancel);
            btnCancel.Click += delegate {
                dialog.Cancel ();
            };

            dialog.Show();
        }
Пример #4
0
        void TimePicker_Dialog(object sender, EventArgs e)
        {
            dialog = new Dialog (this);
            dialog.RequestWindowFeature(1);
            dialog.SetContentView (Resource.Layout.timedialog);
            dialog.Window.SetBackgroundDrawableResource (Resource.Drawable.empty);
            dialog.Window.SetFeatureInt (WindowFeatures.NoTitle,0);
            dialog.Window.ClearFlags (WindowManagerFlags.DimBehind);
            dialog.SetCancelable (true);
            dialog.SetCanceledOnTouchOutside (true);

            // hour
            var hourInput = dialog.FindViewById (Resource.Id.hourInput) as EditText;
            var hourUp = dialog.FindViewById (Resource.Id.hourUp) as Button;
            var hourDown = dialog.FindViewById (Resource.Id.hourDown) as Button;
            hourUp.Tag = Resource.Id.hourInput;
            hourDown.Tag = Resource.Id.hourInput;
            hourUp.Click += Change_Time;
            hourDown.Click += Change_Time;

            // minute
            var minuteInput = dialog.FindViewById (Resource.Id.minuteInput) as EditText;
            var minuteUp = dialog.FindViewById (Resource.Id.minuteUp) as Button;
            var minuteDown = dialog.FindViewById (Resource.Id.minuteDown) as Button;
            minuteUp.Tag = Resource.Id.minuteInput;
            minuteDown.Tag = Resource.Id.minuteInput;
            minuteUp.Click += Change_Time;
            minuteDown.Click += Change_Time;

            var time = timeLabel.Text.Split(':');

            RunOnUiThread (() => {
                hourInput.Text = time [0];
                minuteInput.Text = time [1];
            });

            var btnOk = (Button)dialog.FindViewById(Resource.Id.button2);
            btnOk.Click += delegate {
                RunOnUiThread (() => timeLabel.Text =
                               String.Format ("{0}:{1}", hourInput.Text, minuteInput.Text));
                dialog.Dismiss ();
            };

            var btnCancel = (Button)dialog.FindViewById(Resource.Id.button1);
            btnCancel.Click += delegate {
                dialog.Cancel ();
            };
            dialog.Show();;
        }
Пример #5
0
        void DatePicker_Dialog(object sender, EventArgs e)
        {
            dialog = new Dialog (this);
            dialog.RequestWindowFeature(1);
            dialog.SetContentView (Resource.Layout.datedialog);
            dialog.Window.SetBackgroundDrawableResource (Resource.Drawable.empty);
            dialog.Window.SetFeatureInt (WindowFeatures.NoTitle,0);
            dialog.Window.ClearFlags (WindowManagerFlags.DimBehind);
            dialog.SetCancelable (true);
            dialog.SetCanceledOnTouchOutside (true);

            // day
            var dayInput = dialog.FindViewById (Resource.Id.dayInput) as EditText;
            var dayUp = dialog.FindViewById (Resource.Id.dayUp) as Button;
            var dayDown = dialog.FindViewById (Resource.Id.dayDown) as Button;
            dayUp.Tag = Resource.Id.dayInput;
            dayDown.Tag = Resource.Id.dayInput;
            dayUp.Click += Change_Date;
            dayDown.Click += Change_Date;

            // day
            var monthInput = dialog.FindViewById (Resource.Id.monthInput) as EditText;
            var monthUp = dialog.FindViewById (Resource.Id.monthUp) as Button;
            var monthDown = dialog.FindViewById (Resource.Id.monthDown) as Button;
            monthUp.Tag = Resource.Id.monthInput;
            monthDown.Tag = Resource.Id.monthInput;
            monthUp.Click += Change_Date;
            monthDown.Click += Change_Date;

            // year
            var yearInput = dialog.FindViewById (Resource.Id.yearInput) as TextView;
            var yearUp = dialog.FindViewById (Resource.Id.yearUp) as Button;
            var yearDown = dialog.FindViewById (Resource.Id.yearDown) as Button;
            yearUp.Tag = Resource.Id.yearInput;
            yearDown.Tag = Resource.Id.yearInput;
            yearUp.Click += Change_Date;
            yearDown.Click += Change_Date;

            var date = dateLabel.Text.Split ('/');

            RunOnUiThread (() => {
                dayInput.Text = date [0];
                monthInput.Text = date [1];
                yearInput.Text = String.Format ("20{0}", date [2]);
            });

            var btnOk = (Button)dialog.FindViewById(Resource.Id.button2);
            btnOk.Click += delegate {
                RunOnUiThread (() => dateLabel.Text =
                               String.Format ("{0}/{1}/{2}", dayInput.Text, monthInput.Text, yearInput.Text.Substring (2)));
                dialog.Dismiss ();
            };

            var btnCancel = (Button)dialog.FindViewById(Resource.Id.button1);
            btnCancel.Click += delegate {
                dialog.Cancel ();
            };
            dialog.Show();
        }
Пример #6
0
        /// <summary>
        /// Opens a dialog window with the choice to release the object we picked up (ring)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void releaseClick(object sender, EventArgs e)
        {
            //reset the button drawable
            btnDrawableReset();
            //set the background
            release.SetBackgroundResource(Resource.Drawable.releasebutton_pressed);

            updateThread.Abort();

            //set the content view to the dialogwindow content
            //outside this contentview we are unable to find our resources
            SetContentView(Resource.Layout.DialogWindow);

            //create a new dialog
            dialog = new Dialog(this);
            dialog.SetContentView(Resource.Layout.DialogWindow);
            dialog.SetTitle("Release ring");
            dialog.SetCancelable(true);

            //set the dialog text
            dialogTxt = FindViewById<TextView>(Resource.Id.dialogText);
            dialogTxt.Text = "Are you sure you want to release the ring?";

            //set the buttons
            okButton = FindViewById<Button>(Resource.Id.okButton);
            cancelButton = FindViewById<Button>(Resource.Id.cancelButton);

            //handle click events
            okButton.Click += delegate
            {
                //change the background and finish the current activity (controller)
                okButton.SetBackgroundResource(Resource.Drawable.okbutton_pressed);

                //set bool true to get carmen to release the ring
                Send_Singleton.Instance.releaseRing = 1;

                SetContentView(Resource.Layout.Controller);
                this.OnCreate(bundle);
                //Close the dialog
                dialog.Cancel();
            };//end delegate
            cancelButton.Click += delegate
            {
                //change the background, cancel the dialog and set the contentview back to the controller
                //so we can continue with our activity
                cancelButton.SetBackgroundResource(Resource.Drawable.cancelbutton_pressed);
                dialog.Cancel();
                this.OnCreate(bundle);
            };//end delegate
        }
Пример #7
0
        /// <summary>
        /// overrided bool to show a dialog window 
        /// when trying to exit the controller
        /// </summary>
        /// <param name="keyCode"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        public override bool OnKeyDown(Keycode keyCode, KeyEvent e)
        {
            //if the back key is pressed
            if (keyCode == Keycode.Back)
            {
                updateThread.Abort();
                //set the content view to the dialogwindow content
                //outside this contentview we are unable to find our resources
                SetContentView(Resource.Layout.DialogWindow);

                //create a new dialog
                dialog = new Dialog(this);
                dialog.SetContentView(Resource.Layout.DialogWindow);
                dialog.SetTitle("OML");
                dialog.SetCancelable(true);

                //set the dialog text
                dialogTxt = FindViewById<TextView>(Resource.Id.dialogText);
                dialogTxt.Text = "By leaving the controller interface you will exit the current session. \n\n Do you wish to continue?";

                //set the buttons
                okButton = FindViewById<Button>(Resource.Id.okButton);
                cancelButton = FindViewById<Button>(Resource.Id.cancelButton);

                //handle click events
                okButton.Click += delegate
                {
                    //change the background and finish the current activity (controller)
                    okButton.SetBackgroundResource(Resource.Drawable.okbutton_pressed);
                    //Close the Activity
                    Finish();
                    //Ends the Current Session!
                    Settings_Singleton.Instance.CloseCurrentSession();
                    //Close the Viewer TCP
                    Settings_Singleton.Instance.CloseViewerTCP();

                };//end delegate
                cancelButton.Click += delegate
                {
                    //change the background, cancel the dialog and set the contentview back to the controller
                    //so we can continue with our activity
                    cancelButton.SetBackgroundResource(Resource.Drawable.cancelbutton_pressed);
                    dialog.Cancel();
                    this.OnCreate(bundle);
                };//end delegate

                return true;
            }//end if
             	        return base.OnKeyDown(keyCode, e);
        }