Exemple #1
0
        public CustomPaintTextBox(TextBoxBase clientTextBox, SpellChecker checker)
        {
            //Set up the CustomPaintTextBox
            this.clientTextBox = clientTextBox;
            this.mySpellChecker = checker;

            //Create a bitmap with the same dimensions as the textbox
            myBitmap = new Bitmap(clientTextBox.Width, clientTextBox.Height);

            //Create the graphics object from this bitmpa...this is where we will draw the lines to start with
            bufferGraphics = Graphics.FromImage(this.myBitmap);
            bufferGraphics.Clip = new Region(clientTextBox.ClientRectangle);

            //Get the graphics object for the textbox.  We use this to draw the bufferGraphics
            textBoxGraphics = Graphics.FromHwnd(clientTextBox.Handle);

            //Assign a handle for this class and set it to the handle for the textbox
            this.AssignHandle(clientTextBox.Handle);

            //We also need to make sure we update the handle if the handle for the textbox changes
            //This occurs if wordWrap is turned off for a RichTextBox
            clientTextBox.HandleCreated += TextBoxBase_HandleCreated;

            //We need to add a handler to change the clip rectangle if the textBox is resized
            clientTextBox.ClientSizeChanged += TextBoxBase_ClientSizeChanged;

            //this.disposedValue = false;
        }
Exemple #2
0
        protected override void toolStripButtonSpellCheck_Click(object sender, EventArgs e)
        {
            string localeId = null;

            if (LookupISO_3_1_Codes.ContainsKey(curLangCode))
            {
                localeId = LookupISO_3_1_Codes[curLangCode];
            }
            else if (LookupISO_3_1_Codes.ContainsKey(curLangCode.Substring(0, 3)))
            {
                localeId = LookupISO_3_1_Codes[curLangCode.Substring(0, 3)];
            }

            if (localeId == null)
            {
                MessageBox.Show("Need to add an entry in Data/ISO639-1.xml file.");
                return;
            }

            sp = new SpellChecker(this.textBox1, localeId);

            if (this.toolStripButtonSpellCheck.Checked)
            {
                sp.EnableSpellCheck();
            }
            else
            {
                sp.DisableSpellCheck();
            }
            this.textBox1.Refresh();
        }
Exemple #3
0
        // IDisposable
        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposedValue & disposing)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).

                    if (clientTextBox != null)
                    {
                        this.ReleaseHandle();

                        clientTextBox.Invalidate();

                        clientTextBox.HandleCreated -= TextBoxBase_HandleCreated;
                        clientTextBox.ClientSizeChanged -= TextBoxBase_ClientSizeChanged;

                        clientTextBox.Dispose();
                        clientTextBox = null;
                    }

                    if (myBitmap != null)
                    {
                        myBitmap.Dispose();
                        myBitmap = null;
                    }

                    if (textBoxGraphics != null)
                    {
                        textBoxGraphics.Dispose();
                        textBoxGraphics = null;
                    }

                    if (bufferGraphics != null)
                    {
                        bufferGraphics.Dispose();
                        bufferGraphics = null;
                    }

                    if (mySpellChecker != null)
                    {
                        mySpellChecker = null;
                    }
                }

                // TODO: free unmanaged resources (unmanaged objects) and override Finalize() below.
                // TODO: set large fields to null.
            }
            this.disposedValue = true;
        }