Beispiel #1
0
        private void dialodTransacaoAprovadaMsitef(Intent data)
        {
            Android.App.AlertDialog alertDialog = new Android.App.AlertDialog.Builder(this).Create();

            StringBuilder cupom = new StringBuilder();

            cupom.Append("CODRESP: " + data.GetStringExtra("CODRESP") + "\n");
            cupom.Append("COMP_DADOS_CONF: " + data.GetStringExtra("COMP_DADOS_CONF") + "\n");
            cupom.Append("CODTRANS: " + data.GetStringExtra("CODTRANS") + "\n");

            cupom.Append("CODTRANS: " + data.GetStringExtra("CODTRANS") + " " + Convert.ToString(retornaTipoParcelamento(Convert.ToInt32(data.GetStringExtra("TIPO_PARC")))) + "\n");

            cupom.Append("VLTROCO: " + data.GetStringExtra("VLTROCO") + "\n");
            cupom.Append("REDE_AUT: " + data.GetStringExtra("REDE_AUT") + "\n");
            cupom.Append("BANDEIRA: " + data.GetStringExtra("BANDEIRA") + "\n");

            cupom.Append("NSU_SITEF: " + data.GetStringExtra("NSU_SITEF") + "\n");
            cupom.Append("NSU_HOST: " + data.GetStringExtra("NSU_HOST") + "\n");
            cupom.Append("COD_AUTORIZACAO: " + data.GetStringExtra("COD_AUTORIZACAO") + "\n");
            cupom.Append("NUM_PARC: " + data.GetStringExtra("NUM_PARC") + "\n");

            alertDialog.SetTitle("Ação executada com sucesso");
            alertDialog.SetMessage(cupom.ToString());
            alertDialog.SetButton("OK", delegate
            {
                alertDialog.Dismiss();
            });
            alertDialog.Show();
        }
Beispiel #2
0
 private void Regras_Click(object sender, EventArgs e)
 {
     Android.App.AlertDialog.Builder caixa = new Android.App.AlertDialog.Builder(this);
     caixa.SetTitle("Regras");
     caixa.SetMessage("Pedra, papel, tesoura, lagarto, Spock. É muito simples. Olhe – "
                      + "tesoura corta papel, papel cobre pedra, pedra esmaga lagarto, "
                      + "lagarto envenena Spock, Spock esmaga tesoura, tesoura decapita lagarto,"
                      + "lagarto come papel, papel refuta Spock,"
                      + " Spock vaporiza pedra e como sempre, pedra quebra tesoura.");
     caixa.Show();
 }
Beispiel #3
0
 private void dialogoErro(String msg)
 {
     Android.App.AlertDialog alertDialog = new Android.App.AlertDialog.Builder(this).Create();
     alertDialog.SetTitle("Erro ao executar função");
     alertDialog.SetMessage(msg);
     alertDialog.SetButton("OK", delegate
     {
         //Não existe nenhuma ação
         alertDialog.Dismiss();
     });
     alertDialog.Show();
 }
        public override void OnBackPressed()
        {
            Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(this);
            alertDiag.SetTitle("SALIR");
            alertDiag.SetMessage("¿Desea Cerrar La Aplicacion?");
            alertDiag.SetNegativeButton("SI", (senderAlert, args) => {
                FinishAffinity();
            });
            alertDiag.SetPositiveButton("NO", (senderAlert, args) => {
            });
            Dialog diag = alertDiag.Create();

            diag.Show();
        }
Beispiel #5
0
        private void dialodTransacaoNegadaMsitef(Intent data)
        {
            Android.App.AlertDialog alertDialog = new Android.App.AlertDialog.Builder(this).Create();

            StringBuilder cupom = new StringBuilder();

            cupom.Append("CODRESP: " + data.GetStringExtra("CODRESP") + "\n");

            alertDialog.SetTitle("Ocorreu um erro durante a realização da ação");
            alertDialog.SetMessage(cupom.ToString());
            alertDialog.SetButton("OK", delegate
            {
                alertDialog.Dismiss();
            });
            alertDialog.Show();
        }
Beispiel #6
0
        private void dialodTransacaoNegadaGer7(RetornoGer7 retorno)
        {
            Android.App.AlertDialog alertDialog = new Android.App.AlertDialog.Builder(this).Create();

            StringBuilder cupom = new StringBuilder();

            cupom.Append("version: " + retorno.Version + "\n");
            cupom.Append("errcode: " + retorno.Errcode + "\n");
            cupom.Append("errmsg: " + retorno.Errmsg + "\n");

            alertDialog.SetTitle("Ocorreu um erro durante a realização da ação");
            alertDialog.SetMessage(cupom.ToString());
            alertDialog.SetButton("OK", delegate
            {
                alertDialog.Dismiss();
            });
            alertDialog.Show();
        }
