private void WorkPanel_MouseDown(object sender, EventArgs e) { CurrentTarget = sender as PanelElement; PrevTarget.Target = false; CurrentTarget.Target = true; CurrentTarget.Refresh(); PrevTarget.Refresh(); PrevTarget = CurrentTarget; }
public void CreateWorkPanels(int count, List <Color> colors) { int width = group_WorkPanels.Width / count; int height = group_WorkPanels.Height - 10; int X = 0; int Y = 10; int stepX = width; RoundedLabel.CornerToRound cornerToRound; cornerToRound = RoundedLabel.CornerToRound.All; for (int i = 0; i < count; i++) { if (i == 0) { cornerToRound = RoundedLabel.CornerToRound.BothLeft; } else if (i == count - 1) { cornerToRound = RoundedLabel.CornerToRound.BothRight; } else { cornerToRound = RoundedLabel.CornerToRound.None; } var label = new PanelElement() { cornerToRound = cornerToRound, Anchor = (AnchorStyles.Bottom), Tag = "Work", AutoSize = false, Enabled = true, Location = new Point(X, Y), Size = new Size(width, height), BackColor = colors[i], }; label.WheelChair(4); group_WorkPanels.Controls.Add(label); label.MouseDown += MainForm_MouseDown; label.MouseDown += WorkPanel_MouseDown; PrevTarget = CurrentTarget = label; X += stepX; } }