- Removed Debug

- Don't resize grid when initializing
- Use LoadGrid which adjusts the Grid Font
- Only save contents if in edit mode
Changes to Comments
Added Property MySymbolFontName
- Setup GoTo button to handle ROTable Grids
- Support GoTo for ROTable Grids (MyFlexGrid.IsRoTable)
- Restored code to handle Vertical Alignment
- Added MyItemInfo property
- Removed commented-out debug in DPI property
- Support Font Override
- Use DisplayText to do ReplaceWords
- Set Text Color to Black (Change Links to Black)
Use DebugOutput property rather than _DebugOutput field
- Override Font for printing grids
- Override Font for printing text
This commit is contained in:
Rich
2011-03-11 15:49:39 +00:00
parent ddb2ea162f
commit 6029f6dd8b
8 changed files with 196 additions and 127 deletions

View File

@@ -45,6 +45,12 @@ namespace Volian.Controls.Library
// get { return _MyBorderDetail; }
// set { _MyBorderDetail = value; }
//}
private ItemInfo _MyItemInfo;
public ItemInfo MyItemInfo
{
get { return _MyItemInfo; }
set { _MyItemInfo = value; }
}
[XmlIgnore]
public bool HasVScroll
{
@@ -129,10 +135,6 @@ namespace Volian.Controls.Library
{
_DPI = value;
}
//if (value == 120)
// Console.WriteLine("Test");
// if(!(TableCellEditor is StepRTB))
// Console.WriteLine("{0}",TableCellEditor.GetType().Name);
}
}
#region Grid Initialize
@@ -420,7 +422,26 @@ namespace Volian.Controls.Library
// CellRange cr = GetMergedRange(row, col);
// return (cr.r1 == row && cr.c1 == col);
//}
private static Regex _ReplaceVESymbFix = new Regex(@"({\\f[0-9]+[^ ]* )(VESymbFix)(;})");
private static Regex _ReplaceArialUnicodeMS = new Regex(@"({\\f[0-9]+[^ ]* )(Arial Unicode MS)(;})");
private static Regex _ReplaceTextFont = new Regex(@"({\\f[0-9]+[^ ]* )(?((?!VESymbFix)(?!Arial Unicode MS))([^;]*)|(!!!!))(;})");
public void LoadGrid(ItemInfo itemInfo)
{
MyItemInfo = itemInfo;
string str = itemInfo.MyContent.MyGrid.Data;
VE_Font vefont = MyItemInfo.GetItemFont();
FontFamily ff = StepRTB.MyFontFamily ?? vefont.WindowsFont.FontFamily; // TODO: Does not change fixed font.
if (StepRTB.MySymbolFontName != "VESymbFix")
str = _ReplaceVESymbFix.Replace(str, "$1" + StepRTB.MySymbolFontName + "$3");
if (StepRTB.MySymbolFontName != "Arial Unicode MS")
str = _ReplaceArialUnicodeMS.Replace(str, "$1" + StepRTB.MySymbolFontName + "$3");
str = _ReplaceTextFont.Replace(str, "$1" + ff.Name + "$4");
using (StringReader sr = new StringReader(str))
{
ReadXml(sr);
sr.Close();
}
}
private void SetupGrid(int numrows, int numcols) //C1FlexGrid NewGrid()
{
// setup the default size of each cell in the table/grid
@@ -458,26 +479,20 @@ namespace Volian.Controls.Library
_tableCellEditor = new TableCellEditor(this);
//_tableCellEditor.ContentsResized += new ContentsResizedEventHandler(_tableCellEditor_ContentsResized);
_tableCellEditor.HeightChanged += new StepRTBEvent(_tableCellEditor_HeightChanged);
_clpbrdCpyPste = new TableClipBoardFuncts();
//this.Enter += new System.EventHandler(this.Grid_Enter);
this.AfterResizeRow += new C1.Win.C1FlexGrid.RowColEventHandler(this.Grid_AfterResize);
this.StartEdit += new C1.Win.C1FlexGrid.RowColEventHandler(this._StartEdit);
this.AfterEdit += new C1.Win.C1FlexGrid.RowColEventHandler(this._AfterEdit);
//this.LeaveEdit += new RowColEventHandler(VlnFlexGrid_LeaveEdit);
this.AfterScroll += new C1.Win.C1FlexGrid.RangeEventHandler(this._AfterScroll);
this.AfterResizeColumn += new C1.Win.C1FlexGrid.RowColEventHandler(this.Grid_AfterResize);
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this._KeyPress);
this.OwnerDrawCell += new OwnerDrawCellEventHandler(this.Grid_OwnerDrawCell);
this.LeaveCell += new EventHandler(VlnFlexGrid_LeaveCell);
//this.ValidateEdit += new ValidateEditEventHandler(VlnFlexGrid_ValidateEdit);
this.KeyDown += new KeyEventHandler(VlnFlexGrid_KeyDown);
this.KeyUp +=new KeyEventHandler(VlnFlexGrid_KeyUp);
this.SelChange += new EventHandler(VlnFlexGrid_SelChange);
this.Resize += new EventHandler(VlnFlexGrid_Resize);
TableCellEditor.EditMode = TableCellEditor.Visible; // need to comment out for compile for only jsj - 07FEB2011
}
@@ -512,20 +527,6 @@ namespace Volian.Controls.Library
}
}
}
void VlnFlexGrid_Resize(object sender, EventArgs e)
{
if (TableCellEditor.Visible)
Volian.Base.Library.vlnStackTrace.ShowStackLocal("VlnFlexGrid_Resize", 1);
}
void VlnFlexGrid_SelChange(object sender, EventArgs e)
{
// Possibilities
// Selection is a single cell
// It is part of a range
// It is
//Console.WriteLine("Where Am I {0} {1} {2}", Selection, GetMergedRange(Row, Col), Selection.Equals(GetMergedRange(Row, Col)));
}
void VlnFlexGrid_KeyUp(object sender, KeyEventArgs e)
{
if (e.Control)
@@ -625,6 +626,12 @@ namespace Volian.Controls.Library
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)
@@ -645,7 +652,14 @@ namespace Volian.Controls.Library
break;
}
}
_rtf.ForeColor = e.Style.ForeColor;
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));
//CellRange cr = GetCellRange(e.Row, e.Col);
@@ -740,7 +754,11 @@ namespace Volian.Controls.Library
{
CellRange tmp = this.GetCellRange(rw, col, rw, col);
string StyleName = string.Format("R{0}C{1}Style", rw, col);
CellStyle cs = this.Styles.Add(StyleName, tmp.Style);
CellStyle cs = null;
if (Styles.Contains(StyleName))
cs = Styles[StyleName];
else
cs = this.Styles.Add(StyleName, tmp.Style);
cs.TextAlign = newAlign;
tmp.Style = cs;
}
@@ -773,64 +791,64 @@ namespace Volian.Controls.Library
}
}
}
public void VerticalCenterText()
{
StepRTB myStepRTB = new StepRTB();
CellRange selRange = this.Selection;
for (int r = selRange.r1; r <= selRange.r2; r++)
for (int c = selRange.c1; c <= selRange.c2; c++)
{
CellRange mr = this.GetMergedRange(r, c);
if (mr.r1 == r)
{
int editHeight = (int)mr.UserData;
int cellHeight = GetCellHeight(mr.r1, mr.c1);
if (editHeight < cellHeight)
{
myStepRTB.Rtf = (string)mr.Data;
RTBAPI.SetSpaceBefore(myStepRTB, (cellHeight - editHeight) / 2);
PutCellRTFString(mr.r1, mr.c1, myStepRTB.Rtf);
}
}
}
}
public void VerticalTopText()
{
StepRTB myStepRTB = new StepRTB();
CellRange selRange = this.Selection;
for (int r = selRange.r1; r <= selRange.r2; r++)
for (int c = selRange.c1; c <= selRange.c2; c++)
{
CellRange mr = this.GetMergedRange(r, c);
if (mr.r1 == r)
{
myStepRTB.Rtf = (string)mr.Data;
RTBAPI.SetSpaceBefore(myStepRTB, 0);
PutCellRTFString(mr.r1, mr.c1, myStepRTB.Rtf);
}
}
}
public void VerticalBottomText()
{
StepRTB myStepRTB = new StepRTB();
CellRange selRange = this.Selection;
for (int r = selRange.r1; r <= selRange.r2; r++)
for (int c = selRange.c1; c <= selRange.c2; c++)
{
CellRange mr = this.GetMergedRange(r, c);
if (mr.r1 == r)
{
int editHeight = (int)mr.UserData;
int cellHeight = GetCellHeight(mr.r1, mr.c1);
if (editHeight < cellHeight)
{
myStepRTB.Rtf = (string)mr.Data;
RTBAPI.SetSpaceBefore(myStepRTB, (cellHeight - editHeight));
PutCellRTFString(mr.r1, mr.c1, myStepRTB.Rtf);
}
}
}
}
//public void VerticalCenterText()
//{
// StepRTB myStepRTB = new StepRTB();
// CellRange selRange = this.Selection;
// for (int r = selRange.r1; r <= selRange.r2; r++)
// for (int c = selRange.c1; c <= selRange.c2; c++)
// {
// CellRange mr = this.GetMergedRange(r, c);
// if (mr.r1 == r)
// {
// int editHeight = (int)mr.UserData;
// int cellHeight = GetCellHeight(mr.r1, mr.c1);
// if (editHeight < cellHeight)
// {
// myStepRTB.Rtf = (string)mr.Data;
// RTBAPI.SetSpaceBefore(myStepRTB, (cellHeight - editHeight) / 2);
// PutCellRTFString(mr.r1, mr.c1, myStepRTB.Rtf);
// }
// }
// }
//}
//public void VerticalTopText()
//{
// StepRTB myStepRTB = new StepRTB();
// CellRange selRange = this.Selection;
// for (int r = selRange.r1; r <= selRange.r2; r++)
// for (int c = selRange.c1; c <= selRange.c2; c++)
// {
// CellRange mr = this.GetMergedRange(r, c);
// if (mr.r1 == r)
// {
// myStepRTB.Rtf = (string)mr.Data;
// RTBAPI.SetSpaceBefore(myStepRTB, 0);
// PutCellRTFString(mr.r1, mr.c1, myStepRTB.Rtf);
// }
// }
//}
//public void VerticalBottomText()
//{
// StepRTB myStepRTB = new StepRTB();
// CellRange selRange = this.Selection;
// for (int r = selRange.r1; r <= selRange.r2; r++)
// for (int c = selRange.c1; c <= selRange.c2; c++)
// {
// CellRange mr = this.GetMergedRange(r, c);
// if (mr.r1 == r)
// {
// int editHeight = (int)mr.UserData;
// int cellHeight = GetCellHeight(mr.r1, mr.c1);
// if (editHeight < cellHeight)
// {
// myStepRTB.Rtf = (string)mr.Data;
// RTBAPI.SetSpaceBefore(myStepRTB, (cellHeight - editHeight));
// PutCellRTFString(mr.r1, mr.c1, myStepRTB.Rtf);
// }
// }
// }
//}
//public void SetupCellStyles()
//{
@@ -871,6 +889,7 @@ namespace Volian.Controls.Library
/// </summary>
public void AdjustGridControlSize()
{
if (Parent is GridItem ? (Parent as GridItem).Initializing : false ) return;
int difW = this.Width - this.ClientSize.Width;
int difH = this.Height - this.ClientSize.Height;
int wid = 0;