Beispiel #7
0
        private void dialodTransacaoAprovadaGer7(RetornoGer7 retorno)
        {
            Android.App.AlertDialog alertDialog = new Android.App.AlertDialog.Builder(this).Create();
            StringBuilder           cupom       = new StringBuilder();

            cupom.Append("version: " + retorno.Version + "\n");
            cupom.Append("status: " + retorno.Status + "\n");
            cupom.Append("config: " + retorno.Config + "\n");
            cupom.Append("license: " + retorno.License + "\n");
            cupom.Append("terminal: " + retorno.Terminal + "\n");
            cupom.Append("merchant: " + retorno.Merchant + "\n");
            cupom.Append("id: " + retorno.Id + "\n");
            cupom.Append("type: " + retorno.Type + "\n");
            cupom.Append("product: " + retorno.Product + "\n");
            cupom.Append("response: " + retorno.Response + "\n");
            cupom.Append("authorization: " + retorno.Authorization + "\n");
            cupom.Append("amount: " + retorno.Amount + "\n");
            cupom.Append("installments: " + retorno.Installments + "\n");
            cupom.Append("instmode: " + retorno.Instmode + "\n");
            cupom.Append("stan: " + retorno.Stan + "\n");
            cupom.Append("rrn: " + retorno.Rrn + "\n");
            cupom.Append("time: " + retorno.Time + "\n");
            cupom.Append("track2: " + retorno.Track2 + "\n");
            cupom.Append("aid: " + retorno.Aid + "\n");
            cupom.Append("cardholder: " + retorno.Cardholder + "\n");
            cupom.Append("prefname: " + retorno.Prefname + "\n");
            cupom.Append("errcode: " + retorno.Errcode + "\n");
            cupom.Append("label: " + retorno.Label + "\n");

            alertDialog.SetTitle("Ação executada com sucesso");
            alertDialog.SetMessage(cupom.ToString());
            alertDialog.SetButton("OK", delegate
            {
                alertDialog.Dismiss();
            });
            alertDialog.Show();
        }
Beispiel #8
0
        private void Tesoura_Click(object sender, EventArgs e)
        {
            int teste = rnd.Next(1, 6);

            ImagePlayer.SetImageResource(Resource.Drawable.tesoura);
            ImagePlayer.Visibility = ViewStates.Visible;
            if (teste == papel)
            {
                pontosPlayer++;
                ImageCPU.Visibility = ViewStates.Visible;
                ImageCPU.SetImageResource(Resource.Drawable.papel);
            }
            else if (teste == lagarto)
            {
                pontosPlayer++;
                ImageCPU.Visibility = ViewStates.Visible;
                ImageCPU.SetImageResource(Resource.Drawable.lagarto);
            }
            else if (teste == tesoura)
            {
                empates++;
                ImageCPU.Visibility = ViewStates.Visible;
                ImageCPU.SetImageResource(Resource.Drawable.tesoura);
            }
            else if (teste == spock)
            {
                pontosComputer++;
                ImageCPU.Visibility = ViewStates.Visible;
                ImageCPU.SetImageResource(Resource.Drawable.spock);
            }
            else
            {
                pontosComputer++;
                ImageCPU.Visibility = ViewStates.Visible;
                ImageCPU.SetImageResource(Resource.Drawable.pedra);
            }
            Placar.Text = "Jogador: " + pontosPlayer.ToString() + "     CPU: " + pontosComputer.ToString() + "     Empates: " + empates.ToString();
            placar      = Placar.Text;
            if (pontosComputer == 5)
            {
                if (Audio.Checked)
                {
                    derrota.Start();
                }

                Android.App.AlertDialog.Builder caixa = new Android.App.AlertDialog.Builder(this);
                caixa.SetTitle("Fim de jogo!");
                caixa.SetMessage("O CPU marcou 5 pontos! Você perdeu!");
                caixa.Show();
                pontosComputer = 0;
                pontosPlayer   = 0;
                empates        = 0;
                Placar.Text    = "Jogador: " + pontosPlayer.ToString() + "     CPU: " + pontosComputer.ToString() + "     Empates: " + empates.ToString();
                placar         = Placar.Text;
            }
            if (pontosPlayer == 5)
            {
                if (Audio.Checked)
                {
                    vitoria.Start();
                }

                Android.App.AlertDialog.Builder caixa = new Android.App.AlertDialog.Builder(this);
                caixa.SetTitle("Fim de jogo!");
                caixa.SetMessage("Você marcou 5 pontos! Você ganhou!");
                caixa.Show();
                pontosComputer = 0;
                pontosPlayer   = 0;
                empates        = 0;
                Placar.Text    = "Jogador: " + pontosPlayer.ToString() + "     CPU: " + pontosComputer.ToString() + "     Empates: " + empates.ToString();
                placar         = Placar.Text;

                vitorias++;
                Player player = new Player()
                {
                    Id       = int.Parse(txtNome.Tag.ToString()),
                    Vitorias = vitorias
                };
                db.AtualizarPlayer(player);
                CarregarDados();
            }
        }
