Ejemplo n.º 1
0
 public ZXingModule()
 {
     _scanner = new MobileBarcodeScanner();
 }
Ejemplo n.º 2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.AddItemFormLayout, container, false);

            mBarcode = view.FindViewById <TextView>(Resource.Id.textViewAddBarcodeId);
            mName    = view.FindViewById <AutoCompleteTextView>(Resource.Id.editTextAddName);

            mPrice             = view.FindViewById <EditText>(Resource.Id.editTextAddItemPrice);
            mSpinnerCategories = view.FindViewById <Spinner>(Resource.Id.spinnerAddItemCategory);
            mSpinnerStorages   = view.FindViewById <Spinner>(Resource.Id.spinnerAddItemStorage);
            mExpDateChoose     = view.FindViewById <EditText>(Resource.Id.editTextAddItemExpDate);
            mAddtoInventory    = view.FindViewById <ImageButton>(Resource.Id.buttonAddAddToInventory);
            mScan         = view.FindViewById <ImageButton>(Resource.Id.imageButtonAddScan2);
            mBarcode.Text = "-";
            mPrice.Text   = "0";
            LoadItemData();
            mExpDateChoose.Click += (object sender, EventArgs args) =>
            {
                //ngeluarin dialog
                FragmentTransaction      transaction      = FragmentManager.BeginTransaction();
                DialogDatePickerActivity DatePickerDialog = new DialogDatePickerActivity();
                DatePickerDialog.Show(transaction, "dialogue fragment");
                DatePickerDialog.OnPickDateComplete += DatePickerDialogue_OnComplete;
            };

            mAddtoInventory.Click += (object sender, EventArgs args) =>
            {
                if (mBarcode.Text == "-")
                {
                    for (int i = 0; i < mProducts.Count(); i++)
                    {
                        if (mName.Text == mProducts[i].Name)
                        {
                            mProduct.Id = mProducts[i].Id;
                            AddInventoryData();
                        }
                        else
                        {
                            mProduct.Id = new Guid();
                            AddProductData();
                            AddInventoryData();
                        }
                    }
                }
                else if (mBarcode.Text != "-")
                {
                    if (isBarcodeFound)
                    {
                        AddInventoryData();
                    }
                    else
                    {
                        AddProductData();
                        mProduct.Name      = mName.Text;
                        mProduct.BarcodeId = mBarcode.Text;

                        AddInventoryData();
                    }
                }
            };
            MobileBarcodeScanner.Initialize(this.Activity.Application);
            scanner      = new MobileBarcodeScanner();
            mScan.Click += async delegate {
                scanner.UseCustomOverlay = false;
                scanner.TopText          = "Hold the camera up to the barcode\nAbout 6 inches away";
                scanner.BottomText       = "Wait for the barcode to automatically scan!";

                var result = await scanner.Scan();

                HandleScanResult(result);
                mBarcode.Text = result.Text;
                for (int i = 0; mProducts.Count > i; i++)
                {
                    if (mBarcode.Text == mProducts[i].BarcodeId)
                    {
                        mProduct.Id    = mProducts[i].Id;
                        mName.Text     = mProducts[i].Name;
                        isBarcodeFound = true;
                    }
                }
            };

            void HandleScanResult(ZXing.Result result)
            {
                string msg = "";

                if (result != null && !string.IsNullOrEmpty(result.Text))
                {
                    msg = "Found Barcode: " + result.Text;
                }
                else
                {
                    msg = "Scanning Canceled!";
                }

                this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, msg, ToastLength.Short).Show());
            }

            return(view);
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            ConfigureCultureInfo();

            Platform.Init();
            Appearance.Init();

            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            if (Intent != null && Intent.Extras != null && Intent.Extras.ContainsKey("logistics"))
            {
                try
                {
                    appServices = DependencyService.Get <IAppServices>() as AppServices;
                    if (appServices != null && appServices.MainActivity != null && !appServices.MainActivity.IsDestroyed)
                    {
                        string value = string.Empty;
                        try
                        {
                            value = Intent.Extras.GetString("logistics");
                            var logisticsNotification = JsonConvert.DeserializeObject <LogisticsNotification>(value);
                            appServices.MainActivity.IsNeedRefresh         = true;
                            appServices.MainActivity.LogisticsNotification = logisticsNotification;
                            this.Finish();
                            return;
                        }
                        catch (Exception e1)
                        {
                            appServices.MainActivity.Finish();
                            ExceptionHandler.Catch(e1);
                        }
                    }
                }
                catch (Exception e2)
                {
                    //App is closed, wait app init and show popup below (see enf of method)
                    ExceptionHandler.Catch(e2);
                }
            }

            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().PermitAll().Build();
            StrictMode.SetThreadPolicy(policy);

            MobileBarcodeScanner.Initialize(Application);
            FFImageLoading.Forms.Droid.CachedImageRenderer.Init();

            var config = new FFImageLoading.Config.Configuration()
            {
                VerboseLogging                 = false,
                VerbosePerformanceLogging      = false,
                VerboseMemoryCacheLogging      = false,
                VerboseLoadingCancelledLogging = false,
                Logger = new CustomLogger(),
            };

            ImageService.Instance.Initialize(config);

            AppServices.MainActivityInstance = this;

            global::Xamarin.Forms.Forms.Init(this, bundle);

            Xamarin.FormsMaps.Init(this, bundle);

            DependencyService.Register <ToastNotificatorImplementation>();
            ToastNotificatorImplementation.Init(this);

            LoadApplication(new App());

            ConfigurateServicePoint();

            appServices = DependencyService.Get <IAppServices>() as AppServices;

            mGoogleApiClient = new GoogleApiClient.Builder(this)
                               .AddConnectionCallbacks(this)
                               .AddOnConnectionFailedListener(this)
                               .AddApi(Android.Gms.Location.LocationServices.API)
                               .Build();

            mLocationRequest = LocationRequest.Create()
                               .SetPriority(LocationRequest.PriorityHighAccuracy)
                               .SetSmallestDisplacement(5)
                               .SetInterval(30 * 1000)
                               .SetFastestInterval(10 * 1000);

            GetLocation(false);

            TestIfGooglePlayServicesIsInstalled();

            if (!IsPermissionRequested)
            {
                IsPermissionRequested = true;
                Handler UIHandler = new Handler();
                UIHandler.PostDelayed(() =>
                {
                    try
                    {
                        List <string> permissions = new List <string>();
                        permissions.Add(Manifest.Permission.Camera);
                        permissions.Add(Manifest.Permission.ReadPhoneState);
                        if (permissions.Count > 0)
                        {
                            ActivityCompat.RequestPermissions(this, permissions.ToArray(), RequestPermissionsCode);
                        }
                    }
                    catch (Exception e3)
                    {
                        ExceptionHandler.Catch(e3);
                    }
                }, 2000);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activityMain);

            MobileBarcodeScanner.Initialize(Application);

            _webView = FindViewById <WebView>(Resource.Id.mainWebview);

            this.Window.SetFlags(WindowManagerFlags.KeepScreenOn, WindowManagerFlags.KeepScreenOn);

            AppCenter.Start("APP_CENTER_ID", typeof(Analytics), typeof(Crashes));

            try
            {
                // set up webview client
                _webViewClient = new ThinkActiveWebViewClient();
                _jsInterface   = new ThinkActiveJSInterface();
                _webView.Settings.JavaScriptEnabled = true;
                _webView.AddJavascriptInterface(_jsInterface, "ThinkActiveApplication");
                _webView.SetWebViewClient(_webViewClient);
                _webView.Settings.SetAppCacheEnabled(false);
                WebView.SetWebContentsDebuggingEnabled(true);

                // Start Bluetooth
                _androidBluetoothManager = (BluetoothManager)GetSystemService(Context.BluetoothService);

                _bluetoothBroadcastReceiver = new BluetoothBroadcastReceiver();
                this.RegisterReceiver(_bluetoothBroadcastReceiver, new IntentFilter(BluetoothAdapter.ActionStateChanged));

                _deploymentUsers = new List <DeploymentUser>();

                // Listen for JSInterface events after page finished loading
                _webViewClient.PageFinished += (object sender, EventArgs e) => {};

                _jsInterface.OnSetDeploymentUsers += (object s, DeploymentUser[] deploymentUsers) =>
                {
                    _deploymentUsers = deploymentUsers;

                    foreach (var macAddress in _observedDevices)
                    {
                        DeploymentUser deploymentUser = _deploymentUsers.SingleOrDefault(du => du.device.macAddress == macAddress);
                        // if deploymentUser is found
                        if (deploymentUser != default(DeploymentUser))
                        {
                            RunOnUiThread(() =>
                            {
                                Console.WriteLine($"CONNECTION: SHOW AVATAR");
                                _webViewClient.DeviceJoined(_webView, deploymentUser);
                            });
                        }
                    }
                };

                // QR code scanned, webview is requesting device information from specific device
                _jsInterface.OnRequestData += async(object s, DeploymentUser deploymentUser) =>
                {
                    RunOnUiThread(() =>
                    {
                        _webViewClient.ConsoleLog(_webView, JsonConvert.SerializeObject(deploymentUser));
                    });

                    // try to connect to specfic device
                    if (deploymentUser != null)
                    {
                        // update the _deploymentUser list with the latest information
                        DeploymentUser outdatedDeploymentUser = _deploymentUsers.FirstOrDefault(dU => dU.id == deploymentUser.id);

                        if (outdatedDeploymentUser != null)
                        {
                            //var position = _deploymentUsers.IndexOf(outdatedDeploymentUser);
                            //_deploymentUsers[position] = deploymentUser;
                            outdatedDeploymentUser = deploymentUser;
                        }

                        await ConnectToDevice(deploymentUser);
                    }
                    else
                    {
                        RunOnUiThread(() =>
                        {
                            Toast.MakeText(ApplicationContext, "User not found", ToastLength.Short).Show();
                        });
                    }
                };

                _jsInterface.OnVibrateDevice += async(object s, string macAddress) =>
                {
                    RunOnUiThread(() =>
                    {
                        _webViewClient.ConsoleLog(_webView, $"OnVirbateDevice:{ macAddress }");
                    });

                    await VibrateDevice(macAddress);
                };

                // attach bluetooth receiver
                _bluetoothBroadcastReceiver.onStateChanged += async(object bluetoothSender, State state) => {
                    // check bluetooth state is off, restart if off
                    if (state == Android.Bluetooth.State.Off)
                    {
                        // turn back on
                        EnableBluetooth();
                    }
                    else if (state == Android.Bluetooth.State.On)
                    {
                        await SetupAxLEManager();
                    }
                };

                _webView.LoadUrl(webViewUrl);

                _bluetoothToggleTimer = new System.Timers.Timer
                {
                    Interval  = 1000,
                    AutoReset = true
                };

                _bluetoothToggleTimer.Elapsed += (s, e) => {
                    lock (_syncBluetoothToggle)
                    {
                        var        now    = DateTime.Now;
                        DateTime[] resets =
                        {
                            new DateTime(now.Year, now.Month, now.Day,  7, 00, 0),
                            new DateTime(now.Year, now.Month, now.Day, 12, 30, 0),
                        };
                        bool disable = false;
                        foreach (var reset in resets)
                        {
                            if (_lastTimeBluetoothToggleChecked != default(DateTime) && now >= reset && _lastTimeBluetoothToggleChecked < reset)
                            {
                                disable = true;
                            }
                        }
                        if (disable)
                        {
                            DisableBluetooth();
                        }
                        _lastTimeBluetoothToggleChecked = now;
                    }
                };

                _bluetoothToggleTimer.Start();
            }
            catch (Exception e) {
                Console.WriteLine(e.ToString());
            }
        }
