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.
kev/Drawer/UCDraw/SigmaDrawerWellElement/PropertyEditorFillCurveGrad...

96 lines
3.2 KiB
C#

using GeoSigma.SigmaDrawerElement;
using SigmaDrawerElement;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms.Design;
namespace GeoSigma.SigmaDrawerStyle
{
//设置曲线填充的渐进色
public class PropertyEditorFillCurveGradient : UITypeEditor
{
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
{
return true;
}
public override void PaintValue(PaintValueEventArgs e)
{
if (e.Value is WellTrackGradientStyle style)
{
var g = e.Graphics;
var rect = e.Bounds;
// rect.Width += 100;
using (LinearGradientBrush brush = new LinearGradientBrush(
rect, // 渐变作用区域
style.LeftColor, // 起始颜色
style.RightColor, // 结束颜色
LinearGradientMode.Horizontal)) // 渐变方向
{
// 用渐变色填充矩形
g.FillRectangle(brush, rect);
}
}
}
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if (!(value is WellTrackGradientStyle style))
{
return value;
}
IWindowsFormsEditorService edSvc = provider?.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
if (edSvc == null)
{
return value;
}
List<string> curvesNames = new List<string>();
if (context.Instance is WellCurveTrack curveTrack)
{
if (curveTrack.wellPoleContext.geoWellPole.GetWellAllCurveNames(curveTrack.wellPoleContext.wellObjHandle, out string[] NamesArr) == true)
{
curvesNames = new List<string>(NamesArr);
curvesNames.Insert(0, "");
}
}
else
return value;
using (var editorForm = new FillCurveGradientFrm(style, curvesNames) { StartPosition = FormStartPosition.CenterScreen })
{
if (edSvc.ShowDialog(editorForm) == DialogResult.OK)
{
return new WellTrackGradientStyle()
{
AutoMiddleColor = style.AutoMiddleColor,
Left = style.Left,
Right = style.Right,
CurveName = style.CurveName,
LeftColor = style.LeftColor,
RightColor = style.RightColor,
MiddleColor = style.MiddleColor
};
}
}
return value;
}
}
}