private void SettingsMenu_DropDownOpening(object sender, EventArgs e) { SettingsMenu.DropDownItems.Clear(); Array states = Enum.GetValues(typeof(PlotPointState)); foreach (PlotPointState state in states) { ToolStripMenuItem tsmi = SettingsMenu.DropDownItems.Add(state.ToString()) as ToolStripMenuItem; tsmi.Tag = state; tsmi.Checked = (fPoint.State == state); tsmi.Click += new EventHandler(select_state); } SettingsMenu.DropDownItems.Add(new ToolStripSeparator()); Array colours = Enum.GetValues(typeof(PlotPointColour)); foreach (PlotPointColour colour in colours) { string text = colour.ToString(); if (colour == PlotPointColour.Yellow) { text += " (default)"; } Bitmap img = new Bitmap(16, 16); Rectangle img_rect = new Rectangle(0, 0, 16, 16); Pair <Color, Color> gradient = PlotView.GetColourGradient(colour, 255); Graphics g = Graphics.FromImage(img); g.FillRectangle(new LinearGradientBrush(img_rect, gradient.First, gradient.Second, LinearGradientMode.Vertical), img_rect); ToolStripMenuItem tsmi = SettingsMenu.DropDownItems.Add(text) as ToolStripMenuItem; tsmi.Image = img; tsmi.Tag = colour; tsmi.Checked = (fPoint.Colour == colour); tsmi.Click += new EventHandler(select_colour); } }