private void DisplayAccounts() { if (_mLoadAccounts != null) { clsLoadAccount newact = new clsLoadAccount(); newact.LoadType = LoadAccountType.New; newact.Description = "Add/Edit Account"; newact.LoadId = -1; FileStream fs; BinaryReader br; fs = new FileStream(Application.StartupPath + "\\images\\addLoadAccount.png", FileMode.Open, FileAccess.Read); br = new BinaryReader(fs); newact.ImgFile = br.ReadBytes((int)fs.Length); br.Close(); fs.Close(); _mLoadAccounts.Add(newact); int margin = 10; int left = 5, top = margin, ctr = 1; foreach (clsLoadAccount a in _mLoadAccounts) { ctrlLoadAccount btn = CreateButton(a); btn.Left = left; btn.Top = top; btn.Width = Properties.Settings.Default.LoadBtnSize; btn.Height = Properties.Settings.Default.LoadBtnSize; pnlLoadAccount.Controls.Add(btn); if (ctr >= Properties.Settings.Default.MaxLoadBtnCnt) { left = 5; top += Properties.Settings.Default.LoadBtnSize + margin; ctr = 0; } else { left += Properties.Settings.Default.LoadBtnSize + margin; } ctr++; } pnlLoadAccount.Width = ((Properties.Settings.Default.LoadBtnSize + margin) * Properties.Settings.Default.MaxLoadBtnCnt) + margin; if (pnlLoadAccount.VerticalScroll.Visible) { pnlLoadAccount.Width += 20; } //this.Height = ((Properties.Settings.Default.LoadBtnSize + margin) * (_mLoadAccounts.Count / Properties.Settings.Default.MaxLoadBtnCnt+ 1)) + margin;// top + (int)(Properties.Settings.Default.LoadBtnSize * 1.25); //this.Top = 0; //this.Left = 0; //this.Left = (SystemInformation.VirtualScreen.Width - this.Width) / 2; //this.Top = (SystemInformation.VirtualScreen.Height - this.Height) / 2; } }
private ctrlLoadAccount CreateButton(clsLoadAccount a) { ctrlLoadAccount btn = new ctrlLoadAccount(); btn.Name = "btn" + a.MobileNum; btn.Description = a.Description; btn.LoadType = a.LoadType; btn.LoadId = a.LoadId; //btn.Picture = if (a.ImgFile != null) { MemoryStream mem = new MemoryStream(a.ImgFile); btn.Picture = Image.FromStream(mem); mem.Close(); } else { btn.Picture = null; } btn.OnClick += new ctrlLoadAccount.OnClickHandler(LoadAccount_Click); return(btn); }