using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace TdoCodeGenerator.TdoControls{
public partial class SelectorControl : UserControl
{
private string fToolTip;
private bool pSelected;
[Localizable(true), Bindable(true), Description("Selector Control Click"), Browsable(true)]
public new event MouseEventHandler MouseClick;
public SelectorControl()
{
InitializeComponent();
this.fToolTip = string.Empty;
this.pSelected = false;
}
[Category("Appearance"), Localizable(true), Bindable(true), Description("Selector Text"), Browsable(true)]
public override string Text
{
get
{
return this.label1.Text;
}
set
{
this.label1.Text = value;
}
}
[Category("Appearance"), Localizable(true), Bindable(true), Description("ToolTip Text"), Browsable(true)]
public string ToolTip
{
get
{
return this.fToolTip;
}
set
{
this.fToolTip = value;
this.toolTip1.SetToolTip(this.pictureBox1, this.fToolTip);
this.toolTip1.SetToolTip(this.label1, this.fToolTip);
this.toolTip1.SetToolTip(this, this.fToolTip);
}
}
[Category("Appearance"), Localizable(true), Bindable(true), Description("Selector Font"), Browsable(true)]
public override Font Font
{
get
{
return this.label1.Font;
}
set
{
this.label1.Font = value;
}
}
[Category("Appearance"), Localizable(true), Bindable(true), Description("Selector Image"), Browsable(true)]
public Image Image
{
get
{
return this.pictureBox1.Image;
}
set
{
this.pictureBox1.Image = value;
}
}
[Category("Appearance"), Localizable(true), Bindable(true), Description("Selected or not"), Browsable(true)]
public bool Selected
{
get
{
return this.pSelected;
}
set
{
this.pSelected = value;
this.PaintLeave();
}
}
private void PaintOver()
{
if (this.Selected)
{
this.BackColor = Color.FromArgb(192, 192, 255);
this.label1.Font = new Font(this.label1.Font, FontStyle.Bold);
}
else
{
this.BackColor = Color.FromArgb(192, 255, 192);
this.label1.Font = new Font(this.label1.Font, FontStyle.Bold);
}
}
private void PaintLeave()
{
if (this.Selected)
{
this.BackColor = Color.FromArgb(192, 192, 255);
this.label1.Font = new Font(this.label1.Font, FontStyle.Regular);
}
else
{
this.BackColor = Color.FromArgb(255, 255, 192);
this.label1.Font = new Font(this.label1.Font, FontStyle.Regular);
}
}
private void SelectorControl_MouseEnter(object sender, EventArgs e)
{
this.PaintOver();
}
private void SelectorControl_MouseLeave(object sender, EventArgs e)
{
this.PaintLeave();
}
private void SelectorControl_Click(object sender, EventArgs e)
{
}
private void label1_MouseClick(object sender, MouseEventArgs e)
{
if (this.MouseClick != null)
this.MouseClick(sender, e);
}
}
}
|