protected override NetSyntaxParser CreateSyntaxParser() { NetSyntaxParser parser = new VbParser(); parser.Options = SyntaxOptions.Outline | SyntaxOptions.CodeCompletion | SyntaxOptions.SyntaxErrors | SyntaxOptions.QuickInfoTips | SyntaxOptions.SmartIndent; parser.CodeCompletionChars = SyntaxConsts.ExtendedNetCodeCompletionChars.ToCharArray(); return(parser); }
// ----------------------------------- // Refresh the UI // ----------------------------------- public override void OnRefresh() { // Fill the property grid. XmlNode UINode = XmlHelper.Find(Data, "ui"); string UIXml = "<ui/>"; if ((UINode == null) || UINode.InnerXml == "") { TabControl.TabPages.Remove(Properties); } else { if (TabControl.TabPages.Count == 1) { TabControl.TabPages.Insert(0, Properties); } UIXml = UINode.OuterXml; } GenericUI.OnLoad(Controller, NodePath, UIXml); GenericUI.OnRefresh(); PropertiesMenuItem.Checked = TabControl.TabPages.Count == 2; string scriptText = XmlHelper.Value(Data, "text"); if (scriptText.Contains("Imports ")) { TextBox.Lexer = VbParser; } else { TextBox.Lexer = CsParser; } TextBox.Text = scriptText; Assembly.LoadFile(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "CSDotNetComponentInterface.dll")); Assembly.LoadFile(Types.GetProbeInfoDLLFileName()); foreach (string @ref in XmlHelper.ValuesRecursive(Data, "reference")) { if (File.Exists(@ref)) { Assembly.LoadFile(@ref); } else if (File.Exists(RuntimeEnvironment.GetRuntimeDirectory() + @ref)) { Assembly.LoadFile(RuntimeEnvironment.GetRuntimeDirectory() + @ref); } else if (File.Exists(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), @ref))) { Assembly.LoadFile(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), @ref)); } else { MessageBox.Show("Error loading reference '" + @ref + "' - file does not exist" + Environment.NewLine + "Tried:" + Environment.NewLine + @ref + Environment.NewLine + RuntimeEnvironment.GetRuntimeDirectory() + @ref + Environment.NewLine + Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), @ref)); } } CsParser.RegisterAllAssemblies(); VbParser.RegisterAllAssemblies(); int[] TabStops = { 3 }; TextBox.Lines.TabStops = TabStops; TextBox.Lines.UseSpaces = true; // restore the scrolling and cursor position for the textbox CursorPos pos; if (positions.TryGetValue(this.NodePath, out pos)) { TextBox.MoveToLine(pos.TopLine, 0); // ensure that the cursor is only set if it was in view if (pos.TopLine < TextBox.Source.GetPositionFromCharIndex(pos.CharIndex).Y) { TextBox.Selection.SelectionStart = pos.CharIndex; } TextBox.Selection.SelectionLength = 0; } TextBox.Focus(); // this doesn't really work because the system tinkers with a few other controls // after this procedure and then the textbox loses focus anyway. It would // be good to find a solution for this. }