예제 #1
0
        public static List <Record> GetAllRecords()
        {
            var numOfFiles = new DirectoryInfo(_path).GetFiles().Length;

            for (int i = 1; i <= numOfFiles; i++)
            {
                _fileIoService = new FIleIOService(_path + $"\\day{i}.json");

                try
                {
                    _recordsList = _fileIoService.LoadData();
                    _allRecordsList.AddRange(_recordsList);
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }
            }
            return(_allRecordsList);
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            _fileIoService = new FIleIOService(_path);

            try
            {
                _recordsList = _fileIoService.LoadData();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
                Close();
            }

            if (_recordsList != null)
            {
                dgRecords.ItemsSource = from record in _recordsList
                                        orderby record.Moves, record.TimeTotalMilliseconds, record.Name
                select record;
            }
        }
예제 #3
0
        private void ExportXml()
        {
            if (SelectedDataItem != null)
            {
                _fileIoService = new FIleIOService($"{Environment.CurrentDirectory}\\{SelectedDataItem.UserName}.xml");

                try
                {
                    _fileIoService.ExportDataXml(SelectedDataItem);
                    MessageBox.Show("Экспорт в XML завершен!");
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }
            }
            else
            {
                MessageBox.Show("Не выбран пользователь!");
            }
        }
예제 #4
0
 private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
 {
     mIoService          = new FIleIOService("jsondata.json");
     mArticles           = mIoService.LoadData();
     dgStore.ItemsSource = mArticles;
 }
예제 #5
0
        private void b_Click(object sender, RoutedEventArgs e)
        {
            if (_game.IsSolved())
            {
                return;
            }

            Button button = (Button)sender;

            int x = int.Parse(button.Name.Substring(1, 1));
            int y = int.Parse(button.Name.Substring(2, 1));

            _game.CLickAt(x, y);
            ShowButtons();
            ColoredGameButtons();

            if (_firstClick)
            {
                _stopwatch.Start();
                _timer.Start();

                _firstClick = false;

                ButtonPause.IsEnabled = true;
                ButtonPause.Content   = "𝅛𝅛 Pause";
            }

            if (_game.IsSolved())
            {
                if (_stopwatch.IsRunning)
                {
                    _stopwatch.Stop();
                    _firstClick = true;
                }

                _gameStart = false;

                LabelMoves.Content    = $"You win, {_game.Moves} moves!";
                ButtonStart.IsEnabled = false;
                EnabledGameButtons(false);

                ButtonPause.IsEnabled = false;
                ButtonPause.Content   = "CONGRATULATIONS!";


                NameWindow nw = new NameWindow();
                nw.Owner = this;

                if (nw.ShowDialog() == true)
                {
                    _fileIoService = new FIleIOService(_path);

                    try
                    {
                        _record = _fileIoService.LoadData();
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(exception.Message);
                        Close();
                    }

                    _record.Add(new Records((nw.UserName).TrimStart(), _game.Moves, _currentTime, (_stopwatch.Elapsed).TotalMilliseconds));

                    try
                    {
                        _fileIoService.SaveData(_record);
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(exception.Message);
                        Close();
                    }

                    if (!IsWindowOpen <WindowRecords>())
                    {
                        WindowRecords records = new WindowRecords();
                        records.Owner = this;
                        records.Show();
                    }

                    //UI
                    ButtonRecords.Visibility = Visibility.Visible;
                    Grid.SetColumnSpan(ButtonRecords, 2);
                    Grid.SetColumn(ButtonRecords, 2);

                    Grid.SetColumnSpan(ButtonShuffle, 2);
                }
            }
        }