-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHome.cs
More file actions
169 lines (146 loc) · 5.23 KB
/
Home.cs
File metadata and controls
169 lines (146 loc) · 5.23 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
using System.Reflection;
using System.Drawing.Drawing2D;
namespace Panopticon;
public partial class Home : Form
{
public Home()
{
this.ClientSize = new System.Drawing.Size(800, 800);
this.Text = "Dominion: Panopticon";
// Load App icon
string basePath = AppDomain.CurrentDomain.BaseDirectory;
string icon_path = Path.Combine(basePath, "Assets", "app.ico");
Icon = new Icon(icon_path);
InitializeFeatures();
InitializeAboutSection();
InitializeBackground();
}
private void InitializeFeatures()
{
// Global styling
Padding padding = new(2);
const int height = 30;
Button NewTimeLineButton = new()
{
Dock = DockStyle.Top,
Height = height,
Text = "New Timeline",
BackColor = Color.LightGreen,
Padding = padding,
TabIndex = 1
};
Button LoadTimeLineButton = new()
{
Dock = DockStyle.Top,
Height = height,
Text = "Load Timeline",
BackColor = Color.LightSteelBlue,
Padding = padding,
TabIndex = 2
};
Button BattleLogAnalyzer = new()
{
Dock = DockStyle.Top,
Height = height,
Text = "Battle Log Analyzer (Under development)",
BackColor = Color.Plum,
Padding = padding,
TabIndex = 3
};
Controls.Add(BattleLogAnalyzer);
Controls.Add(LoadTimeLineButton);
Controls.Add(NewTimeLineButton);
NewTimeLineButton.Click += new EventHandler(this.NewTimeLine_Click);
LoadTimeLineButton.Click += new EventHandler(this.LoadTimeLine_Click);
}
private void NewTimeLine_Click(object? sender, EventArgs e)
{
var NewTimeLine = new NewTimeline
{
Location = this.Location,
StartPosition = FormStartPosition.CenterScreen
};
NewTimeLine.FormClosing += delegate { this.Show(); };
NewTimeLine.Show();
this.Hide();
}
private void LoadTimeLine_Click(object? sender, EventArgs e)
{
var LoadTimeLine = new LoadTimeline
{
Location = this.Location,
StartPosition = FormStartPosition.CenterScreen
};
LoadTimeLine.FormClosing += delegate { this.Show(); };
LoadTimeLine.Show();
this.Hide();
}
private void InitializeAboutSection()
{
// Get informationalVersion from the current build
// Strip git commit (e.g., +b5fa5fe4...) via Split
var informationalVersion = Assembly.GetExecutingAssembly()
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion.Split('+')[0]
?? "Unknown";
Label About = new()
{
Dock = DockStyle.Bottom,
Text = $"Coded by globz - https://github.com/globz - v{informationalVersion}",
TextAlign = ContentAlignment.MiddleCenter,
ForeColor = Game.UI.ForeColor,
Height = 50
};
Controls.Add(About);
}
private Image? LoadBackgroundImage()
{
try
{
// Use the executable's directory as the base path
string basePath = AppDomain.CurrentDomain.BaseDirectory;
string imagePath = Path.Combine(basePath, "Assets", "background.png");
// Check if the file exists
if (!File.Exists(imagePath))
{
MessageBox.Show($"Image not found: {imagePath}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
// Load the image
return Image.FromFile(imagePath);
}
catch (Exception ex)
{
MessageBox.Show($"Failed to load image: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
}
private void InitializeBackground()
{
Image? bg_source = LoadBackgroundImage();
BackColor = Game.UI.Theme;
if (bg_source != null)
{
Image bg = RoundCorners(bg_source, 250, Game.UI.Theme);
BackgroundImage = bg;
BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
}
}
private static Bitmap RoundCorners(Image StartImage, int CornerRadius, Color BackgroundColor)
{
CornerRadius *= 2;
Bitmap RoundedImage = new Bitmap(StartImage.Width, StartImage.Height);
using (Graphics g = Graphics.FromImage(RoundedImage))
{
g.Clear(BackgroundColor);
g.SmoothingMode = SmoothingMode.AntiAlias;
Brush brush = new TextureBrush(StartImage);
GraphicsPath gp = new GraphicsPath();
gp.AddArc(0, 0, CornerRadius, CornerRadius, 180, 90);
gp.AddArc(0 + RoundedImage.Width - CornerRadius, 0, CornerRadius, CornerRadius, 270, 90);
gp.AddArc(0 + RoundedImage.Width - CornerRadius, 0 + RoundedImage.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
gp.AddArc(0, 0 + RoundedImage.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
g.FillPath(brush, gp);
return RoundedImage;
}
}
}