Example #1
0
        public RecordsPage()
        {
            InitializeComponent();

            _recordsListView.ItemsSource = RecordsDatabase.GetInstance().GetRecords().Result;

            _recordsListView.ItemTemplate = new DataTemplate(typeof(RecordCell));

            _recordsListView.ItemTapped += RecordSelected;

            _recordsListView.RowHeight = 50;
        }
Example #2
0
        public App()
        {
            InitializeComponent();

            RecordsDatabase.GetInstance();

            NavigationPage navigation = new NavigationPage();

            navigation.PushAsync(new MainPage(), true);
            NavigationPage.SetHasNavigationBar(navigation, false);
            MainPage = navigation;
        }
Example #3
0
        private async void RecordSelected(object sender, ItemTappedEventArgs e)
        {
            Record record = e.Item as Record;

            bool willDeleteRecord = await DisplayAlert(record.ToString(), "Do you want to delete this record ?", "Yes", "No");

            if (willDeleteRecord)
            {
                await RecordsDatabase.GetInstance().DeleteRecord(record);

                _recordsListView.ItemsSource = RecordsDatabase.GetInstance().GetRecords().Result;
            }
        }
Example #4
0
        public void Stop(object sender, Minesweeper.GameOverArgs e)
        {
            if (e.IsVictory)
            {
                Record record = new Record
                {
                    Time       = Timer.Timer,
                    MinesCount = Settings.GetSettings().CountMines,
                    AreaSize   = Settings.GetSettings().AreaSize.ToString() + "x" + (Settings.GetSettings().AreaSize / 2).ToString(),
                    Date       = DateTime.Now
                };

                RecordsDatabase.GetInstance().SaveRecord(record);

                AudioPlayer.Load(AudioPlayer.Sounds.Victory);
                AudioPlayer.Play();
            }
            else
            {
                if (Settings.GetSettings().CountMines / Minesweeper.MinesLeft > 10 && Settings.GetSettings().CountMines > 50)
                {
                    AudioPlayer.Load(AudioPlayer.Sounds.SpecialLose);
                }
                else
                {
                    AudioPlayer.Load(AudioPlayer.Sounds.Lose);
                }

                AudioPlayer.Play();
            }

            Pause();

            HasGameStarted = false;

            DisplayGameNotification(e.IsVictory, e.WrongMines);
        }