/// <summary> /// Constructor with parameters</summary> /// <param name="fileType">File type (a string like "Text", "Lua", etc)</param> /// <param name="extension">Extension</param> /// <param name="imageName">Name of image file for editor's Open icon</param> /// <param name="bOpenEverything">Whether to open all documents</param> /// <param name="syntaxHighlighter">SledDocumentSyntaxHighlighter</param> /// <param name="embeddedTypes">SledDocumentEmbeddedTypeInfo array</param> public SledDocumentClient(string fileType, string extension, string imageName, bool bOpenEverything, SledDocumentSyntaxHighlighter syntaxHighlighter, params SledDocumentEmbeddedTypeInfo[] embeddedTypes) { Info = new DocumentClientInfo(fileType, extension, null, null) { NewIconName = imageName, OpenIconName = imageName }; if (bOpenEverything) { if (s_catchAllClient != null) { throw new InvalidOperationException("catch-all ISledDocumentClient already set"); } s_catchAllClient = this; } SyntaxHighlighter = syntaxHighlighter; EmbeddedTypes = new List <SledDocumentEmbeddedTypeInfo>( embeddedTypes); }
/// <summary> /// Set the ISyntaxEditorControl to use highlighting from the SledDocumentSyntaxHighlighter</summary> /// <param name="highlighter">SledDocumentSyntaxHighlighter to use</param> /// <param name="syntaxEditor">ISyntaxEditorControl</param> public static void FeedHighlighterToSyntaxEditor(SledDocumentSyntaxHighlighter highlighter, ISyntaxEditorControl syntaxEditor) { if (syntaxEditor == null) { return; } var bSuccess = false; try { if (highlighter == null) { return; } if (highlighter.Highlighter == null) { return; } var hl = highlighter.Highlighter; if (hl is Languages) { syntaxEditor.SetLanguage((Languages)hl); bSuccess = true; } else if (hl is Stream) { syntaxEditor.SetLanguage((Stream)hl); bSuccess = true; } else if (hl is LanguageStreamPair) { var pair = (LanguageStreamPair)hl; syntaxEditor.SetLanguage(pair.BaseLanguage, pair.LanguageDefinition); bSuccess = true; } } catch (Exception) { bSuccess = false; } finally { if (!bSuccess) { syntaxEditor.SetLanguage(Languages.Text); } } }
/// <summary> /// Set the ISyntaxEditorControl to use highlighting from the SledDocumentSyntaxHighlighter</summary> /// <param name="highlighter">SledDocumentSyntaxHighlighter to use</param> /// <param name="syntaxEditor">ISyntaxEditorControl</param> public static void FeedHighlighterToSyntaxEditor(SledDocumentSyntaxHighlighter highlighter, ISyntaxEditorControl syntaxEditor) { if (syntaxEditor == null) return; var bSuccess = false; try { if (highlighter == null) return; if (highlighter.Highlighter == null) return; var hl = highlighter.Highlighter; if (hl is Languages) { syntaxEditor.SetLanguage((Languages)hl); bSuccess = true; } else if (hl is Stream) { syntaxEditor.SetLanguage((Stream)hl); bSuccess = true; } else if (hl is LanguageStreamPair) { var pair = (LanguageStreamPair)hl; syntaxEditor.SetLanguage(pair.BaseLanguage, pair.LanguageDefinition); bSuccess = true; } } catch (Exception) { bSuccess = false; } finally { if (!bSuccess) syntaxEditor.SetLanguage(Languages.Text); } }
/// <summary> /// Constructor with parameters</summary> /// <param name="fileType">File type (a string like "Text", "Lua", etc)</param> /// <param name="extension">Extension</param> /// <param name="imageName">Name of image file for editor's Open icon</param> /// <param name="bOpenEverything">Whether to open all documents</param> /// <param name="syntaxHighlighter">SledDocumentSyntaxHighlighter</param> /// <param name="embeddedTypes">SledDocumentEmbeddedTypeInfo array</param> public SledDocumentClient(string fileType, string extension, string imageName, bool bOpenEverything, SledDocumentSyntaxHighlighter syntaxHighlighter, params SledDocumentEmbeddedTypeInfo[] embeddedTypes) { Info = new DocumentClientInfo(fileType, extension, null, null) { NewIconName = imageName, OpenIconName = imageName }; if (bOpenEverything) { if (s_catchAllClient != null) throw new InvalidOperationException("catch-all ISledDocumentClient already set"); s_catchAllClient = this; } SyntaxHighlighter = syntaxHighlighter; EmbeddedTypes = new List<SledDocumentEmbeddedTypeInfo>( embeddedTypes); }
/// <summary> /// Constructor with parameters</summary> /// <param name="fileType">File type (a string like "Text", "Lua", etc)</param> /// <param name="extension">Extension</param> /// <param name="imageName">Name of image file for editor's Open icon</param> /// <param name="syntaxHighlighter">SledDocumentSyntaxHighlighter</param> /// <param name="embeddedTypes">SledDocumentEmbeddedTypeInfo array</param> public SledDocumentClient(string fileType, string extension, string imageName, SledDocumentSyntaxHighlighter syntaxHighlighter, params SledDocumentEmbeddedTypeInfo[] embeddedTypes) : this(fileType, extension, imageName, false, syntaxHighlighter, embeddedTypes) { }