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.
78 lines
2.3 KiB
C#
78 lines
2.3 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Drawing.Design;
|
|
using System.Drawing.Drawing2D;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Forms.Design;
|
|
|
|
namespace GeoSigma.SigmaDrawerStyle
|
|
{
|
|
/// <summary>
|
|
/// ÇúÏßÑùʽ UI ½çÃæ
|
|
/// </summary>
|
|
public class PropertyEditorWellCurveStyle : UITypeEditor
|
|
{
|
|
/// <inheritdoc/>
|
|
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
|
{
|
|
return UITypeEditorEditStyle.Modal;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
|
{
|
|
if (!(value is WellLineStyle style))
|
|
{
|
|
return value;
|
|
}
|
|
|
|
IWindowsFormsEditorService edSvc = provider?.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
|
|
if (edSvc == null)
|
|
{
|
|
return value;
|
|
}
|
|
|
|
using (var editorForm = new WellCurveStyleEditForm(style))
|
|
{
|
|
if (edSvc.ShowDialog(editorForm) == DialogResult.OK)
|
|
{
|
|
WellLineStyle retStyle = new WellLineStyle();
|
|
retStyle.Color = editorForm.style.Color;
|
|
retStyle.Width = editorForm.style.Width;
|
|
retStyle.Style = editorForm.style.Style;
|
|
return retStyle;
|
|
}
|
|
}
|
|
|
|
return value;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public override void PaintValue(PaintValueEventArgs e)
|
|
{
|
|
if (e.Value is WellLineStyle style)
|
|
{
|
|
var g = e.Graphics;
|
|
var rect = e.Bounds;
|
|
|
|
using (var pen = new Pen(style.Color, (float)Math.Max(1, style.Width)))
|
|
{
|
|
// ÉèÖà DashStyle£¨³ý·Ç Solid ÊôÐÔÇ¿ÖÆÎªÊµÏߣ©
|
|
pen.DashStyle = DashStyle.Solid;
|
|
|
|
// ¾ÓÖлÏß
|
|
int y = rect.Top + (rect.Height / 2);
|
|
g.DrawLine(pen, rect.Left, y, rect.Right, y);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|