Ejemplo n.º 5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            RequestWindowFeature(WindowFeatures.NoTitle);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            /**/
            var j = this.Intent.GetStringExtra("ItemRow");

            item = JsonConvert.DeserializeObject <Item>(j);

            ColorDrawable color = new ColorDrawable(Color.OrangeRed);

            var actionBar = FindViewById <LinearLayout>(Resource.Id.actonBar);

            actionBar.SetBackgroundDrawable(color);

            FindViewById <TextView>(Resource.Id.txtTitle).Text = item.Descrip;
            //back
            ImageButton btnBack = this.FindViewById <ImageButton>(Resource.Id.btnBack);

            btnBack.Click += (s1, e1) =>
            {
                this.Finish();
                // wv.GoBack();
            };
            btnBack.SetBackgroundResource(Resource.Drawable.back);
            //scan
            ImageButton btnScan = this.FindViewById <ImageButton>(Resource.Id.btnScan);

            btnScan.Click += (s1, e1) =>
            {
                CallWebViewSendData();
            };

            btnScan.SetBackgroundResource(Resource.Drawable.Barcode2);

            Information info = new Information()
            {
                user_id = "A110018", user_name = "Roger Roan"
            };
            String content = JsonConvert.SerializeObject(info, Formatting.None);

            MobileBarcodeScanner.Initialize(Application);

            wv = this.FindViewById <WebView>(Resource.Id.webview);

            refresher = FindViewById <CustomSwipeRefreshLayout>(Resource.Id.refresher);

            refresher.setCanChildScrollUpCallback(this);

            refresher.SetColorScheme(Resource.Color.xam_dark_blue,
                                     Resource.Color.xam_purple,
                                     Resource.Color.xam_gray,
                                     Resource.Color.xam_green);

            wv.Settings.JavaScriptEnabled = true;

            wv.AddJavascriptInterface(new JsInteration(this), "control");

            wv.Settings.SetSupportZoom(true);
            wv.Settings.BuiltInZoomControls = true;


            wv.Settings.UseWideViewPort      = true;
            wv.Settings.LoadWithOverviewMode = true;

            WebChromeClient wc = new WebChromeClient();

            wv.SetWebChromeClient(wc);

            MyWebViewClient wvc = new MyWebViewClient(refresher);

            wv.SetWebViewClient(wvc);

            wv.LoadUrl(item.Link);

            refresher.Refresh += delegate
            {
                wv.Reload();
            };
        }
Ejemplo n.º 6
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            // return inflater.Inflate(Resource.Layout.YourFragment, container, false);
            //return base.OnCreateView(inflater, container, savedInstanceState);

            rootView = inflater.Inflate(Resource.Layout.fragmentrental, container, false);
            //INICIALIZAR LOS OBJETOS
            MobileBarcodeScanner.Initialize(Activity.Application);

            scanner = new MobileBarcodeScanner();

            edtCedula    = rootView.FindViewById <EditText>(Resource.Id.editText1);
            edtNombres   = rootView.FindViewById <EditText>(Resource.Id.editText2);
            edtCodAlq    = rootView.FindViewById <EditText>(Resource.Id.editText3);
            edtFechaalq  = rootView.FindViewById <EditText>(Resource.Id.editText4);
            edtFechaDevo = rootView.FindViewById <EditText>(Resource.Id.editText5);

            //DESACTIVAR LOS EDITEXT DE FECHA Y OTROS
            edtFechaalq.Enabled  = false;
            edtFechaDevo.Enabled = false;
            edtCodAlq.Enabled    = false;
            edtNombres.Enabled   = false;

            int var = int.Parse(Service.RentalCode());

            edtCodAlq.Text   = var.ToString();
            edtFechaalq.Text = DateTime.Now.ToShortDateString();

            //ASIGNACION DE OBJETOS Y ELIMINACION DE FONDOS A IMAGEBOTTON
            btnScan = rootView.FindViewById <ImageButton>(Resource.Id.button1);
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnScan.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            btnAgregar = rootView.FindViewById <ImageButton>(Resource.Id.button2);
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnAgregar.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            btnFecha = rootView.FindViewById <ImageButton>(Resource.Id.button3);
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnFecha.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            btnlibros = rootView.FindViewById <ImageButton>(Resource.Id.button4);
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnlibros.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            btnguardar = rootView.FindViewById <ImageButton>(Resource.Id.button5);
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnguardar.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            btnAceptar = rootView.FindViewById <ImageButton>(Resource.Id.button6);
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnAceptar.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos

            listacopias = rootView.FindViewById <ListView>(Resource.Id.listView1);

            btnlibros.Click  += Btnlibros_Click;
            btnFecha.Click   += BtnFecha_Click;
            btnAgregar.Click += BtnAgregar_Click;
            btnguardar.Click += Btnguardar_Click;
            btnAceptar.Click += BtnAceptar_Click;

            //ACTIVA EL ESCANEO
            btnScan.Click += async delegate {
                //Tell our scanner to use the default overlay
                scanner.UseCustomOverlay = false;

                //PERSONALIZAR LOS MENSAJES QUE SE MOSTRARAN EN LA CAMARA DEL SCANNER
                scanner.TopText    = "Por favor, no mueva el dispositivo móvil\nMantengalo al menos 10cm de distancia";
                scanner.BottomText = "Espere mientras el scanner lee el código de barra";

                //COMIENZO DEL SCANEO
                var result = await scanner.Scan();

                HandleScanResult(result);
            };

            return(rootView);
        }
Ejemplo n.º 7
0
 public BarCode()
 {
     scanner = new MobileBarcodeScanner();
 }
Ejemplo n.º 8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            Console.Error.WriteLine("--------------------------- Creating activity ---------------------------");

            base.OnCreate(savedInstanceState);

            _activityResultWait      = new ManualResetEvent(false);
            _facebookCallbackManager = CallbackManagerFactory.Create();
            _serviceBindWait         = new ManualResetEvent(false);

            Window.AddFlags(global::Android.Views.WindowManagerFlags.DismissKeyguard);
            Window.AddFlags(global::Android.Views.WindowManagerFlags.ShowWhenLocked);
            Window.AddFlags(global::Android.Views.WindowManagerFlags.TurnScreenOn);

            Forms.Init(this, savedInstanceState);
            FormsMaps.Init(this, savedInstanceState);
            MapExtendRenderer.Init(this, savedInstanceState);
            CrossCurrentActivity.Current.Activity = this;

#if UNIT_TESTING
            Forms.ViewInitialized += (sender, e) =>
            {
                if (!string.IsNullOrWhiteSpace(e.View.StyleId))
                {
                    e.NativeView.ContentDescription = e.View.StyleId;
                }
            };
#endif

            _app = new App();
            LoadApplication(_app);

            MobileBarcodeScanner.Initialize(Application);

            _serviceConnection = new AndroidSensusServiceConnection();

            _serviceConnection.ServiceConnected += (o, e) =>
            {
                // it's happened that the service is created / started after the service helper is disposed:  https://insights.xamarin.com/app/Sensus-Production/issues/46
                // binding to the service in such a situation can result in a null service helper within the binder. if the service helper was disposed, then the goal is
                // to close down sensus. so finish the activity.
                if (e.Binder.SensusServiceHelper == null)
                {
                    Finish();
                    return;
                }

                if (e.Binder.SensusServiceHelper.BarcodeScanner == null)
                {
                    try
                    {
                        e.Binder.SensusServiceHelper.BarcodeScanner = new MobileBarcodeScanner();
                    }
                    catch (Exception ex)
                    {
                        e.Binder.SensusServiceHelper.Logger.Log("Failed to create barcode scanner:  " + ex.Message, LoggingLevel.Normal, GetType());
                    }
                }

                // tell the service to finish this activity when it is stopped
                e.Binder.ServiceStopAction = Finish;

                // signal the activity that the service has been bound
                _serviceBindWait.Set();

                // if we're unit testing, try to load and run the unit testing protocol from the embedded assets
#if UNIT_TESTING
                using (Stream protocolFile = Assets.Open("UnitTestingProtocol.json"))
                {
                    Protocol.RunUnitTestingProtocol(protocolFile);
                }
#endif
            };

            // the following is fired if the process hosting the service crashes or is killed.
            _serviceConnection.ServiceDisconnected += (o, e) =>
            {
                Toast.MakeText(this, "The Sensus service has crashed.", ToastLength.Long);
                DisconnectFromService();
                Finish();
            };

            OpenIntentAsync(Intent);
        }
Ejemplo n.º 9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.SendBurstScreen);
            MobileBarcodeScanner.Initialize(Application);
            scanner = new MobileBarcodeScanner();

            RuntimeVar   RT   = new RuntimeVar();
            RuntimeVarDB RTDB = new RuntimeVarDB();

            RT = RTDB.Get();


            burstAddress = Intent.GetStringExtra("BurstAddress");


            RecipientBurstAddress = FindViewById <EditText>(Resource.Id.sendBurstAddress);
            Message   = FindViewById <EditText>(Resource.Id.sendMessage);
            Amount    = FindViewById <EditText>(Resource.Id.sendAmount);
            Fee       = FindViewById <EditText>(Resource.Id.sendFee);
            cbEncrypt = FindViewById <CheckBox>(Resource.Id.cbEncryptMessage);

            CreateQRCode = FindViewById <Button>(Resource.Id.btnViewQRCode);

            UARDB = new UserAccountRuntimeDB();
            UAR   = UARDB.Get();
            string password     = UAR.Password;
            string SecretPhrase = StringCipher.Decrypt(RT.CurrentPassphrase, password);



            CreateQRCode.Click += delegate
            {
                Intent intent = new Intent(this, typeof(QRCodeView));
                intent.SetFlags(ActivityFlags.SingleTop);
                StartActivity(intent);
            };

            Button btnsend = FindViewById <Button>(Resource.Id.btnSend);

            btnsend.Click += delegate
            {
                AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
                alertDialog.SetTitle("Confirmation");
                alertDialog.SetMessage("Are you sure all the details are correct?");
                alertDialog.SetPositiveButton("Yes", delegate
                {
                    double amntdbl = Convert.ToDouble(Amount.Text);
                    amntdbl        = amntdbl * 100000000;
                    amount         = amntdbl.ToString();

                    double amntdblconf = Convert.ToDouble(amount);
                    amntdblconf        = amntdblconf / 100000000;
                    Amount.Text        = amntdblconf.ToString("#,0.00000000");

                    double feeamnt = Convert.ToDouble(Fee.Text);
                    feeamnt        = feeamnt * 100000000;
                    fee            = feeamnt.ToString();

                    double feeamntconf = Convert.ToDouble(fee);
                    feeamntconf        = feeamntconf / 100000000;
                    Fee.Text           = feeamntconf.ToString("#,0.00000000");

                    BNWAPI = new BNWalletAPI();
                    GetsendMoneyResult gsmr = BNWAPI.sendMoney(RecipientBurstAddress.Text, amount, fee, SecretPhrase, Message.Text, cbEncrypt.Checked);
                    if (gsmr.success)
                    {
                        GetTransactionResult gtr = BNWAPI.getTransaction(gsmr.transaction);
                        if (gtr.success)
                        {
                            AlertDialog.Builder ConfirmationDetailsDialog = new AlertDialog.Builder(this);
                            ConfirmationDetailsDialog.SetTitle("Confirmation Details");
                            ConfirmationDetailsDialog.SetMessage("Sender Address: " + gtr.senderRS + "\n" + "Amount of Burst sent: " + Amount.Text + "\n" + "Fee: " + Fee.Text + "\n" + "Recipient Address: " + gtr.recipientRS + "\n" + "Signature Hash: " + gsmr.signatureHash
                                                                 + "\n" + "Transaction ID: " + gsmr.transaction + "\n" + "Block Height: " + gtr.ecBlockHeight);

                            ConfirmationDetailsDialog.SetPositiveButton("OK", delegate
                            {
                                GetAccountResult gar = BNWAPI.getAccount(gtr.senderRS);
                                if (gar.success)
                                {
                                    Intent intent = new Intent(this, typeof(InfoScreen));
                                    intent.PutExtra("WalletAddress", gar.accountRS);
                                    intent.PutExtra("WalletName", gar.name);
                                    intent.PutExtra("WalletBalance", gar.balanceNQT);
                                    intent.SetFlags(ActivityFlags.SingleTop);
                                    StartActivity(intent);
                                    Finish();
                                }
                            });
                            ConfirmationDetailsDialog.Show();
                        }
                    }
                    else
                    {
                        toast = Toast.MakeText(this, "Received API Error: " + gsmr.errorMsg, ToastLength.Long);
                        toast.Show();
                    }
                });
                alertDialog.SetNegativeButton("No", delegate
                {
                    alertDialog.Dispose();
                });
                alertDialog.Show();
            };



            Button ScanQRCode = FindViewById <Button>(Resource.Id.btnSendQRCode);

            ScanQRCode.Click += async delegate
            {
                await ScanFunction();
            };



            // Create your application here
        }