Beispiel #9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {

            string appDirectory;
            string newDirectory;
            string textFilePath;
            string text;
            IEnumerable entries;
            IEnumerable files;

            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            Button read = FindViewById<Button>(Resource.Id.button1);
            Button write = FindViewById<Button>(Resource.Id.button2);
            Button log = FindViewById<Button>(Resource.Id.button3);
            Button readLog = FindViewById<Button>(Resource.Id.button4);
            EditText editText = FindViewById<EditText>(Resource.Id.editText1);
            EditText textArea = FindViewById<EditText>(Resource.Id.editText2);

            FloatingActionButton fab = FindViewById<FloatingActionButton>(Resource.Id.fab);
            fab.Click += delegate
            {

                //Grab the app storage directory
                // In this case we're going to use the external files directory becasue android devices have limited storage in terms of the app storage area
                appDirectory = Android.App.Application.Context.GetExternalFilesDir(null).AbsolutePath;
                entries = Directory.EnumerateDirectories(appDirectory);
                files = Directory.EnumerateFiles(appDirectory);

                //The following method takes an absolute path and appends another item to it which can be a folder (and creates the foñder) or a file (if it ends with a ".'extension'", so it creates a file)
                newDirectory = Path.Combine(appDirectory, "myDirectory");

                Directory.CreateDirectory(newDirectory); //Creates if it doesn't exists

                textFilePath = Path.Combine(appDirectory, "myTXT.txt");
                File.CreateText(textFilePath);

                foreach(var e in entries)
                {
                    Log.Debug("DEBUG", e.ToString());
                }

                foreach (var e in files)
                {
                    Log.Debug("DEBUG", e.ToString());
                }

                //Unless you really, really, relly have to, never use the internal storage

            };

            read.Click += delegate
            {
                appDirectory = Android.App.Application.Context.GetExternalFilesDir(null).AbsolutePath;
                textFilePath = Path.Combine(appDirectory, "myTXT.txt");
                text = File.ReadAllText(textFilePath);
                textArea.Text = text;
            };

            write.Click += delegate
            {
                appDirectory = Android.App.Application.Context.GetExternalFilesDir(null).AbsolutePath;
                textFilePath = Path.Combine(appDirectory, "myTXT.txt");
                File.AppendAllText(textFilePath, editText.Text);
                editText.Text = "";
            };

            log.Click += delegate
            {
                Toast.MakeText(this, "Creating log...", ToastLength.Short).Show();
                appDirectory = Android.App.Application.Context.GetExternalFilesDir(null).AbsolutePath;
                textFilePath = Path.Combine(appDirectory, "log.txt");
                File.WriteAllText(textFilePath, "");

                Task.Factory.StartNew(() => { //Let's create a new thread

                    RunOnUiThread(() => {
                        readLog.Enabled = false; //We're trying to acces a button which lies on th UI thread and we're running our whole taks into a separate thread. Let's make this run back on the main thread
                    });
                    
                    for (int i = 0; i < 5; i++)
                    {
                        File.AppendAllText(textFilePath, DateTime.Now.ToString() + "\n");
                        Thread.Sleep(1000);
                    }

                    RunOnUiThread(() => {
                        readLog.Enabled = true;
                    });

                });
            };

            readLog.Click += delegate
            {
                appDirectory = Android.App.Application.Context.GetExternalFilesDir(null).AbsolutePath;
                textFilePath = Path.Combine(appDirectory, "log.txt");
                text = File.ReadAllText(textFilePath);
                Log.Debug("FILE", text);
                AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this);
                alert.SetTitle("Log records");
                alert.SetMessage(text);
                alert.Show();
            };
        }