using System;
using System.ComponentModel;
using System.Drawing.Design;
namespace Core.Common.Gui
{
///
/// Use this type in combination with the Editor Attribute on properties in property classes which you want to
/// edit with a Ringtoets view.
///
/// The property grid will display an ellipsis button (...). Clicking on the button will open the default view
/// for the data object in the central tabbed document area of Ringtoets. The view will remain open until
/// closed by the user and is not modal.
///
///
///
/// Usage (for example):
///
/// [Editor(typeof(ViewPropertyEditor), typeof(UITypeEditor))]
/// public TimeSeries TimeSeries
/// {
/// get { return data.TimeSeries; }
/// set { data.TimeSeries = value; } //not called
/// }
///
/// This would typically open a FunctionView to edit the time series.
///
public class ViewPropertyEditor : UITypeEditor
{
public static IGui Gui { get; set; } //static: injected in RingtoetsGui
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
Gui.ViewCommands.OpenView(value);
return value;
}
}
}