-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser_RepoProp.cs
More file actions
105 lines (84 loc) · 2.9 KB
/
Copy pathUser_RepoProp.cs
File metadata and controls
105 lines (84 loc) · 2.9 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace git_hub_app
{
public partial class User_RepoProp : Form
{
public User_RepoProp()
{
InitializeComponent();
labelTitle.Text = "Repository Details";
}
public void ShowFileCards(List<(string Name, string Type, string Updated)> files)
{
flowPanelFiles.Controls.Clear();
foreach (var file in files)
{
var card = CreateFileCard(file.Name, file.Type, file.Updated);
flowPanelFiles.Controls.Add(card);
}
}
private Panel CreateFileCard(string name, string type, string updated)
{
Panel card = new Panel
{
Width = 350,
Height = 60,
BackColor = Color.WhiteSmoke,
BorderStyle = BorderStyle.FixedSingle,
Margin = new Padding(8),
Cursor = Cursors.Hand
};
PictureBox icon = new PictureBox
{
Width = 28,
Height = 28,
Location = new Point(10, 15),
SizeMode = PictureBoxSizeMode.StretchImage,
// Image = type == "dir"
//? Image.FromFile(Path.Combine(Application.StartupPath, "Media", "folder.ico"))
//: Image.FromFile(Path.Combine(Application.StartupPath, "Media", "documents.ico"))
};
Label lblName = new Label
{
Text = name,
Font = new Font("Segoe UI", 10, FontStyle.Bold),
Location = new Point(50, 8),
AutoSize = true
};
Label lblUpdated = new Label
{
Text = updated,
Font = new Font("Segoe UI", 8, FontStyle.Italic),
ForeColor = Color.DimGray,
Location = new Point(50, 30),
AutoSize = true
};
card.Controls.Add(icon);
card.Controls.Add(lblName);
card.Controls.Add(lblUpdated);
card.MouseEnter += (s, e) => card.BackColor = Color.Gainsboro;
card.MouseLeave += (s, e) => card.BackColor = Color.WhiteSmoke;
// Optional: Card click to open or preview file
card.Click += (s, e) =>
{
MessageBox.Show($"You clicked {name}", "File", MessageBoxButtons.OK, MessageBoxIcon.Information);
};
return card;
}
private void BtnExit_Click(object sender, EventArgs e)
{
this.Close();
flowPanelFiles.Controls.Clear();
labelTitle.Text = "Repository Details";
}
}
}