Beispiel #1
0
        public void RoundTimer(TimeSpan time, int intTime, ref TournamentMainRoundInfoTimer_ViewModel timerRoundBtn_VM)
        {
            //Set timer to the round's end time, cancelling any existing timer and starting with the new time in mind.
            round_time = intTime;
            if (timerRoundBtn_VM != null)
            {
                tmpVM            = timerRoundBtn_VM;
                tmpVM.TimerValue = round_time.ToString();
            }

            if (ROUND_TIMER != null)
            {
                ROUND_TIMER.Stop();
                ROUND_TIMER.Enabled = false;
                ROUND_TIMER         = null;
            }

            ROUND_TIMER = new System.Timers.Timer();

            //Trigger event every second
            ROUND_TIMER.Interval = 1000;
            ROUND_TIMER.Elapsed += roundTimer_Tick;
            ROUND_TIMER.Enabled  = true;
            ROUND_TIMER.Start();
        }
        public Tournaments_RoundInfo(Tournaments_AllInfo allInfoPage, string strTitle, int intRoundId, int intRoundCount)
        {
            InitializeComponent();
            Title = strTitle;
            intDefaultRoundLength = allInfoPage.intDefaultRoundLength;
            this.intRoundId       = intRoundId;

            //Tie the loading Overlay to the main page since this is what will be flagged as "IsBusy" when generating new rounds etc.
            loadingOverlay.BindingContext = allInfoPage;

            timerRoundBtn_VM             = new TournamentMainRoundInfoTimer_ViewModel();
            timerRoundBtn.BindingContext = timerRoundBtn_VM;

            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH))
            {
                TournamentMainRound round = new TournamentMainRound();
                round          = conn.GetWithChildren <TournamentMainRound>(intRoundId);
                intRoundNumber = round.Number;

                bool blnEnableRows = (round.Number < intRoundCount ? false : true);

                blnEnableRows = true;  //Keeping them all enabled for now

                //Set using the ViewModel version.  This allows being able to manipulate back and forth across the class properties, while displaying as intended on the GUI
                //while also ensuring none of the goings ons of the properties touching each other don't occur without this specific view model (such as the SQL table updates)
                ObservableCollection <TournamentMainRoundTable_ViewModel> lstTables = new ObservableCollection <TournamentMainRoundTable_ViewModel>();
                foreach (TournamentMainRoundTable table in round.Tables)
                {
                    lstTables.Add(new TournamentMainRoundTable_ViewModel(table, blnEnableRows));
                }
                tournamentTableListView.ItemsSource = lstTables;

                if (!blnEnableRows)
                {
                    timerRoundBtn.IsVisible             = false;
                    tournamentTableListView.ItemTapped -= tournamentTableListView_ItemTapped;
                }
                else
                {
                    timerRoundBtn.IsVisible = true;

                    //If the round time started previously, keep it going
                    if (round.RoundTimeEnd > DateTime.Now)
                    {
                        dteRoundTimeEnd = round.RoundTimeEnd ?? DateTime.Now;
                        TimeSpan time = (round.RoundTimeEnd ?? DateTime.Now) - DateTime.Now;
                        App.MasterMainPage.RoundTimer(time, Convert.ToInt32(time.TotalSeconds), ref timerRoundBtn_VM);
                    }
                }
            }
        }
Beispiel #3
0
        private void roundTimer_Tick(object sender, System.Timers.ElapsedEventArgs e)
        {
            round_time--;

            if (tmpVM != null)
            {
                tmpVM.TimerValue = round_time.ToString();
            }

            if (round_time <= 0)
            {
                ROUND_TIMER.Stop();
                ROUND_TIMER.Enabled = false;
                ROUND_TIMER         = null;

                if (tmpVM != null)
                {
                    tmpVM.TimerValue = "0";
                    tmpVM            = null;
                }

                RoundOver();
            }
        }