1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
4
using ICSharpCode.SharpDevelop.Gui.OptionPanels;
7
using System.Windows.Forms;
8
using ICSharpCode.Core;
9
using ICSharpCode.SharpDevelop.Gui;
11
namespace ICSharpCode.CodeCoverage
13
public class CodeCoverageOptionsPanel : XmlFormsOptionPanel
15
static readonly string foregroundCustomColourButtonName = "foregroundCustomColourButton";
16
static readonly string backgroundCustomColourButtonName = "backgroundCustomColourButton";
17
static readonly string foregroundColourComboBoxName = "foregroundColorPickerComboBox";
18
static readonly string backgroundColourComboBoxName = "backgroundColorPickerComboBox";
19
static readonly string displayItemsListBoxName = "displayItemsListBox";
20
static readonly string sampleTextLabelName = "sampleTextLabel";
22
ColorPickerComboBox foregroundColorPickerComboBox;
23
ColorPickerComboBox backgroundColorPickerComboBox;
24
ListBox displayItemsListBox;
25
Label sampleTextLabel;
27
public override void LoadPanelContents()
29
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("ICSharpCode.CodeCoverage.Resources.CodeCoverageOptionsPanel.xfrm"));
31
ControlDictionary[foregroundCustomColourButtonName].Click += ForegroundCustomColourButtonClick;
32
ControlDictionary[backgroundCustomColourButtonName].Click += BackgroundCustomColourButtonClick;
34
foregroundColorPickerComboBox = (ColorPickerComboBox)ControlDictionary[foregroundColourComboBoxName];
35
foregroundColorPickerComboBox.SelectedIndexChanged += ForegroundColorPickerComboBoxSelectedIndexChanged;
37
backgroundColorPickerComboBox = (ColorPickerComboBox)ControlDictionary[backgroundColourComboBoxName];
38
backgroundColorPickerComboBox.SelectedIndexChanged += BackgroundColorPickerComboBoxSelectedIndexChanged;
40
sampleTextLabel = (Label)ControlDictionary[sampleTextLabelName];
42
displayItemsListBox = (ListBox)ControlDictionary[displayItemsListBoxName];
43
displayItemsListBox.Items.Add(new CodeCoverageDisplayItem(StringParser.Parse("${res:ICSharpCode.CodeCoverage.CodeCovered}"), CodeCoverageOptions.VisitedColorProperty, CodeCoverageOptions.VisitedColor, CodeCoverageOptions.VisitedForeColorProperty, CodeCoverageOptions.VisitedForeColor));
44
displayItemsListBox.Items.Add(new CodeCoverageDisplayItem(StringParser.Parse("${res:ICSharpCode.CodeCoverage.CodeNotCovered}"), CodeCoverageOptions.NotVisitedColorProperty, CodeCoverageOptions.NotVisitedColor, CodeCoverageOptions.NotVisitedForeColorProperty, CodeCoverageOptions.NotVisitedForeColor));
45
displayItemsListBox.SelectedIndexChanged += DisplayItemsListBoxSelectedIndexChanged;
46
displayItemsListBox.SelectedIndex = 0;
49
public override bool StorePanelContents()
51
bool codeCoverageColorsChanged = false;
53
foreach (CodeCoverageDisplayItem item in displayItemsListBox.Items) {
54
CodeCoverageOptions.Properties.Set<Color>(item.ForeColorPropertyName, item.ForeColor);
55
CodeCoverageOptions.Properties.Set<Color>(item.BackColorPropertyName, item.BackColor);
56
if (item.HasChanged) {
57
codeCoverageColorsChanged = true;
61
if (codeCoverageColorsChanged) {
62
CodeCoverageService.RefreshCodeCoverageHighlights();
68
void ForegroundCustomColourButtonClick(object sender, EventArgs e)
70
SelectCustomColour(foregroundColorPickerComboBox);
73
void BackgroundCustomColourButtonClick(object sender, EventArgs e)
75
SelectCustomColour(backgroundColorPickerComboBox);
78
void SelectCustomColour(ColorPickerComboBox comboBox)
80
using (SharpDevelopColorDialog colorDialog = new SharpDevelopColorDialog()) {
81
colorDialog.FullOpen = true;
82
colorDialog.Color = comboBox.SelectedColor;
83
if (colorDialog.ShowDialog() == DialogResult.OK) {
84
comboBox.SelectedColor = colorDialog.Color;
89
void DisplayItemsListBoxSelectedIndexChanged(object sender, EventArgs e)
91
CodeCoverageDisplayItem item = (CodeCoverageDisplayItem)displayItemsListBox.SelectedItem;
92
sampleTextLabel.BackColor = item.BackColor;
93
sampleTextLabel.ForeColor = item.ForeColor;
94
foregroundColorPickerComboBox.SelectedColor = item.ForeColor;
95
backgroundColorPickerComboBox.SelectedColor = item.BackColor;
98
void ForegroundColorPickerComboBoxSelectedIndexChanged(object sender, EventArgs e)
100
CodeCoverageDisplayItem item = (CodeCoverageDisplayItem)displayItemsListBox.SelectedItem;
101
sampleTextLabel.ForeColor = foregroundColorPickerComboBox.SelectedColor;
102
item.ForeColor = foregroundColorPickerComboBox.SelectedColor;
105
void BackgroundColorPickerComboBoxSelectedIndexChanged(object sender, EventArgs e)
107
CodeCoverageDisplayItem item = (CodeCoverageDisplayItem)displayItemsListBox.SelectedItem;
108
sampleTextLabel.BackColor = backgroundColorPickerComboBox.SelectedColor;
109
item.BackColor = backgroundColorPickerComboBox.SelectedColor;