Spell checker fix
This commit is contained in:
parent
45a5ea5263
commit
f66289aacf
@ -12,6 +12,7 @@ using System.IO;
|
|||||||
using Volian.Controls.Library;
|
using Volian.Controls.Library;
|
||||||
using VEPROMS.CSLA.Library;
|
using VEPROMS.CSLA.Library;
|
||||||
using C1.Win.C1FlexGrid;
|
using C1.Win.C1FlexGrid;
|
||||||
|
using C1.Win.C1SpellChecker;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
@ -22,6 +23,14 @@ namespace Volian.Controls.Library
|
|||||||
public delegate string VlnFlexGridPasteEvent(object sender, VlnFlexGridPasteEventArgs args);
|
public delegate string VlnFlexGridPasteEvent(object sender, VlnFlexGridPasteEventArgs args);
|
||||||
public partial class VlnFlexGrid : C1.Win.C1FlexGrid.C1FlexGrid
|
public partial class VlnFlexGrid : C1.Win.C1FlexGrid.C1FlexGrid
|
||||||
{
|
{
|
||||||
|
private C1SpellChecker _SpellChecker;
|
||||||
|
|
||||||
|
public C1SpellChecker SpellChecker
|
||||||
|
{
|
||||||
|
get { return _SpellChecker; }
|
||||||
|
set { _SpellChecker = value; }
|
||||||
|
}
|
||||||
|
|
||||||
public static GridCopyInfo MyCopyInfo = new GridCopyInfo();
|
public static GridCopyInfo MyCopyInfo = new GridCopyInfo();
|
||||||
private Color _DefaultCellBackgroundcolor;
|
private Color _DefaultCellBackgroundcolor;
|
||||||
|
|
||||||
@ -633,6 +642,7 @@ namespace Volian.Controls.Library
|
|||||||
_tableCellEditor = new TableCellEditor(this);
|
_tableCellEditor = new TableCellEditor(this);
|
||||||
_tableCellEditor.HeightChanged += new StepRTBEvent(_tableCellEditor_HeightChanged);
|
_tableCellEditor.HeightChanged += new StepRTBEvent(_tableCellEditor_HeightChanged);
|
||||||
_clpbrdCpyPste = new TableClipBoardFuncts();
|
_clpbrdCpyPste = new TableClipBoardFuncts();
|
||||||
|
_SpellChecker = _tableCellEditor.SpellCheckerInstance;
|
||||||
|
|
||||||
this.AfterResizeRow += new C1.Win.C1FlexGrid.RowColEventHandler(this.Grid_AfterResize);
|
this.AfterResizeRow += new C1.Win.C1FlexGrid.RowColEventHandler(this.Grid_AfterResize);
|
||||||
this.StartEdit += new C1.Win.C1FlexGrid.RowColEventHandler(this._StartEdit);
|
this.StartEdit += new C1.Win.C1FlexGrid.RowColEventHandler(this._StartEdit);
|
||||||
@ -814,15 +824,14 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
// it does, so draw background
|
// it does, so draw background
|
||||||
e.DrawCell(DrawCellFlags.Background);
|
e.DrawCell(DrawCellFlags.Background);
|
||||||
|
// Please add a comment if this value needs to be changed
|
||||||
|
_rtf.Rtf = rtfText;
|
||||||
if (rtfText.StartsWith(@"{\rtf"))
|
if (rtfText.StartsWith(@"{\rtf"))
|
||||||
{
|
{
|
||||||
|
|
||||||
// draw the RTF text
|
// draw the RTF text
|
||||||
if (e.Bounds.Width > 0 && e.Bounds.Height > 0)
|
if (e.Bounds.Width > 0 && e.Bounds.Height > 0)
|
||||||
{
|
{
|
||||||
_rtf.Width = e.Bounds.Width - 1; // This has also been -3 which matchs the rener command
|
_rtf.Width = e.Bounds.Width - 1; // This has also been -3 which matchs the rener command
|
||||||
// Please add a comment if this value nedds to be changed
|
|
||||||
_rtf.Rtf = rtfText;
|
|
||||||
CellRange cr = GetMergedRange(e.Row, e.Col);
|
CellRange cr = GetMergedRange(e.Row, e.Col);
|
||||||
cr.UserData = _rtf.Height;
|
cr.UserData = _rtf.Height;
|
||||||
int hAdjust = 0;
|
int hAdjust = 0;
|
||||||
@ -863,9 +872,31 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
_rtf.BackColor = e.Style.BackColor;
|
_rtf.BackColor = e.Style.BackColor;
|
||||||
_rtf.Render(e.Graphics, new Rectangle(e.Bounds.X + 1, e.Bounds.Y + hAdjust, e.Bounds.Width - 3, e.Bounds.Height));
|
_rtf.Render(e.Graphics, new Rectangle(e.Bounds.X + 1, e.Bounds.Y + hAdjust, e.Bounds.Width - 3, e.Bounds.Height));
|
||||||
//CellRange cr = GetCellRange(e.Row, e.Col);
|
}
|
||||||
//Console.WriteLine("ownerDraw UserData [{0},{1}] = {2}", cr.r1, cr.c1, _rtf.ContentsRectangle.Height);
|
}
|
||||||
//cr.UserData = _rtf.ContentsRectangle.Height;
|
// spell check unless (we're just measuring)
|
||||||
|
if (!e.Measuring)
|
||||||
|
{
|
||||||
|
CharRangeList errors = SpellChecker.CheckText(_rtf.Text);//(text);
|
||||||
|
// underline errors
|
||||||
|
if (errors.Count > 0)
|
||||||
|
{
|
||||||
|
CharacterRange[] ranges = new CharacterRange[1];
|
||||||
|
ranges[0] = new CharacterRange(0, 1);
|
||||||
|
Pen pn = new Pen(Color.Green, 2);
|
||||||
|
StringFormat sf = new StringFormat(e.Style.StringFormat);
|
||||||
|
sf.SetMeasurableCharacterRanges(ranges);
|
||||||
|
Rectangle rc = e.Style.GetTextRectangle(e.Bounds, null);
|
||||||
|
Region[] rgns = e.Graphics.MeasureCharacterRanges(_rtf.Text, e.Style.Font, rc, sf);//(text, e.Style.Font, rc, sf);
|
||||||
|
float btm = rgns[0].GetBounds(e.Graphics).Bottom;
|
||||||
|
float top = rgns[0].GetBounds(e.Graphics).Top;
|
||||||
|
int adj = (int)(btm - top);
|
||||||
|
for (int i = 0; i < errors.Count; i++)
|
||||||
|
{
|
||||||
|
Point ptStart = _rtf.GetPositionFromCharIndex(errors[i].Start);
|
||||||
|
Point ptEnd = _rtf.GetPositionFromCharIndex(errors[i].Start + errors[i].Length);
|
||||||
|
SquigleLine(e.Graphics, e.Bounds.Left + ptStart.X, e.Bounds.Top + ptStart.Y + adj, e.Bounds.Left + ptEnd.X);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// and draw border last
|
// and draw border last
|
||||||
@ -876,6 +907,20 @@ namespace Volian.Controls.Library
|
|||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SquigleLine(Graphics graphics, int x1, int y1, int x2)
|
||||||
|
{
|
||||||
|
for (Point pt = new Point(x1, y1); pt.X + 2 < x2; pt.X += 4)
|
||||||
|
{
|
||||||
|
//Console.WriteLine("squiggle point {0}", pt);
|
||||||
|
graphics.DrawLines(Pens.Red, new Point[]
|
||||||
|
{
|
||||||
|
new Point(pt.X, pt.Y),
|
||||||
|
new Point(pt.X + 2, pt.Y - 2),
|
||||||
|
new Point(pt.X + 4, pt.Y)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
private static Color _BorderColor = Color.Black;
|
private static Color _BorderColor = Color.Black;
|
||||||
public static Color BorderColor
|
public static Color BorderColor
|
||||||
{
|
{
|
||||||
@ -3965,7 +4010,6 @@ namespace Volian.Controls.Library
|
|||||||
BackColor = Color.SkyBlue;
|
BackColor = Color.SkyBlue;
|
||||||
BorderStyle = BorderStyle.None;
|
BorderStyle = BorderStyle.None;
|
||||||
ScrollBars = RichTextBoxScrollBars.None;
|
ScrollBars = RichTextBoxScrollBars.None;
|
||||||
|
|
||||||
_initializingEdit = false;
|
_initializingEdit = false;
|
||||||
_pendingKey = (char)0;
|
_pendingKey = (char)0;
|
||||||
_cancel = false;
|
_cancel = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user