private void prgmInit() { updateUI += new CommCallback(updateCommUI); commandsInit(); CmdList = CmdList.OrderBy(a => a.Text).ToList(); // fill tableLayoutPanel foreach (CmdButton cmd in CmdList) { cmd.Anchor = AnchorStyles.Top; cmd.Width = 180; cmd.Height = 30; toolTip.SetToolTip(cmd, cmd.toolTip); flowCmdList.Controls.Add(cmd); } flowCmdListCheckForScrolling(); clearDetails(); // initialize the Comm panel for (int i = 0; i < arrowArray.Length; i++) { arrowArray[i] = new PictureBox(); arrowArray[i].Height = 64; arrowArray[i].SizeMode = PictureBoxSizeMode.Zoom; arrowArray[i].Dock = DockStyle.Top; flowCommStatus.Controls.Add(arrowArray[i]); } }
/// <summary> /// Sort all buttons from a to z or reversed. /// </summary> private void btnSort_Click(object sender, EventArgs e) { sortAlphabetic = !sortAlphabetic; Image newImage; if (sortAlphabetic == true) { CmdList = CmdList.OrderBy(a => a.Text).ToList(); newImage = Properties.Resources.sort_az; } else { CmdList = CmdList.OrderByDescending(a => a.Text).ToList(); newImage = Properties.Resources.sort_za; } flowCmdList.Controls.Clear(); // refill flowLayoutPanel foreach (CmdButton c in CmdList) { flowCmdList.Controls.Add(c); } Button b = sender as Button; b.BackgroundImage = newImage; }