C2018-039: Upgrade – User Control of Format
This commit is contained in:
36
PROMS/Volian.Base.Library/RtfEditor.cs
Normal file
36
PROMS/Volian.Base.Library/RtfEditor.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Design;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Design;
|
||||
using System;
|
||||
|
||||
|
||||
namespace Volian.Base.Library
|
||||
{
|
||||
// The RtfEditor inherits from the UITypeEditor and is used to edit Rtf fields. This provides the interface for fields in FormatConfig
|
||||
// and uses the frmRtfEdit to provide a mechanism to do basic editing of text with a subset of rtf command support.
|
||||
public class RtfEditor : UITypeEditor
|
||||
{
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
return UITypeEditorEditStyle.Modal;
|
||||
}
|
||||
public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
|
||||
{
|
||||
IWindowsFormsEditorService svc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
|
||||
string rw = value as string;
|
||||
if (svc != null && rw != null)
|
||||
{
|
||||
using (frmRtfEdit form = new frmRtfEdit())
|
||||
{
|
||||
form.Value = rw;
|
||||
if (svc.ShowDialog(form) == DialogResult.OK)
|
||||
{
|
||||
rw = form.Value; // update object
|
||||
}
|
||||
}
|
||||
}
|
||||
return rw;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user