using System;
using Android.Content;
using Android.Views;
using Android.Widget;
using HDL_ON_Android;

namespace HDL_ON
{
 
    public class ZXingCustomScanView : RelativeLayout
    {
        public Action OnCancel;
        public Action OnTorch;
        public TextView cancelTextView, flashTextView, titleTextView;
        public ZXingCustomScanView(Context context) : base(context)
        {
            View.Inflate(context, Resource.Layout.zxing_layout, this);

            titleTextView = FindViewById<TextView>(Resource.Id.tv_zxing_scan);

            cancelTextView = FindViewById<TextView>(Resource.Id.tv_zxing_back);
            cancelTextView.Text = cancelText;
            flashTextView = FindViewById<TextView>(Resource.Id.tv_zxing_flash);
            flashTextView.Text = flashText;

            cancelTextView.Click += Cancel_Click;
            flashTextView.Click += Flash_Click;
        }
        
        String cancelText = "Cancel";
        public String CancelText
        {
            get
            {
                return cancelText;
            }
            set {
                cancelText = value;
                cancelTextView.Text = cancelText;
            }
        }

        String flashText = "Flash";
        public String FlashText
        {
            get
            {
                return flashText;
            }
            set
            {
                flashText = value;
                flashTextView.Text = flashText;
            }
        }





        private void Flash_Click(object sender, EventArgs e)
        {
            OnTorch?.Invoke();
        }

        private void Cancel_Click(object sender, System.EventArgs e)
        {
            OnCancel?.Invoke();
        }

    }
}