Ejemplo n.º 1
0
        /// <summary>
        /// Constructor with parameters</summary>
        /// <param name="fileType">File type (a string like &quot;Text&quot;, &quot;Lua&quot;, 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);
        }
Ejemplo n.º 2
0
        /// <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);
                }
            }
        }
Ejemplo n.º 3
0
        /// <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);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructor with parameters</summary>
        /// <param name="fileType">File type (a string like &quot;Text&quot;, &quot;Lua&quot;, 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);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Constructor with parameters</summary>
 /// <param name="fileType">File type (a string like &quot;Text&quot;, &quot;Lua&quot;, 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)
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Constructor with parameters</summary>
 /// <param name="fileType">File type (a string like &quot;Text&quot;, &quot;Lua&quot;, 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)
 {
 }