37 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| 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;
 | |
| 		}
 | |
| 	}
 | |
| }
 |