-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1407 from glopesdev/mono-compatibility
Mono compatibility improvements
- Loading branch information
Showing
40 changed files
with
1,069 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using System.Drawing.Design; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
using System.Windows.Forms.Design; | ||
|
||
namespace Bonsai.Design | ||
{ | ||
/// <summary> | ||
/// Provides a user interface editor that displays a rich text box for editing | ||
/// the property value. | ||
/// </summary> | ||
public class RichTextEditor : UITypeEditor | ||
{ | ||
internal static string CamelCaseToSpaces(string text) | ||
{ | ||
var textBuilder = new StringBuilder(text.Length * 2); | ||
for (int i = 0; i < text.Length; i++) | ||
{ | ||
if (i > 0 && char.IsUpper(text[i]) && !char.IsUpper(text[i - 1])) | ||
{ | ||
textBuilder.Append(' '); | ||
} | ||
|
||
textBuilder.Append(text[i]); | ||
} | ||
|
||
return textBuilder.ToString(); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) | ||
{ | ||
return UITypeEditorEditStyle.Modal; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) | ||
{ | ||
if (provider != null) | ||
{ | ||
var editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); | ||
if (editorService != null) | ||
{ | ||
using var editorDialog = new RichTextEditorDialog(); | ||
editorDialog.Value = (string)value; | ||
if (GetType() is Type editorType && editorType != typeof(RichTextEditor)) | ||
{ | ||
editorDialog.Text = CamelCaseToSpaces(editorType.Name); | ||
} | ||
|
||
if (editorService.ShowDialog(editorDialog) == DialogResult.OK) | ||
{ | ||
return editorDialog.Value; | ||
} | ||
} | ||
} | ||
|
||
return base.EditValue(context, provider, value); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.