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