Ejemplo n.º 10
0
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Activity_To_Do);
            scanner = new MobileBarcodeScanner(this);


            // botao de scan

            Button button = FindViewById <Button> (Resource.Id.scanBNT);

            button.Click += async delegate {
                base.OnCreate(bundle);
                AlertCenter.Default.Init(Application);
                AlertCenter.Default.PostMessage("Abre o scan", "Iniciando scaneamento do produto", Resource.Drawable.icon);

                //Tell our scanner to use the default overlay
                scanner.UseCustomOverlay = true;
                scanner.TopText          = "Hold the camera up to the barcode\nAbout 6 inches away";
                scanner.BottomText       = "Wait for the barcode to automatically scan!";
                var result = await scanner.Scan();

                HandleScanResult(result);
            };



            progressBar = FindViewById <ProgressBar> (Resource.Id.loadingProgressBar);

            // Initialize the progress bar
            progressBar.Visibility = ViewStates.Gone;

            // Create ProgressFilter to handle busy state
            var progressHandler = new ProgressHandler();

            progressHandler.BusyStateChange += (busy) => {
                if (progressBar != null)
                {
                    progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone;
                }
            };

            try {
                CurrentPlatform.Init();

                // Create the Mobile Service Client instance, using the provided
                // Mobile Service URL and key
                client = new MobileServiceClient(
                    applicationURL,
                    applicationKey, progressHandler);

                // Get the Mobile Service Table instance to use
                toDoTable = client.GetTable <ToDoItem> ();

                textNewToDo = FindViewById <EditText> (Resource.Id.textNewToDo);

                // Create an adapter to bind the items with the view
                adapter = new ToDoItemAdapter(this, Resource.Layout.Row_List_To_Do);
                var listViewToDo = FindViewById <ListView> (Resource.Id.listViewToDo);
                listViewToDo.Adapter = adapter;

                // Load the items from the Mobile Service
                await RefreshItemsFromTableAsync();
            } catch (Java.Net.MalformedURLException) {
                CreateAndShowDialog(new Exception("There was an error creating the Mobile Service. Verify the URL"), "Error");
            } catch (Exception e) {
                CreateAndShowDialog(e, "Error");
            }
        }
Ejemplo n.º 11
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.MedicationDosageView);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            //Toolbar will now take on default actionbar characteristics
            SetSupportActionBar(toolbar);

            SupportActionBar.Title = AppResources.MedicationDosageViewModel_Title;
            nameText   = FindViewById <EditText>(Resource.Id.NameEditText);
            dosageText = FindViewById <EditText>(Resource.Id.DosageEditText);

            takePicutre = FindViewById <LinearLayout>(Resource.Id.take_photo);
            picture     = FindViewById <ImageView>(Resource.Id.photo);

            daysOfWeek = FindViewById <TextView>(Resource.Id.label_medication_days_of_week);

            deleteBtn  = FindViewById <Button>(Resource.Id.deleteBtn);
            hoursList  = FindViewById <MedicationDosageTimeLayout>(Resource.Id.notificationHours);
            timePicker = FindViewById <Button>(Resource.Id.time_picker);

            everyday = FindViewById <RadioButton>(Resource.Id.everyday);
            custom   = FindViewById <RadioButton>(Resource.Id.custom);


            hoursList.ItemTemplateId = Resource.Layout.time_item;

            barScan = FindViewById <FloatingActionButton>(Resource.Id.barScan);

            MobileBarcodeScanner.Initialize(Application);

            barScan.Click += async(sender, e) =>
            {
                // Initialize the scanner first so it can track the current context



                var scanner = new MobileBarcodeScanner();

                var result = await scanner.Scan();

                if (result != null)
                {
                    nameText.SetText(result.ToString(), TextView.BufferType.Editable);
                }
            };

            //obsluga usuwania - jedna z kilku mozliwosci
            //wcisniecie przyscisku delete spowoduje wywolanie na adapterze komendy z usuwana godzina (implementacja w MedicationDosageTimeListAdapter
            var hourAdapter = (MedicationDosageTimeListAdapter)hoursList.Adapter;//dialog tworzymy i pokazujemy z kodu

            hourAdapter.DeleteRequested.Subscribe(time => this.ViewModel.DosageHours.Remove(time));

            //aby ui sie odswiezyl, lista godzin powinna być jakimś typem NotifyCollectionChanged (np. ReactiveList)
            //w samym UI można użyć MvxLinearLayout, który działa podobnie do listy,ale nie spowoduje scrolla w scrollu
            //wtedy właściwość Times bindujemy to tego komponentu
            timePicker.Click += (o, e) =>
            {
                TimePickerDialog timePickerFragment = new TimePickerDialog(
                    this,
                    (s, args) =>
                {
                    // handler jest wołany dwukrotnie: raz bo wybrana została godzina, drugi bo picker został zamknięty - ten musimy zignorować
                    if (((TimePicker)s).IsShown)
                    {
                        this.ViewModel.DosageHours.Add(new TimeSpan(args.HourOfDay, args.Minute, 0));
                    }
                },
                    12,
                    00,
                    true
                    );
                timePickerFragment.Show();
            };

            SecondBottomSheet secondDialog = new SecondBottomSheet(this);
            DeleteDialog      deleteDialog = new DeleteDialog(this);

            View deleteView = LayoutInflater.Inflate(Resource.Layout.delete_dialog, null);

            deleteDialog.SetContentView(deleteView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent));

            custom.Click += (o, e) =>
            {
                secondDialog.Show(ViewModel.Monday, ViewModel.Tuesday, ViewModel.Wednesday, ViewModel.Thursday, ViewModel.Friday, ViewModel.Saturday, ViewModel.Sunday);
            };

            secondDialog.Accept.Subscribe(x =>
            {
                this.ViewModel.Monday    = x[0];
                this.ViewModel.Tuesday   = x[1];
                this.ViewModel.Wednesday = x[2];
                this.ViewModel.Thursday  = x[3];
                this.ViewModel.Friday    = x[4];
                this.ViewModel.Saturday  = x[5];
                this.ViewModel.Sunday    = x[6];
                secondDialog.Hide();
            });
            secondDialog.Cancel.Subscribe(x =>
            {
                secondDialog.Dismiss();
            });


            deleteDialog.Create();
            deleteBtn.Click += (o, e) => deleteDialog.Show();
            deleteDialog.Accept.Subscribe(x =>
            {
                if (((ICommand)ViewModel.Delete).CanExecute(null))
                {
                    ViewModel.Delete.Execute().Subscribe();
                }
            });
            deleteDialog.Cancel.Subscribe(x => deleteDialog.Dismiss());

            SetBinding();
        }
Ejemplo n.º 12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Produit);

            //initialise le scanner de code barre
            MobileBarcodeScanner.Initialize(Application);

            //Récupère le ID_Produit lorsque l'on scanne un produit
            string IDproduit = Intent.GetStringExtra("IDproduit") ?? "Data not available";

            //initialise la classe MaBase et connecte la base de donnnées
            MaBase db = new MaBase();

            db.ExistBase();

            //chargement des variables des boutons et textViews
            var menuProfil        = FindViewById <ImageView>(Resource.Id.imageViewProduitProfil);
            var menuHistorique    = FindViewById <ImageView>(Resource.Id.imageViewProduitHistorique);
            var menuScanner       = FindViewById <ImageView>(Resource.Id.imageViewProduitScann);
            var menuConseil       = FindViewById <ImageView>(Resource.Id.imageViewProduitConseil);
            var menuAvertissement = FindViewById <ImageView>(Resource.Id.imageViewProduitAvertissement);
            var txtIdProduit      = FindViewById <TextView>(Resource.Id.textViewIdProduit);
            var txtInfoScan       = FindViewById <TextView>(Resource.Id.textViewInfoScan);

            //On charge le produit Le IdProduit va dans le texteView IdProduit
            //On créer d'abbord un objet produit qui contiendra tout le contenu du produit
            Produits produits = new Produits();

            produits = db.SelectIdProduit(IDproduit);

            txtIdProduit.Text = "Id : " + produits.GetId_Produit() + ", Nom : " + produits.GetProduct_name();
            txtInfoScan.Text  = "Code scanné : " + IDproduit;



            //Lorsque l'on clique sur le bouton menuProfil
            menuProfil.Click += delegate
            {
                StartActivity(typeof(Profil));
            };

            //Lorsque l'on clique sur le bouton menuHistorique
            menuHistorique.Click += delegate
            {
                StartActivity(typeof(Historique));
            };

            //Lorsque l'on clique sur le bouton menuConseilMoi
            menuConseil.Click += delegate
            {
                StartActivity(typeof(Conseil));
            };

            //Clik sur le bouton scanner
            menuScanner.Click += async(sender, e) =>
            {
                //on active le lecteur code barre et on attend une réponse (un code barre est lu)
                var scanner = new ZXing.Mobile.MobileBarcodeScanner();

                //un code bare est lu, le résultat va dans la variable résult
                var result = await scanner.Scan();

                if (result != null)
                {
                    //Intent stocke la variable ID Produit et la transmet à l'activité Produit
                    Intent produit = new Intent(this, typeof(Produit));
                    produit.PutExtra("IDproduit", result.Text);
                    StartActivity(produit);
                }
                else
                {
                }
            };

            //Lorsque l'on clique sur menuAvertissement
            menuAvertissement.Click += delegate
            {
                StartActivity(typeof(Avertissement));
            };
        }
