private void SetLabel()
{
XCore.ChoiceRelatedClass choice = (XCore.ChoiceRelatedClass) this.Tag;
UIItemDisplayProperties display = choice.GetDisplayProperties();
string s = display.Text.Replace("_", "&");
Graphics g = this.CreateGraphics();
this.Width = (int)(g.MeasureString(s, this.Font).Width);
this.Text = s;
this.Style.Alignment = System.Drawing.StringAlignment.Center;
if(display.Checked)
{
this.Style.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemCheckedBackground;
this.Style.BackColor2.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemCheckedBackground2;
this.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemCheckedText;
}
else
{
this.Style.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground;
this.Style.BackColor2.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2;
this.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText;
}
// Simulate a mouse enter or leave event to get the correct highlighting
if(mouseOverControl)
this.panelButton_MouseEnter(null, null);
else
this.panelButton_MouseLeave(null, null);
this.Controls.Clear(); // Clear out any previous checkboxes and images
// Add in a checkbox that reflects the "checked" status of the button
CheckBox checkBox = new CheckBox();
checkBox.Checked = display.Checked;
checkBox.Click +=new EventHandler(PanelButton_Click);
checkBox.Location = new Point(0,0);
checkBox.Anchor = System.Windows.Forms.AnchorStyles.Left;
checkBox.Dock = System.Windows.Forms.DockStyle.None;
checkBox.Width = 17;
this.Width += checkBox.Width;
checkBox.MouseEnter += new EventHandler(panelButton_MouseEnter);
checkBox.MouseLeave += new EventHandler(panelButton_MouseLeave);
checkBox.MouseDown += new MouseEventHandler(panelButton_MouseDown);
this.Controls.Add(checkBox);
this.Style.Alignment = System.Drawing.StringAlignment.Far;
if(display.ImageLabel != null && display.ImageLabel !="" && display.ImageLabel !="default")
{
PanelEx p = new PanelEx();
Image i = m_images.GetImage(display.ImageLabel);
p.Style.BackgroundImage = i;
p.Style.BackgroundImagePosition = eBackgroundImagePosition.Center;
p.Location = new Point(checkBox.Width,0);
p.Anchor = System.Windows.Forms.AnchorStyles.Left;
p.Dock = System.Windows.Forms.DockStyle.None;
p.Size = new Size(17,this.Height);
this.Width += p.Size.Width;
this.Controls.Add(p);
p.Click +=new EventHandler(PanelButton_Click);
p.MouseEnter += new EventHandler(panelButton_MouseEnter);
p.MouseLeave += new EventHandler(panelButton_MouseLeave);
p.MouseDown += new MouseEventHandler(panelButton_MouseDown);
}
this.Refresh();
}