-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHistory.cs
More file actions
74 lines (63 loc) · 2.32 KB
/
History.cs
File metadata and controls
74 lines (63 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Text.Json;
namespace Arc
{
public partial class History : Form
{
private readonly string historyFilePath = "history.json";
public History()
{
InitializeComponent();
}
private void History_Load(object sender, EventArgs e)
{
// Check if the history file exists
if (File.Exists(historyFilePath))
{
// Read the file and convert it back into a List of MatchRecords
string json = File.ReadAllText(historyFilePath);
List<MatchRecord> matchHistory = JsonSerializer.Deserialize<List<MatchRecord>>(json) ?? new List<MatchRecord>();
historyGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
// //binding the List of MatchRecords to the DataGridView
historyGridView.DataSource = matchHistory;
if (historyGridView.Columns["AggroScore"] != null)
{
historyGridView.Columns["AggroScore"].DefaultCellStyle.Format = "F2";
}
if (historyGridView.Columns["ScoreDifference"] != null)
{
historyGridView.Columns["ScoreDifference"].DefaultCellStyle.Format = "F2";
}
if (historyGridView.Columns["DmgDealt"] != null)
{
historyGridView.Columns["DmgDealt"].DefaultCellStyle.Format = "F2";
}
if (historyGridView.Columns["DmgReceived"] != null)
{
historyGridView.Columns["DmgReceived"].DefaultCellStyle.Format = "F2";
}
}
}
// Navigation Logic
private void MainWindow_Click(object sender, EventArgs e)
{
this.Close(); // Closes History, unhiding Main
}
private void SettingWindow_Click(object sender, EventArgs e)
{
Settings settingsPage = new Settings();
this.Hide();
settingsPage.ShowDialog();
this.Show();
}
}
}