示例#1
0
        public async void OnClick()
        {
            if (_isFlashOn)
            {
                _isFlashOn = await CameraActions.TurnOffFlash(_isFlashOn);

                ImageActions.SwitchImage(_switchButton, _isFlashOn);
            }
            else
            {
                SoundActions.PlaySound(this, MediaPlayer);
                _isFlashOn = await CameraActions.TurnOnFlash(_isFlashOn);

                ImageActions.SwitchImage(_switchButton, _isFlashOn);
            }
        }
示例#2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState); // Obligatoire pour l'utilisation de Xamarin.Essentials
            // Set our view from the "main" layout resource

            SetContentView(Resource.Layout.activity_main);

            _switchButton = (ImageButton)FindViewById <ImageButton>(Resource.Id.imageButton);
            ImageActions.SwitchImage(_switchButton, _isFlashOn);

            _switchButton.Click += delegate
            {
                OnClick();
                ImageActions.SwitchImage(_switchButton, _isFlashOn);
            };

            _infoTextView            = (TextView)FindViewById <TextView>(Resource.Id.textView);
            _infoTextView.Visibility = Android.Views.ViewStates.Gone;

            _infoButton        = (Button)FindViewById <Button>(Resource.Id.button);
            _infoButton.Click += delegate
            {
                if (_isInfoShown)
                {
                    _isInfoShown             = false;
                    _infoTextView.Visibility = Android.Views.ViewStates.Gone;
                    _switchButton.Visibility = Android.Views.ViewStates.Visible;
                    _infoButton.Text         = "Info";
                }
                else
                {
                    _isInfoShown             = true;
                    _infoTextView.Visibility = Android.Views.ViewStates.Visible;
                    _switchButton.Visibility = Android.Views.ViewStates.Gone;
                    _infoButton.Text         = "Back";
                }
            };
        }