public void LoadTimerSensor() { View viewAlert = View.Inflate(this, Resource.Layout.LayoutTimerSensor, null); AlertDialog.Builder Message = new AlertDialog.Builder(this); Message.SetTitle("زمان را برحسب دقیقه انتخاب کنید"); Message.SetView(viewAlert); Message.SetIcon(Resource.Drawable.Timer); NumberPicker np = (NumberPicker)viewAlert.FindViewById(Resource.Id.LTimerSensorNumberPickerTS); np.MaxValue = 25; np.MinValue = 1; np.SetOnClickListener(this); Message.SetPositiveButton("فعال کن", delegate { ValueTS = (np.Value * 60) * 10; TimerSensor.Start(); Toast.MakeText(this, np.Value + " M " + "تایمر سنسور فعال شد", ToastLength.Short).Show(); WLock = dfpowermanager.NewWakeLock(WakeLockFlags.Full, "DoNotSleep"); WLock.Acquire(); }); Message.SetNegativeButton("لغو", delegate { }); Message.SetNeutralButton("لغو تایمر", delegate { TimerSensor.Stop(); ValueTS = 0; Toast.MakeText(this, "تایمر سنسور غیر فعال شد", ToastLength.Short).Show(); try { WLock.Release(); } catch { } }); Message.Create(); Message.Show(); }