73 lines
2.8 KiB
C#
73 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Drawing;
|
|
using System.Drawing.Design;
|
|
using System.Windows.Forms.Design;
|
|
|
|
namespace ShapeControl
|
|
{
|
|
public class SaveFileEditor : System.Drawing.Design.UITypeEditor
|
|
{
|
|
public SaveFileEditor()
|
|
{
|
|
}
|
|
|
|
// Indicates whether the UITypeEditor provides a form-based (modal) dialog,
|
|
// drop down dialog, or no UI outside of the properties window.
|
|
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
|
|
public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
|
|
{
|
|
return UITypeEditorEditStyle.DropDown;
|
|
|
|
|
|
}
|
|
|
|
// Displays the UI for value selection.
|
|
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
|
|
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
|
|
{
|
|
|
|
//if( value.GetType() != typeof(Color))
|
|
// return value;
|
|
|
|
// Uses the IWindowsFormsEditorService to display a
|
|
// drop-down UI in the Properties window.
|
|
IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
|
|
if (edSvc != null)
|
|
{
|
|
//ColorEditorControl editor = new ColorEditorControl((Color)value);
|
|
//edSvc.DropDownControl(editor);
|
|
|
|
//// Return the value in the appropraite data format.
|
|
//if (value.GetType() == typeof(Color))
|
|
// return editor.color;
|
|
|
|
FormSaveFileEditor sfeditor = new FormSaveFileEditor();
|
|
edSvc.ShowDialog(sfeditor);
|
|
|
|
//if (value.GetType() == typeof(Color))
|
|
// return sfeditor.color;
|
|
return sfeditor.filename;
|
|
|
|
}
|
|
return value;
|
|
}
|
|
|
|
// Draws a representation of the property's value.
|
|
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
|
|
public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e)
|
|
{
|
|
e.Graphics.FillRectangle(new SolidBrush((Color)e.Value), 1, 1, e.Bounds.Width, e.Bounds.Height);
|
|
}
|
|
|
|
// Indicates whether the UITypeEditor supports painting a
|
|
// representation of a property's value.
|
|
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
|
|
public override bool GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|