示例#1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            UIHelper.init(this);
            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);
            //Create a new instance of our Scanner
            scanner = new MobileBarcodeScanner(this);
            buttonScanDefaultView = this.FindViewById<Button>(Resource.Id.mainButtonNew);
            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);
            };

            var buttonBook = this.FindViewById<Button>(Resource.Id.mainButtonBook);
            buttonBook.Click += delegate
            {
                UIHelper.DelayedToast("Book", 10);
                var activity2 = new Intent(this, typeof(Activity2));
                activity2.PutExtra("genre", "Book");
                StartActivity(activity2);
            };
            var buttonGame = this.FindViewById<Button>(Resource.Id.mainButtonGame);
            buttonGame.Click += delegate
            {
                UIHelper.DelayedToast("Game", 10);
                var activity2 = new Intent(this, typeof(Activity2));
                activity2.PutExtra("genre", "game");
                StartActivity(activity2);
            };
            var buttonCd = this.FindViewById<Button>(Resource.Id.mainButtonCD);
            buttonCd.Click += delegate
            {
                UIHelper.DelayedToast("CD", 10);
                var activity2 = new Intent(this, typeof(Activity2));
                activity2.PutExtra("genre", "CD");
                StartActivity(activity2);
            };
            var buttonDVD = this.FindViewById<Button>(Resource.Id.mainButtonDVD);
            buttonDVD.Click += delegate
            {
                UIHelper.DelayedToast("DVD", 10);
                var activity2 = new Intent(this, typeof(Activity2));
                activity2.PutExtra("genre", "DVD");
                StartActivity(activity2);
            };

            //	�~�O���t�ǂݍ��݋y�э쐬
            var imageViewPieChart = FindViewById<ImageView>(Resource.Id.mainImageViewPieChart);
            if (SDCardHelper.ISExistFile(Constant.APP_NAME + "/PieChart.jpg"))
            {
                byte[] bytes = SDCardHelper.loadBytes(Constant.APP_NAME + "/PieChart.jpg");
                Bitmap bitmap = BitmapFactory.DecodeByteArray(bytes, 0, bytes.Length);
                imageViewPieChart.SetImageBitmap(bitmap);
            }
            var heartRailsAPI = new HeartRailsAPI();
            string[] genres = {"Book", "Game", "CD", "DVD"};
            int cnt = 0;
            for (int i = 0; i < 4; i++)
            {
                string datDirectoryPath = MyData.GetDatDirectory(genres[i]);
                if (!SDCardHelper.ISExistDirectory(datDirectoryPath)) continue;
                int num = SDCardHelper.GetFiles(datDirectoryPath).Length;
                heartRailsAPI.AddElement(genres[i], num);
                cnt++;
            }
            if (cnt == 0) heartRailsAPI.AddElement("None", 100);
            //			heartRailsAPI.Query.title_top = "Genre Pie Chart";
            heartRailsAPI.CallBackBytes += (byte[] bytes) =>
            {
                SDCardHelper.save(Constant.APP_NAME + "/PieChart.jpg", bytes);
                Bitmap bitmap = BitmapFactory.DecodeByteArray(bytes, 0, bytes.Length);
                imageViewPieChart.SetImageBitmap(bitmap);
            };
            heartRailsAPI.start();
        }
示例#2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            UIHelper.init(this);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            //Create a new instance of our Scanner
            scanner = new MobileBarcodeScanner(this);
            buttonScanDefaultView        = this.FindViewById <Button>(Resource.Id.mainButtonNew);
            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);
            };

            var buttonBook = this.FindViewById <Button>(Resource.Id.mainButtonBook);

            buttonBook.Click += delegate
            {
                UIHelper.DelayedToast("Book", 10);
                var activity2 = new Intent(this, typeof(Activity2));
                activity2.PutExtra("genre", "Book");
                StartActivity(activity2);
            };
            var buttonGame = this.FindViewById <Button>(Resource.Id.mainButtonGame);

            buttonGame.Click += delegate
            {
                UIHelper.DelayedToast("Game", 10);
                var activity2 = new Intent(this, typeof(Activity2));
                activity2.PutExtra("genre", "game");
                StartActivity(activity2);
            };
            var buttonCd = this.FindViewById <Button>(Resource.Id.mainButtonCD);

            buttonCd.Click += delegate
            {
                UIHelper.DelayedToast("CD", 10);
                var activity2 = new Intent(this, typeof(Activity2));
                activity2.PutExtra("genre", "CD");
                StartActivity(activity2);
            };
            var buttonDVD = this.FindViewById <Button>(Resource.Id.mainButtonDVD);

            buttonDVD.Click += delegate
            {
                UIHelper.DelayedToast("DVD", 10);
                var activity2 = new Intent(this, typeof(Activity2));
                activity2.PutExtra("genre", "DVD");
                StartActivity(activity2);
            };

            //	円グラフ読み込み及び作成
            var imageViewPieChart = FindViewById <ImageView>(Resource.Id.mainImageViewPieChart);

            if (SDCardHelper.ISExistFile(Constant.APP_NAME + "/PieChart.jpg"))
            {
                byte[] bytes  = SDCardHelper.loadBytes(Constant.APP_NAME + "/PieChart.jpg");
                Bitmap bitmap = BitmapFactory.DecodeByteArray(bytes, 0, bytes.Length);
                imageViewPieChart.SetImageBitmap(bitmap);
            }
            var heartRailsAPI = new HeartRailsAPI();

            string[] genres = { "Book", "Game", "CD", "DVD" };
            int      cnt    = 0;

            for (int i = 0; i < 4; i++)
            {
                string datDirectoryPath = MyData.GetDatDirectory(genres[i]);
                if (!SDCardHelper.ISExistDirectory(datDirectoryPath))
                {
                    continue;
                }
                int num = SDCardHelper.GetFiles(datDirectoryPath).Length;
                heartRailsAPI.AddElement(genres[i], num);
                cnt++;
            }
            if (cnt == 0)
            {
                heartRailsAPI.AddElement("None", 100);
            }
//			heartRailsAPI.Query.title_top = "Genre Pie Chart";
            heartRailsAPI.CallBackBytes += (byte[] bytes) =>
            {
                SDCardHelper.save(Constant.APP_NAME + "/PieChart.jpg", bytes);
                Bitmap bitmap = BitmapFactory.DecodeByteArray(bytes, 0, bytes.Length);
                imageViewPieChart.SetImageBitmap(bitmap);
            };
            heartRailsAPI.start();
        }