-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAboutBoxForm.cs
More file actions
167 lines (146 loc) · 5.96 KB
/
AboutBoxForm.cs
File metadata and controls
167 lines (146 loc) · 5.96 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;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using ClearCacheIcons.Helpers;
#pragma warning disable CS8600
namespace ClearCacheIcons
{
public sealed class AboutBoxForm : Form
{
public AboutBoxForm()
{
// ==========================================
// CONFIGURACIÓN GENERAL (DPI SAFE)
// ==========================================
Text = LocalizationManager.GetString("AboutBox_Title");
AutoScaleMode = AutoScaleMode.Dpi;
AutoScaleDimensions = new SizeF(96F, 96F); // Base DPI
ClientSize = new Size(404, 231); // Tamaño BASE (100%)
FormBorderStyle = FormBorderStyle.FixedDialog;
StartPosition = FormStartPosition.CenterParent;
MaximizeBox = false;
MinimizeBox = false;
ShowInTaskbar = false;
BackColor = Color.FromArgb(2, 48, 71);
CargarIconoFormulario();
// ==========================================
// LAYOUT PRINCIPAL
// ==========================================
var mainLayout = new TableLayoutPanel
{
Dock = DockStyle.Fill,
ColumnCount = 2,
RowCount = 2,
BackColor = Color.Transparent,
Padding = new Padding(6) // padding general DPI-friendly
};
mainLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 60F));
mainLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 40F));
mainLayout.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
mainLayout.RowStyles.Add(new RowStyle(SizeType.Absolute, 42F));
Controls.Add(mainLayout);
// ==========================================
// PANEL IZQUIERDO (INFO)
// ==========================================
var infoPanel = new Panel
{
Dock = DockStyle.Fill,
Padding = new Padding(18, 12, 10, 12),
BackColor = Color.Transparent
};
var infoPicture = new PictureBox
{
Dock = DockStyle.Fill,
SizeMode = PictureBoxSizeMode.Zoom,
BackColor = Color.Transparent,
Image = CargarImagenSegura("informacion.png")
};
infoPanel.Controls.Add(infoPicture);
mainLayout.Controls.Add(infoPanel, 0, 0);
// ==========================================
// PANEL DERECHO (ROBOT)
// ==========================================
var robotPicture = new PictureBox
{
Size = new Size(150, 150), // ⬅ aumento moderado
Anchor = AnchorStyles.None,
SizeMode = PictureBoxSizeMode.Zoom,
BackColor = Color.Transparent,
Margin = new Padding(6, 6, 8, 0), // pequeño ajuste para centrar visualmente
Image = CargarImagenSegura("robot.png")
};
mainLayout.Controls.Add(robotPicture, 1, 0);
// ==========================================
// BOTÓN CERRAR
// ==========================================
var btnCerrar = new Button
{
Text = LocalizationManager.GetString("AboutBox_CloseButton"),
Font = new Font("Segoe UI", 9.5f, FontStyle.Bold),
ForeColor = Color.White,
Size = new Size(96, 34),
FlatStyle = FlatStyle.Flat,
TabStop = false,
Anchor = AnchorStyles.None,
Margin = new Padding(0, 0, 0, 6)
};
btnCerrar.FlatAppearance.BorderSize = 0;
btnCerrar.FlatAppearance.MouseOverBackColor = Color.Transparent;
btnCerrar.FlatAppearance.MouseDownBackColor = Color.Transparent;
Image botonImg = CargarImagenSegura("boton.png");
if (botonImg != null)
{
btnCerrar.BackgroundImage =
ImageUtils.EscalarImagenAltaCalidad(
botonImg,
btnCerrar.Width,
btnCerrar.Height);
}
else
{
btnCerrar.BackColor = Color.FromArgb(0, 158, 166);
}
btnCerrar.MouseEnter += (_, _) => btnCerrar.ForeColor = Color.Gold;
btnCerrar.MouseLeave += (_, _) => btnCerrar.ForeColor = Color.White;
btnCerrar.Click += (_, _) => Close();
mainLayout.Controls.Add(btnCerrar, 0, 1);
mainLayout.SetColumnSpan(btnCerrar, 2);
}
// ==========================================
// MÉTODOS AUXILIARES
// ==========================================
private void CargarIconoFormulario()
{
try
{
var assembly = System.Reflection.Assembly.GetExecutingAssembly();
const string resourceName = "ClearCacheIcons.images.icon.ico";
using Stream? stream = assembly.GetManifestResourceStream(resourceName);
if (stream == null)
{
Logger.Log($"Embedded icon not found: {resourceName}", true);
return;
}
Icon = new Icon(stream);
}
catch (Exception ex)
{
Logger.Log($"Error loading AboutBox icon: {ex.Message}", true);
}
}
private static Image? CargarImagenSegura(string nombre)
{
try
{
var img = ImageUtils.CargarImagenDesdeRecurso(nombre);
return img != null ? (Image)img.Clone() : null;
}
catch (Exception ex)
{
Logger.Log($"Error loading image {nombre}: {ex.Message}", true);
return null;
}
}
}
}