3
3
using System . ComponentModel ;
4
4
using System . Windows . Forms . Design ;
5
5
using System . Windows . Forms ;
6
+ using Bonsai . Design ;
6
7
7
8
namespace Bonsai . Scripting . IronPython . Design
8
9
{
9
10
/// <summary>
10
11
/// Provides a user interface editor that displays a dialog box for editing
11
12
/// the Python script.
12
13
/// </summary>
13
- public class PythonScriptEditor : UITypeEditor
14
+ public class PythonScriptEditor : RichTextEditor
14
15
{
16
+ static readonly bool IsRunningOnMono = Type . GetType ( "Mono.Runtime" ) != null ;
17
+
15
18
/// <inheritdoc/>
16
19
public override UITypeEditorEditStyle GetEditStyle ( ITypeDescriptorContext context )
17
20
{
@@ -21,15 +24,17 @@ public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext contex
21
24
/// <inheritdoc/>
22
25
public override object EditValue ( ITypeDescriptorContext context , IServiceProvider provider , object value )
23
26
{
24
- var editorService = ( IWindowsFormsEditorService ) provider . GetService ( typeof ( IWindowsFormsEditorService ) ) ;
25
- if ( editorService != null )
27
+ if ( provider != null && ! IsRunningOnMono )
26
28
{
27
- var script = value as string ;
28
- var editorDialog = new PythonScriptEditorDialog ( ) ;
29
- editorDialog . Script = script ;
30
- if ( editorService . ShowDialog ( editorDialog ) == DialogResult . OK )
29
+ var editorService = ( IWindowsFormsEditorService ) provider . GetService ( typeof ( IWindowsFormsEditorService ) ) ;
30
+ if ( editorService != null )
31
31
{
32
- return editorDialog . Script ;
32
+ using var editorDialog = new PythonScriptEditorDialog ( ) ;
33
+ editorDialog . Script = ( string ) value ;
34
+ if ( editorService . ShowDialog ( editorDialog ) == DialogResult . OK )
35
+ {
36
+ return editorDialog . Script ;
37
+ }
33
38
}
34
39
}
35
40
0 commit comments