using System;
using System.ComponentModel;
#if WEB_SERVICE
#else
using System.Drawing.Design;
using System.Windows.Forms;
#endif
using GeoSigma.SigmaDrawerStyle.Converter;
namespace GeoSigma.SigmaDrawerStyle
{
public enum ContourFaultKind
{
没有断层,
断层在文件中,
断层在指定类别中
}
public class ContourGenerationProperty
{
private double interval; //等值线间隔
private int step; //等值线上数步长
private double zMax;
private double zMin;
private string categoryNameA;//等值线上数类别名
private string categoryNameB;//等值线非上数类别名
private ContourFaultKind faultKind = ContourFaultKind.没有断层; //断层存在方式
private string faultFile = string.Empty; //断层文件
// private LayerNamesWrapper layerNamesWrapper = new LayerNamesWrapper();
[Category("\t\t间隔"), DisplayName("\t\t\t\t\t\t等值线间隔"), ReadOnly(false)]
public double Interval { get => interval; set => interval = value; }
[Category("\t\t间隔"), DisplayName("\t\t\t\t\t\t等值线上数步长"), ReadOnly(false)]
public int Step { get => step; set => step = value; }
[Category("\tZ值范围"), DisplayName("\t\t\t\t\t\t最小"), ReadOnly(false)]
public double ZMin { get => zMin; set => zMin = value; }
[Category("\tZ值范围"), DisplayName("\t\t\t\t\t\t最大"), ReadOnly(false)]
public double ZMax { get => zMax; set => zMax = value; }
[Category("\t层位"), DisplayName("\t\t\t\t\t\t带标注"), ReadOnly(false)]
public string CategoryNameA { get => categoryNameA; set => categoryNameA = value; }
[Category("\t层位"), DisplayName("\t\t\t\t\t\t无标注"), ReadOnly(false)]
public string CategoryNameB { get => categoryNameB; set => categoryNameB = value; }
[Category("\t断层"), DisplayName("\t\t\t\t\t\t断层存在方式"), ReadOnly(false)]
public ContourFaultKind FaultKind { get => faultKind; set => faultKind = value; }
[Category("\t断层"), DisplayName("\t\t\t断层文件"), ReadOnly(true)]
//[Editor("UCDraw.PropertyGrids.PropertyGridOpenFile, UCDraw", typeof(UITypeEditor))]
#if WEB_SERVICE
#else
[Editor(typeof(UIFilenameEditor), typeof(System.Drawing.Design.UITypeEditor))]
#endif
public string FaultFile
{
get
{
return faultFile;
}
set
{
faultFile = value;
}
}
[Category("\t断层"), DisplayName("\t\t\t断层类别")]
#if WEB_SERVICE
#else
[Editor(typeof(DropDownTypeEditor), typeof(UITypeEditor)), ReadOnly(true)]
#endif
public DropdownPropertyWrapper LayerNames { get; set; } = new DropdownPropertyWrapper();
}
#if WEB_SERVICE
#else
public class UIFilenameEditor : System.Drawing.Design.UITypeEditor
{
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
if (context != null && context.Instance != null)
{
if (!context.PropertyDescriptor.IsReadOnly)
{
return UITypeEditorEditStyle.Modal;
}
}
return UITypeEditorEditStyle.DropDown;
}
[RefreshProperties(RefreshProperties.All)]
public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
{
if (context == null || provider == null || context.Instance == null)
{
return base.EditValue(provider, value);
}
FileDialog fileDlg;
if (context.PropertyDescriptor.Attributes[typeof(SaveFileAttribute)] == null)
{
fileDlg = new OpenFileDialog();
}
else
{
fileDlg = new SaveFileDialog();
}
fileDlg.Title = "Select " + context.PropertyDescriptor.DisplayName;
fileDlg.FileName = (string)value;
FileDialogFilterAttribute filterAtt = (FileDialogFilterAttribute)context.PropertyDescriptor.Attributes[typeof(FileDialogFilterAttribute)];
if (filterAtt != null)
{
fileDlg.Filter = filterAtt.Filter;
}
if (fileDlg.ShowDialog() == DialogResult.OK)
{
value = fileDlg.FileName;
}
fileDlg.Dispose();
return value;
}
[AttributeUsage(AttributeTargets.Property)]
public class FileDialogFilterAttribute : Attribute
{
private string _filter;
public string Filter
{
get
{
return this._filter;
}
}
///
/// Initializes a new instance of the class.
///
///
public FileDialogFilterAttribute(string filter)
{
this._filter = filter;
}
}
[AttributeUsage(AttributeTargets.Property)]
public class SaveFileAttribute : Attribute
{
}
public enum FileDialogType
{
LoadFileDialog,
SaveFileDialog
}
}
#endif
}