-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestForm.cs
115 lines (104 loc) · 4.38 KB
/
TestForm.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using FinancialCrm.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FinancialCrm
{
public partial class TestForm : Form
{
public TestForm()
{
InitializeComponent();
this.BackColor = Color.SaddleBrown;
LoadPanels();
}
private void LoadPanels()
{
using (var context = new FinancialCrmDbEntities())
{
var banks = context.Banks.ToList();
int panelHeight = 114;
int panelWidth = this.Width/3 - 9;
int padding = 3;
// TableLayoutPanel Ayarları
TableLayoutPanel layoutPanel = new TableLayoutPanel
{
Dock = DockStyle.Fill,
ColumnCount = banks.Count, /* Math.Min(banks.Count, 3), // Örnek: Her satırda en fazla 3 panel*/
RowCount = 1, // Tek satırda veya (int)Math.Ceiling((double)banks.Count / 3)
AutoScroll = true,
Padding = new Padding(padding),
};
foreach (var bank in banks)
{
// Panel oluşturma
Panel panel = new Panel
{
Size = new Size(panelWidth, panelHeight),
BackColor = Color.Moccasin,
Margin = new Padding(padding)
};
// Label 1 (BankTitle)
System.Windows.Forms.Label lblBankTitle = new System.Windows.Forms.Label
{
Text = bank.BankTitle,
Font = new Font("Calibri", 12, FontStyle.Bold),
ForeColor = Color.FromArgb(101, 67, 33),
Location = new Point(9, 9),
AutoSize = true
};
panel.Controls.Add(lblBankTitle);
// Label 2 (BankBalance)
System.Windows.Forms.Label lblBankBalance = new System.Windows.Forms.Label
{
Text = bank.BankBalance.ToString() + "₺",
Font = new Font("Calibri", 36, FontStyle.Bold),
ForeColor = Color.FromArgb(101, 67, 33),
Anchor = AnchorStyles.Bottom | AnchorStyles.Right,
Location = new Point(10, 40),
AutoSize = true
};
panel.Controls.Add(lblBankBalance);
// IconButton (BankAccountNumber)
FontAwesome.Sharp.IconButton bankNo = new FontAwesome.Sharp.IconButton
{
Text = bank.BankAccountNumber,
Location = new Point(8, 28),
Size = new Size(192, 20),
FlatStyle = FlatStyle.Flat,
Font = new Font("Calibri", 8),
ForeColor = Color.FromArgb(101, 67, 33),
IconColor = Color.FromArgb(101, 67, 33),
IconChar = FontAwesome.Sharp.IconChar.Copy,
IconFont = FontAwesome.Sharp.IconFont.Solid,
IconSize = 16,
ImageAlign = ContentAlignment.MiddleRight,
TextAlign = ContentAlignment.MiddleLeft,
UseVisualStyleBackColor = false
};
bankNo.FlatAppearance.BorderSize = 0;
panel.Controls.Add(bankNo);
// Paneli TableLayoutPanel'e ekle
layoutPanel.Controls.Add(panel);
SetLocationBalanceLabels(lblBankBalance,panel);
}
// TableLayoutPanel'i forma ekle
this.Controls.Add(layoutPanel);
}
}
private void SetLocationBalanceLabels(System.Windows.Forms.Label label, Panel panel)
{
int width, height;
width = panel.Width - (label.Width + 3);
height = panel.Height - (label.Height + 6);
label.Location = new Point(width, height);
}
}
}