/// <summary>
    /// Sets the editor style for Python language.
    /// </summary>
    /// <param name="scintilla"></param>
    /// <param name="fontname">Name of the font to be used.</param>
    /// <param name="fontsize">Size of the font to be used.</param>
    /// <param name="viewspaces">Enables or disables whitspace highlighting.</param>
    /// <remarks></remarks>
    public static void SetEditorStyle(this ScintillaNET.Scintilla scintilla, string fontname, int fontsize, bool viewspaces)
    {
        scintilla.StyleResetDefault();
        scintilla.Styles[Style.Default].Font = fontname;
        scintilla.Styles[Style.Default].Size = fontsize;
        scintilla.StyleClearAll();

        // i.e. Apply to all
        // Set the lexer

        scintilla.Lexer = Lexer.Python;

        // Known lexer properties:
        // "tab.timmy.whinge.level",
        // "lexer.python.literals.binary",
        // "lexer.python.strings.u",
        // "lexer.python.strings.b",
        // "lexer.python.strings.over.newline",
        // "lexer.python.keywords2.no.sub.identifiers",
        // "fold.quotes.python",
        // "fold.compact",
        // "fold"

        // Some properties we like

        scintilla.SetProperty("tab.timmy.whinge.level", "1");
        scintilla.SetProperty("fold", "1");

        scintilla.Margins[0].Width = 20;

        // Use margin 2 for fold markers

        scintilla.Margins[1].Type      = MarginType.Symbol;
        scintilla.Margins[1].Mask      = Marker.MaskFolders;
        scintilla.Margins[1].Sensitive = true;
        scintilla.Margins[1].Width     = 20;

        // Reset folder markers

        for (int i = Marker.FolderEnd; i <= Marker.FolderOpen; i++)
        {
            scintilla.Markers[i].SetForeColor(SystemColors.ControlLightLight);
            scintilla.Markers[i].SetBackColor(SystemColors.ControlDark);
        }

        // Style the folder markers

        scintilla.Markers[Marker.Folder].Symbol = MarkerSymbol.BoxPlus;
        scintilla.Markers[Marker.Folder].SetBackColor(SystemColors.ControlText);
        scintilla.Markers[Marker.FolderOpen].Symbol = MarkerSymbol.BoxMinus;
        scintilla.Markers[Marker.FolderEnd].Symbol  = MarkerSymbol.BoxPlusConnected;
        scintilla.Markers[Marker.FolderEnd].SetBackColor(SystemColors.ControlText);
        scintilla.Markers[Marker.FolderMidTail].Symbol = MarkerSymbol.TCorner;
        scintilla.Markers[Marker.FolderOpenMid].Symbol = MarkerSymbol.BoxMinusConnected;
        scintilla.Markers[Marker.FolderSub].Symbol     = MarkerSymbol.VLine;
        scintilla.Markers[Marker.FolderTail].Symbol    = MarkerSymbol.LCorner;

        // Enable automatic folding

        scintilla.AutomaticFold = (AutomaticFold.Show | AutomaticFold.Click | AutomaticFold.Change);

        // Set the styles

        scintilla.Styles[Style.Python.Default].ForeColor      = Color.FromArgb(0x80, 0x80, 0x80);
        scintilla.Styles[Style.Python.CommentLine].ForeColor  = Color.FromArgb(0x0, 0x7f, 0x0);
        scintilla.Styles[Style.Python.CommentLine].Italic     = true;
        scintilla.Styles[Style.Python.Number].ForeColor       = Color.FromArgb(0x0, 0x7f, 0x7f);
        scintilla.Styles[Style.Python.String].ForeColor       = Color.FromArgb(0x7f, 0x0, 0x7f);
        scintilla.Styles[Style.Python.Character].ForeColor    = Color.FromArgb(0x7f, 0x0, 0x7f);
        scintilla.Styles[Style.Python.Word].ForeColor         = Color.FromArgb(0x0, 0x0, 0x7f);
        scintilla.Styles[Style.Python.Word].Bold              = true;
        scintilla.Styles[Style.Python.Triple].ForeColor       = Color.FromArgb(0x7f, 0x0, 0x0);
        scintilla.Styles[Style.Python.TripleDouble].ForeColor = Color.FromArgb(0x7f, 0x0, 0x0);
        scintilla.Styles[Style.Python.ClassName].ForeColor    = Color.FromArgb(0x0, 0x0, 0xff);
        scintilla.Styles[Style.Python.ClassName].Bold         = true;
        scintilla.Styles[Style.Python.DefName].ForeColor      = Color.FromArgb(0x0, 0x7f, 0x7f);
        scintilla.Styles[Style.Python.DefName].Bold           = true;
        scintilla.Styles[Style.Python.Operator].Bold          = true;
        scintilla.Styles[Style.Python.CommentBlock].ForeColor = Color.FromArgb(0x7f, 0x7f, 0x7f);
        scintilla.Styles[Style.Python.CommentBlock].Italic    = true;
        scintilla.Styles[Style.Python.StringEol].ForeColor    = Color.FromArgb(0x0, 0x0, 0x0);
        scintilla.Styles[Style.Python.StringEol].BackColor    = Color.FromArgb(0xe0, 0xc0, 0xe0);
        scintilla.Styles[Style.Python.StringEol].FillLine     = true;

        scintilla.Styles[Style.Python.DefName].ForeColor = Color.Brown;
        scintilla.Styles[Style.Python.DefName].Bold      = true;

        scintilla.Styles[Style.Python.Word2].ForeColor = Color.DarkRed;
        scintilla.Styles[Style.Python.Word2].Bold      = true;

        var _with1 = scintilla.Styles[Style.CallTip];

        _with1.Font      = fontname;
        _with1.Size      = fontsize - 2;
        _with1.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText);

        if (viewspaces)
        {
            scintilla.ViewWhitespace = WhitespaceMode.VisibleAfterIndent;
        }

        // Keyword lists:
        // 0 "Keywords",
        // 1 "Highlighted identifiers"

        dynamic python2 = "and as assert break class continue def del elif else except exec finally for from global if import in is lambda not or pass print raise return try while with yield";
        dynamic python3 = "False None True and as assert break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield";

        //add keywords from DWSIM classes properties and methods

        string netprops = "";

        dynamic props = Type.GetType("DWSIM.DWSIM.SimulationObjects.Streams.MaterialStream").GetProperties();

        foreach (var p_loopVariable in props)
        {
            var p = p_loopVariable;
            netprops += p.Name + " ";
        }
        dynamic methods = Type.GetType("DWSIM.DWSIM.SimulationObjects.Streams.MaterialStream").GetMethods();

        foreach (var m_loopVariable in methods)
        {
            var m = m_loopVariable;
            netprops += m.Name + " ";
        }
        props = Type.GetType("DWSIM.DWSIM.SimulationObjects.Streams.EnergyStream").GetProperties();
        foreach (var p_loopVariable in props)
        {
            var p = p_loopVariable;
            netprops += p.Name + " ";
        }
        methods = Type.GetType("DWSIM.DWSIM.SimulationObjects.Streams.EnergyStream").GetMethods();
        foreach (var m_loopVariable in methods)
        {
            var m = m_loopVariable;
            netprops += m.Name + " ";
        }
        props = Type.GetType("DWSIM.FormFlowsheet").GetProperties();
        foreach (var p_loopVariable in props)
        {
            var p = p_loopVariable;
            if (p.PropertyType.Namespace != "System.Windows.Forms")
            {
                netprops += p.Name + " ";
            }
        }
        methods = Type.GetType("DWSIM.FormFlowsheet").GetMethods();
        foreach (var m_loopVariable in methods)
        {
            var m = m_loopVariable;
            netprops += m.Name + " ";
        }
        props = Type.GetType("DWSIM.SpreadsheetForm").GetProperties();
        foreach (var p_loopVariable in props)
        {
            var p = p_loopVariable;
            if (p.PropertyType.Namespace != "System.Windows.Forms")
            {
                netprops += p.Name + " ";
            }
        }
        methods = Type.GetType("DWSIM.SpreadsheetForm").GetMethods();
        foreach (var m_loopVariable in methods)
        {
            var m = m_loopVariable;
            netprops += m.Name + " ";
        }
        props = Type.GetType("DWSIM.DWSIM.SimulationObjects.PropertyPackages.PropertyPackage").GetProperties();
        foreach (var p_loopVariable in props)
        {
            var p = p_loopVariable;
            if (p.PropertyType.Namespace != "System.Windows.Forms")
            {
                netprops += p.Name + " ";
            }
        }
        methods = Type.GetType("DWSIM.DWSIM.SimulationObjects.PropertyPackages.PropertyPackage").GetMethods();
        foreach (var m_loopVariable in methods)
        {
            var m = m_loopVariable;
            netprops += m.Name + " ";
        }

        string objects = "";

        if ((Convert.ToInt32(scintilla.Tag)) == 1)
        {
            //editor is being used at flowsheet level.
            props = Type.GetType("DWSIM.DWSIM.Flowsheet.FlowsheetSolver").GetProperties();
            foreach (var p_loopVariable in props)
            {
                var p = p_loopVariable;
                if (p.PropertyType.Namespace != "System.Windows.Forms")
                {
                    netprops += p.Name + " ";
                }
            }
            methods = Type.GetType("DWSIM.DWSIM.Flowsheet.FlowsheetSolver").GetMethods();
            foreach (var m_loopVariable in methods)
            {
                var m = m_loopVariable;
                netprops += m.Name + " ";
            }
            objects = "MaterialStream EnergyStream PropertyPackage UnitOp Flowsheet Spreadsheet Plugins Solver DWSIM";
        }
        else
        {
            //editor is being used at script unit operation level
            objects = "ims1 ims2 ims3 ims4 ims5 ims6 ies1 oms1 oms2 oms3 oms4 oms5 oms6 oes1 Flowsheet Spreadsheet Plugins Solver Me DWSIM";
        }

        scintilla.SetKeywords(0, python2 + " " + python3);
        scintilla.SetKeywords(1, objects + " " + netprops);

        ScintillaExtender.SetColumnMargins(scintilla);
    }