SetResetText() public method

public SetResetText ( string resetText ) : void
resetText string
return void
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            var svc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (svc != null)
            {
                var frm = new TemplateTextEditorForm();

                string template    = "";
                string valueToEdit = (value == null ? "" : value.ToString());
                if (context.Instance is ReportView)
                {
                    frm.View = context.Instance as ReportView;
                    if (context.PropertyDescriptor.Name == "CustomTemplate")
                    {
                        if (string.IsNullOrEmpty(valueToEdit))
                        {
                            valueToEdit = frm.View.ViewTemplateText;
                        }
                        template = frm.View.ViewTemplateText.Trim();
                        frm.Text = "Edit custom template";
                        frm.TypeForCheckSyntax = frm.View.Template.ForModel ? typeof(ReportModel) : typeof(Report);
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                    else if (context.PropertyDescriptor.Name == "CustomConfiguration")
                    {
                        if (string.IsNullOrEmpty(valueToEdit))
                        {
                            valueToEdit = frm.View.Template.Configuration;
                        }
                        template = frm.View.Template.Configuration.Trim();
                        frm.Text = "Edit template configuration";
                        frm.TypeForCheckSyntax = typeof(ReportViewTemplate);
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                }
                else if (context.Instance is ReportTask)
                {
                    template = razorTaskTemplate;
                    frm.TypeForCheckSyntax = typeof(ReportTask);
                    frm.Text = "Edit task script";
                    frm.textBox.ConfigurationManager.Language = "cs";
                    frm.TextToAddForCheck = ((ReportTask)context.Instance).Report.TasksScript + "\r\n" + ((ReportTask)context.Instance).Source.TasksScript;
                    List <string> samples = new List <string>();
                    samples.Add("@using Seal.Model\r\n@using Seal.Helpers\r\n@{\r\n\t//Refresh Data Sources enumerated lists\r\n\tReportTask task = Model;\r\n\tvar helper = new TaskHelper(task);\r\n\thelper.RefreshRepositoryEnums();\r\n}");
                    samples.Add("@using Seal.Model\r\n@using Seal.Helpers\r\n@{\r\n\t//Load a table from an Excel file, may need ODBC Office 2007 Drivers\r\n\tReportTask task = Model;\r\n\tvar helper = new TaskHelper(task);\r\n\thelper.LoadTableFromExcel(@\"c:\\temp\\loadFolder\", @\"c:\\temp\\excelFile.xlsx\", \"ExcelTabName\", \"DestinationTableName\", false /* true to load in all connections */);\r\n}");
                    samples.Add("@using Seal.Model\r\n@using Seal.Helpers\r\n@{\r\n\t//Load a table from a CSV file\r\n\tReportTask task = Model;\r\n\tvar helper = new TaskHelper(task);\r\n\thelper.LoadTableFromCSV(@\"c:\\temp\\loadFolder\", @\"c:\\temp\\aCSVFile.csv\", \"DestinationTableName\", null /* separator may be specified here */, false /* true to load in all connections */);\r\n}");
                    samples.Add("@using Seal.Model\r\n@using Seal.Helpers\r\n@{\r\n\t//Load a table from a source table located in an external data source\r\n\tReportTask task = Model;\r\n\tvar helper = new TaskHelper(task);\r\n\thelper.LoadTableFromExternalSource(\"SourceConnectionString\", \"SourceSelectStatement\", \"DestinationTableName\", false /* true to load in all connections */, \"OptionalSourceCheckSelect\", \"OptionalDestinationCheckSelect\");\r\n}");
                    samples.Add("@using Seal.Model\r\n@using Seal.Helpers\r\n@{\r\n\t//Query or update the database\r\n\tReportTask task = Model;\r\n\tvar helper = new TaskHelper(task);\r\n\tstring name = (string) helper.ExecuteScalar(\"select LastName from employees\");\r\n\thelper.LogMessage(\"Name=\" + name);\r\n\thelper.ExecuteNonQuery(\"update employees set LastName = '' where 1=0\", false /* true to execute in all connections */);\r\n}");
                    samples.Add("@using Seal.Model\r\n@using Seal.Helpers\r\n@{\r\n\t//Execute a program and display Standard Output and Errors\r\n\tReportTask task = Model;\r\n\tvar helper = new TaskHelper(task);\r\n\thelper.ExecuteProcess(@\"executablePath\");\r\n}");
                    frm.SetSamples(samples);
                }
                else if (context.Instance is ReportOutput)
                {
                    if (context.PropertyDescriptor.Name == "PreScript")
                    {
                        template = razorPreOutputTemplate;
                    }
                    else if (context.PropertyDescriptor.Name == "PostScript")
                    {
                        template = razorPostOutputTemplate;
                    }
                    frm.TypeForCheckSyntax = typeof(ReportOutput);
                    frm.Text = "Edit output script";
                    frm.textBox.ConfigurationManager.Language = "cs";
                }
                else if (context.Instance is Parameter)
                {
                    Parameter parameter = context.Instance as Parameter;
                    template = parameter.ConfigValue;
                    frm.Text = parameter.DisplayName;
                    frm.textBox.ConfigurationManager.Language = (string.IsNullOrEmpty(parameter.EditorLanguage) ? "" : parameter.EditorLanguage);
                }
                else if (context.Instance.GetType().ToString() == "SealPdfConverter.PdfConverter")
                {
                    string           language  = "cs";
                    SealPdfConverter converter = SealPdfConverter.Create("");
                    converter.ConfigureTemplateEditor(frm, context.PropertyDescriptor.Name, ref template, ref language);
                    frm.textBox.ConfigurationManager.Language = language;
                }
                else if (context.Instance.GetType().ToString() == "SealExcelConverter.ExcelConverter")
                {
                    string             language  = "cs";
                    SealExcelConverter converter = SealExcelConverter.Create("");
                    converter.ConfigureTemplateEditor(frm, context.PropertyDescriptor.Name, ref template, ref language);
                    frm.textBox.ConfigurationManager.Language = language;
                }
                else if (context.Instance is ViewFolder)
                {
                    if (context.PropertyDescriptor.Name == "DisplayName")
                    {
                        template = displayNameTemplate;
                        frm.TypeForCheckSyntax = typeof(Report);
                        frm.Text = "Edit display name script";
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                    else if (context.PropertyDescriptor.Name == "InitScript")
                    {
                        template = razorInitScriptTemplate;
                        frm.TypeForCheckSyntax = typeof(Report);
                        frm.Text = "Edit the script executed when the report is initialized";
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                }
                else if (context.Instance is ReportElement)
                {
                    ReportElement element = context.Instance as ReportElement;
                    if (context.PropertyDescriptor.Name == "CellScript")
                    {
                        frm.Text = "Edit custom script for the cell";
                        template = razorCellScriptTemplate;
                        frm.TypeForCheckSyntax = typeof(ResultCell);
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                    else if (context.PropertyDescriptor.Name == "SQL")
                    {
                        frm.Text = "Edit custom SQL";
                        frm.textBox.ConfigurationManager.Language = "sql";
                        template = element.RawSQLColumn;
                        List <string> samples = new List <string>();
                        samples.Add(element.RawSQLColumn);
                        if (!string.IsNullOrEmpty(element.SQL) && !samples.Contains(element.SQL))
                        {
                            samples.Add(element.SQL);
                        }
                        frm.SetSamples(samples);
                        frm.textBox.LineWrapping.Mode = ScintillaNET.LineWrappingMode.Word;
                    }
                    else if (context.PropertyDescriptor.Name == "CellCss")
                    {
                        frm.Text = "Edit custom CSS";
                        frm.textBox.ConfigurationManager.Language = "css";
                        List <string> samples = new List <string>();
                        samples.Add("text-align:right;");
                        samples.Add("text-align:center;");
                        samples.Add("text-align:left;");
                        samples.Add("font-style:italic;");
                        samples.Add("font-weight:bold;color:red;background-color:yellow;");
                        samples.Add("color:green;text-align:right;|color:black;|font-weight:bold;color:red;text-align:right;");
                        samples.Add("white-space: nowrap;");
                        frm.SetSamples(samples);
                        frm.textBox.LineWrapping.Mode = ScintillaNET.LineWrappingMode.Word;
                    }
                }
                else if (context.Instance is MetaColumn)
                {
                    if (context.PropertyDescriptor.Name == "Name")
                    {
                        frm.Text = "Edit column name";
                        frm.textBox.ConfigurationManager.Language = "sql";
                        frm.textBox.LineWrapping.Mode             = ScintillaNET.LineWrappingMode.Word;
                    }
                }
                else if (context.Instance is SealSecurity)
                {
                    if (context.PropertyDescriptor.Name == "Script" || context.PropertyDescriptor.Name == "ProviderScript")
                    {
                        template = ((SealSecurity)context.Instance).ProviderScript;
                        frm.TypeForCheckSyntax = typeof(SecurityUser);
                        frm.Text = "Edit security script";
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                }
                else if (context.Instance is MetaTable)
                {
                    if (context.PropertyDescriptor.Name == "DefinitionScript")
                    {
                        template = razorTableDefinitionScriptTemplate;
                        frm.TypeForCheckSyntax = typeof(MetaTable);
                        frm.Text = "Edit the script to define the table";
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                    else if (context.PropertyDescriptor.Name == "LoadScript")
                    {
                        template = razorTableLoadScriptTemplate;
                        frm.TypeForCheckSyntax = typeof(MetaTable);
                        frm.Text = "Edit the default script to load the table";
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                }
                else if (context.Instance is ReportModel)
                {
                    if (context.PropertyDescriptor.Name == "PreLoadScript")
                    {
                        template = razorModelPreLoadScriptTemplateNoSQL;
                        frm.TypeForCheckSyntax = typeof(ReportModel);
                        frm.Text = "Edit the script executed before table load";
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                    else if (context.PropertyDescriptor.Name == "FinalScript")
                    {
                        template = razorTableFinalScriptTemplate;
                        frm.TypeForCheckSyntax = typeof(ReportModel);
                        frm.Text = "Edit the final script executed for the model";
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                    else if (context.PropertyDescriptor.Name == "LoadScript")
                    {
                        if (((ReportModel)context.Instance).Source.IsNoSQL)
                        {
                            frm.Text = "Edit the script executed after table load";
                            template = razorModelLoadScriptTemplateNoSQL;
                        }
                        else
                        {
                            frm.Text = "Edit the script to load the table";
                            template = razorModelLoadScriptTemplate;
                        }
                        frm.TypeForCheckSyntax = typeof(ReportModel);
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                }
                else if (context.Instance is TasksFolder || context.Instance is MetaSource)
                {
                    template = razorTasksTemplate;
                    frm.TypeForCheckSyntax = typeof(ReportTask);
                    frm.Text = "Edit the script that will be added to all task scripts";
                    frm.textBox.ConfigurationManager.Language = "cs";
                }

                if (!string.IsNullOrEmpty(template) && string.IsNullOrWhiteSpace(valueToEdit) && !context.PropertyDescriptor.IsReadOnly)
                {
                    valueToEdit = template;
                }

                //Reset button
                if (!string.IsNullOrEmpty(template) && !context.PropertyDescriptor.IsReadOnly)
                {
                    frm.SetResetText(template);
                }

                frm.textBox.Text = valueToEdit.ToString();

                if (context.PropertyDescriptor.IsReadOnly)
                {
                    frm.textBox.IsReadOnly         = true;
                    frm.okToolStripButton.Visible  = false;
                    frm.cancelToolStripButton.Text = "Close";
                }
                frm.checkSyntaxToolStripButton.Visible = (frm.TypeForCheckSyntax != null);

                if (svc.ShowDialog(frm) == DialogResult.OK)
                {
                    if (frm.textBox.Text.Trim() != template || string.IsNullOrEmpty(template))
                    {
                        value = frm.textBox.Text;
                    }
                    else if (frm.textBox.Text.Trim() == template && !string.IsNullOrEmpty(template))
                    {
                        value = "";
                    }
                }
            }
            return(value);
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            var svc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (svc != null)
            {
                var frm = new TemplateTextEditorForm();

                string template = "";
                string valueToEdit = (value == null ? "" : value.ToString());
                if (context.Instance is ReportView)
                {
                    frm.View = context.Instance as ReportView;
                    if (context.PropertyDescriptor.Name == "CustomTemplate")
                    {
                        if (string.IsNullOrEmpty(valueToEdit)) valueToEdit = frm.View.ViewTemplateText;
                        template = frm.View.ViewTemplateText.Trim();
                        frm.Text = "Edit custom template";
                        frm.TypeForCheckSyntax = frm.View.Template.ForModel ? typeof(ReportModel) : typeof(Report);
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                    else if (context.PropertyDescriptor.Name == "CustomConfiguration")
                    {
                        if (string.IsNullOrEmpty(valueToEdit)) valueToEdit = frm.View.Template.Configuration;
                        template = frm.View.Template.Configuration.Trim();
                        frm.Text = "Edit template configuration";
                        frm.TypeForCheckSyntax = typeof(ReportViewTemplate);
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                    else if (context.PropertyDescriptor.Name == "NVD3Configuration")
                    {
                        frm.Text = frm.View.NVD3ConfigurationParameter.DisplayName;
                        var param = frm.View.Template.Parameters.FirstOrDefault(i => i.Name == Parameter.NVD3ConfigurationParameter);
                        if (param != null) template = param.TextValue;
                        frm.textBox.ConfigurationManager.Language = (string.IsNullOrEmpty(frm.View.NVD3ConfigurationParameter.EditorLanguage) ? "" : frm.View.NVD3ConfigurationParameter.EditorLanguage);
                    }
                }
                else if (context.Instance is ReportTask)
                {
                    template = razorTaskTemplate;
                    frm.TypeForCheckSyntax = typeof(ReportTask);
                    frm.Text = "Edit task script";
                    frm.textBox.ConfigurationManager.Language = "cs";
                    List<string> samples = new List<string>();
                    samples.Add("@using Seal.Model\r\n@using Seal.Helpers\r\n@{\r\n\t//Refresh Data Sources enumerated lists\r\n\tReportTask task = Model;\r\n\tvar helper = new TaskHelper(task);\r\n\thelper.RefreshRepositoryEnums();\r\n}");
                    samples.Add("@using Seal.Model\r\n@using Seal.Helpers\r\n@{\r\n\t//Load a table from an Excel file, may need ODBC Office 2007 Drivers\r\n\tReportTask task = Model;\r\n\tvar helper = new TaskHelper(task);\r\n\thelper.LoadTableFromExcel(@\"c:\\temp\\loadFolder\", @\"c:\\temp\\excelFile.xlsx\", \"ExcelTabName\", \"DestinationTableName\", false /* true to load in all connections */);\r\n}");
                    samples.Add("@using Seal.Model\r\n@using Seal.Helpers\r\n@{\r\n\t//Load a table from a CSV file\r\n\tReportTask task = Model;\r\n\tvar helper = new TaskHelper(task);\r\n\thelper.LoadTableFromCSV(@\"c:\\temp\\loadFolder\", @\"c:\\temp\\aCSVFile.csv\", \"DestinationTableName\", null /* separator may be specified here */, false /* true to load in all connections */);\r\n}");
                    samples.Add("@using Seal.Model\r\n@using Seal.Helpers\r\n@{\r\n\t//Load a table from a source table located in an external data source\r\n\tReportTask task = Model;\r\n\tvar helper = new TaskHelper(task);\r\n\thelper.LoadTableFromExternalSource(\"SourceConnectionString\", \"SourceSelectStatement\", \"DestinationTableName\", false /* true to load in all connections */, \"OptionalSourceCheckSelect\", \"OptionalDestinationCheckSelect\");\r\n}");
                    samples.Add("@using Seal.Model\r\n@using Seal.Helpers\r\n@{\r\n\t//Execute a program and display Standard Output and Errors\r\n\tReportTask task = Model;\r\n\tvar helper = new TaskHelper(task);\r\n\thelper.ExecuteProcess(@\"executablePath\");\r\n}");
                    frm.SetSamples(samples);
                }
                else if (context.Instance is ReportOutput)
                {
                    if (context.PropertyDescriptor.Name == "PreScript") template = razorPreOutputTemplate;
                    else if (context.PropertyDescriptor.Name == "PostScript") template = razorPostOutputTemplate;
                    frm.TypeForCheckSyntax = typeof(ReportOutput);
                    frm.Text = "Edit output script";
                    frm.textBox.ConfigurationManager.Language = "cs";
                }
                else if (context.Instance is Parameter)
                {
                    Parameter parameter = context.Instance as Parameter;
                    frm.Text = parameter.DisplayName;
                    frm.textBox.ConfigurationManager.Language = (string.IsNullOrEmpty(parameter.EditorLanguage) ? "" : parameter.EditorLanguage);
                }
                else if (context.Instance.GetType().ToString() == "SealPdfConverter.PdfConverter")
                {
                    string language = "cs";
                    SealPdfConverter converter = SealPdfConverter.Create("");
                    converter.ConfigureTemplateEditor(frm, context.PropertyDescriptor.Name, ref template, ref language);
                    frm.textBox.ConfigurationManager.Language = language;
                }
                else if (context.Instance.GetType().ToString() == "SealExcelConverter.ExcelConverter")
                {
                    string language = "cs";
                    SealExcelConverter converter = SealExcelConverter.Create("");
                    converter.ConfigureTemplateEditor(frm, context.PropertyDescriptor.Name, ref template, ref language);
                    frm.textBox.ConfigurationManager.Language = language;
                }
                else if (context.Instance is ViewFolder)
                {
                    if (context.PropertyDescriptor.Name == "DisplayName")
                    {
                        template = displayNameTemplate;
                        frm.TypeForCheckSyntax = typeof(Report);
                        frm.Text = "Edit display name script";
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                }
                else if (context.Instance is ReportElement)
                {
                    ReportElement element = context.Instance as ReportElement;
                    if (context.PropertyDescriptor.Name == "CellScript")
                    {
                        frm.Text = "Edit custom script for the cell";
                        template = razorCellScriptTemplate;
                        frm.TypeForCheckSyntax = typeof(ResultCell);
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                    else if (context.PropertyDescriptor.Name == "SQL")
                    {
                        frm.Text = "Edit custom SQL";
                        frm.textBox.ConfigurationManager.Language = "sql";
                        template = element.RawSQLColumn;
                        List<string> samples = new List<string>();
                        samples.Add(element.RawSQLColumn);
                        if (!string.IsNullOrEmpty(element.SQL) && !samples.Contains(element.SQL)) samples.Add(element.SQL);
                        frm.SetSamples(samples);
                        frm.textBox.LineWrapping.Mode = ScintillaNET.LineWrappingMode.Word;
                    }
                    else if (context.PropertyDescriptor.Name == "CellCss")
                    {
                        frm.Text = "Edit custom CSS";
                        frm.textBox.ConfigurationManager.Language = "css";
                        List<string> samples = new List<string>();
                        samples.Add("text-align:right;");
                        samples.Add("text-align:center;");
                        samples.Add("text-align:left;");
                        samples.Add("font-style:italic;");
                        samples.Add("font-weight:bold;color:red;background-color:yellow;");
                        samples.Add("color:green;text-align:right;|color:black;|font-weight:bold;color:red;text-align:right;");
                        samples.Add("white-space: nowrap;");
                        frm.SetSamples(samples);
                        frm.textBox.LineWrapping.Mode = ScintillaNET.LineWrappingMode.Word;
                    }
                }
                else if (context.Instance is MetaColumn)
                {
                    if (context.PropertyDescriptor.Name == "Name")
                    {
                        frm.Text = "Edit column name";
                        frm.textBox.ConfigurationManager.Language = "sql";
                        frm.textBox.LineWrapping.Mode = ScintillaNET.LineWrappingMode.Word;
                    }
                }
                else if (context.Instance is SealSecurity)
                {
                    if (context.PropertyDescriptor.Name == "Script" || context.PropertyDescriptor.Name == "ProviderScript")
                    {
                        template = ((SealSecurity)context.Instance).ProviderScript;
                        frm.TypeForCheckSyntax = typeof(SecurityUser);
                        frm.Text = "Edit security script";
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                }
                else if (context.Instance is MetaTable)
                {
                    if (context.PropertyDescriptor.Name == "DefinitionScript")
                    {
                        template = razorTableDefinitionScriptTemplate;
                        frm.TypeForCheckSyntax = typeof(MetaTable);
                        frm.Text = "Edit the script to define the table";
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                    else if (context.PropertyDescriptor.Name == "LoadScript")
                    {
                        template = razorTableLoadScriptTemplate;
                        frm.TypeForCheckSyntax = typeof(MetaTable);
                        frm.Text = "Edit the default script to load the table";
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                }
                else if (context.Instance is ReportModel)
                {
                   if (context.PropertyDescriptor.Name == "PreLoadScript")
                    {
                        template = razorModelPreLoadScriptTemplateNoSQL;
                        frm.TypeForCheckSyntax = typeof(ReportModel);
                        frm.Text = "Edit the script executed before table load";
                        frm.textBox.ConfigurationManager.Language = "cs";
                    }
                   else if (context.PropertyDescriptor.Name == "FinalScript")
                   {
                       template = razorTableFinalScriptTemplate;
                       frm.TypeForCheckSyntax = typeof(ReportModel);
                       frm.Text = "Edit the final script executed for the model";
                       frm.textBox.ConfigurationManager.Language = "cs";
                   }
                   else if (context.PropertyDescriptor.Name == "LoadScript")
                   {
                       if (((ReportModel)context.Instance).Source.IsNoSQL)
                       {
                           frm.Text = "Edit the script executed after table load";
                           template = razorModelLoadScriptTemplateNoSQL;
                       }
                       else
                       {
                           frm.Text = "Edit the script to load the table";
                           template = razorModelLoadScriptTemplate;
                       }
                       frm.TypeForCheckSyntax = typeof(ReportModel);
                       frm.textBox.ConfigurationManager.Language = "cs";
                   }
                }

                if (!string.IsNullOrEmpty(template) && string.IsNullOrWhiteSpace(valueToEdit))
                {
                    valueToEdit = template;
                }

                //Reset button
                if (!string.IsNullOrEmpty(template) && !context.PropertyDescriptor.IsReadOnly) frm.SetResetText(template);

                frm.textBox.Text = valueToEdit.ToString();

                if (context.PropertyDescriptor.IsReadOnly)
                {
                    frm.textBox.IsReadOnly = true;
                    frm.okToolStripButton.Visible = false;
                    frm.cancelToolStripButton.Text = "Close";
                }
                frm.checkSyntaxToolStripButton.Visible = (frm.TypeForCheckSyntax != null);

                if (svc.ShowDialog(frm) == DialogResult.OK)
                {
                    if (frm.textBox.Text.Trim() != template || string.IsNullOrEmpty(template)) value = frm.textBox.Text;
                    else if (frm.textBox.Text.Trim() == template && !string.IsNullOrEmpty(template)) value = "";
                }
            }
            return value;
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            var svc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (svc != null)
            {
                var frm = new TemplateTextEditorForm();

                string template    = "";
                string valueToEdit = (value == null ? "" : value.ToString());
                if (context.Instance is ReportView)
                {
                    var view = context.Instance as ReportView;
                    if (context.PropertyDescriptor.Name == "CustomTemplate")
                    {
                        if (string.IsNullOrEmpty(valueToEdit))
                        {
                            valueToEdit = view.ViewTemplateText;
                        }
                        template = view.Template.Text.Trim();
                        frm.Text = "Edit custom template";
                        frm.ObjectForCheckSyntax = view.Report;
                        ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                    }
                    else if (context.PropertyDescriptor.Name == "CustomConfiguration")
                    {
                        if (string.IsNullOrEmpty(valueToEdit))
                        {
                            valueToEdit = view.Template.Configuration;
                        }
                        template = view.Template.Configuration.Trim();
                        frm.Text = "Edit template configuration";
                        frm.ObjectForCheckSyntax = view.Template;
                        ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                    }
                }
                else if (context.Instance is ReportViewPartialTemplate)
                {
                    var pt           = context.Instance as ReportViewPartialTemplate;
                    var templateText = pt.View.Template.GetPartialTemplateText(pt.Name);
                    if (string.IsNullOrEmpty(valueToEdit))
                    {
                        valueToEdit = templateText;
                    }
                    template = templateText;
                    frm.Text = "Edit custom partial template";
                    frm.ObjectForCheckSyntax = pt.View.Template.ForReportModel ? (object)pt.View.Model : (object)pt.View;
                    ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                }
                else if (context.Instance is ReportTask)
                {
                    template = razorTaskTemplate;
                    frm.ObjectForCheckSyntax = context.Instance;
                    frm.Text = "Edit task script";
                    ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                    List <string> samples = new List <string>();
                    foreach (var sample in tasksSamples)
                    {
                        samples.Add("@using Seal.Model\r\n@using Seal.Helpers\r\n@using System.Data\r\n@{\r\n\t//" + sample.Item1 + "\r\n\t" + sample.Item2 + "}\r\n|" + sample.Item1);
                    }
                    frm.SetSamples(samples);
                }
                else if (context.Instance is ReportOutput)
                {
                    if (context.PropertyDescriptor.Name == "PreScript")
                    {
                        template = razorPreOutputTemplate;
                    }
                    else if (context.PropertyDescriptor.Name == "PostScript")
                    {
                        template = razorPostOutputTemplate;
                    }
                    frm.ObjectForCheckSyntax = context.Instance;
                    frm.Text = "Edit output script";
                    ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                }
                else if (context.Instance is Parameter || context.Instance is ParametersEditor)
                {
                    Parameter parameter = context.Instance is Parameter ? context.Instance as Parameter : ((ParametersEditor)context.Instance).GetParameter(context.PropertyDescriptor.Name);
                    if (parameter != null)
                    {
                        template = parameter.ConfigValue;
                        frm.Text = parameter.DisplayName;
                        ScintillaHelper.Init(frm.textBox, (string.IsNullOrEmpty(parameter.EditorLanguage) ? "" : parameter.EditorLanguage));
                        if (parameter.TextSamples != null)
                        {
                            frm.SetSamples(parameter.TextSamples.ToList());
                        }
                    }
                }
                else if (context.Instance.GetType().ToString() == "SealPdfConverter.PdfConverter")
                {
                    string           language  = "cs";
                    SealPdfConverter converter = (SealPdfConverter)context.Instance;
                    converter.ConfigureTemplateEditor(frm, context.PropertyDescriptor.Name, ref template, ref language);
                    ScintillaHelper.Init(frm.textBox, language);
                }
                else if (context.Instance.GetType().ToString() == "SealExcelConverter.ExcelConverter")
                {
                    string             language  = "cs";
                    SealExcelConverter converter = (SealExcelConverter)context.Instance;
                    converter.ConfigureTemplateEditor(frm, context.PropertyDescriptor.Name, ref template, ref language);
                    ScintillaHelper.Init(frm.textBox, language);
                }
                else if (context.Instance is ViewFolder)
                {
                    if (context.PropertyDescriptor.Name == "DisplayName")
                    {
                        template = displayNameTemplate;
                        frm.ObjectForCheckSyntax = ((ReportComponent)context.Instance).Report;
                        frm.Text = "Edit display name script";
                        ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                    }
                    else if (context.PropertyDescriptor.Name == "InitScript")
                    {
                        template = razorInitScriptTemplate;
                        frm.ObjectForCheckSyntax = ((ReportComponent)context.Instance).Report;
                        frm.Text = "Edit the script executed when the report is initialized";
                        ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                    }
                }
                else if (context.Instance is ReportElement)
                {
                    ReportElement element = context.Instance as ReportElement;
                    if (context.PropertyDescriptor.Name == "CellScript")
                    {
                        frm.Text = "Edit custom script for the cell";
                        template = razorCellScriptTemplate;
                        List <string> samples = new List <string>();
                        foreach (var sample in razorCellScriptSamples)
                        {
                            samples.Add("@using Seal.Model\r\n@{\r\n\t//" + sample.Item1 + "\r\n\tResultCell cell=Model;\r\n\tReportElement element = cell.Element;\r\n\tReportModel reportModel = element.Model;\r\n\tReport report = reportModel.Report;\r\n\t" + sample.Item2 + "}\r\n|" + sample.Item1);
                        }
                        frm.SetSamples(samples);

                        frm.ObjectForCheckSyntax = new ResultCell();
                        ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                    }
                    else if (context.PropertyDescriptor.Name == "SQL")
                    {
                        frm.Text = "Edit custom SQL";
                        ScintillaHelper.Init(frm.textBox, Lexer.Sql);
                        template = element.RawSQLColumn;
                        List <string> samples = new List <string>();
                        samples.Add(element.RawSQLColumn);
                        if (!string.IsNullOrEmpty(element.SQL) && !samples.Contains(element.SQL))
                        {
                            samples.Add(element.SQL);
                        }
                        frm.SetSamples(samples);
                        frm.textBox.WrapMode = WrapMode.Word;
                    }
                    else if (context.PropertyDescriptor.Name == "CellCss")
                    {
                        frm.Text = "Edit custom CSS";
                        ScintillaHelper.Init(frm.textBox, Lexer.Css);
                        List <string> samples = new List <string>();
                        samples.Add("text-align:right;");
                        samples.Add("text-align:center;");
                        samples.Add("text-align:left;");
                        samples.Add("font-style:italic;");
                        samples.Add("font-weight:bold;color:red;background-color:yellow;");
                        samples.Add("color:green;text-align:right;|color:black;|font-weight:bold;color:red;text-align:right;");
                        samples.Add("white-space: nowrap;");
                        frm.SetSamples(samples);
                        frm.textBox.WrapMode = WrapMode.Word;
                    }
                }
                else if (context.Instance is MetaColumn)
                {
                    if (context.PropertyDescriptor.Name == "Name")
                    {
                        frm.Text = "Edit column name";
                        ScintillaHelper.Init(frm.textBox, Lexer.Sql);
                        frm.textBox.WrapMode = WrapMode.Word;
                    }
                }
                else if (context.Instance is SealSecurity)
                {
                    if (context.PropertyDescriptor.Name == "Script" || context.PropertyDescriptor.Name == "ProviderScript")
                    {
                        template = ((SealSecurity)context.Instance).ProviderScript;
                        frm.ObjectForCheckSyntax = new SecurityUser(null);
                        frm.Text = "Edit security script";
                        ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                    }
                }
                else if (context.Instance is MetaTable)
                {
                    if (context.PropertyDescriptor.Name == "DefinitionScript")
                    {
                        template = razorTableDefinitionScriptTemplate;
                        frm.ObjectForCheckSyntax = context.Instance;
                        frm.Text = "Edit the script to define the table";
                        ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                    }
                    else if (context.PropertyDescriptor.Name == "LoadScript")
                    {
                        template = razorTableLoadScriptTemplate;
                        frm.ObjectForCheckSyntax = context.Instance;
                        frm.Text = "Edit the default script to load the table";
                        ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                    }
                }
                else if (context.Instance is ReportModel)
                {
                    if (context.PropertyDescriptor.Name == "PreLoadScript")
                    {
                        template = razorModelPreLoadScriptTemplateNoSQL;
                        frm.ObjectForCheckSyntax = context.Instance;
                        frm.Text = "Edit the script executed before table load";
                        ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                    }
                    else if (context.PropertyDescriptor.Name == "FinalScript")
                    {
                        template = razorTableFinalScriptTemplate;
                        frm.ObjectForCheckSyntax = context.Instance;
                        frm.Text = "Edit the final script executed for the model";
                        ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                    }
                    else if (context.PropertyDescriptor.Name == "LoadScript")
                    {
                        if (((ReportModel)context.Instance).Source.IsNoSQL)
                        {
                            frm.Text = "Edit the script executed after table load";
                            template = razorModelLoadScriptTemplateNoSQL;
                        }
                        else
                        {
                            frm.Text = "Edit the script to load the table";
                            template = razorModelLoadScriptTemplate;
                        }
                        frm.ObjectForCheckSyntax = context.Instance;
                        ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                    }
                }
                else if (context.Instance is MetaSource && context.PropertyDescriptor.Name == "InitScript")
                {
                    template = razorSourceInitScriptTemplate;
                    frm.ObjectForCheckSyntax = context.Instance;
                    frm.Text = "Edit the init script of the source";
                    ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                }
                else if (context.Instance is TasksFolder)
                {
                    if (context.PropertyDescriptor.Name == "TasksScript")
                    {
                        template = razorTasksTemplate;
                        frm.ObjectForCheckSyntax = new ReportTask();
                        if (CurrentEntity is Report)
                        {
                            frm.ScriptHeader  = ((Report)CurrentEntity).Repository.Configuration.CommonScriptsHeader;
                            frm.ScriptHeader += ((Report)CurrentEntity).Repository.Configuration.TasksScript;
                            frm.ScriptHeader += ((Report)CurrentEntity).CommonScriptsHeader;
                        }
                        frm.Text = "Edit the script that will be added to all task scripts";
                        ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                    }
                }
                else if (context.Instance is CommonScript)
                {
                    template = CommonScript.RazorTemplate;
                    frm.Text = "Edit the script that will be added to all scripts executed for the report.";
                    if (CurrentEntity is SealServerConfiguration)
                    {
                        //common script from configuration
                        frm.ScriptHeader = ((SealServerConfiguration)CurrentEntity).GetCommonScriptsHeader((CommonScript)context.Instance);
                    }
                    if (CurrentEntity is Report)
                    {
                        //common script from report
                        frm.ScriptHeader  = ((Report)CurrentEntity).Repository.Configuration.CommonScriptsHeader;
                        frm.ScriptHeader += ((Report)CurrentEntity).GetCommonScriptsHeader((CommonScript)context.Instance);
                    }
                    frm.ObjectForCheckSyntax = CurrentEntity;
                    ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                }
                else if (context.Instance is SealServerConfiguration)
                {
                    //use report tag to store current config
                    var report = new Report();
                    report.Tag = context.Instance;
                    if (context.PropertyDescriptor.Name == "InitScript")
                    {
                        template = razorConfigurationInitScriptTemplate;
                        frm.ObjectForCheckSyntax = report;
                        frm.Text = "Edit the root init script";
                        ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                    }
                    else if (context.PropertyDescriptor.Name == "TasksScript")
                    {
                        template                 = razorTasksTemplate;
                        frm.ScriptHeader         = ((SealServerConfiguration)context.Instance).CommonScriptsHeader;
                        frm.ObjectForCheckSyntax = new ReportTask();
                        frm.Text                 = "Edit the script that will be added to all task scripts";
                        ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                    }
                    else if (context.PropertyDescriptor.Name == "ReportCreationScript")
                    {
                        template = razorConfigurationReportCreationScriptTemplate;
                        frm.ObjectForCheckSyntax = report;
                        frm.Text = "Edit the script executed when a new report is created";
                        ScintillaHelper.Init(frm.textBox, Lexer.Cpp);
                    }
                }

                if (!string.IsNullOrEmpty(template) && string.IsNullOrWhiteSpace(valueToEdit) && !context.PropertyDescriptor.IsReadOnly)
                {
                    valueToEdit = template;
                }

                //Reset button
                if (!string.IsNullOrEmpty(template) && !context.PropertyDescriptor.IsReadOnly)
                {
                    frm.SetResetText(template);
                }

                frm.textBox.Text = valueToEdit.ToString();

                if (context.PropertyDescriptor.IsReadOnly)
                {
                    frm.textBox.ReadOnly           = true;
                    frm.okToolStripButton.Visible  = false;
                    frm.cancelToolStripButton.Text = "Close";
                }
                frm.checkSyntaxToolStripButton.Visible = (frm.ObjectForCheckSyntax != null);

                if (svc.ShowDialog(frm) == DialogResult.OK)
                {
                    if (string.IsNullOrEmpty(template))
                    {
                        template = "";
                    }

                    if (frm.textBox.Text.Trim() != template.Trim() || string.IsNullOrEmpty(template))
                    {
                        value = frm.textBox.Text;
                    }
                    else if (frm.textBox.Text.Trim() == template.Trim() && !string.IsNullOrEmpty(template))
                    {
                        value = "";
                    }
                }
            }
            return(value);
        }