public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value) { if (context == null || provider == null || context.Instance == null) { return(base.EditValue(provider, value)); } string label = "s_type_text"; foreach (Attribute attrib in context.PropertyDescriptor.Attributes) { if (attrib is EditorDisplayLabelAttribute) { label = ((EditorDisplayLabelAttribute)attrib).Label; } } CodeLanguage lang = CodeLanguage.None; foreach (Attribute attrib in context.PropertyDescriptor.Attributes) { if (attrib is SyntaxEditorLanguageAttribute) { lang = ((SyntaxEditorLanguageAttribute)attrib).Language; } } string res = SyntaxEditorForm.Run(VersionInfo.ProgramTitle, label, value.SafeToString(), lang); return(res ?? value); }
public static string Run(string caption, string label, string text, CodeLanguage lang) { SyntaxEditorForm win = new SyntaxEditorForm(); win.codeEditor1.Language = lang; win.codeEditor1.Text = text; win.textBox1.Text = Texts.Get(label); win.Text = Texts.Get(caption); if (win.ShowDialogEx() == DialogResult.OK) { return(win.codeEditor1.Text); } return(null); }