Move frmErrors when frmLoader is moved
Shutoff SpellCheck for StepRTB Use using for temporary StepRTB Use using for vlnFlexGrid Added debug output to track StepRTBs and vlnFlexGrids in memory Limit bottom margin to 0 or above Dispose of roImage after it is done being used Dispose of Figure after it is done being used. Use GetJustRODB so that images are not loaded. Added ErrorHandler if annotation is deleted after a search Track create, dispose and finalize Add static variable to control if SpellCheck is used Use using for temporary StepRTB Lazy Load SelectionStack Clean-up on Dispose Track create, dispose and finalize Make MyCopyInfo Lazy Loaded Use using for temporary StepRTB Add Dispose method for TableCellEditor Cleanup on Dispose Only kill MSWord instances that are invisible
This commit is contained in:
parent
ce21565a15
commit
7bcfafcc8b
@ -118,10 +118,11 @@ namespace DataLoader
|
||||
string fixStpText = "";
|
||||
if (IsATable(content.Type))
|
||||
{
|
||||
//if (ProcNumber == "EOP-ES-1.2")
|
||||
// Console.WriteLine("here");
|
||||
bool hasBorder = !WithoutBorder(content.Type);
|
||||
fixStpText = ConvertTableToGrid(stptext, content, fmt, isROTable, hasBorder ? GridLinePattern.Single : GridLinePattern.None );
|
||||
frmMain.AddInfo("Memory After Grid Convert {0}", GC.GetTotalMemory(true)); // This will force a Garbage Collection
|
||||
frmMain.AddInfo("VlnFlexGrid Counts: {0}, {1}, {2}", VlnFlexGrid.CountCreated, VlnFlexGrid.CountNotDisposed, VlnFlexGrid.CountNotFinalized);
|
||||
frmMain.AddInfo("StepRTB Counts: {0}, {1}, {2}", StepRTB.CountCreated, StepRTB.CountNotDisposed, StepRTB.CountNotFinalized);
|
||||
int? typ = ConvertTableType(content, fmt);
|
||||
if (typ != null) content.Type = typ;
|
||||
else _ContentMigrationErrors.Add(content.ContentID, null);
|
||||
@ -372,25 +373,26 @@ namespace DataLoader
|
||||
{
|
||||
//string savethis = stepText;
|
||||
string strGrid = "";
|
||||
VlnFlexGrid grd = new VlnFlexGrid(1, 1);
|
||||
grd.IsRoTable = isROTable;
|
||||
VE_Font vefont = fmt.PlantFormat.FormatData.StepDataList.Table.Font;
|
||||
Font GridFont = new Font(vefont.Family, (float)vefont.Size);
|
||||
grd.Font = GridFont; // this also changes the default Row Height "Rows.DefaultSize"
|
||||
grd.ParseTableFromText(stepText,border);
|
||||
grd.AutoSizeCols();
|
||||
grd.AutoSizeRows();
|
||||
grd.MakeRTFcells();
|
||||
|
||||
using (StringWriter sw = new StringWriter())
|
||||
//MessageBox.Show("Before ConvertTableToGrid " + GC.GetTotalMemory(true).ToString());
|
||||
using (VlnFlexGrid grd = new VlnFlexGrid(1, 1))
|
||||
{
|
||||
grd.WriteXml(sw);
|
||||
//Console.WriteLine(sw.GetStringBuilder().ToString());
|
||||
content.MyGrid.Data = sw.GetStringBuilder().ToString();
|
||||
strGrid = grd.GetSearchableText();
|
||||
sw.Close();
|
||||
grd.IsRoTable = isROTable;
|
||||
VE_Font vefont = fmt.PlantFormat.FormatData.StepDataList.Table.Font;
|
||||
Font GridFont = new Font(vefont.Family, (float)vefont.Size);
|
||||
grd.Font = GridFont; // this also changes the default Row Height "Rows.DefaultSize"
|
||||
grd.ParseTableFromText(stepText, border);
|
||||
grd.AutoSizeCols();
|
||||
grd.AutoSizeRows();
|
||||
grd.MakeRTFcells();
|
||||
using (StringWriter sw = new StringWriter())
|
||||
{
|
||||
grd.WriteXml(sw);
|
||||
//Console.WriteLine(sw.GetStringBuilder().ToString());
|
||||
content.MyGrid.Data = sw.GetStringBuilder().ToString();
|
||||
strGrid = grd.GetSearchableText();
|
||||
sw.Close();
|
||||
}
|
||||
}
|
||||
grd.Dispose();
|
||||
return strGrid;
|
||||
}
|
||||
|
||||
|
@ -16,9 +16,13 @@ namespace DataLoader
|
||||
{
|
||||
InitializeComponent();
|
||||
_MyParent = myParent;
|
||||
_MyParent.Move += new EventHandler(_MyParent_Move);
|
||||
}
|
||||
void _MyParent_Move(object sender, EventArgs e)
|
||||
{
|
||||
AdjustLocation();
|
||||
}
|
||||
private int _ErrorCount = 0;
|
||||
|
||||
public int ErrorCount
|
||||
{
|
||||
get { return _ErrorCount; }
|
||||
@ -67,9 +71,18 @@ namespace DataLoader
|
||||
}
|
||||
private void frmErrors_Load(object sender, EventArgs e)
|
||||
{
|
||||
Rectangle rec = Screen.GetWorkingArea(this);
|
||||
AdjustLocation();
|
||||
}
|
||||
private void AdjustLocation()
|
||||
{
|
||||
int maxRight = Screen.GetWorkingArea(this).Right;
|
||||
if (Screen.AllScreens.Length > 1)
|
||||
{
|
||||
foreach (Screen sc in Screen.AllScreens)
|
||||
if (sc.WorkingArea.Right > maxRight) maxRight = sc.WorkingArea.Right;
|
||||
}
|
||||
Top = _MyParent.Top;
|
||||
Left = _MyParent.Right + Width > rec.Right ? rec.Right - Width : _MyParent.Right;
|
||||
Left = _MyParent.Right + Width > maxRight ? maxRight - Width : _MyParent.Right;
|
||||
}
|
||||
public void Save(string path)
|
||||
{
|
||||
|
@ -588,6 +588,7 @@ namespace DataLoader
|
||||
_Loading = false;
|
||||
MSWordToPDF.CloseWordWhenDone = false;
|
||||
Format.FormatLoaded += new FormatEvent(Format_FormatLoaded);
|
||||
StepRTB.DoSpellCheck = false;
|
||||
}
|
||||
void Format_FormatLoaded(object sender, FormatEventArgs args)
|
||||
{
|
||||
@ -601,21 +602,23 @@ namespace DataLoader
|
||||
//List<int> cachePdfInfo = PdfInfo.CacheList;
|
||||
//List<int> cacheDocVersionInfo = DocVersionInfo.CacheList;
|
||||
//if (!CheckLogPath()) return;
|
||||
StepRTB rtb = new StepRTB();
|
||||
TransitionFixer myFixer = new TransitionFixer(rtb,MySettings.LogFilePath);
|
||||
myFixer.StatusChanged += new TransitionFixerEvent(myFixer_StatusChanged);
|
||||
TimeSpan howlong = myFixer.Process(MySettings.CheckRTF);
|
||||
string TransFixTime = string.Format("Fix Transitions completion time: {0:D2}:{1:D2}:{2:D2}.{3}", howlong.Hours, howlong.Minutes, howlong.Seconds, howlong.Milliseconds);
|
||||
MyInfo = TransFixTime;
|
||||
if(!ProcessComplete) MessageBox.Show(string.Format("{0}\r\n\n({1} Total Seconds)", TransFixTime, howlong.TotalSeconds));
|
||||
//MessageBox.Show(string.Format("Fix Transitions completion time: {0:D2}:{1:D2}:{2:D2}.{3}\r\n\n({4} Total Seconds)", howlong.Hours, howlong.Minutes, howlong.Seconds, howlong.Milliseconds, howlong.TotalSeconds));
|
||||
CreateBackupRestoreBatchFiles();
|
||||
ItemInfo.RestoreCacheList(cacheItemInfo);
|
||||
ContentInfo.RestoreCacheList(cacheContentInfo);
|
||||
//EntryInfo.RestoreCacheList(cacheEntryInfo);
|
||||
//PdfInfo.RestoreCacheList(cachePdfInfo);
|
||||
//DocVersionInfo.RestoreCacheList(cacheDocVersionInfo);
|
||||
MyInfo = CSLACache.UsageAll;
|
||||
using (StepRTB rtb = new StepRTB())
|
||||
{
|
||||
TransitionFixer myFixer = new TransitionFixer(rtb, MySettings.LogFilePath);
|
||||
myFixer.StatusChanged += new TransitionFixerEvent(myFixer_StatusChanged);
|
||||
TimeSpan howlong = myFixer.Process(MySettings.CheckRTF);
|
||||
string TransFixTime = string.Format("Fix Transitions completion time: {0:D2}:{1:D2}:{2:D2}.{3}", howlong.Hours, howlong.Minutes, howlong.Seconds, howlong.Milliseconds);
|
||||
MyInfo = TransFixTime;
|
||||
if (!ProcessComplete) MessageBox.Show(string.Format("{0}\r\n\n({1} Total Seconds)", TransFixTime, howlong.TotalSeconds));
|
||||
//MessageBox.Show(string.Format("Fix Transitions completion time: {0:D2}:{1:D2}:{2:D2}.{3}\r\n\n({4} Total Seconds)", howlong.Hours, howlong.Minutes, howlong.Seconds, howlong.Milliseconds, howlong.TotalSeconds));
|
||||
CreateBackupRestoreBatchFiles();
|
||||
ItemInfo.RestoreCacheList(cacheItemInfo);
|
||||
ContentInfo.RestoreCacheList(cacheContentInfo);
|
||||
//EntryInfo.RestoreCacheList(cacheEntryInfo);
|
||||
//PdfInfo.RestoreCacheList(cachePdfInfo);
|
||||
//DocVersionInfo.RestoreCacheList(cacheDocVersionInfo);
|
||||
MyInfo = CSLACache.UsageAll;
|
||||
}
|
||||
}
|
||||
|
||||
void myFixer_StatusChanged(object sender, TransitionFixerEventArgs args)
|
||||
|
@ -770,16 +770,15 @@ namespace VEPROMS.CSLA.Library
|
||||
float oldRight = myDoc.PageSetup.RightMargin;
|
||||
float oldHeight = myDoc.PageSetup.PageHeight;
|
||||
float oldWidth = myDoc.PageSetup.PageWidth;
|
||||
float newRight = oldWidth - (newWidth + newLeft);
|
||||
if (newRight < 0) newRight = 0;
|
||||
float newBottom = oldBottom - newTop;
|
||||
float newRight = Math.Max(0, oldWidth - (newWidth + newLeft));
|
||||
float newBottom = Math.Max(0, oldHeight - (newLength + newTop + 1));
|
||||
//Console.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", newTop, newLeft, newLength, newWidth, oldTop, oldLeft, oldBottom, oldRight,oldHeight,oldWidth);
|
||||
if (printingMode)
|
||||
{
|
||||
if (myDoc.PageSetup.BottomMargin != 9999999)
|
||||
{
|
||||
// the + 1 in the next line allows for rounding.
|
||||
myDoc.PageSetup.BottomMargin = 11 * 72 - (newTop + newLength + 1);
|
||||
myDoc.PageSetup.BottomMargin = newBottom;
|
||||
myDoc.PageSetup.RightMargin = newRight;
|
||||
myDoc.PageSetup.LeftMargin = newLeft;
|
||||
myDoc.PageSetup.TopMargin = newTop;
|
||||
@ -789,7 +788,7 @@ namespace VEPROMS.CSLA.Library
|
||||
try
|
||||
{
|
||||
// the + 1 in the next line allows for rounding.
|
||||
myDoc.PageSetup.BottomMargin = 11 * 72 - (newTop + newLength + 1);
|
||||
myDoc.PageSetup.BottomMargin = newBottom;
|
||||
myDoc.PageSetup.RightMargin = newRight;
|
||||
myDoc.PageSetup.LeftMargin = newLeft;
|
||||
myDoc.PageSetup.TopMargin = newTop;
|
||||
|
@ -541,11 +541,15 @@ namespace VEPROMS.CSLA.Library
|
||||
byte[] ab = r.ReadBytes((int)fsIn.Length);
|
||||
r.Close();
|
||||
fsIn.Close();
|
||||
roImg = ROImage.MakeROImage(rodb, imgname, ab, null, fi.LastWriteTimeUtc, "Migration");
|
||||
Figure figure = Figure.GetByROFstID_ImageID(this.ROFstID, roImg.ImageID);
|
||||
if (figure != null) return;
|
||||
figure = Figure.MakeFigure(rofst, roImg, null);
|
||||
myAddedROImages.Add(key);
|
||||
using (roImg = ROImage.MakeROImage(rodb, imgname, ab, null, fi.LastWriteTimeUtc, "Migration"))
|
||||
{
|
||||
using (Figure figure = Figure.GetByROFstID_ImageID(this.ROFstID, roImg.ImageID))
|
||||
{
|
||||
if (figure != null) return;
|
||||
Figure.MakeFigure(rofst, roImg, null).Dispose();
|
||||
myAddedROImages.Add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ namespace VEPROMS.CSLA.Library
|
||||
get
|
||||
{
|
||||
CanReadProperty("MyRODb", true);
|
||||
if (_MyRODb == null && _RODbID != 0) _MyRODb = RODbInfo.Get(_RODbID);
|
||||
if (_MyRODb == null && _RODbID != 0) _MyRODb = RODbInfo.GetJustRODB(_RODbID);
|
||||
return _MyRODb;
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
public partial class AnnotationDetails : UserControl
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
#region Properties
|
||||
private bool _LoadingAnnotation = false;
|
||||
private bool _LoadingGrid = false;
|
||||
@ -266,9 +267,16 @@ namespace Volian.Controls.Library
|
||||
break;
|
||||
}
|
||||
}
|
||||
dgAnnotations.Rows[row].Selected = true;
|
||||
if (!_LoadingGrid && (dgAnnotations.FirstDisplayedScrollingRowIndex != -1))
|
||||
dgAnnotations.FirstDisplayedScrollingRowIndex = row;
|
||||
try
|
||||
{
|
||||
dgAnnotations.Rows[row].Selected = true;
|
||||
if (!_LoadingGrid && (dgAnnotations.FirstDisplayedScrollingRowIndex != -1))
|
||||
dgAnnotations.FirstDisplayedScrollingRowIndex = row;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_MyLog.InfoFormat("Trying to open an annotation which has been removed");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,25 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private bool _Disposed = false;
|
||||
private static int _CountCreated = 0;
|
||||
private static int _CountDisposed = 0;
|
||||
private static int _CountFinalized = 0;
|
||||
private static int IncrementCountCreated
|
||||
{ get { return ++_CountCreated; } }
|
||||
private int _CountWhenCreated = IncrementCountCreated;
|
||||
public static int CountCreated
|
||||
{ get { return _CountCreated; } }
|
||||
public static int CountNotDisposed
|
||||
{ get { return _CountCreated - _CountDisposed; } }
|
||||
public static int CountNotFinalized
|
||||
{ get { return _CountCreated - _CountFinalized; } }
|
||||
private bool _Finalized = false;
|
||||
~StepRTB()
|
||||
{
|
||||
if (!_Finalized) _CountFinalized++;
|
||||
_Finalized = true;
|
||||
}
|
||||
#region Events
|
||||
public event StepRTBRoEvent RoInsert;
|
||||
public void OnRoInsert(object sender, StepRTBRoEventArgs args)
|
||||
@ -207,12 +226,12 @@ namespace Volian.Controls.Library
|
||||
font = new Font(value, 10, FontStyle.Italic);
|
||||
using (StepRTB srtb = new StepRTB())
|
||||
{
|
||||
if (srtb.FontIsFixed(font)) _MySymbolFontName = "VESymbFix";
|
||||
else _MySymbolFontName = "Arial Unicode MS";
|
||||
}
|
||||
if (srtb.FontIsFixed(font)) _MySymbolFontName = "VESymbFix";
|
||||
else _MySymbolFontName = "Arial Unicode MS";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// use newer rich text box....
|
||||
//[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
|
||||
//static extern IntPtr LoadLibrary(string lpFileName);
|
||||
@ -542,7 +561,6 @@ namespace Volian.Controls.Library
|
||||
SetUpStepRTB();
|
||||
AddEventHandlers();
|
||||
this.BorderStyleChanged += new EventHandler(StepRTB_BorderStyleChanged);
|
||||
|
||||
}
|
||||
protected override void OnMouseWheel(MouseEventArgs e)
|
||||
{
|
||||
@ -646,7 +664,8 @@ namespace Volian.Controls.Library
|
||||
private void SetUpStepRTB()
|
||||
{
|
||||
DetectUrls = false;
|
||||
C1SpellChecker2.SetActiveSpellChecking(this, true);
|
||||
if(DoSpellCheck)
|
||||
C1SpellChecker2.SetActiveSpellChecking(this, true);
|
||||
this.Height = 10; // initialize the height to 10, the default height was too big for the cells in grid tables
|
||||
BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.ScrollBars = RichTextBoxScrollBars.None;
|
||||
@ -892,7 +911,7 @@ namespace Volian.Controls.Library
|
||||
if(newRtf != _LastRtf || ReadOnly != _lastReadOnly)
|
||||
{
|
||||
//Console.WriteLine("ItemID:{0}\r\nOld:'{1}'\r\nNew:'{2}'\r\n", MyItemInfo.ItemID, Rtf, newRtf);
|
||||
this.ContentsResized -=new ContentsResizedEventHandler(StepRTB_ContentsResized);
|
||||
this.ContentsResized -= new ContentsResizedEventHandler(StepRTB_ContentsResized);
|
||||
Text = "";
|
||||
this.ContentsResized += new ContentsResizedEventHandler(StepRTB_ContentsResized);
|
||||
SelectedRtf = _LastRtf = newRtf;
|
||||
@ -1704,37 +1723,39 @@ namespace Volian.Controls.Library
|
||||
|
||||
private string GetSelectedDisplayableText()
|
||||
{
|
||||
StepRTB srtb = new StepRTB();
|
||||
srtb.Rtf = this.SelectedRtf.Replace(@"\u8209?", "-");
|
||||
string rtnstr = "";
|
||||
string ctxt = srtb.Text;//this.SelectedText;
|
||||
if (ctxt.EndsWith("<START]"))
|
||||
ctxt = ctxt.Substring(0, ctxt.Length - 7);
|
||||
int idx = 0;
|
||||
int strtidx = ctxt.IndexOf("<START]");
|
||||
int lnkidx = ctxt.IndexOf("#Link");
|
||||
int endidx = ctxt.IndexOf("[END>");
|
||||
if ((strtidx == -1 || strtidx > lnkidx) && lnkidx > -1 && endidx > -1)
|
||||
using (StepRTB srtb = new StepRTB())
|
||||
{
|
||||
rtnstr += ctxt.Substring(idx, lnkidx);
|
||||
idx = endidx + 5;
|
||||
strtidx = ctxt.IndexOf("<START]", idx);
|
||||
lnkidx = ctxt.IndexOf("#Link:", idx);
|
||||
endidx = ctxt.IndexOf("[END>", idx);
|
||||
srtb.Rtf = this.SelectedRtf.Replace(@"\u8209?", "-");
|
||||
string rtnstr = "";
|
||||
string ctxt = srtb.Text;//this.SelectedText;
|
||||
if (ctxt.EndsWith("<START]"))
|
||||
ctxt = ctxt.Substring(0, ctxt.Length - 7);
|
||||
int idx = 0;
|
||||
int strtidx = ctxt.IndexOf("<START]");
|
||||
int lnkidx = ctxt.IndexOf("#Link");
|
||||
int endidx = ctxt.IndexOf("[END>");
|
||||
if ((strtidx == -1 || strtidx > lnkidx) && lnkidx > -1 && endidx > -1)
|
||||
{
|
||||
rtnstr += ctxt.Substring(idx, lnkidx);
|
||||
idx = endidx + 5;
|
||||
strtidx = ctxt.IndexOf("<START]", idx);
|
||||
lnkidx = ctxt.IndexOf("#Link:", idx);
|
||||
endidx = ctxt.IndexOf("[END>", idx);
|
||||
}
|
||||
while (strtidx > -1)
|
||||
{
|
||||
rtnstr += ctxt.Substring(idx, strtidx - idx);
|
||||
idx = strtidx + 7;
|
||||
rtnstr += ctxt.Substring(idx, lnkidx - idx);
|
||||
idx = endidx + 5;
|
||||
strtidx = ctxt.IndexOf("<START]", idx);
|
||||
lnkidx = ctxt.IndexOf("#Link:", idx);
|
||||
endidx = ctxt.IndexOf("[END>", idx);
|
||||
}
|
||||
if (idx < ctxt.Length)
|
||||
rtnstr += ctxt.Substring(idx);
|
||||
return rtnstr;
|
||||
}
|
||||
while (strtidx > -1)
|
||||
{
|
||||
rtnstr += ctxt.Substring(idx, strtidx - idx);
|
||||
idx = strtidx + 7;
|
||||
rtnstr += ctxt.Substring(idx, lnkidx - idx);
|
||||
idx = endidx + 5;
|
||||
strtidx = ctxt.IndexOf("<START]", idx);
|
||||
lnkidx = ctxt.IndexOf("#Link:", idx);
|
||||
endidx = ctxt.IndexOf("[END>", idx);
|
||||
}
|
||||
if (idx < ctxt.Length)
|
||||
rtnstr += ctxt.Substring(idx);
|
||||
return rtnstr;
|
||||
}
|
||||
|
||||
private bool IsControlChar = false;
|
||||
@ -2158,14 +2179,25 @@ namespace Volian.Controls.Library
|
||||
#endregion
|
||||
#endregion
|
||||
#region SelectionStack
|
||||
Stack<SelectionData> _SelectionStack = new Stack<SelectionData>();
|
||||
Stack<SelectionData> _SelectionStack = null;
|
||||
public Stack<SelectionData> SelectionStack
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_SelectionStack == null)
|
||||
_SelectionStack = new Stack<SelectionData>();
|
||||
return _SelectionStack;
|
||||
}
|
||||
}
|
||||
public void PushSelection()
|
||||
{
|
||||
_SelectionStack.Push(new SelectionData(this));
|
||||
SelectionStack.Push(new SelectionData(this));
|
||||
}
|
||||
public void PopSelection()
|
||||
{
|
||||
SelectionData selection = _SelectionStack.Pop();
|
||||
SelectionData selection = SelectionStack.Pop();
|
||||
if (SelectionStack.Count == 0)
|
||||
_SelectionStack = null;
|
||||
Select(selection.SelectionStart, selection.SelectionLength);
|
||||
}
|
||||
public class SelectionData
|
||||
@ -2299,59 +2331,61 @@ namespace Volian.Controls.Library
|
||||
private RichTextBoxFinds _FindOptions = RichTextBoxFinds.None;
|
||||
public bool FindText(string str, bool caseSensitive, bool matchWholeWord, bool reverse)
|
||||
{
|
||||
StepRTB savRTF = new StepRTB();
|
||||
int startpos = SelectionStart + SelectionLength;
|
||||
savRTF.Text = this.Text;
|
||||
using (StepRTB savRTF = new StepRTB())
|
||||
{
|
||||
int startpos = SelectionStart + SelectionLength;
|
||||
savRTF.Text = this.Text;
|
||||
|
||||
_FindOptions = RichTextBoxFinds.None;
|
||||
if (caseSensitive)
|
||||
_FindOptions |= RichTextBoxFinds.MatchCase;
|
||||
if (matchWholeWord)
|
||||
_FindOptions |= RichTextBoxFinds.WholeWord;
|
||||
if (reverse)
|
||||
{
|
||||
_FindOptions |= RichTextBoxFinds.Reverse;
|
||||
savRTF.Text = this.Text.Substring(0, SelectionStart);
|
||||
startpos = savRTF.Text.Length;
|
||||
if (startpos == 0)
|
||||
return false; // at beginning of rtfbox during a reverse find
|
||||
}
|
||||
else
|
||||
{
|
||||
if (startpos >= savRTF.Text.Length)
|
||||
return false; // at end of rtfbox during a forward find
|
||||
}
|
||||
// look for the find string in the temporary rtfbox
|
||||
// then set the cursor selection in the real rtfbox
|
||||
bool keepgoing = true;
|
||||
while (keepgoing)
|
||||
{
|
||||
int pos = savRTF.Find(str, startpos, _FindOptions);
|
||||
keepgoing = false;
|
||||
if (pos >= 0)
|
||||
_FindOptions = RichTextBoxFinds.None;
|
||||
if (caseSensitive)
|
||||
_FindOptions |= RichTextBoxFinds.MatchCase;
|
||||
if (matchWholeWord)
|
||||
_FindOptions |= RichTextBoxFinds.WholeWord;
|
||||
if (reverse)
|
||||
{
|
||||
if (this.SkipLinkInfo(pos, str.Length))
|
||||
{
|
||||
if (reverse)
|
||||
{
|
||||
startpos--;
|
||||
savRTF.Text = savRTF.Text.Substring(0, startpos);
|
||||
}
|
||||
else
|
||||
startpos++;
|
||||
if (startpos > 0 && startpos < savRTF.Text.Length)
|
||||
keepgoing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectionStart = pos;
|
||||
SelectionLength = str.Length;
|
||||
}
|
||||
_FindOptions |= RichTextBoxFinds.Reverse;
|
||||
savRTF.Text = this.Text.Substring(0, SelectionStart);
|
||||
startpos = savRTF.Text.Length;
|
||||
if (startpos == 0)
|
||||
return false; // at beginning of rtfbox during a reverse find
|
||||
}
|
||||
else
|
||||
return false;
|
||||
{
|
||||
if (startpos >= savRTF.Text.Length)
|
||||
return false; // at end of rtfbox during a forward find
|
||||
}
|
||||
// look for the find string in the temporary rtfbox
|
||||
// then set the cursor selection in the real rtfbox
|
||||
bool keepgoing = true;
|
||||
while (keepgoing)
|
||||
{
|
||||
int pos = savRTF.Find(str, startpos, _FindOptions);
|
||||
keepgoing = false;
|
||||
if (pos >= 0)
|
||||
{
|
||||
if (this.SkipLinkInfo(pos, str.Length))
|
||||
{
|
||||
if (reverse)
|
||||
{
|
||||
startpos--;
|
||||
savRTF.Text = savRTF.Text.Substring(0, startpos);
|
||||
}
|
||||
else
|
||||
startpos++;
|
||||
if (startpos > 0 && startpos < savRTF.Text.Length)
|
||||
keepgoing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectionStart = pos;
|
||||
SelectionLength = str.Length;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private int FindStart()
|
||||
{
|
||||
@ -2784,6 +2818,12 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
#endregion
|
||||
#region SpellChecker
|
||||
private static bool _DoSpellCheck = true;
|
||||
public static bool DoSpellCheck
|
||||
{
|
||||
get { return StepRTB._DoSpellCheck; }
|
||||
set { StepRTB._DoSpellCheck = value; }
|
||||
}
|
||||
// We made the Spell Checker method a static so that all of the StepRTB boxes will bare the same instance of the dictionary.
|
||||
// This allow all the StepRTB's to automatically update when a new word is added.
|
||||
private static C1.Win.C1SpellChecker.C1SpellChecker _C1SpellChecker2;
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
namespace Volian.Controls.Library
|
||||
{
|
||||
partial class StepRTB
|
||||
@ -13,11 +14,16 @@ namespace Volian.Controls.Library
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (_Disposed) return;
|
||||
_CountDisposed++;
|
||||
_Disposed = true;
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
if(!_Finalized)
|
||||
GC.ReRegisterForFinalize(this); // Make sure that StepRTB is finalized
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
@ -1,3 +1,5 @@
|
||||
using System;
|
||||
|
||||
namespace Volian.Controls.Library
|
||||
{
|
||||
partial class VlnFlexGrid
|
||||
@ -11,16 +13,22 @@ namespace Volian.Controls.Library
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
_SpellChecker.Dispose();
|
||||
_tableCellEditor.Dispose();
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (_Disposed) return;
|
||||
_CountDisposed++;
|
||||
_Disposed = true;
|
||||
_MyBorders = null;
|
||||
_SpellChecker = null;
|
||||
_tableCellEditor = null;
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
if(!_Finalized)
|
||||
GC.ReRegisterForFinalize(this);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
|
@ -25,8 +25,26 @@ namespace Volian.Controls.Library
|
||||
|
||||
public partial class VlnFlexGrid : C1.Win.C1FlexGrid.C1FlexGrid
|
||||
{
|
||||
private bool _Disposed = false;
|
||||
private static int _CountCreated = 0;
|
||||
private static int _CountDisposed = 0;
|
||||
private static int _CountFinalized = 0;
|
||||
private static int IncrementCountCreated
|
||||
{ get { return ++_CountCreated; } }
|
||||
private int _CountWhenCreated = IncrementCountCreated;
|
||||
public static int CountCreated
|
||||
{ get { return _CountCreated; } }
|
||||
public static int CountNotDisposed
|
||||
{ get { return _CountCreated - _CountDisposed; } }
|
||||
public static int CountNotFinalized
|
||||
{ get { return _CountCreated - _CountFinalized; } }
|
||||
private bool _Finalized = false;
|
||||
~VlnFlexGrid()
|
||||
{
|
||||
if(!_Finalized) _CountFinalized++;
|
||||
_Finalized = true;
|
||||
}
|
||||
private C1SpellChecker _SpellChecker;
|
||||
|
||||
public C1SpellChecker SpellChecker
|
||||
{
|
||||
get { return _SpellChecker; }
|
||||
@ -185,7 +203,16 @@ namespace Volian.Controls.Library
|
||||
return string.Empty;
|
||||
return xd.SelectSingleNode("C1FlexGrid/MergedRanges").InnerXml;
|
||||
}
|
||||
public static GridCopyInfo MyCopyInfo = new GridCopyInfo();
|
||||
private static GridCopyInfo _MyCopyInfo;
|
||||
public static GridCopyInfo MyCopyInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_MyCopyInfo == null)
|
||||
_MyCopyInfo = new GridCopyInfo();
|
||||
return _MyCopyInfo;
|
||||
}
|
||||
}
|
||||
private Color _DefaultCellBackgroundcolor;
|
||||
|
||||
public Color DefaultCellBackgroundcolor
|
||||
@ -646,26 +673,28 @@ namespace Volian.Controls.Library
|
||||
//int curRowHeightNLines = curRowHeight / (Rows.DefaultSize - 3);
|
||||
if (curColWidth <= Cols.DefaultSize - 3) return 0; // never have col less than default width
|
||||
int blankColSpace = curColWidth;
|
||||
for (int r = 0; r < Rows.Count; r++)
|
||||
{
|
||||
StepRTB srtb = new StepRTB();
|
||||
CellRange cr = GetMergedRange(r, Col);
|
||||
srtb.Rtf = GetCellRTFString(cr.r1, cr.c1);
|
||||
if (Col >= cr.c1 && Col <= cr.c2)
|
||||
{
|
||||
int cellWidth = GetCellWidth(r, Col);
|
||||
//srtb.Width = cellWidth;
|
||||
srtb.AdjustWidthForContent();
|
||||
//Application.DoEvents();
|
||||
//int mergeCellHeightNLines = cellHeight / (Rows.DefaultSize - 3);
|
||||
//int dataHeight = (cr.UserData == null) ? cellHeight : (int)cr.UserData;
|
||||
//int ud = dataHeight / (Rows.DefaultSize - 3);
|
||||
//if (cellHeight < dataHeight)
|
||||
// Console.WriteLine("r {0}, c {1}, cell{2}, data{3}", Row, c, cellHeight, dataHeight);
|
||||
//blankColSpace = Math.Min(blankColSpace, Math.Max(0, cellWidth - srtb.MaxTextWidth));
|
||||
blankColSpace = Math.Min(blankColSpace, Math.Max(0, cellWidth - srtb.Width));
|
||||
}
|
||||
}
|
||||
for (int r = 0; r < Rows.Count; r++)
|
||||
{
|
||||
using (StepRTB srtb = new StepRTB())
|
||||
{
|
||||
CellRange cr = GetMergedRange(r, Col);
|
||||
srtb.Rtf = GetCellRTFString(cr.r1, cr.c1);
|
||||
if (Col >= cr.c1 && Col <= cr.c2)
|
||||
{
|
||||
int cellWidth = GetCellWidth(r, Col);
|
||||
//srtb.Width = cellWidth;
|
||||
srtb.AdjustWidthForContent();
|
||||
//Application.DoEvents();
|
||||
//int mergeCellHeightNLines = cellHeight / (Rows.DefaultSize - 3);
|
||||
//int dataHeight = (cr.UserData == null) ? cellHeight : (int)cr.UserData;
|
||||
//int ud = dataHeight / (Rows.DefaultSize - 3);
|
||||
//if (cellHeight < dataHeight)
|
||||
// Console.WriteLine("r {0}, c {1}, cell{2}, data{3}", Row, c, cellHeight, dataHeight);
|
||||
//blankColSpace = Math.Min(blankColSpace, Math.Max(0, cellWidth - srtb.MaxTextWidth));
|
||||
blankColSpace = Math.Min(blankColSpace, Math.Max(0, cellWidth - srtb.Width));
|
||||
}
|
||||
}
|
||||
}
|
||||
//Console.WriteLine("BlankRowSpace {0}", blankRowSpace);
|
||||
return blankColSpace;
|
||||
}
|
||||
@ -981,116 +1010,116 @@ namespace Volian.Controls.Library
|
||||
// //Console.WriteLine("LeaveEdit Style = {0}", this.GetCellRange(e.Row, e.Col).Style.Name);
|
||||
// this.GetCellRange(e.Row, e.Col).Style.ForeColor = Color.Black;
|
||||
//}
|
||||
private void Grid_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
|
||||
{
|
||||
private void Grid_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
|
||||
{
|
||||
using (RTF _rtf = new RTF())
|
||||
{
|
||||
// use nearest solid color
|
||||
// (the RTF control doesn't dither, and doesn't support transparent backgrounds)
|
||||
Color solid = e.Graphics.GetNearestColor(e.Style.BackColor);
|
||||
DPI = e.Graphics.DpiX;
|
||||
if (e.Style.BackColor != solid)
|
||||
e.Style.BackColor = solid;
|
||||
// use nearest solid color
|
||||
// (the RTF control doesn't dither, and doesn't support transparent backgrounds)
|
||||
Color solid = e.Graphics.GetNearestColor(e.Style.BackColor);
|
||||
DPI = e.Graphics.DpiX;
|
||||
if (e.Style.BackColor != solid)
|
||||
e.Style.BackColor = solid;
|
||||
|
||||
// check whether the cell contains RTF
|
||||
string rtfText = this.GetDataDisplay(e.Row, e.Col).Replace(@"\~", @"\u160?");
|
||||
GridItem gi = Parent as GridItem;
|
||||
if (gi != null)
|
||||
{
|
||||
DisplayText dt = new DisplayText(gi.MyItemInfo, rtfText, true);
|
||||
rtfText = dt.StartText;
|
||||
}
|
||||
// it does, so draw background
|
||||
e.DrawCell(DrawCellFlags.Background);
|
||||
if (rtfText.StartsWith(@"{\rtf"))
|
||||
{
|
||||
// Please add a comment if this value needs to be changed
|
||||
_rtf.Rtf = rtfText;
|
||||
// draw the RTF text
|
||||
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
|
||||
CellRange cr = GetMergedRange(e.Row, e.Col);
|
||||
cr.UserData = _rtf.Height;
|
||||
int hAdjust = 0;
|
||||
int hDiff = e.Bounds.Height - _rtf.Height;
|
||||
if (hDiff < 0)
|
||||
{
|
||||
Rows[e.Row].Height = _rtf.Height + 4;
|
||||
AdjustGridControlSize();
|
||||
hDiff = 0;
|
||||
}
|
||||
if (e.Style != null)
|
||||
{
|
||||
switch (e.Style.TextAlign)
|
||||
{
|
||||
case TextAlignEnum.CenterBottom:
|
||||
case TextAlignEnum.GeneralBottom:
|
||||
case TextAlignEnum.LeftBottom:
|
||||
case TextAlignEnum.RightBottom:
|
||||
hAdjust = hDiff;
|
||||
break;
|
||||
case TextAlignEnum.CenterCenter:
|
||||
case TextAlignEnum.GeneralCenter:
|
||||
case TextAlignEnum.LeftCenter:
|
||||
case TextAlignEnum.RightCenter:
|
||||
hAdjust = hDiff / 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (IsRoTable)
|
||||
{
|
||||
_rtf.ForeColor = Color.Red;
|
||||
}
|
||||
else
|
||||
{
|
||||
_rtf.ForeColor = e.Style.ForeColor;
|
||||
}
|
||||
_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));
|
||||
}
|
||||
}
|
||||
else
|
||||
_rtf.Text = rtfText;
|
||||
// check whether the cell contains RTF
|
||||
string rtfText = this.GetDataDisplay(e.Row, e.Col).Replace(@"\~", @"\u160?");
|
||||
GridItem gi = Parent as GridItem;
|
||||
if (gi != null)
|
||||
{
|
||||
DisplayText dt = new DisplayText(gi.MyItemInfo, rtfText, true);
|
||||
rtfText = dt.StartText;
|
||||
}
|
||||
// it does, so draw background
|
||||
e.DrawCell(DrawCellFlags.Background);
|
||||
if (rtfText.StartsWith(@"{\rtf"))
|
||||
{
|
||||
// Please add a comment if this value needs to be changed
|
||||
_rtf.Rtf = rtfText;
|
||||
// draw the RTF text
|
||||
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
|
||||
CellRange cr = GetMergedRange(e.Row, e.Col);
|
||||
cr.UserData = _rtf.Height;
|
||||
int hAdjust = 0;
|
||||
int hDiff = e.Bounds.Height - _rtf.Height;
|
||||
if (hDiff < 0)
|
||||
{
|
||||
Rows[e.Row].Height = _rtf.Height + 4;
|
||||
AdjustGridControlSize();
|
||||
hDiff = 0;
|
||||
}
|
||||
if (e.Style != null)
|
||||
{
|
||||
switch (e.Style.TextAlign)
|
||||
{
|
||||
case TextAlignEnum.CenterBottom:
|
||||
case TextAlignEnum.GeneralBottom:
|
||||
case TextAlignEnum.LeftBottom:
|
||||
case TextAlignEnum.RightBottom:
|
||||
hAdjust = hDiff;
|
||||
break;
|
||||
case TextAlignEnum.CenterCenter:
|
||||
case TextAlignEnum.GeneralCenter:
|
||||
case TextAlignEnum.LeftCenter:
|
||||
case TextAlignEnum.RightCenter:
|
||||
hAdjust = hDiff / 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (IsRoTable)
|
||||
{
|
||||
_rtf.ForeColor = Color.Red;
|
||||
}
|
||||
else
|
||||
{
|
||||
_rtf.ForeColor = e.Style.ForeColor;
|
||||
}
|
||||
_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));
|
||||
}
|
||||
}
|
||||
else
|
||||
_rtf.Text = rtfText;
|
||||
|
||||
// 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++)
|
||||
{
|
||||
// The positioning of the the squigle line does not account for mixed font sizes
|
||||
// should we support having mixed fonts in the table cells, we will need to add
|
||||
// logic to support it.
|
||||
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
|
||||
//e.DrawCell(DrawCellFlags.Border);
|
||||
// This can be used to draw more specific borders
|
||||
DrawCellBorder(e);
|
||||
// we're done with this cell
|
||||
e.Handled = true;
|
||||
// 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++)
|
||||
{
|
||||
// The positioning of the the squigle line does not account for mixed font sizes
|
||||
// should we support having mixed fonts in the table cells, we will need to add
|
||||
// logic to support it.
|
||||
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
|
||||
//e.DrawCell(DrawCellFlags.Border);
|
||||
// This can be used to draw more specific borders
|
||||
DrawCellBorder(e);
|
||||
// we're done with this cell
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SquigleLine(Graphics graphics, int x1, int y1, int x2)
|
||||
{
|
||||
@ -1386,28 +1415,32 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
// only used in test program
|
||||
CellRange cr = this.Selection;
|
||||
StepRTB srtb = new StepRTB();
|
||||
srtb.Rtf = this.GetCellRTFString(cr.r1, cr.c1);
|
||||
using (StepRTB srtb = new StepRTB())
|
||||
{
|
||||
srtb.Rtf = this.GetCellRTFString(cr.r1, cr.c1);
|
||||
|
||||
srtb.SelectAll();
|
||||
int align = (int)srtb.SelectionAlignment;
|
||||
align = (align + 1) % 3;
|
||||
srtb.SelectAll();
|
||||
int align = (int)srtb.SelectionAlignment;
|
||||
align = (align + 1) % 3;
|
||||
|
||||
srtb.SelectionAlignment = (HorizontalAlignment)align;
|
||||
this.PutCellRTFString(cr.r1, cr.c1, srtb.Rtf);
|
||||
srtb.SelectionAlignment = (HorizontalAlignment)align;
|
||||
this.PutCellRTFString(cr.r1, cr.c1, srtb.Rtf);
|
||||
}
|
||||
}
|
||||
|
||||
public void RTFTextAlignment(CellRange cr, HorizontalAlignment ha)
|
||||
{
|
||||
StepRTB srtb = new StepRTB();
|
||||
for (int rw = cr.r1; rw <= cr.r2; rw++)
|
||||
for (int cl = cr.c1; cl <= cr.c2; cl++)
|
||||
{
|
||||
srtb.Rtf = this.GetCellRTFString(rw, cl);
|
||||
srtb.SelectAll();
|
||||
srtb.SelectionAlignment = ha;
|
||||
this.PutCellRTFString(rw, cl, srtb.Rtf);
|
||||
}
|
||||
using (StepRTB srtb = new StepRTB())
|
||||
{
|
||||
for (int rw = cr.r1; rw <= cr.r2; rw++)
|
||||
for (int cl = cr.c1; cl <= cr.c2; cl++)
|
||||
{
|
||||
srtb.Rtf = this.GetCellRTFString(rw, cl);
|
||||
srtb.SelectAll();
|
||||
srtb.SelectionAlignment = ha;
|
||||
this.PutCellRTFString(rw, cl, srtb.Rtf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1578,51 +1611,52 @@ namespace Volian.Controls.Library
|
||||
|
||||
public void ConvertTextCellToRTF(int r, int c)
|
||||
{
|
||||
StepRTB trtb = new StepRTB();
|
||||
string tstr = null;
|
||||
bool dummyCharWidth = false;
|
||||
bool AllowWidthShrink = false;
|
||||
trtb.SetTableGridCellRTFPrefix(this.Font);
|
||||
trtb.Clear();
|
||||
tstr = (string)this[r, c];
|
||||
trtb.Font = this.Font;
|
||||
if (tstr != null && tstr.Length > 0)
|
||||
using (StepRTB trtb = new StepRTB())
|
||||
{
|
||||
string tsave = tstr;
|
||||
// regular text has special characters to toggle Bold, Underline, and Italics
|
||||
// we need to subtract the width of these characters (allow column/row to shrink)
|
||||
//AllowWidthShrink = RemoveBoldUlineItalicChars(trtb.Rtf);
|
||||
AllowWidthShrink = tstr.Contains("#Link:");
|
||||
// this will convert the special characters for Bold, Underline, and Italics
|
||||
// into RTF commands
|
||||
//trtb.Rtf = trtb.RtfPrefix + ConvertTableText(trtb.Rtf) + "}";
|
||||
//string fromRTF = trtb.Rtf;
|
||||
//string prefix = trtb.RtfPrefix;
|
||||
//if (tstr.Contains("#Link:")) prefix += @"{\colortbl ;\red255\green0\blue0;}";
|
||||
//if (tstr.Contains("#Link:"))
|
||||
// Console.WriteLine("here");
|
||||
//string jText = trtb.RtfPrefix + ConvertTableText(tstr) + @"\par}";
|
||||
//trtb.Rtf = jText;
|
||||
trtb.Rtf = trtb.RtfPrefix + ConvertTableText(tstr) + @"\par}";
|
||||
//string fromStr = trtb.Rtf;
|
||||
//if (fromRTF.Contains("SimSun"))
|
||||
// Console.WriteLine("SimSun");
|
||||
//else
|
||||
// Compare(fromRTF, fromStr, tsave);
|
||||
}
|
||||
else
|
||||
{
|
||||
trtb.Text = "X"; // this is to trick steprtf in giving a char width to fit one character
|
||||
// note that a space character was too small.
|
||||
dummyCharWidth = true;
|
||||
}
|
||||
// find the needed cell width
|
||||
trtb.AdjustWidthForContent();
|
||||
if (dummyCharWidth)
|
||||
{
|
||||
trtb.Text = ""; // clear out the dummy character before saving
|
||||
dummyCharWidth = false;
|
||||
}
|
||||
string tstr = null;
|
||||
bool dummyCharWidth = false;
|
||||
bool AllowWidthShrink = false;
|
||||
trtb.SetTableGridCellRTFPrefix(this.Font);
|
||||
trtb.Clear();
|
||||
tstr = (string)this[r, c];
|
||||
trtb.Font = this.Font;
|
||||
if (tstr != null && tstr.Length > 0)
|
||||
{
|
||||
string tsave = tstr;
|
||||
// regular text has special characters to toggle Bold, Underline, and Italics
|
||||
// we need to subtract the width of these characters (allow column/row to shrink)
|
||||
//AllowWidthShrink = RemoveBoldUlineItalicChars(trtb.Rtf);
|
||||
AllowWidthShrink = tstr.Contains("#Link:");
|
||||
// this will convert the special characters for Bold, Underline, and Italics
|
||||
// into RTF commands
|
||||
//trtb.Rtf = trtb.RtfPrefix + ConvertTableText(trtb.Rtf) + "}";
|
||||
//string fromRTF = trtb.Rtf;
|
||||
//string prefix = trtb.RtfPrefix;
|
||||
//if (tstr.Contains("#Link:")) prefix += @"{\colortbl ;\red255\green0\blue0;}";
|
||||
//if (tstr.Contains("#Link:"))
|
||||
// Console.WriteLine("here");
|
||||
//string jText = trtb.RtfPrefix + ConvertTableText(tstr) + @"\par}";
|
||||
//trtb.Rtf = jText;
|
||||
trtb.Rtf = trtb.RtfPrefix + ConvertTableText(tstr) + @"\par}";
|
||||
//string fromStr = trtb.Rtf;
|
||||
//if (fromRTF.Contains("SimSun"))
|
||||
// Console.WriteLine("SimSun");
|
||||
//else
|
||||
// Compare(fromRTF, fromStr, tsave);
|
||||
}
|
||||
else
|
||||
{
|
||||
trtb.Text = "X"; // this is to trick steprtf in giving a char width to fit one character
|
||||
// note that a space character was too small.
|
||||
dummyCharWidth = true;
|
||||
}
|
||||
// find the needed cell width
|
||||
trtb.AdjustWidthForContent();
|
||||
if (dummyCharWidth)
|
||||
{
|
||||
trtb.Text = ""; // clear out the dummy character before saving
|
||||
dummyCharWidth = false;
|
||||
}
|
||||
|
||||
this[r, c] = trtb.Rtf; // save the cleaned up and processed cell text as RTF
|
||||
this.Select(r, c, false);
|
||||
@ -1701,41 +1735,44 @@ namespace Volian.Controls.Library
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
private void AdjustCellHeightWidth(int r, int c)
|
||||
{
|
||||
StepRTB trtb = new StepRTB();
|
||||
string tstr = null;
|
||||
bool dummyCharWidth = false;
|
||||
bool AllowWidthShrink = false;
|
||||
trtb.SetTableGridCellRTFPrefix(this.Font);
|
||||
trtb.Clear();
|
||||
trtb.Font = this.Font;
|
||||
trtb.Rtf = (string)this[r, c];
|
||||
tstr = trtb.Text;
|
||||
if (tstr != null && tstr.Length > 0)
|
||||
AllowWidthShrink = tstr.Contains("#Link:");
|
||||
else
|
||||
{
|
||||
trtb.Text = "X"; // this is to trick steprtf in giving a char width to fit one character
|
||||
// note that a space character was too small.
|
||||
dummyCharWidth = true;
|
||||
}
|
||||
// find the needed cell width
|
||||
trtb.AdjustWidthForContent();
|
||||
private void AdjustCellHeightWidth(int r, int c)
|
||||
{
|
||||
using (StepRTB trtb = new StepRTB())
|
||||
{
|
||||
string tstr = null;
|
||||
bool dummyCharWidth = false;
|
||||
bool AllowWidthShrink = false;
|
||||
trtb.SetTableGridCellRTFPrefix(this.Font);
|
||||
trtb.Clear();
|
||||
trtb.Font = this.Font;
|
||||
trtb.Rtf = (string)this[r, c];
|
||||
tstr = trtb.Text;
|
||||
if (tstr != null && tstr.Length > 0)
|
||||
AllowWidthShrink = tstr.Contains("#Link:");
|
||||
else
|
||||
{
|
||||
trtb.Text = "X"; // this is to trick steprtf in giving a char width to fit one character
|
||||
// note that a space character was too small.
|
||||
dummyCharWidth = true;
|
||||
}
|
||||
// find the needed cell width
|
||||
trtb.AdjustWidthForContent();
|
||||
|
||||
if (dummyCharWidth)
|
||||
{
|
||||
trtb.Text = ""; // clear out the dummy character before saving
|
||||
dummyCharWidth = false;
|
||||
}
|
||||
if (dummyCharWidth)
|
||||
{
|
||||
trtb.Text = ""; // clear out the dummy character before saving
|
||||
dummyCharWidth = false;
|
||||
}
|
||||
|
||||
this.Select(r, c, false);
|
||||
CellRange sel = this.Selection;
|
||||
this.Select(r, c, false);
|
||||
CellRange sel = this.Selection;
|
||||
|
||||
// Now adjust the Height and Width in the defined merge ranges
|
||||
AdjustMergeRangeHeightWidth(r, c, trtb, tstr, AllowWidthShrink);
|
||||
}
|
||||
// Now adjust the Height and Width in the defined merge ranges
|
||||
AdjustMergeRangeHeightWidth(r, c, trtb, tstr, AllowWidthShrink);
|
||||
}
|
||||
}
|
||||
|
||||
private void AdjustMergeRangeHeightWidth(int r, int c, StepRTB trtb, string tstr, bool AllowWidthShrink)
|
||||
{
|
||||
@ -2043,13 +2080,15 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
CellRange cr = GetMergedRange(r, Col);
|
||||
// find the needed cell width
|
||||
if (Col == cr.c1)
|
||||
{
|
||||
StepRTB srtb = new StepRTB();
|
||||
srtb.Rtf = GetCellRTFString(cr.r1, cr.c1);
|
||||
srtb.AdjustWidthForContent();
|
||||
curColWidth = Math.Max(curColWidth, srtb.Width + 3);
|
||||
}
|
||||
if (Col == cr.c1)
|
||||
{
|
||||
using (StepRTB srtb = new StepRTB())
|
||||
{
|
||||
srtb.Rtf = GetCellRTFString(cr.r1, cr.c1);
|
||||
srtb.AdjustWidthForContent();
|
||||
curColWidth = Math.Max(curColWidth, srtb.Width + 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
return curColWidth;
|
||||
}
|
||||
@ -2230,11 +2269,13 @@ namespace Volian.Controls.Library
|
||||
string rtfText = GetDataDisplay(r, c);
|
||||
if (rtfText.StartsWith(@"{\rtf"))
|
||||
{
|
||||
RTF _rtf = new RTF();
|
||||
_rtf.Width = Cols[c].Width;
|
||||
_rtf.Rtf = rtfText;
|
||||
CellRange cr = GetCellRange(r, c);
|
||||
cr.UserData = _rtf.ContentsRectangle.Height;
|
||||
using (StepRTB _rtf = new StepRTB())
|
||||
{
|
||||
_rtf.Width = Cols[c].Width;
|
||||
_rtf.Rtf = rtfText;
|
||||
CellRange cr = GetCellRange(r, c);
|
||||
cr.UserData = _rtf.ContentsRectangle.Height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4156,11 +4197,13 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
foreach (CellRange cr in MySelection)
|
||||
{
|
||||
StepRTB rtb = new StepRTB();
|
||||
rtb.Rtf = GetCellRTFString(cr.r1, cr.c1);
|
||||
rtb.SelectAll();
|
||||
rtb.SelectionFont = new Font(rtb.SelectionFont, FontStyle.Bold);
|
||||
this[cr.r1, cr.c1] = rtb.Rtf;
|
||||
using (StepRTB rtb = new StepRTB())
|
||||
{
|
||||
rtb.Rtf = GetCellRTFString(cr.r1, cr.c1);
|
||||
rtb.SelectAll();
|
||||
rtb.SelectionFont = new Font(rtb.SelectionFont, FontStyle.Bold);
|
||||
this[cr.r1, cr.c1] = rtb.Rtf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4205,7 +4248,10 @@ namespace Volian.Controls.Library
|
||||
public enum GridCopyOption { Row, Column, Selection };
|
||||
|
||||
#region RTF Class for Cell rendering
|
||||
class RTF : StepRTB //RichTextBox
|
||||
/// <summary>
|
||||
/// RTF Should only be used if the contents of the richtextbox are to be converted to an image.
|
||||
/// </summary>
|
||||
class RTF : StepRTB
|
||||
{
|
||||
// messages used by RichEd20.dll
|
||||
internal const int
|
||||
@ -4351,7 +4397,10 @@ namespace Volian.Controls.Library
|
||||
this.Leave += new EventHandler(_editor_Leave);
|
||||
//this.HeightChanged += new StepRTBEvent(_HeightChanged);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
// start editing: move to cell and activate
|
||||
public void StartEditing(int row, int col)
|
||||
{
|
||||
|
@ -118,10 +118,11 @@ namespace Volian.MSWord
|
||||
{
|
||||
foreach (System.Diagnostics.Process proc in wordProcesses)
|
||||
{
|
||||
// TODO: Determine if Word is Visible
|
||||
// Determine if Word is Visible
|
||||
// If it is let it run
|
||||
// otherwise Kill it.
|
||||
proc.Kill();
|
||||
if(proc.MainWindowTitle=="")
|
||||
proc.Kill();
|
||||
}
|
||||
_MyWordApp = null;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user