private void addBtn_Click(object sender, EventArgs e) { if (accounts == null) { accounts = new List <Account>(); } string[] data = { "Web Site", "Login", "Password" }; if (Forms.InputBox("Create new account", "Enter your data", ref data) == DialogResult.OK) { accounts.Add(new Account(data[0], data[1], data[2])); ValidSystem.ClearFilter(accounts, filterAccounts); Forms.Fill(listFlp, accounts, filterAccounts); } }
public static Panel FormUnit(FlowLayoutPanel listFlp, string[] data, List <Account> accounts, List <Account> filterAccounts, int num) { Panel panel = new Panel(); Label webSitelbl = new Label(); Label loginlbl = new Label(); Label passwordLbl = new Label(); Button change = new Button(); Button remove = new Button(); panel.BorderStyle = BorderStyle.FixedSingle; change.FlatStyle = FlatStyle.Flat; change.FlatAppearance.BorderColor = Color.Black; change.FlatAppearance.BorderSize = 1; remove.FlatStyle = FlatStyle.Flat; remove.FlatAppearance.BorderColor = Color.Black; remove.FlatAppearance.BorderSize = 1; webSitelbl.Text = "Web Site " + data[0]; loginlbl.Text = "Login " + data[1]; passwordLbl.Text = "Password "; foreach (var c in data[2]) { passwordLbl.Text += '*'; } change.Text = "Change"; remove.Text = "Delete"; panel.SetBounds(0, 0, listFlp.Width - 10, 86); webSitelbl.SetBounds(21, 12, panel.Width - 101 - 25, 14); loginlbl.SetBounds(21, 37, panel.Width - 101 - 25, 14); passwordLbl.SetBounds(21, 64, panel.Width - 101 - 25, 14); change.SetBounds(panel.Width - 101, 12, 76, 23); remove.SetBounds(panel.Width - 101, 55, 76, 23); panel.Anchor = AnchorStyles.Left | AnchorStyles.Top; webSitelbl.Anchor = AnchorStyles.Left | AnchorStyles.Top; loginlbl.Anchor = AnchorStyles.Left | AnchorStyles.Top; passwordLbl.Anchor = AnchorStyles.Left | AnchorStyles.Top; change.Anchor = AnchorStyles.Right | AnchorStyles.Top; remove.Anchor = AnchorStyles.Right | AnchorStyles.Top; webSitelbl.Click += delegate { ShowToolTipWhenClick(accounts[num].WebSite, webSitelbl); }; loginlbl.Click += delegate { ShowToolTipWhenClick(accounts[num].Login, loginlbl); }; passwordLbl.Click += delegate { ShowToolTipWhenClick(accounts[num].Password, passwordLbl); }; change.Click += delegate { string[] data1 = { "Web Site", "Login", "Password" }; if (Forms.InputBox("Change data of account", "Enter your data (you can fill in not everything)", ref data1) == DialogResult.OK) { accounts[num].WebSite = data1[0] == "" || data1[0] == "Web Site" ? accounts[num].WebSite : data1[0]; accounts[num].Login = data1[1] == "" || data1[1] == "Login" ? accounts[num].Login : data1[1]; string newPass = ""; if (data1[2] != "" && data1[2] != "Password") { accounts[num].Password = data1[2]; foreach (var c in data1[2]) { newPass += '*'; } passwordLbl.Text = newPass; } ValidSystem.ClearFilter(accounts, filterAccounts); Fill(listFlp, accounts, filterAccounts); } }; remove.Click += delegate { if (MessageBox.Show("Are you sure you want to Delete", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { accounts.RemoveAt(num); ValidSystem.ClearFilter(accounts, filterAccounts); Fill(listFlp, accounts, filterAccounts); } }; panel.Controls.AddRange(new Control[] { webSitelbl, loginlbl, passwordLbl, change, remove }); return(panel); }