using System.Drawing;
using System.Windows.Forms;
namespace GeoSigma.SigmaDrawerElement
{
///
/// 曲线渐变填充界面
///
public partial class GradientFillForm : Form
{
///
/// Initializes a new instance of the class.
///
public GradientFillForm()
{
InitializeComponent();
LeftColorComboBox.DrawItem += LeftColorComboBox_DrawItem;
RightColorComboBox.DrawItem += RightColorComboBox_DrawItem;
}
public string CurveName
{
get => CurveComoBox.Text;
set => CurveComoBox.Text = value;
}
public WellTrackGradientStyle GradientStyle
{
set
{
CurveComoBox.Text = value.CurveName;
LeftValueTextBox.Text = value.Left.ToString();
RightValueTextBox.Text = value.Right.ToString();
}
}
private void RightColorComboBox_DrawItem(object sender, DrawItemEventArgs e)
{
throw new System.NotImplementedException();
}
private void LeftColorComboBox_DrawItem(object sender, DrawItemEventArgs e)
{
throw new System.NotImplementedException();
}
private void DrawItem(object sender, DrawItemEventArgs e)
{
e.DrawBackground();
var comboBox = sender as ComboBox;
if (e.Index >= 0)
{
object item = comboBox.Items[e.Index];
if (item is Color color)
{
// 画颜色块
using (Brush brush = new SolidBrush(color))
{
e.Graphics.FillRectangle(brush, e.Bounds.Left + 2, e.Bounds.Top + 2, 20, e.Bounds.Height - 4);
e.Graphics.DrawRectangle(Pens.Black, e.Bounds.Left + 2, e.Bounds.Top + 2, 20, e.Bounds.Height - 4);
}
// 画颜色名字
e.Graphics.DrawString(color.Name, e.Font, Brushes.Black, e.Bounds.Left + 25, e.Bounds.Top + 2);
}
}
e.DrawFocusRectangle();
}
}
}