Ejemplo n.º 13
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Somewhere in your app, call the initialization code:
            MobileBarcodeScanner.Initialize(Application);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            //Create a new instance of our Scanner
            scanner = new MobileBarcodeScanner();

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById <Button>(Resource.Id.myButton);

            button.Click += delegate
            {
                _imageView = FindViewById <ImageView>(Resource.Id.imageView1);
                //BitmapFactory.Options options = new BitmapFactory.Options
                //{
                //    InJustDecodeBounds = false
                //};

                //// The result will be null because InJustDecodeBounds == true.
                //Bitmap bitmapToDisplay = await BitmapFactory.DecodeResourceAsync(Resources, Resource.Drawable.download1);
                //_imageView.SetImageBitmap(bitmapToDisplay);
                _imageView.SetImageBitmap(
                    decodeSampledBitmapFromResource(Resources, Resource.Drawable.qrcode, 375, 375));
            };


            Button buttonScan = FindViewById <Button>(Resource.Id.buttonScan);

            //buttonScan.Click += async delegate {
            //var scanner = new ZXing.Mobile.MobileBarcodeScanner();
            //var result = await scanner.Scan();

            //if (result != null)
            //    Console.WriteLine("Scanned Barcode: " + result.Text);


            //};

            buttonScan.Click += delegate
            {
                //var fullName = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Images", "download.png");

                String path = System.Environment.CurrentDirectory;

                BitmapFactory.Options options = new BitmapFactory.Options
                {
                    InPreferredConfig = Bitmap.Config.Argb8888
                };

                //BitmapFactory.Options options = new BitmapFactory.Options
                //{
                //    InJustDecodeBounds = true
                //};



                // The result will be null because InJustDecodeBounds == true.
                //Bitmap bitmap = await BitmapFactory.DecodeResourceAsync(Resources, Resource.Drawable.download1, options);
                Bitmap bitmap = decodeSampledBitmapFromResource(Resources, Resource.Drawable.qrcode, 375, 375);


                // var imageHeight = options.OutHeight;
                //var imageWidth = options.OutWidth;
                var imageHeight = (int)bitmap.GetBitmapInfo().Height;
                var imageWidth  = (int)bitmap.GetBitmapInfo().Width;

                //using (var stream = new MemoryStream())
                //{
                //    bitmap.Compress(Bitmap.CompressFormat.Png, 0, stream);
                //    bitmapData = stream.ToArray();
                //}

                int size = (int)bitmap.RowBytes * (int)bitmap.GetBitmapInfo().Height;
                Java.Nio.ByteBuffer byteBuffer = Java.Nio.ByteBuffer.Allocate(size);
                bitmap.CopyPixelsToBuffer(byteBuffer);
                byte[] byteArray  = new byte[byteBuffer.Remaining()];
                var    imageBytes = byteBuffer.Get(byteArray);

                LuminanceSource source = new ZXing.RGBLuminanceSource(byteArray, (int)imageWidth, (int)imageHeight);

                var barcodeReader = new BarcodeReader();
                barcodeReader.Options.TryHarder = true;
                //barcodeReader.Options.ReturnCodabarStartEnd = true;
                //barcodeReader.Options.PureBarcode = true;
                //barcodeReader.Options.PossibleFormats = new List<BarcodeFormat>();
                //barcodeReader.Options.PossibleFormats.Add(BarcodeFormat.QR_CODE);
                ZXing.Result result  = barcodeReader.Decode(source);
                var          result2 = barcodeReader.DecodeMultiple(source);

                ZXing.Result result3 = barcodeReader.Decode(byteArray, (int)imageWidth, (int)imageHeight, RGBLuminanceSource.BitmapFormat.RGB24);
                ZXing.Result result4 = barcodeReader.Decode(source);

                HybridBinarizer   hb      = new HybridBinarizer(source);
                var               a       = hb.createBinarizer(source);
                BinaryBitmap      bBitmap = new BinaryBitmap(a);
                MultiFormatReader reader1 = new MultiFormatReader();
                var               r       = reader1.decodeWithState(bBitmap);


                int[] intarray = new int[((int)imageHeight * (int)imageWidth)];
                bitmap.GetPixels(intarray, 0, (int)bitmap.GetBitmapInfo().Width, 0, 0, (int)imageWidth, (int)imageHeight);
                LuminanceSource source5 = new RGBLuminanceSource(byteArray, (int)imageWidth, (int)imageHeight);

                BinaryBitmap bitmap3 = new BinaryBitmap(new HybridBinarizer(source));
                ZXing.Reader reader  = new DataMatrixReader();
                //....doing the actually reading
                ZXing.Result result10 = reader.decode(bitmap3);



                //InputStream is = this.Resources.OpenRawResource(Resource.Id.imageView1);
                //Bitmap originalBitmap = BitmapFactory.decodeStream(is);

                //UIImage

                //var barcodeBitmap = (Bitmap)Bitmap.FromFile(@"C:\Users\jeremy\Desktop\qrimage.bmp");
            };


            Button buttonScan2 = FindViewById <Button>(Resource.Id.buttonScan2);

            buttonScan2.Click += async delegate
            {
                //Tell our scanner to activiyt use the default overlay
                scanner.UseCustomOverlay = false;

                //We can customize the top and bottom text of the default overlay
                scanner.TopText    = "Hold the camera up to the barcode\nAbout 6 inches away";
                scanner.BottomText = "Wait for the barcode to automatically scan!";

                //Start scanning
                var result = await scanner.Scan();

                // Handler for the result returned by the scanner.
                HandleScanResult(result);
            };
        }
Ejemplo n.º 14
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.AddCopy);
            // Create your application here

            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            SetActionBar(toolbar);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetHomeButtonEnabled(true);

            btnScan        = FindViewById <ImageButton>(Resource.Id.button1);
            btnCheck       = FindViewById <ImageButton>(Resource.Id.button2);
            btnSave        = FindViewById <Button>(Resource.Id.button3);
            edtISBN        = FindViewById <EditText>(Resource.Id.editText1);
            edtNumber      = FindViewById <EditText>(Resource.Id.editText3);
            edtTitulo      = FindViewById <EditText>(Resource.Id.editText2);
            btnSave.Click += BtnSave_Click;

            isbn = Intent.GetStringExtra("libroId");


            if (isbn != null)
            {
                edtISBN.Text = isbn;
                libro        = Service.SearchBook(edtISBN.Text);
                if (libro != null)
                {
                    edtISBN.Text   = libro.ISBN;
                    edtTitulo.Text = libro.Titulo;
                }
                else
                {
                    Toast.MakeText(this, "El libro no existe", ToastLength.Long).Show();
                }
            }


#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnScan.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnCheck.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos

            btnCheck.Click += BtnCheck_Click;

            MobileBarcodeScanner.Initialize(Application);
            scanner = new MobileBarcodeScanner();

            btnScan.Click += async delegate {
                //Tell our scanner to use the default overlay
                scanner.UseCustomOverlay = false;

                //PERSONALIZAR LOS MENSAJES QUE SE MOSTRARAN EN LA CAMARA DEL SCANNER
                scanner.TopText    = "Por favor, no mueva el dispositivo móvil\nMantengalo al menos 10cm de distancia";
                scanner.BottomText = "Espere mientras el scanner lee el código de barra";

                //COMIENZO DEL SCANEO
                var result = await scanner.Scan();

                HandleScanResult(result);
            };
        }
Ejemplo n.º 15
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            string address = Intent.GetStringExtra("address") ?? string.Empty;

            addy = address;

            SimpleStorage.SetContext(ApplicationContext);
            SetContentView(Resource.Layout.activity_edit);

            Button backButton = (Button)FindViewById(Resource.Id.buttonEditBack);

            backButton.Click += editPageBack;

            ImageButton QRButton = (ImageButton)FindViewById(Resource.Id.imageButtonQREdit);

            QRButton.Click += EditScanQR;

            MobileBarcodeScanner.Initialize(Application);

            Button saveButton = (Button)FindViewById(Resource.Id.buttonEditSave);

            saveButton.Click += EditSaveData;

            Button deleteButton = (Button)FindViewById(Resource.Id.buttonDeleteAddy);

            deleteButton.Click += deleteAddy;

            SimpleStorage.SetContext(ApplicationContext);
            var storage = SimpleStorage.EditGroup(address);

            string isMN      = storage.Get("IsMN");
            string IsStaking = storage.Get("IsStaking");
            string Nickname  = storage.Get("Nickname");

            EditText pubAddy = (EditText)FindViewById(Resource.Id.editTextPubEdit);

            pubAddy.Text = address;
            EditText pubNick = (EditText)FindViewById(Resource.Id.editTextNickEdit);

            pubNick.Text = Nickname;
            CheckBox mnChk = (CheckBox)FindViewById(Resource.Id.checkBoxMNEdit);
            CheckBox stChk = (CheckBox)FindViewById(Resource.Id.checkBoxStakeEdit);

            if (isMN == "true")
            {
                mnChk.Checked = true;
            }
            else
            {
                mnChk.Checked = false;
            }
            if (IsStaking == "true")
            {
                stChk.Checked = true;
            }
            else
            {
                stChk.Checked = false;
            }
        }
