public static RecordDatabase getInstance()
 {
     if (instance == null)
     {
         instance = XmlDatabaser.loadDatabase <RecordDatabase>(DatabaseName);
     }
     return(instance);
 }
Exemple #2
0
        public RecordDisplayPanel()
        {
            InitializeComponent();

            //Only display races in use
            pages = new List <TrackRecordList>();
            icons = new List <BitmapImage>();

            AntPlusRacerConfig cfg = AntPlusRacerConfig.getInstance();
            RecordDatabase     db  = RecordDatabase.getInstance();

            if (cfg.enabledRaceTracks.Count == 0)
            {
                Viewbox vb = new Viewbox();
                vb.Child = new Label()
                {
                    Content = "No races selected for use. Exit and add races to 'UsingRaceTracks' in " + AntPlusRacerConfig.DatabaseName + ".db.xml"
                };
                this.Content = vb;
                return;
            }

            //Get all tracks with records
            foreach (AntPlusRacerConfig.RaceTrack i in cfg.enabledRaceTracks)
            {
                TrackRecordList recordList = db.getTrackRecordList(i.sportType, i.distance);
                if (recordList.trackRecords.Count > 0)
                {
                    pages.Add(recordList);
                }
            }

            if (pages.Count == 0)
            {
                Viewbox vb = new Viewbox();
                vb.Child = new Label()
                {
                    Content = "No records exist in database. After you complete races and save some records, then reload this page to view records."
                };
                this.Content = vb;
                return;
            }

            foreach (TrackRecordList i in pages)
            {
                icons.Add(RacerInfoPanel.getRaceDisplayBitmap(i.sportType));
            }

            pageNum = -1;
            nextPage();

            if (pages.Count > 1)
            {
                pageCycleTimer.Elapsed += new System.Timers.ElapsedEventHandler(pageCycleTimer_Elapsed);
                pageCycleTimer.Start();
            }
        }
        public static int saveRacerRecord(TrackRecordList list, RecordData racer)
        {
            int ret = list.addRecord(racer);

            RecordDatabase db        = RecordDatabase.getInstance();
            String         saveError = XmlDatabaser.saveDatabase(RecordDatabase.DatabaseName, db);

            if (saveError != null) //Save succeeded
            {
                MessageBox.Show(saveError, "Ant+ Racer Database Error");
            }

            return(ret);
        }
        public PostRacePanel(Action <TrackRecordList, int> finishedDisplay, RacerDetails racerDetails)
        {
            InitializeComponent();
            finished   = finishedDisplay;
            racer      = racerDetails;
            recordList = RecordDatabase.getInstance().getTrackRecordList(racer.dataSource.getSportType(), racer.targetValue);
            finished   = finishedDisplay;

            Label_RacerTag.Content = racer.dataSource.getSourceName() + " - " + racer.finishResult.ToString("0.0");

            int i;

            for (i = 0; i < recordList.trackRecords.Count; ++i)
            {
                if (recordList.trackRecords[i].recordValue > racer.finishResult)
                {
                    break;
                }
            }
            Label_ListResultTag.Content = "You placed " + (i + 1) + " out of " + (recordList.trackRecords.Count + 1) + " on the leaderboard";
        }