Esempio n. 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.LifeCounter);

            SqliteConnection conn = new SqliteConnection();

            conn.SQLiteConnection();
            conn.CreateTables();

            var model = conn.GetLatestEntry();

            if (model == null || model.Life == 0)
            {
                ViewModel.LifeCounter lifeModel = new ViewModel.LifeCounter();
                lifeModel.CommanderDamageCounter = 0;
                lifeModel.PoisonDamageCounter    = 0;
                lifeModel.Life = 40;
                var returnModel = conn.AddLifeCounter(Translate(lifeModel));
                mainActivityModel = Translate(returnModel);
            }
            else
            {
                mainActivityModel = Translate(model);
            }

            SetupTabs(conn, model);

            ActionBar.Title = "EDH MTG Life Counter";
        }
Esempio n. 2
0
        private void SetupLifeMainView(ViewModel.LifeCounter ViewModel)
        {
            SqliteConnection conn = new SqliteConnection();

            conn.SQLiteConnection();

            TextView txthealt          = FindViewById <TextView>(Resource.Id.txtHealth);
            Button   addOneButton      = FindViewById <Button>(Resource.Id.btnAddOne);
            Button   subtractOneButton = FindViewById <Button>(Resource.Id.btnSubtractOne);

            TextView counterText = FindViewById <TextView>(Resource.Id.txtHealth);

            if (ActionBar.SelectedTab.Position == 0)
            {
                counterText.Text = ViewModel.Life.ToString();
            }
            else if (ActionBar.SelectedTab.Position == 1)
            {
                counterText.Text = ViewModel.PoisonDamageCounter.ToString();
            }
            else if (ActionBar.SelectedTab.Position == 2)
            {
                counterText.Text = ViewModel.CommanderDamageCounter.ToString();
            }
            txthealt.Click          += delegate { AddFiveHealth(conn); };
            addOneButton.Click      += delegate { AddOneHealth(mainActivityModel, conn); };
            subtractOneButton.Click += delegate { SubtractOneHealth(mainActivityModel, conn); };
        }
Esempio n. 3
0
        private Model.ModelLifeCounter Translate(ViewModel.LifeCounter dataModel)
        {
            Model.ModelLifeCounter model = new Model.ModelLifeCounter();
            model.CommanderDamageCounter = dataModel.CommanderDamageCounter;
            model.CreateDate             = dataModel.CreateDate;
            model.Deleted             = dataModel.Deleted;
            model.Id                  = dataModel.Id;
            model.Inserted            = dataModel.Inserted;
            model.Life                = dataModel.Life;
            model.PoisonDamageCounter = dataModel.PoisonDamageCounter;
            model.Updated             = dataModel.Updated;
            model.UpdateDate          = dataModel.UpdateDate;
            model.User                = dataModel.User;

            return(model);
        }
Esempio n. 4
0
        private ViewModel.LifeCounter Translate(Model.ModelLifeCounter model)
        {
            ViewModel.LifeCounter returnView = new ViewModel.LifeCounter();
            returnView.CommanderDamageCounter = model.CommanderDamageCounter;
            returnView.CreateDate             = model.CreateDate;
            returnView.Deleted             = model.Deleted;
            returnView.Id                  = model.Id;
            returnView.Inserted            = model.Inserted;
            returnView.Life                = model.Life;
            returnView.PoisonDamageCounter = model.PoisonDamageCounter;
            returnView.Updated             = model.Updated;
            returnView.UpdateDate          = model.UpdateDate;
            returnView.User                = model.User;

            return(returnView);
        }
Esempio n. 5
0
        private void SubtractOneHealth(ViewModel.LifeCounter ViewModel, SqliteConnection conn)
        {
            TextView txtHelth = FindViewById <TextView>(Resource.Id.txtHealth);

            if (ActionBar.SelectedTab.Position == 0)
            {
                mainActivityModel.Life -= 1;
                if (mainActivityModel.Life <= 0)
                {
                    mainActivityModel.Life = 0;
                    txtHelth.Text          = (0).ToString();
                }
                else
                {
                    txtHelth.Text = (mainActivityModel.Life).ToString();
                }
                conn.UpdateLifeCounter(Translate(mainActivityModel));
            }
            else if (ActionBar.SelectedTab.Position == 1)
            {
                mainActivityModel.PoisonDamageCounter -= 1;
                if (mainActivityModel.PoisonDamageCounter <= 0)
                {
                    mainActivityModel.PoisonDamageCounter = 0;
                    txtHelth.Text = (0).ToString();
                }
                else
                {
                    txtHelth.Text = (mainActivityModel.PoisonDamageCounter).ToString();
                }
                conn.UpdateLifeCounter(Translate(mainActivityModel));
            }
            else if (ActionBar.SelectedTab.Position == 2)
            {
                mainActivityModel.CommanderDamageCounter -= 1;
                if (mainActivityModel.CommanderDamageCounter <= 0)
                {
                    mainActivityModel.CommanderDamageCounter = 0;
                    txtHelth.Text = (0).ToString();
                }
                else
                {
                    txtHelth.Text = (mainActivityModel.CommanderDamageCounter).ToString();
                }
                conn.UpdateLifeCounter(Translate(mainActivityModel));
            }
        }
Esempio n. 6
0
        private void AddOneHealth(ViewModel.LifeCounter ViewModel, SqliteConnection conn)
        {
            TextView txtHelth = FindViewById <TextView>(Resource.Id.txtHealth);

            if (ActionBar.SelectedTab.Position == 0)
            {
                mainActivityModel.Life += 1;
                txtHelth.Text           = mainActivityModel.Life.ToString();
                conn.UpdateLifeCounter(Translate(mainActivityModel));
            }
            else if (ActionBar.SelectedTab.Position == 1)
            {
                mainActivityModel.PoisonDamageCounter += 1;
                txtHelth.Text = mainActivityModel.PoisonDamageCounter.ToString();
                conn.UpdateLifeCounter(Translate(mainActivityModel));
            }
            else if (ActionBar.SelectedTab.Position == 2)
            {
                mainActivityModel.CommanderDamageCounter += 1;
                txtHelth.Text = mainActivityModel.CommanderDamageCounter.ToString();
                conn.UpdateLifeCounter(Translate(mainActivityModel));
            }
        }