Ejemplo n.º 16
0
        private void CreatElement(JObject jElement, TableLayout mTableLayout)
        {
            JValue  jReadOnly;
            JObject jParam;
            JValue  jSubType;

            var jType  = jElement["Type"];
            var jValue = jElement["Value"];

            long   Id          = (long)((JValue)jElement["Id"]).Value;
            string Name        = (string)((JValue)jElement["Name"]).Value;
            string Description = (string)((JValue)jElement["Description"]).Value;

            TableRow mNewRow = new TableRow(this);

            mTableLayout.AddView(mNewRow);

            TextView mTextViewDesc = new TextView(this);

            if (Description == "")
            {
                mTextViewDesc.Visibility = ViewStates.Invisible;
            }
            else
            {
                mTextViewDesc.Text = Description + ":";
                mTextViewDesc.SetPadding(10, 0, 0, 0);
            }
            mNewRow.AddView(mTextViewDesc);

            if (jType.Type != JTokenType.Array) //елси это одиночный тип
            {
                string Type = (string)((JValue)jType).Value;
                switch (Type)
                {
                case "button":
                    mTextViewDesc.Visibility = ViewStates.Gone;
                    string buttonValue = (string)((JValue)jValue).Value;

                    if (buttonValue == "save")
                    {
                        mSaveButtonVisible = true;
                    }
                    else
                    {
                        Button nButton = new Button(this)
                        {
                            Id = (int)Id
                        };
                        nButton.Text   = Description;
                        nButton.Click += (sender, args) =>
                        {
                            lastButtonName  = Name;
                            lastButtonValue = buttonValue;
                            SetDataByRef(Name, buttonValue);
                        };
                        mLinearLayout.AddView(nButton);
                    }
                    break;

                case "textview":
                    TextView nTextView = new TextView(this)
                    {
                        Id = (int)Id
                    };
                    nTextView.SetTextSize(Android.Util.ComplexUnitType.Sp, 18);
                    nTextView.Text = (string)((JValue)jValue).Value;
                    mNewRow.AddView(nTextView);

                    if (jElement.Property("Param") != null)
                    {
                        jParam = (JObject)jElement["Param"];
                        if (jParam.Property("SubType") != null)
                        {
                            jSubType = (JValue)jParam["SubType"];
                            switch ((string)jSubType.Value)
                            {
                            case "phone":
                                ImageButton nButtonOpenFile = new ImageButton(this)
                                {
                                    Id = (int)Id
                                };
                                nButtonOpenFile.SetImageResource(Resource.Drawable.ic_action_call);
                                nButtonOpenFile.Click += (bsender, bargs) => {
                                    var    uri        = Android.Net.Uri.Parse("tel:" + (string)((JValue)jValue).Value);
                                    Intent callIntent = new Intent(Intent.ActionDial, uri);
                                    StartActivity(callIntent);
                                };
                                mNewRow.AddView(nButtonOpenFile);
                                break;
                            }
                        }
                    }
                    break;

                case "textedit":
                    string TextEditValue = (string)((JValue)jValue).Value;

                    mElements.Add(Id, new ElementData()
                    {
                        Name = Name, Data = TextEditValue
                    });

                    jSubType  = (JValue)jElement["Param"]["SubType"];
                    jReadOnly = (JValue)jElement["Param"]["ReadOnly"];
                    JValue jMultiline = (JValue)jElement["Param"]["Multiline"];

                    EditText nEditText = new EditText(this)
                    {
                        Id = (int)Id
                    };
                    switch ((string)jSubType.Value)
                    {
                    case "text":
                        if ((bool)jMultiline.Value)
                        {
                            nEditText.InputType = Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextFlagMultiLine;
                            nEditText.SetMinLines(1);
                            nEditText.SetMaxLines(3);
                            nEditText.SetScroller(new Scroller(this));
                            nEditText.VerticalScrollBarEnabled = true;
                        }
                        else
                        {
                            nEditText.InputType = Android.Text.InputTypes.ClassText;
                        }
                        nEditText.SetSingleLine(false);
                        break;

                    case "number":
                        nEditText.InputType = Android.Text.InputTypes.ClassNumber | Android.Text.InputTypes.NumberFlagDecimal | Android.Text.InputTypes.NumberFlagSigned;
                        break;

                    case "email":
                        nEditText.InputType = Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextVariationEmailAddress;
                        break;

                    case "password":
                        nEditText.InputType = Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextVariationPassword;
                        break;

                    case "phone":
                        nEditText.InputType = Android.Text.InputTypes.ClassPhone;
                        break;
                    }
                    nEditText.Text = TextEditValue;
                    if ((bool)jReadOnly.Value)
                    {
                        nEditText.Focusable = false;
                    }

                    nEditText.AfterTextChanged += (sender, args) =>
                    {
                        mElements[Id].Data = nEditText.Text;
                    };
                    mNewRow.AddView(nEditText);
                    break;

                case "dateedit":
                    DateTime DateEditValue = (DateTime)((JValue)jValue).Value;

                    mElements.Add(Id, new ElementData()
                    {
                        Name = Name, Data = DateEditValue
                    });

                    EditText nTextDateEdit = new EditText(this)
                    {
                        Id = (int)Id
                    };
                    nTextDateEdit.Focusable = false;
                    nTextDateEdit.Text      = DateEditValue.ToShortDateString();
                    mNewRow.AddView(nTextDateEdit);

                    ImageButton nButtonDateEdit = new ImageButton(this)
                    {
                        Id = (int)Id
                    };
                    nButtonDateEdit.SetImageResource(Resource.Drawable.ic_action_edit);
                    nButtonDateEdit.Click += (bsender, bargs) => {
                        if (mDialogLoading == false)
                        {
                            mDialogLoading = true;
                            DateTime         currently = (mElements[Id].Data == null) ? DateTime.Now : mElements[Id].Data;
                            DatePickerDialog ddialog   = new DatePickerDialog(this, (dsender, dargs) => {
                                string strDate     = ((DateTime)dargs.Date).ToShortDateString();
                                nTextDateEdit.Text = strDate;
                                mElements[Id].Data = (DateTime)dargs.Date;
                                mDialogLoading     = false;
                            }, currently.Year, currently.Month - 1, currently.Day);
                            ddialog.Show();
                            ddialog.CancelEvent += (dsender, dargs) =>
                            {
                                mDialogLoading = false;
                            };
                        }
                    };
                    mNewRow.AddView(nButtonDateEdit);
                    break;

                case "timeedit":
                    DateTime TimeEditValue = (DateTime)((JValue)jValue).Value;

                    mElements.Add(Id, new ElementData()
                    {
                        Name = Name, Data = TimeEditValue
                    });

                    EditText nTextTimeEdit = new EditText(this)
                    {
                        Id = (int)Id
                    };
                    nTextTimeEdit.Focusable = false;
                    nTextTimeEdit.Text      = TimeEditValue.ToShortTimeString();
                    mNewRow.AddView(nTextTimeEdit);

                    ImageButton nButtonTimeEdit = new ImageButton(this)
                    {
                        Id = (int)Id
                    };
                    nButtonTimeEdit.SetImageResource(Resource.Drawable.ic_action_edit);
                    nButtonTimeEdit.Click += (bsender, bargs) => {
                        if (mDialogLoading == false)
                        {
                            mDialogLoading = true;
                            DateTime         tcurrently = (mElements[Id].Data == null) ? DateTime.Now : mElements[Id].Data;
                            TimePickerDialog tdialog    = new TimePickerDialog(this, (tsender, targs) =>
                            {
                                string strTime     = String.Format("{0:d2}", (int)targs.HourOfDay) + ":" + String.Format("{0:d2}", (int)targs.Minute);
                                nTextTimeEdit.Text = strTime;
                                mElements[Id].Data = DateTime.Parse("01.01.0001 " + strTime + ":00");
                                mDialogLoading     = false;
                            }, tcurrently.Hour, tcurrently.Minute, true);
                            tdialog.Show();
                            tdialog.CancelEvent += (dsender, dargs) =>
                            {
                                mDialogLoading = false;
                            };
                        }
                    };
                    mNewRow.AddView(nButtonTimeEdit);

                    break;

                case "checkbox":
                    bool CheckBoxValue = (bool)((JValue)jValue).Value;

                    mElements.Add(Id, new ElementData()
                    {
                        Name = Name, Data = CheckBoxValue
                    });

                    jReadOnly = (JValue)jElement["Param"]["ReadOnly"];

                    CheckBox nCheckBox = new CheckBox(this)
                    {
                        Id = (int)Id
                    };
                    if ((bool)jReadOnly.Value)
                    {
                        nCheckBox.Enabled = false;
                    }
                    nCheckBox.Checked = CheckBoxValue;
                    nCheckBox.Click  += (csender, cargs) =>
                    {
                        mElements[Id].Data = nCheckBox.Checked;
                    };
                    mNewRow.AddView(nCheckBox);
                    break;

                case "datalist":
                    string DataListValue = (string)((JValue)jValue).Value;

                    mElements.Add(Id, new ElementData()
                    {
                        Name = Name, Data = DataListValue
                    });

                    EditText nTextDataList = new EditText(this)
                    {
                        Id = (int)Id
                    };
                    nTextDataList.Focusable = false;
                    mNewRow.AddView(nTextDataList);

                    ImageButton nButtonDataList = new ImageButton(this)
                    {
                        Id = (int)Id
                    };
                    nButtonDataList.SetImageResource(Resource.Drawable.ic_action_edit);

                    PopupMenu DataListMenu = new PopupMenu(this, nButtonDataList);
                    int       menuItemId   = 0;
                    Dictionary <int, string> mElementsDropMenu = new Dictionary <int, string>();
                    foreach (var jDataListValue in jElement["DataArray"])
                    {
                        string PresentMenuItem = String.Empty;
                        string DataMenuItem    = String.Empty;
                        if (jDataListValue.Type == JTokenType.String)
                        {
                            PresentMenuItem = (string)((JValue)jDataListValue).Value;
                            DataMenuItem    = PresentMenuItem;
                        }
                        else
                        {
                            PresentMenuItem = ((JObject)jDataListValue).Property("Present") != null ? (string)(((JObject)jDataListValue).Property("Present")).Value : (string)(((JObject)jDataListValue).Property("Data")).Value;
                            DataMenuItem    = (string)(((JObject)jDataListValue).Property("Data")).Value;
                        }
                        DataListMenu.Menu.Add(0, menuItemId, Menu.None, PresentMenuItem);
                        mElementsDropMenu.Add(menuItemId, DataMenuItem);
                        menuItemId++;

                        if (DataListValue == DataMenuItem)
                        {
                            nTextDataList.Text = PresentMenuItem;
                        }
                    }

                    DataListMenu.MenuItemClick += (psender, pargs) =>
                    {
                        string selectedData = pargs.Item.TitleFormatted.ToString();
                        nTextDataList.Text = selectedData;
                        mElements[Id].Data = mElementsDropMenu[pargs.Item.ItemId];
                    };

                    nButtonDataList.Click += (bsender, bargs) => {
                        DataListMenu.Show();
                    };
                    mNewRow.AddView(nButtonDataList);
                    break;

                case "data":
                    string dataValue = (string)((JValue)jValue["Present"]).Value;
                    string dataRef   = (string)((JValue)jValue["Ref"]).Value;
                    string dataType  = (string)((JValue)jElement["DataType"]).Value;

                    mElements.Add(Id, new ElementData()
                    {
                        Name = Name, Data = dataRef
                    });

                    EditText nTextDataEdit = new EditText(this)
                    {
                        Id = (int)Id
                    };
                    nTextDataEdit.Focusable = false;
                    nTextDataEdit.Text      = dataValue;
                    mNewRow.AddView(nTextDataEdit);

                    ImageButton nButtonDataEdit = new ImageButton(this)
                    {
                        Id = 1000 + (int)Id
                    };
                    nButtonDataEdit.SetImageResource(Resource.Drawable.ic_action_edit);
                    nButtonDataEdit.Click += (bsender, bargs) => {
                        mIdDataSelect = (int)Id;
                        Intent intentData = new Intent(this, typeof(ActivityDataList));
                        mEditTextDataSelect = nTextDataEdit;
                        intentData.PutExtra("ref", dataType);
                        intentData.PutExtra("name", Description);
                        intentData.PutExtra("selected", true);
                        StartActivityForResult(intentData, 1);
                    };
                    mNewRow.AddView(nButtonDataEdit);

                    break;

                case "file":
                    string filesValue = (string)((JValue)jValue["Present"]).Value;
                    string filesRef   = (string)((JValue)jValue["Ref"]).Value;

                    TextView nTextViewFile = new TextView(this)
                    {
                        Id = (int)Id
                    };
                    nTextViewFile.SetTextSize(Android.Util.ComplexUnitType.Sp, 18);
                    nTextViewFile.Text = filesValue;
                    mNewRow.AddView(nTextViewFile);

                    ImageButton nButtonTextView = new ImageButton(this)
                    {
                        Id = (int)Id
                    };
                    nButtonTextView.SetImageResource(Resource.Drawable.ic_action_attachment);
                    nButtonTextView.Click += (bsender, bargs) => {
                        Intent intentFiles = new Intent(this, typeof(ActivityFiles));
                        intentFiles.PutExtra("ref", filesRef);
                        intentFiles.PutExtra("name", filesValue);
                        StartActivity(intentFiles);
                    };
                    mNewRow.AddView(nButtonTextView);
                    break;

                case "barcode":
                    string BarCodeEditValue = (string)((JValue)jValue).Value;

                    mElements.Add(Id, new ElementData()
                    {
                        Name = Name, Data = BarCodeEditValue
                    });

                    EditText nTextBarCodeEdit = new EditText(this)
                    {
                        Id = (int)Id
                    };
                    nTextBarCodeEdit.Text = BarCodeEditValue;
                    mNewRow.AddView(nTextBarCodeEdit);

                    ImageButton nButtonBarCodeEdit = new ImageButton(this)
                    {
                        Id = (int)Id
                    };
                    nButtonBarCodeEdit.SetImageResource(Resource.Drawable.ic_action_camera);
                    nButtonBarCodeEdit.Click += async(bsender, bargs) => {
                        /*if (mDialogLoading == false)
                         * {
                         *  mDialogLoading = true;
                         *  DateTime currently = (mElements[Id].Data == null) ? DateTime.Now : mElements[Id].Data;
                         *  DatePickerDialog ddialog = new DatePickerDialog(this, (dsender, dargs) => {
                         *      string strDate = ((DateTime)dargs.Date).ToShortDateString();
                         *      nTextDateEdit.Text = strDate;
                         *      mElements[Id].Data = (DateTime)dargs.Date;
                         *      mDialogLoading = false;
                         *  }, currently.Year, currently.Month - 1, currently.Day);
                         *  ddialog.Show();
                         *  ddialog.CancelEvent += (dsender, dargs) =>
                         *  {
                         *      mDialogLoading = false;
                         *  };
                         * }*/

                        MobileBarcodeScanner.Initialize(Application);
                        var scanner = new ZXing.Mobile.MobileBarcodeScanner();
                        var result  = await scanner.Scan();

                        if (result != null)
                        {
                            nTextBarCodeEdit.Text = result.Text;
                            mElements[Id].Data    = result.Text;
                        }
                    };
                    mNewRow.AddView(nButtonBarCodeEdit);
                    break;

                default:

                    break;
                }
            }
            else //если это массив типов
            {
            }
        }
