示例#1
0
 private void m_rScintilla_TextArea_DwellEnd(object sender, DwellEventArgs e)
 {
     m_rScintilla_TextArea.CallTipCancel();
 }
    /// <summary>
    /// Show a tooltip with information about the entered object method or property.
    /// </summary>
    /// <param name="scintilla"></param>
    /// <param name="reader">Jolt's XmlDocCommentReader instance, to get and display comments from assembly-generated XML file.</param>
    /// <remarks></remarks>
    public static void ShowToolTip(this ScintillaNET.Scintilla scintilla, Jolt.XmlDocCommentReader reader)
    {
        //parses the last keyword (object) (before the ".") and get suggestions for the autocomplete box from its properties and methods

        string [] splitters =
        {
            ".",
            "(",
            ")",
            " ",
            "\r",
            "\n",
            "\r\n"
        };

        dynamic text     = ScintillaExtender.getLastWord(scintilla).Split(splitters, StringSplitOptions.RemoveEmptyEntries);
        dynamic lastchar = Convert.ToChar(scintilla.GetCharAt(scintilla.CurrentPosition));

        string helptext = "";

        if (text.Length >= 2)
        {
            string lastkeyword = text[text.Length - 1];
            string lastobj     = text[text.Length - 2].Trim();
            //string obj = Convert.ToString(lastobj));
            switch (lastobj)
            {
            case "Browser":
                dynamic prop = typeof(TopDown_QA_FrameWork.Driver).GetMember(lastkeyword);
                if (prop.Length > 0)
                {
                    helptext = ScintillaExtender.FormatHelpTip(scintilla, prop[0], reader);
                }
                break;

            case "ims1":
            case "ims2":
            case "ims3":
            case "ims4":
            case "ims5":
            case "ims6":
            case "oms1":
            case "oms2":
            case "oms3":
            case "oms4":
            case "oms5":
            case "MaterialStream":
                prop = Type.GetType("DWSIM.DWSIM.SimulationObjects.Streams.MaterialStream").GetMember(lastkeyword);
                if (prop.Length > 0)
                {
                    helptext = ScintillaExtender.FormatHelpTip(scintilla, prop[0], reader);
                }
                break;

            case "ies1":
            case "oes1":
            case "EnergyStream":
                prop = Type.GetType("DWSIM.DWSIM.SimulationObjects.Streams.EnergyStream").GetMember(lastkeyword);
                if (prop.Length > 0)
                {
                    helptext = ScintillaExtender.FormatHelpTip(scintilla, prop[0], reader);
                }
                break;

            case "Flowsheet":
                prop = Type.GetType("DWSIM.FormFlowsheet").GetMember(lastkeyword);
                if (prop.Length > 0)
                {
                    helptext = ScintillaExtender.FormatHelpTip(scintilla, prop[0], reader);
                }
                break;

            case "Spreadsheet":
                prop = Type.GetType("DWSIM.SpreadsheetForm").GetMember(lastkeyword);
                if (prop.Length > 0)
                {
                    helptext = ScintillaExtender.FormatHelpTip(scintilla, prop[0], reader);
                }
                break;

            case "PropertyPackage":
                prop = Type.GetType("DWSIM.DWSIM.SimulationObjects.PropertyPackages.PropertyPackage").GetMember(lastkeyword);
                if (prop.Length > 0)
                {
                    helptext = ScintillaExtender.FormatHelpTip(scintilla, prop[0], reader);
                }
                break;

            case "UnitOp":
            case "Me":
                prop = Type.GetType("DWSIM.SimulationObjects_UnitOpBaseClass").GetMember(lastkeyword);
                if (prop.Length > 0)
                {
                    helptext = ScintillaExtender.FormatHelpTip(scintilla, prop(0), reader);
                }
                break;

            case "Solver":
                prop = Type.GetType("DWSIM.DWSIM.Flowsheet.FlowsheetSolver").GetMember(lastkeyword);
                if (prop.Length > 0)
                {
                    helptext = ScintillaExtender.FormatHelpTip(scintilla, prop(0), reader);
                }
                break;
            }

            //shows the tooltip

            if (!string.IsNullOrEmpty(helptext))
            {
                scintilla.CallTipShow(scintilla.CurrentPosition, helptext);
            }
            else
            {
                scintilla.CallTipCancel();
            }
        }
        else
        {
            //hides tooltip if visible

            scintilla.CallTipCancel();
        }
    }