protected override View OnCreateDialogView()
      {
         
         LayoutInflater inflator = LayoutInflater.FromContext(this.Context);
         View dialog = inflator.Inflate(Resource.Layout.opencl_preference, null);

         _openCLRadioGroup = dialog.FindViewById<RadioGroup>(Resource.Id.opencl_preference_radio_group);

         AppPreference preference = new AppPreference();

         RadioButton checkedButton = null;
         RadioButton cpuButton = new RadioButton(this.Context);
         cpuButton.Text = "CPU";

         _openCLRadioGroup.AddView(cpuButton);
         //int selectedIdx = -1;
         if (preference.UseOpenCL == false)
         {
            checkedButton = cpuButton;
         }
         cpuButton.Click += (sender, args) =>
         {
            preference.UseOpenCL = false;
            //Toast.MakeText(this.Context, "cpu clicked", ToastLength.Short).Show();
         };

         String selectedDeviceName = preference.OpenClDeviceName;
         if (selectedDeviceName == null && CvInvoke.HaveOpenCL && preference.UseOpenCL)
         {
            selectedDeviceName = OclDevice.Default.Name;
         }
         //int counter = 1;
         using (VectorOfOclPlatformInfo oclPlatformInfos = OclInvoke.GetPlatformsInfo())
         {
            if (oclPlatformInfos.Size > 0)
            {
               for (int i = 0; i < oclPlatformInfos.Size; i++)
               {
                  OclPlatformInfo platformInfo = oclPlatformInfos[i];

                  for (int j = 0; j < platformInfo.DeviceNumber; j++)
                  {
                     OclDevice device = platformInfo.GetDevice(j);
                     RadioButton deviceButton = new RadioButton(this.Context);
                     deviceButton.Text = "OpenCL: " + device.Name;

                     if (preference.UseOpenCL == true && device.Name.Equals(selectedDeviceName))
                     {
                        checkedButton = deviceButton;
                     }
                     _openCLRadioGroup.AddView(deviceButton);

                     //counter++;
                     deviceButton.Click += (sender, args) =>
                     {
                        preference.UseOpenCL = true;
                        preference.OpenClDeviceName = device.Name;
                        //Toast.MakeText(this.Context, device.Name + " clicked", ToastLength.Short).Show();
                     };

                  }
               }
            }
         }
         if (checkedButton != null)
            _openCLRadioGroup.Check(checkedButton.Id);
         //_openCLRadioGroup.in
         /*
            _openCLToggleButton.Checked = preference.UseOpenCL;

            _openCLToggleButton.CheckedChange += (sender, args) =>
            {
               bool isChecked = args.IsChecked;

               if (isChecked && !CvInvoke.HaveOpenCL)
               {
                  _openCLToggleButton.Checked = false;
                  Toast.MakeText(Context, "No OpenCL compatible device found.", ToastLength.Long).Show();
                  isChecked = false;
               }

               preference.UseOpenCL = isChecked;
            };
            */
         return dialog;
      }
        protected void InitRadioButtons(string[,] aLaunchExtensions, string aUrl, string aResourceID, RadioGroup aRadioGroup)
        {
            aRadioGroup.RemoveAllViews();

            SortedList<int, RadioButton> _myList = new SortedList<int, RadioButton>();

            for (int i = 0; i < aLaunchExtensions.GetLength(0); i++)
            {
                string _curS = aLaunchExtensions[i, 0];
                string _curParam = aLaunchExtensions[i, 1];

                RadioButton _button = new RadioButton(this);
                _button.Text = string.Format("{0} [{1}]",_curS,_curParam);
                _button.Tag = i;

                string _resourceName = aResourceID + _curParam;
                if (_resourceName == aResourceID)
                { _resourceName = aResourceID+"nothing"; };

                // int _resourceID = Resources.GetIdentifier(_resourceName, "drawable", this.PackageName);
                if (_resourceName != "nothing")
                {
                    try
                    {
                        var _resourceID = (int)typeof(Resource.Drawable).GetField(_resourceName).GetValue(null);
                        if (_resourceID > 0)
                        {
                            Android.Graphics.Drawables.Drawable _d = Resources.GetDrawable(_resourceID);
                            _d.SetBounds(0, 0, 120, 120);
                            _button.SetCompoundDrawables(_d, null, null, null);
                        };
                    }
                    catch { };
                };
                aRadioGroup.AddView(_button);

                if ((aUrl.IndexOf(_curParam) >= 0) && (_curParam != ""))
                {
                    _myList.Add(_curParam.Length, _button);
                };
            };

            if (_myList.Count > 0)
            {
                RadioButton _button = _myList.Values[_myList.Count() - 1];
                aRadioGroup.Check(_button.Id);
            };
        }
Beispiel #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            SetTheme (Android.Resource.Style.ThemeHoloLightNoActionBar);
            SetContentView (Resource.Layout.frmAggiungiUtente);

            txtCognome = FindViewById<EditText> (Resource.Id.txtCognome);
            txtNome = FindViewById<EditText> (Resource.Id.txtNome);
            txtNumeroTessera = FindViewById<EditText> (Resource.Id.txtNumeroTessera);
            radioTipo = FindViewById<RadioGroup> (Resource.Id.gruppoTipi);
            dataIscrizione = FindViewById<DatePicker> (Resource.Id.datePicker1);
            dataIscrizione.Init (DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,new DateChangedListener((picker, year, month, day) => {
                valutaScadenza();
            }));
            txtSaldo = FindViewById<EditText> (Resource.Id.txtSaldo);
            txtDataScadenza = FindViewById<TextView> (Resource.Id.txtScadenza);

            Button btnSalva = FindViewById<Button> (Resource.Id.btnSalva);
            Button btnAnnulla = FindViewById<Button> (Resource.Id.btnAnnulla);
            Button btnElimina = FindViewById<Button> (Resource.Id.btnElimina);
            btnScade = FindViewById<ToggleButton> (Resource.Id.btnPuoScadere);
            btnScade.Activated = puoScadere;

            btnScade.CheckedChange+= BtnScade_CheckedChange;

            btnElimina.Enabled = false;
            if (this.Intent.HasExtra("numtessera")) {
                insertMode = false;
                numtessera =  Intent.GetIntExtra ("numtessera",0).ToString();
                btnElimina.Enabled = true;
                riprendiCliente (numtessera);
            }
            btnElimina.Click += BtnElimina_Click;
            btnSalva.Click+= BtnSalva_Click;
            btnAnnulla.Click += (sender, e) => {
                funzioni.MsgBox(this,"Annullare l'inserimento (Tutti i dati non salvati andranno persi!) ?",
                    "Vegetha",
                    "SI",
                    ()=>{SetResult(Result.Ok);  Finish(); },
                    "NO",
                    ()=>{});

            };

            txtCognome.FocusChange+= txtFocusChange;
            txtNome.FocusChange += txtFocusChange;
            radioTipo.CheckedChange += (sender, e) => {
                valutaScadenza ();
            };
            radioTipo.Check( Resource.Id.radioAnnuale);
            valutaScadenza ();
        }