Ejemplo n.º 17
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.AddCatalog);
            // Create your application here

            edtISBN     = FindViewById <EditText>(Resource.Id.editText1);
            edtCod      = FindViewById <EditText>(Resource.Id.editText2);
            edtTitle    = FindViewById <EditText>(Resource.Id.editText3);
            edtAutor    = FindViewById <EditText>(Resource.Id.editText4);
            edtPreview  = FindViewById <EditText>(Resource.Id.editText5);
            sp_Materias = FindViewById <Spinner>(Resource.Id.spinner1);
            toolbar     = FindViewById <Toolbar>(Resource.Id.toolbar);

            edtCod.Enabled      = false;
            edtCod.Text         = Service.BookCode();
            edtTitle.Enabled    = false;
            edtPreview.Enabled  = false;
            edtAutor.Enabled    = false;
            sp_Materias.Enabled = false;

            MobileBarcodeScanner.Initialize(Application);

            scanner = new MobileBarcodeScanner();

            btnScan        = FindViewById <ImageButton>(Resource.Id.button1);
            btnCheck       = FindViewById <ImageButton>(Resource.Id.button2);
            Img            = FindViewById <ImageButton>(Resource.Id.imageButton1);
            btnSave        = FindViewById <Button>(Resource.Id.button3);
            btnSave.Click += BtnSave_Click;

#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnScan.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnCheck.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos

            btnCheck.Click += BtnCheck_Click;
            Img.Click      += Img_Click;

            SetActionBar(toolbar);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetHomeButtonEnabled(true);

            btnScan.Click += async delegate {
                //Tell our scanner to use the default overlay
                scanner.UseCustomOverlay = false;

                //PERSONALIZAR LOS MENSAJES QUE SE MOSTRARAN EN LA CAMARA DEL SCANNER
                scanner.TopText    = "Por favor, no mueva el dispositivo móvil\nMantengalo al menos 10cm de distancia";
                scanner.BottomText = "Espere mientras el scanner lee el código de barra";

                //COMIENZO DEL SCANEO
                var result = await scanner.Scan();

                HandleScanResult(result);
            };

            //BUSCO LAS MATERIAS
            listasp = Service.CategoryList();
            //LLENAR EL ADAPTER CON LA LISTA DEL SERVICIO
            sp_Materias.Adapter       = new AdapterSpMaterias(this, listasp);
            sp_Materias.ItemSelected += Sp_Materias_ItemSelected;
        }
Ejemplo n.º 18
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            db.ExistBase(this);
            SetContentView(Resource.Layout.Historique);

            /*var lv = FindViewById<TextView>(Resource.Id.textViewTest);
             * lv.Text = db.SelectIdProduittest();*/

            lstData = FindViewById <ListView>(Resource.Id.listView);
            LoadData();


            lstData.ItemClick += (s, e) => {
                for (int i = 0; i < lstData.Count; i++)
                {
                    if (e.Position == i)
                    {
                        lstData.GetChildAt(i).SetBackgroundColor(Android.Graphics.Color.DarkGray);
                    }
                    else
                    {
                        lstData.GetChildAt(i).SetBackgroundColor(Android.Graphics.Color.Transparent);
                    }

                    //Bindind data
                    var txtproduitid   = e.View.FindViewById <TextView>(Resource.Id.textView1);
                    var txttypeid      = e.View.FindViewById <TextView>(Resource.Id.textView2);
                    var txtnameproduit = e.View.FindViewById <TextView>(Resource.Id.textView4);
                    var txtdate        = e.View.FindViewById <TextView>(Resource.Id.textView3);
                }
            };
            //*****************************************************************************//
            MobileBarcodeScanner.Initialize(Application);

            var menuProfil        = FindViewById <ImageView>(Resource.Id.imageViewHistoriqueProfil);
            var menuHistorique    = FindViewById <ImageView>(Resource.Id.imageViewHistoriqueHistorique);
            var menuScanner       = FindViewById <ImageView>(Resource.Id.imageViewHistoriqueScann);
            var menuConseil       = FindViewById <ImageView>(Resource.Id.imageViewHistoriqueConseil);
            var menuAvertissement = FindViewById <ImageView>(Resource.Id.imageViewHistoriqueAvertissement);


            menuProfil.Click += delegate
            {
                StartActivity(typeof(Profil));
            };
            menuHistorique.Click += delegate
            {
                StartActivity(typeof(Historique));
            };

            menuConseil.Click += delegate
            {
                StartActivity(typeof(Conseil));
            };

            //Clik sur le bouton scanner
            menuScanner.Click += async(sender, e) =>
            {
                var scanner = new ZXing.Mobile.MobileBarcodeScanner();
                var result  = await scanner.Scan();

                if (result != null)
                {
                    //Intent garde la variable ID Produit et la transmet à l'activité Produit
                    Intent produit = new Intent(this, typeof(Produit));
                    produit.PutExtra("IDproduit", result.Text);
                    StartActivity(produit);
                }
                else
                {
                }
            };

            menuAvertissement.Click += delegate
            {
                StartActivity(typeof(Avertissement));
            };
        }
