You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
4.5 KiB
C#

1 month ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using GeoSigma.SigmaDrawerElement;
namespace GeoSigma.SigmaDrawerStyle
{
public partial class FillCurveGradientFrm : Form
{
public WellTrackGradientStyle thisStyle ;
public System.Drawing.Color leftColor = new Color();
public System.Drawing.Color rightColor = new Color();
public System.Drawing.Color midColor = new Color();
public bool bAutoMidClr = false;
public String fillCurveName = "";
public double leftValue = 0;
public double rightValue = 100;
public List<string> curvesName = new List<string>();
public FillCurveGradientFrm(WellTrackGradientStyle style, List<string> tcurvesNames)
{
InitializeComponent();
fillCurveName = style.CurveName;
leftValue = style.Left;
rightValue = style.Right;
bAutoMidClr = style.AutoMiddleColor;
leftColor = style.LeftColor;
rightColor = style.RightColor;
midColor = style.MiddleColor;
curvesName = tcurvesNames;
thisStyle = style;
}
private void btnLeftClr_Click(object sender, EventArgs e)
{
ColorDialog clrDlg = new ColorDialog
{
AllowFullOpen = true,
ShowHelp = false,
AnyColor = true,
SolidColorOnly = true // 只允许纯色(推荐)
};
clrDlg.Color = leftColor;
if(clrDlg.ShowDialog() == DialogResult.OK)
{
leftColor = clrDlg.Color;
btnLeftClr.BackColor = leftColor;
}
}
private void btnMidClr_Click(object sender, EventArgs e)
{
ColorDialog clrDlg = new ColorDialog
{
AllowFullOpen = true,
ShowHelp = false,
AnyColor = true,
SolidColorOnly = true // 只允许纯色(推荐)
};
clrDlg.Color = midColor;
if (clrDlg.ShowDialog() == DialogResult.OK)
{
midColor = clrDlg.Color;
btnMidClr.BackColor = midColor;
}
}
private void btnRightClr_Click(object sender, EventArgs e)
{
ColorDialog clrDlg = new ColorDialog
{
AllowFullOpen = true,
ShowHelp = false,
AnyColor = true,
SolidColorOnly = true // 只允许纯色(推荐)
};
clrDlg.Color = rightColor;
if (clrDlg.ShowDialog() == DialogResult.OK)
{
rightColor = clrDlg.Color;
btnRightClr.BackColor = rightColor;
}
}
private void btnOK_Click(object sender, EventArgs e)
{
if(double.TryParse(textBoxRightValue.Text, out double rvalue))
{
rightValue = rvalue;
}
if (double.TryParse(textBoxLeftValue.Text, out double lvalue))
{
leftValue = lvalue;
}
fillCurveName = cbxSelectCurve.SelectedItem.ToString();
bAutoMidClr = checkBoxAutoMidClr.Checked;
thisStyle.CurveName = fillCurveName;
thisStyle.Left = leftValue;
thisStyle.Right = rightValue;
thisStyle.AutoMiddleColor = bAutoMidClr;
thisStyle.LeftColor = leftColor;
thisStyle.RightColor = rightColor;
thisStyle.MiddleColor = midColor;
}
private void FillCurveGradientFrm_Shown(object sender, EventArgs e)
{
textBoxRightValue.Text = rightValue.ToString();
textBoxLeftValue.Text = leftValue.ToString();
checkBoxAutoMidClr.Checked = bAutoMidClr;
btnLeftClr.BackColor = leftColor;
btnRightClr.BackColor = rightColor;
btnMidClr.BackColor = midColor;
cbxSelectCurve.DataSource = curvesName;
for(int i = 0; i < cbxSelectCurve.Items.Count; i++)
{
string tstr = cbxSelectCurve.Items[i].ToString();
if(tstr == fillCurveName)
{
cbxSelectCurve.SelectedIndex = i;
break;
}
}
}
}
}