-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathListGenerator.cs
98 lines (90 loc) · 3.37 KB
/
ListGenerator.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _4re5_manager
{
public class ListGenerator
{
private static int maxTextLength = 20;
private static string SetLabelText(string text)
{
if (text.Length > maxTextLength)
return text.Substring(0, maxTextLength) + "...";
else
return text;
}
public static void AddAppPanel(Control parent, int pos, string appName, string description, string platform, Image icon, EventHandler onDownloadClick, EventHandler onAppRowClick)
{
Panel panel = new Panel
{
Name = "panel_"+appName,
BackColor = Color.FromArgb(50, 50, 50), // Gris foncé
Size = new Size(parent.Width, 50),
Margin = new Padding(5),
Location = new Point(0, pos * 50),
};
// Label App Name
Label lblAppName = new Label
{
Name = "appName_"+appName,
Text = SetLabelText(appName),
ForeColor = Color.White,
Font = new Font("Arial", 10, FontStyle.Bold),
Location = new Point(40, 5),
AutoSize = true
};
// Label Description
Label lblDescription = new Label
{
Name = "appDesc_"+appName,
Text = SetLabelText(description),
ForeColor = Color.LightGray,
Font = new Font("Arial", 8),
Location = new Point(40, 25),
AutoSize = true
};
// Label Platform
Label lblPlatform = new Label // platform -> version
{
Name = "appPlatform_" + appName,
Text = SetLabelText(platform),
ForeColor = Color.White,
Font = new Font("Arial", 9),
Location = new Point((parent.Width/2)-40, 15),
AutoSize = true
};
// Platform Icon
PictureBox picPlatform = new PictureBox
{
Name = "appPic_" + appName,
Image = icon, // Remplace par une icône valide
Size = new Size(20, 20),
Location = new Point(15, 15),
SizeMode = PictureBoxSizeMode.Zoom
};
// Download Button
Button btnDownload = new Button
{
Name="downloadbtn_" + appName,
Text = "Download",
BackColor = Color.White,
ForeColor = Color.Black,
FlatStyle = FlatStyle.Flat,
Size = new Size(90, 30),
Location = new Point(parent.Width-110, 10)
};
btnDownload.Click += onDownloadClick;
panel.Click += onAppRowClick;
// Ajout des contrôles au panel
panel.Controls.Add(lblAppName);
panel.Controls.Add(lblDescription);
panel.Controls.Add(lblPlatform);
panel.Controls.Add(picPlatform);
panel.Controls.Add(btnDownload);
// Ajout du panel au parent
parent.Controls.Add(panel);
}
}
}