Example #1
0
        public HtmlDoc()
        {
            InitializeComponent();
            this.IsMdiContainer = false;

            // Create and attach Plug-Ins
            this.tableDesigner1 = new GuruComponents.Netrix.TableDesigner.TableDesigner(this.components);
            this.speller1       = new GuruComponents.Netrix.SpellChecker.Speller(this.components);

            // create the netspell instance, connect to property bag and register with one editor instance
            IDocumentSpellChecker  doc        = this.speller1.GetSpellChecker(htmlEditor1);
            SpellCheckerProperties spellProps = new SpellCheckerProperties(doc);

            this.speller1.SetSpeller(htmlEditor1, spellProps);

            this.helpLine1 = new GuruComponents.Netrix.HelpLine.HelpLine(this.components);
            this.helpLine1.SetHelpLine(htmlEditor1, new HelpLineProperties());
            this.helpLine2 = new GuruComponents.Netrix.HelpLine.HelpLine(this.components);
            this.helpLine2.SetHelpLine(htmlEditor1, new HelpLineProperties());

            // Here we register the plug-in as an extender with the control
            this.tableDesigner1.SetTableDesigner(htmlEditor1, new TableDesignerProperties());
            // Setting properties requires retrieving the propertybag using the editor as a key. That way one plug-in can support multiple editor instances.
            // commands defined by the plug-in can be send through the Invoke method
            this.tableDesigner1.GetTableDesigner(htmlEditor1).Active = true;

            // The spellchecker has two bags, 'GetSpellChecker' provides direct access to commands. Invoke is just an alternative way.
            doc.BackgroundService = false;
            // 'GetSpeller' retrieves the regular property bag
            this.speller1.GetSpeller(htmlEditor1).IgnoreHtml = true;

            // 'GetHelpLine'  retrieves the regular property bag
            this.helpLine2.GetHelpLine(htmlEditor1).LineVisible = false;
            this.helpLine2.GetHelpLine(htmlEditor1).LineColor   = Color.Blue;
            this.helpLine2.GetHelpLine(htmlEditor1).X           = 100;
            this.helpLine2.GetHelpLine(htmlEditor1).Y           = 100;

            this.helpLine1.GetHelpLine(htmlEditor1).LineVisible = false;
            this.helpLine1.GetHelpLine(htmlEditor1).LineColor   = Color.Red;
            this.helpLine1.GetHelpLine(htmlEditor1).X           = 30;
            this.helpLine1.GetHelpLine(htmlEditor1).Y           = 30;
            // some plug-ins support events
            helpLine1.HelpLineMoving += new GuruComponents.Netrix.HelpLine.Events.HelpLineMoving(helpLine1_HelpLineMoving);
            helpLine1.HelpLineMoved  += new GuruComponents.Netrix.HelpLine.Events.HelpLineMoved(helpLine1_HelpLineMoved);

            tableDesigner1.TableBecomesActive   += new TableEventBecomesActiveHandler(tableDesigner1_TableBecomesActive);
            tableDesigner1.TableBecomesInactive += new TableEventBecomesInactiveHandler(tableDesigner1_TableBecomesInactive);

            speller1.WordChecker    += new GuruComponents.Netrix.SpellChecker.WordCheckerHandler(speller1_WordChecker);
            speller1.WordOnContext  += new GuruComponents.Netrix.SpellChecker.WordOnContextHandler(speller1_WordOnContext);
            speller1.MisspelledWord += new GuruComponents.Netrix.SpellChecker.WordEventHandler(speller1_MisspelledWord);
            speller1.EndOfText      += new GuruComponents.Netrix.SpellChecker.WordEventHandler(speller1_EndOfText);
            speller1.DoubledWord    += new GuruComponents.Netrix.SpellChecker.WordEventHandler(speller1_DoubledWord);

            // some plug-ins have methods that act as shortcuts
            tableDesigner1.SetActive(htmlEditor1, true);
            // other controls are just regular user controls
            codeEditorControl1.Document.SyntaxFile = @"Resources\Syntaxfile\HTML.syn";
        }
        /// <summary>
        /// Constructor for properties with backreference parameter to spellchecker instance.
        /// </summary>
        /// <param name="documentSpellChecker">Spellchecker instance this property instance refers to.</param>
        public SpellCheckerProperties(IDocumentSpellChecker documentSpellChecker)
        {
            this.documentSpellChecker = (DocumentSpellChecker)documentSpellChecker;
            // default for spellchecking
            HighlightColor  hc = HighlightColor.Color(Color.Red);
            UnderlineStyle  us = UnderlineStyle.Wave;
            IHighLightStyle hs = new HighLightStyle();

            hs.LineColor      = hc;
            hs.UnderlineStyle = us;
            this.documentSpellChecker.HighLightStyle = hs;
            ignoreWordsWithDigits = true;
            ignoreUpperCaseWords  = true;
            maxSuggestionsCount   = 25;
            ignoreHtml            = true;
            ignoreList            = new List <string>();
            replaceList           = new Dictionary <string, string>();
            checkInternal         = true;
            if (String.IsNullOrEmpty(this.Dictionary))
            {
                this.Dictionary = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
            }
        }