Ejemplo n.º 19
0
        private void OpenCamera()
        {
            try
            {
                var version = Build.VERSION.SdkInt;

                if (version >= BuildVersionCodes.Gingerbread)
                {
                    Android.Util.Log.Debug(MobileBarcodeScanner.TAG, "Checking Number of cameras...");

                    var numCameras = Camera.NumberOfCameras;
                    var camInfo    = new Camera.CameraInfo();
                    var found      = false;
                    Android.Util.Log.Debug(MobileBarcodeScanner.TAG, "Found " + numCameras + " cameras...");

                    var whichCamera = CameraFacing.Back;

                    if (_scannerHost.ScanningOptions.UseFrontCameraIfAvailable.HasValue &&
                        _scannerHost.ScanningOptions.UseFrontCameraIfAvailable.Value)
                    {
                        whichCamera = CameraFacing.Front;
                    }

                    for (var i = 0; i < numCameras; i++)
                    {
                        Camera.GetCameraInfo(i, camInfo);
                        if (camInfo.Facing == whichCamera)
                        {
                            Android.Util.Log.Debug(MobileBarcodeScanner.TAG,
                                                   "Found " + whichCamera + " Camera, opening...");
                            Camera    = Camera.Open(i);
                            _cameraId = i;
                            found     = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        Android.Util.Log.Debug(MobileBarcodeScanner.TAG,
                                               "Finding " + whichCamera + " camera failed, opening camera 0...");
                        Camera    = Camera.Open(0);
                        _cameraId = 0;
                    }
                }
                else
                {
                    Camera = Camera.Open();
                }

                //if (Camera != null)
                //    Camera.SetPreviewCallback(_cameraEventListener);
                //else
                //    MobileBarcodeScanner.LogWarn(MobileBarcodeScanner.TAG, "Camera is null :(");
            }
            catch (Exception ex)
            {
                ShutdownCamera();
                MobileBarcodeScanner.LogError("Setup Error: {0}", ex);
            }
        }
Ejemplo n.º 20
0
        public async Task GetQRCodeAsync(bool InOrOut)
        {
            var app = Forms.Context as Activity;

            MobileBarcodeScanner.Initialize(app.Application);

            var scanner = new MobileBarcodeScanner();

            var result = await scanner.Scan();

            if (result != null)
            {
                string[] block = result.Text.Split(',');

                if (InOrOut)
                {
                    blockIn = new Block(block[1], block[2], block[0]);
                    PageAddInBlock.IsEnabled = false;
                    PageAddInBlock.Text      = "Установлен: " + blockIn.GetText();
                }
                else
                {
                    blockOut = new Block(block[1], block[2], block[0]);
                    PageAddOutBlock.IsEnabled = false;
                    PageAddOutBlock.Text      = "Снят: " + blockOut.GetText();
                }

                Console.WriteLine("Scanned Barcode: " + result.Text);

                if ((blockIn != null) && (blockOut != null))
                {
                    Console.WriteLine("Собрана замена: ");
                    bool defect = false;
                    defect = await DisplayAlert("Замена оборудования", "Замененное оборудование вышло из строя?", "Да", "Нет");

                    Replace.CreateReplace(blockIn, blockOut, defect);
                    var str     = Replace.GetReplaces.Last().GetText();
                    var strings = str.Split(';');
                    Label.Text = strings[0].TrimEnd(' ') + "\n" + strings[1].TrimStart(' ').TrimEnd(' ');

                    var childs = new List <View>();
                    foreach (View v in GetLayout.Children)
                    {
                        childs.Add(v);
                    }
                    GetLayout.Children.Clear();

                    var RemoveReplace = new TapGestureRecognizer();
                    RemoveReplace.Tapped += (s, e) =>
                    {
                        Replace.GetReplaces.Remove(Replace.GetReplaces.Last());
                        PageReload();
                    };

                    var ApplyReplace = new TapGestureRecognizer();
                    ApplyReplace.Tapped += (s, e) =>
                    {
                        PageReload();
                    };

                    var ApplyLabel = new Label()
                    {
                        Text                    = "Нажмите сюда чтобы запомнить замену",
                        VerticalOptions         = LayoutOptions.Start,
                        HorizontalOptions       = LayoutOptions.FillAndExpand,
                        HeightRequest           = 70,
                        FontSize                = 18,
                        VerticalTextAlignment   = TextAlignment.Center,
                        HorizontalTextAlignment = TextAlignment.Center,
                        BackgroundColor         = Color.Teal,
                    };
                    ApplyLabel.GestureRecognizers.Add(ApplyReplace);

                    var RemoveLabel = new Label()
                    {
                        Text                    = "Нажмите сюда чтобы сбросить замену",
                        VerticalOptions         = LayoutOptions.End,
                        HorizontalOptions       = LayoutOptions.FillAndExpand,
                        HeightRequest           = 70,
                        FontSize                = 18,
                        VerticalTextAlignment   = TextAlignment.Center,
                        HorizontalTextAlignment = TextAlignment.Center,
                        BackgroundColor         = Color.DarkRed
                    };
                    RemoveLabel.GestureRecognizers.Add(RemoveReplace);

                    GetLayout.Children.Add(ApplyLabel);
                    foreach (View v in childs)
                    {
                        GetLayout.Children.Add(v);
                    }
                    GetLayout.Children.Add(RemoveLabel);
                }
            }
            else
            {
                scanner.Cancel();
            }
        }
Ejemplo n.º 21
0
        void GetActivationDialog()
        {
            ImageButton addCodeImageButtonFake = FindViewById <ImageButton>(Resource.Id.NavBar_addcodeImageButtonFake);
            ImageButton addCodeImageButton     = FindViewById <ImageButton>(Resource.Id.NavBar_addcodeImageButton);

            _activateMessageBadgeDialogBuilder = new AlertDialog.Builder(this);
            LayoutInflater addBadgeMenulayoutInflater = (LayoutInflater)BaseContext.GetSystemService(LayoutInflaterService);
            RelativeLayout addBadgeRelativeLayout     = new RelativeLayout(this);
            View           addBadgeView = addBadgeMenulayoutInflater.Inflate(Resource.Layout.addbadgemenulayoutlayout, null);


            Button addBadgeCancelButton = (Button)addBadgeView.FindViewById(Resource.Id.addbadge_cancelButton);
            Button readQRCodeButton     = (Button)addBadgeView.FindViewById(Resource.Id.addbadge_readQRButton);
            Button addCodeButton        = (Button)addBadgeView.FindViewById(Resource.Id.addbadge_addcodeButton);

            readQRCodeButton.SetTypeface(_font, TypefaceStyle.Normal);
            addCodeButton.SetTypeface(_font, TypefaceStyle.Normal);

            TextView addBadgeTitleTextView = (TextView)addBadgeView.FindViewById(Resource.Id.textView1);
            TextView addBadgeHintTextView  = (TextView)addBadgeView.FindViewById(Resource.Id.addbadge_hintTextView);

            addBadgeRelativeLayout.AddView(addBadgeView);

            addBadgeTitleTextView.SetTypeface(_font, TypefaceStyle.Normal);
            addBadgeHintTextView.SetTypeface(_font, TypefaceStyle.Normal);

            LayoutInflater addCodeMenulayoutInflater = (LayoutInflater)BaseContext.GetSystemService(LayoutInflaterService);
            RelativeLayout addCodeRelativeLayout     = new RelativeLayout(this);
            View           addCodeView = addCodeMenulayoutInflater.Inflate(Resource.Layout.entercodelayout, null);

            Button addCodeCancelButton = (Button)addCodeView.FindViewById(Resource.Id.addcode_cancelButton);
            Button addCodeReadyButton  = (Button)addCodeView.FindViewById(Resource.Id.addcode_readyButton);

            _enterCodeLineImageView = (ImageView)addCodeView.FindViewById(Resource.Id.imageView1);

            TextView addCodeDescrTextView = (TextView)addCodeView.FindViewById(Resource.Id.textView2);
            TextView addCodeTitleTextView = (TextView)addCodeView.FindViewById(Resource.Id.textView1);

            addCodeDescrTextView.SetTypeface(_font, TypefaceStyle.Normal);
            addCodeTitleTextView.SetTypeface(_font, TypefaceStyle.Normal);

            _codeCompleteTextView = (AutoCompleteTextView)addCodeView.FindViewById(Resource.Id.addcode_autoCompleteTextView);
            _codeCompleteTextView.SetTypeface(_font, TypefaceStyle.Normal);


            if (!AppInfo.IsLocaleRu)
            {
                addBadgeTitleTextView.Text       = "Activate Badge";
                addBadgeHintTextView.Text        = "Enter a code or read a QR from a certificate of achivement to get a new badge.";
                addCodeButton.Text               = "   Via Entering code";
                readQRCodeButton.Text            = "   Via QR-reader";
                addCodeDescrTextView.Text        = "Confirmation a code is a process for which is given a badge.";
                addCodeTitleTextView.Text        = "Enter code";
                _wrongCodeDialogReadyButton.Text = "Ok";
                addBadgeCancelButton.Text        = "Cancel";
                addCodeCancelButton.Text         = "Cancel";
                addCodeReadyButton.Text          = "Ok";
            }


            _codeCompleteTextView.Click += delegate
            {
                InputMethodManager im = (InputMethodManager)this.GetSystemService(InputMethodService);
                if (im.IsAcceptingText)
                {
                    _enterCodeLineImageView.SetBackgroundResource(Resource.Drawable.line_blue);
                }
                else
                {
                    _enterCodeLineImageView.SetBackgroundResource(Resource.Drawable.line);
                }
            };
            //codeCompleteTextView.SetDropDownBackgroundDrawable();
            addCodeRelativeLayout.AddView(addCodeView);

            Dialog addBadgeDialog = new Dialog(this, Resource.Style.FullHeightDialog);

            addBadgeDialog.SetTitle("");
            addBadgeDialog.SetContentView(addBadgeRelativeLayout);

            Dialog addCodeDialog = new Dialog(this, Resource.Style.FullHeightDialog);

            addCodeDialog.SetTitle("");
            addCodeDialog.SetContentView(addCodeRelativeLayout);

            addCodeImageButtonFake.Click += delegate {
                if (!_badgePopupWindow.IsShowing)
                {
                    _categoriesListView.Visibility           = ViewStates.Gone;
                    _categoriesshadowImageView.Visibility    = ViewStates.Gone;
                    _inactiveListButton.Visibility           = ViewStates.Gone;
                    _subcategoriesListView.Visibility        = ViewStates.Gone;
                    _subcategoriesshadowImageView.Visibility = ViewStates.Gone;
                    _isProjectsListOpen  = false;
                    isCategoriesListOpen = false;
                    _vibe.Vibrate(50);
                    _codeCompleteTextView.Text = "";
                    addCodeImageButton.StartAnimation(_buttonClickAnimation);
                    addBadgeDialog.Show();
                    addBadgeRelativeLayout.StartAnimation(AnimationUtils.LoadAnimation(this, global::Android.Resource.Animation.FadeIn));
                }
            };



            addBadgeCancelButton.Click += delegate { _vibe.Vibrate(50); addBadgeCancelButton.StartAnimation(_buttonClickAnimation); addBadgeDialog.Dismiss(); };
            addCodeButton.Click        += delegate { _vibe.Vibrate(50); addCodeButton.StartAnimation(_buttonClickAnimation); addBadgeDialog.Dismiss(); addCodeDialog.Show(); addCodeRelativeLayout.StartAnimation(AnimationUtils.LoadAnimation(this, global::Android.Resource.Animation.FadeIn)); };
            addCodeCancelButton.Click  += delegate { _vibe.Vibrate(50); addCodeCancelButton.StartAnimation(_buttonClickAnimation); addCodeDialog.Dismiss(); };
            readQRCodeButton.Click     += delegate
            {
                _vibe.Vibrate(50);
                readQRCodeButton.StartAnimation(_buttonClickAnimation); addBadgeDialog.Dismiss();
                _scanner = new MobileBarcodeScanner(this);
                _scanner.UseCustomOverlay = true;
                var      zxingOverlay   = LayoutInflater.FromContext(this).Inflate(Resource.Layout.qrreaderlayout, null);
                TextView qrTitleContent = (TextView)zxingOverlay.FindViewById(Resource.Id.qrreader_codetextView);
                qrTitleContent.SetTypeface(_font, TypefaceStyle.Normal);


                if (!AppInfo.IsLocaleRu)
                {
                    qrTitleContent.Text = "Check QR-Code";
                }

                _scanner.CustomOverlay = zxingOverlay;

                _scanner.Scan().ContinueWith((t) =>
                {
                    if (t.Status == System.Threading.Tasks.TaskStatus.RanToCompletion)
                    {
                        HandleScanResult(t.Result);
                    }
                });
            };

            addCodeReadyButton.Click += delegate
            {
                _vibe.Vibrate(50);
                if (_codeCompleteTextView.Text.Replace(" ", "") != "")
                {
                    addCodeReadyButton.StartAnimation(_buttonClickAnimation);
                    addCodeDialog.Dismiss();



                    _progressDialogMessage.Text = "Активация достижения...";
                    if (!AppInfo.IsLocaleRu)
                    {
                        _progressDialogMessage.Text = "Badge activation...";
                    }

                    _progressDialog.SetCancelable(false);
                    _progressDialog.Show();

                    ThreadStart threadStart = new ThreadStart(AsyncActivizationViaEntering);
                    Thread      loadThread  = new Thread(threadStart);
                    loadThread.Start();
                }
                else
                {
                    string toastStr = "Введите код активации";
                    if (!AppInfo.IsLocaleRu)
                    {
                        toastStr = "Enter activation code";
                    }

                    Toast.MakeText(this, toastStr, ToastLength.Short).Show();
                    addCodeReadyButton.StartAnimation(_buttonClickAnimation);
                }
            };
        }
Ejemplo n.º 22
0
 public override void OnCreate()
 {
     base.OnCreate();
     RegisterActivityLifecycleCallbacks(this);
     MobileBarcodeScanner.Initialize(this);
 }
Ejemplo n.º 23
0
        public override void ViewDidLoad()
        {
            //Create a new instance of our scanner
            scanner = new MobileBarcodeScanner(this.NavigationController);

            Root = new RootElement("ZXing.Net.Mobile")
            {
                new Section {
                    new StyledStringElement("Scan with Default View", async() => {
                        //Tell our scanner to use the default overlay
                        scanner.UseCustomOverlay = false;
                        //We can customize the top and bottom text of the default overlay
                        scanner.TopText    = "Hold camera up to barcode to scan";
                        scanner.BottomText = "Barcode will automatically scan";

                        //Start scanning
                        var result = await scanner.Scan();

                        HandleScanResult(result);
                    }),

                    new StyledStringElement("Scan Continuously", () => {
                        //Tell our scanner to use the default overlay
                        scanner.UseCustomOverlay = false;

                        //Tell our scanner to use our custom overlay
                        scanner.UseCustomOverlay = true;
                        scanner.CustomOverlay    = customOverlay;


                        var opt = new MobileBarcodeScanningOptions();
                        opt.DelayBetweenContinuousScans = 3000;

                        //Start scanning
                        scanner.ScanContinuously(opt, true, HandleScanResult);
                    }),

                    new StyledStringElement("Scan with Custom View", async() => {
                        //Create an instance of our custom overlay
                        customOverlay = new CustomOverlayView();
                        //Wireup the buttons from our custom overlay
                        customOverlay.ButtonTorch.TouchUpInside += delegate {
                            scanner.ToggleTorch();
                        };
                        customOverlay.ButtonCancel.TouchUpInside += delegate {
                            scanner.Cancel();
                        };

                        //Tell our scanner to use our custom overlay
                        scanner.UseCustomOverlay = true;
                        scanner.CustomOverlay    = customOverlay;

                        var result = await scanner.Scan();

                        HandleScanResult(result);
                    }),

                    new StyledStringElement("Scan with AVCapture Engine", async() => {
                        //Tell our scanner to use the default overlay
                        scanner.UseCustomOverlay = false;
                        //We can customize the top and bottom text of the default overlay
                        scanner.TopText    = "Hold camera up to barcode to scan";
                        scanner.BottomText = "Barcode will automatically scan";

                        //Start scanning
                        var result = await scanner.Scan(true);

                        HandleScanResult(result);
                    }),

                    new StyledStringElement("Generate Barcode", () => {
                        NavigationController.PushViewController(new ImageViewController(), true);
                    })
                }
            };
        }
Ejemplo n.º 24
0
 public StartPage()
 {
     InitializeComponent();
     scanner = new MobileBarcodeScanner();
 }
Ejemplo n.º 25
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);
            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab);

            fab.Click += FabOnClick;

            DrawerLayout          drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);

            drawer.AddDrawerListener(toggle);
            toggle.SyncState();

            NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            navigationView.SetNavigationItemSelectedListener(this);

            MobileBarcodeScanner.Initialize(Application);

            Agent = "Скай";
            FindViewById <ImageView>(Resource.Id.imageView1).SetImageResource(Resource.Drawable.Sky);

            var button = FindViewById <ImageButton>(Resource.Id.fab);

            button.Click += async delegate
            {
                var scanner = new MobileBarcodeScanner();
                var result  = await scanner.Scan();

                /*К сожалению qr код не может правильно передать зашифрованное сообщение
                 * string enctyptedIp = result.Text;
                 * string IpKey = enctyptedIp.Substring(enctyptedIp.Length - 28);
                 * enctyptedIp = enctyptedIp.Substring(0, enctyptedIp.Length - 28);
                 * LFSR IpProtection = new LFSR();
                 *
                 * IpProtection.EnterKey(IpKey);
                 * string dectyptedIp = IpProtection.Decrypt(enctyptedIp);
                 */
                if (result == null)
                {
                    return;
                }

                string ip = result.Text;

                string[] randStrs = { "fdytrtfv", "dcdsvsd", "sdasxcwfw", "jult,", "ascsdcr", "yujtytr", "ecl,", "i;remcd", "mkfwec", "sa;xlz," };
                string   LastName = Agent;
                string   mess     = "";
                Random   rnd      = new Random();
                for (int i = 0; i < randStrs.Length; i++)
                {
                    if (i == 7)
                    {
                        mess += LastName;
                    }
                    else
                    {
                        mess += randStrs[rnd.Next(randStrs.Length)];
                    }
                    mess += ":";
                }
                LFSR   messProtection = new LFSR();
                string key            = messProtection.GenerateKey();
                string enctyptedMess  = messProtection.Encrypt(mess);

                /*
                 * messProtection.EnterKey(key);
                 * string dectyptedMess = messProtection.Decrypt(enctyptedMess);
                 */
                new Tcp_S_R.Tcp_S_R(ip).SendMessage(enctyptedMess);
                new Tcp_S_R.Tcp_S_R(ip).SendMessage(enctyptedMess.Length.ToString());
                new Tcp_S_R.Tcp_S_R(ip).SendMessage(key);
                new Tcp_S_R.Tcp_S_R(ip).SendMessage(key.Length.ToString());
            };
        }
        public MobileBarcodeScanner GetMobileBarcodeScanner()
        {
            MobileBarcodeScanner.Initialize(MainActivity.MainApplication);

            return(new MobileBarcodeScanner());
        }
