|
using System;
using System.Windows.Forms.Design;
using System.Drawing;
using System.Drawing.Design;
namespace ExtCursors.Design
{
#region "Class : ExtCursorSelectEditor"
//=====================================================================
//=====================================================================
public class ExtCursorSelectEditor : UITypeEditor
{
//=====================================================================
public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
{
if ((context != null) && (context.Instance != null))
return UITypeEditorEditStyle.DropDown;
else
return base.GetEditStyle(context);
}
//=====================================================================
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if ((context != null) && (context.Instance != null) && (provider != null))
{
IWindowsFormsEditorService EditorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
ExtCursorSelectDropDown DropDownControl = new ExtCursorSelectDropDown(context, EditorService, value);
object Result = value;
EditorService.DropDownControl(DropDownControl);
if (!DropDownControl._Cancelled)
{
Result = DropDownControl._SelectedValue;
}
DropDownControl.Dispose();
return Result;
}
return value;
}
//=====================================================================
public override bool GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context)
{
if (context.Instance != null)
{
object PtyValue = context.PropertyDescriptor.GetValue(context.Instance);
if (PtyValue != null)
{
return (PtyValue is ExtCursor);
}
}
return false;
}
//=====================================================================
public override void PaintValue(PaintValueEventArgs e)
{
if (e.Value is ExtCursor)
{
ExtCursor ThisCursor = (ExtCursor)e.Value;
if (ThisCursor._Cursor != null)
{
e.Graphics.FillRectangle(SystemBrushes.ControlLight, e.Bounds);
ThisCursor._Cursor.DrawStretched(e.Graphics, e.Bounds);
}
}
else
{
base.PaintValue(e);
}
}
//=====================================================================
public override bool IsDropDownResizable
{
get
{
return true;
}
}
}
#endregion
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I've been involved in software design and development for more years than I care to remember. Started out in Engineering and drifted into computing as a real-time software engineer (assembler) working on industrial robotic systems.
Moved into application development (in Clipper, Delphi and, more recently, .Net) in a wide variety of industries including banking, manufacturing, betting & gaming, travel industry, sport (Formula 1), public sector and a few others.
Spent many years involved in designing and developing commercial websites, becoming a specialist in XML and XSLT. Designed and developed an XSLT IDE (Xselerator), which is now available free on SourceForge.