Ejemplo n.º 27
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Xamarin.Essentials.Platform.Init(Application);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            //Create a new instance of our Scanner
            scanner = new MobileBarcodeScanner();

            buttonScanDefaultView        = this.FindViewById <Button>(Resource.Id.buttonScanDefaultView);
            buttonScanDefaultView.Click += async delegate
            {
                //Tell our scanner to use the default overlay
                scanner.UseCustomOverlay = false;

                //We can customize the top and bottom text of the default overlay
                scanner.TopText    = "Hold the camera up to the barcode\nAbout 6 inches away";
                scanner.BottomText = "Wait for the barcode to automatically scan!";

                //Start scanning
                var result = await scanner.Scan();

                HandleScanResult(result);
            };

            buttonContinuousScan        = FindViewById <Button>(Resource.Id.buttonScanContinuous);
            buttonContinuousScan.Click += delegate
            {
                scanner.UseCustomOverlay = false;

                //We can customize the top and bottom text of the default overlay
                scanner.TopText    = "Hold the camera up to the barcode\nAbout 6 inches away";
                scanner.BottomText = "Wait for the barcode to automatically scan!";

                var opt = new MobileBarcodeScanningOptions();
                opt.DelayBetweenContinuousScans = 3000;

                //Start scanning
                scanner.ScanContinuously(opt, HandleScanResult);
            };

            Button flashButton;
            View   zxingOverlay;

            buttonScanCustomView        = this.FindViewById <Button>(Resource.Id.buttonScanCustomView);
            buttonScanCustomView.Click += async delegate
            {
                //Tell our scanner we want to use a custom overlay instead of the default
                scanner.UseCustomOverlay = true;

                //Inflate our custom overlay from a resource layout
                zxingOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.ZxingOverlay, null);

                //Find the button from our resource layout and wire up the click event
                flashButton        = zxingOverlay.FindViewById <Button>(Resource.Id.buttonZxingFlash);
                flashButton.Click += (sender, e) => scanner.ToggleTorch();

                //Set our custom overlay
                scanner.CustomOverlay = zxingOverlay;

                //Start scanning!
                var result = await scanner.Scan(new MobileBarcodeScanningOptions { AutoRotate = true });

                HandleScanResult(result);
            };

            buttonFragmentScanner        = FindViewById <Button>(Resource.Id.buttonFragment);
            buttonFragmentScanner.Click += delegate
            {
                StartActivity(typeof(FragmentActivity));
            };

            buttonGenerate        = FindViewById <Button>(Resource.Id.buttonGenerate);
            buttonGenerate.Click += delegate
            {
                StartActivity(typeof(ImageActivity));
            };
        }
Ejemplo n.º 28
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);


            //inicializar dialogos
            UserDialogs.Init(Application);
            MobileBarcodeScanner.Initialize(Application);
            // Create your application here
            SetContentView(Resource.Layout.DetalleProducto);
            _producto = new Negocio.Producto()
            {
                IdProducto = Intent.GetIntExtra(Negocio.Constantes.MENSAJE_IDPRODUCTO, 0)
            };
            _producto.GetProductoById();

            TextView txt     = FindViewById <TextView>(Resource.Id.txtBarraProducto);
            EditText txtEdit = FindViewById <EditText>(Resource.Id.txtEditProducto);
            var      button  = FindViewById <SatelliteMenu.SatelliteMenuButton>(Resource.Id.menuSateliteProducto);

            button.AddItems(new[] {
                new SatelliteMenuButtonItem(Negocio.Constantes.MENU_SCAN, Resource.Drawable.ic_barcode_scan)
            });
            button.MenuItemClick += MenuItem_Click;

            View vBotonBack = FindViewById <View>(Resource.Id.BackButtonProducto);

            vBotonBack.Click += BotonBack_Click;

            Spinner spinner1 = FindViewById <Spinner>(Resource.Id.spinner1);


            txt.Visibility      = ViewStates.Visible;
            txtEdit.Visibility  = ViewStates.Gone;
            spinner1.Visibility = ViewStates.Gone;

            txt.Text     = _producto.Descripcion;
            txtEdit.Text = _producto.Descripcion;
            if (savedInstanceState != null)
            {
                int accionTemp = savedInstanceState.GetInt(Negocio.Constantes.MENSAJE_ACCION);
                AccionEnCurso        = (Negocio.Constantes.Acciones)accionTemp;
                _producto.IdProducto = savedInstanceState.GetInt(Negocio.Constantes.MENSAJE_IDPRODUCTO);
                if (_producto.IdProducto != 0)
                {
                    if (AccionEnCurso == Negocio.Constantes.Acciones.ACCIONES_NONE)
                    {
                        button.AddItems(new[] {
                            new SatelliteMenuButtonItem(Negocio.Constantes.MENU_ANADIR, Resource.Drawable.ic_add_circle_outline_black_24dp),
                            new SatelliteMenuButtonItem(Negocio.Constantes.MENU_BORRAR, Resource.Drawable.ic_delete_black_24dp),
                            new SatelliteMenuButtonItem(Negocio.Constantes.MENU_EDIT, Resource.Drawable.ic_create_black_24dp)
                        });
                    }
                    else if (AccionEnCurso == Negocio.Constantes.Acciones.ACCIONES_EDIT)
                    {
                        txt.Visibility      = ViewStates.Gone;
                        txtEdit.Visibility  = ViewStates.Visible;
                        spinner1.Visibility = ViewStates.Visible;
                        List <Negocio.Grupo> ListaGrupo = GestorApp.myData.GetAllGrupos();
                        ListaGrupo.OrderBy(g => g.Descripcion);
                        List <string> ListaGrupoString = GetDescripcionesGrupos(ListaGrupo);
                        ArrayAdapter  SpinnerAdapter   = new ArrayAdapter(this, Resource.Layout.ProductLayoutSpinner, ListaGrupoString);
                        spinner1.Adapter = SpinnerAdapter;
                        Negocio.Grupo _grupo   = _producto.GetGrupo();
                        int           posicion = ListaGrupoString.IndexOf(_grupo.Descripcion);
                        spinner1.SetSelection(posicion);
                        button.AddItems(new[] {
                            new SatelliteMenuButtonItem(Negocio.Constantes.MENU_SALVAR, Resource.Drawable.ic_save_black_24dp),
                            new SatelliteMenuButtonItem(Negocio.Constantes.MENU_CANCELAR, Resource.Drawable.ic_clear_black_24dp),
                        });
                    }
                }
            }
            else
            {
                button.AddItems(new[] {
                    new SatelliteMenuButtonItem(Negocio.Constantes.MENU_ANADIR, Resource.Drawable.ic_add_circle_outline_black_24dp),
                    new SatelliteMenuButtonItem(Negocio.Constantes.MENU_BORRAR, Resource.Drawable.ic_delete_black_24dp),
                    new SatelliteMenuButtonItem(Negocio.Constantes.MENU_EDIT, Resource.Drawable.ic_create_black_24dp)
                });
            }

            List <Negocio.Existencias> lExistencias = _producto.GetExistencias();
            List <Negocio.Elemento>    lElementos   = _producto.GetElementos();

            var listView = FindViewById <ExpandableListView>(Resource.Id.lListaProducto);

            listView.SetAdapter(new Negocio.Adaptadores.ProductoExpandableAdapter(this, lExistencias, lElementos));
        }
Ejemplo n.º 29
0
 public void Dispose()
 {
     MobileBarcodeScanner.Uninitialize(_application);
 }
Ejemplo n.º 30
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            // return inflater.Inflate(Resource.Layout.YourFragment, container, false);

            var ignored = base.OnCreateView(inflater, container, savedInstanceState);

            view = inflater.Inflate(Resource.Layout.ListEPISRepuestos, null);

            var count = ManagerRepuestos.getRepuestos();

            // this.Activity.Title = empleado.FullName;
            empleado = ManagerRepuestos.getEmpleado();
            MobileBarcodeScanner.Initialize(this.Activity.Application);

            listRepuestosEpis = ManagerRepuestos.getRepuestos();
            // listRepuestosEpis.Clear();
            listViewEmpleados = (ListView)view.FindViewById(Resource.Id.listProductos);
            adapterRepuestos  = new AdapterRepuestos(this.Activity, listRepuestosEpis);//new ArrayAdapter<string>(this,Android.Resource.Layout.SimpleListItem1, listRepuestosEpis);

            // adapterRepuestos;

            adaptarSwipe = new SwipeActionAdapter(adapterRepuestos);

            adaptarSwipe.SetSwipeActionListener(this)
            .SetDimBackgrounds(true)
            .SetListView(this.listViewEmpleados);

            listViewEmpleados.Adapter = adaptarSwipe;
            adaptarSwipe.AddBackground(SwipeDirection.DirectionFarLeft, Resource.Menu.row_bg_left_far);
            adaptarSwipe.AddBackground(SwipeDirection.DirectionNormalLeft, Resource.Menu.row_bg_left);
            adaptarSwipe.AddBackground(SwipeDirection.DirectionFarRight, Resource.Menu.row_bg_right_far);
            adaptarSwipe.AddBackground(SwipeDirection.DirectionNormalRight, Resource.Menu.row_bg_right);



            //listViewEmpleados.ItemClick += OnListItemClick;

            var fab = view.FindViewById <com.refractored.fab.FloatingActionButton>(Resource.Id.floating);

            fab.AttachToListView(listViewEmpleados);
            // Button btoScan = FindViewById<Button>(Resource.Id.btoScanear);
            fab.Click += (object sender, EventArgs e) =>
            {
                var code = launchScaner();
            };

            listViewEmpleados.ItemClick += (sender, e) =>
            {
                //var activityDetalleRepuestoActivity = new Intent(this.Activity, typeof(detalleRepuestoActivity));
                //activityDetalleRepuestoActivity.PutExtra("idEntregaAlmacen", ManagerRepuestos.getRepuestos()[e.Position].Key);
                //StartActivity(activityDetalleRepuestoActivity);

                Android.Support.V4.App.Fragment fragment = new AlmacenRepuestosXamarin.Fragments.DetalleRepuesto();

                Bundle bundle = new Bundle();
                bundle.PutString("idEntregaAlmacen", ManagerRepuestos.getRepuestos()[e.Position].Key);
                fragment.Arguments = bundle;

                FragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment)
                .AddToBackStack("ListaRepuestosEntrega")
                .Commit();
            };


            progressLayout            = view.FindViewById <LinearLayout>(Resource.Id.progressBarListaEntrega);
            progressLayout.Visibility = ViewStates.Gone;



            return(view);
        }