Eliminate some properties from the saved XML by using the XmlIgnore Attribute.
Added DPI property to VlnFlexGrid Added a number of CellRange properties to support printing Replace \~ (Hard Space) with \u160? before display or editing Adjust the width of the StepRTB in Grid_OwnerDrawCell
This commit is contained in:
parent
b0c65d03ea
commit
9a9e57020f
@ -13,6 +13,7 @@ using Volian.Controls.Library;
|
|||||||
using VEPROMS.CSLA.Library;
|
using VEPROMS.CSLA.Library;
|
||||||
using C1.Win.C1FlexGrid;
|
using C1.Win.C1FlexGrid;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
namespace Volian.Controls.Library
|
namespace Volian.Controls.Library
|
||||||
{
|
{
|
||||||
@ -58,7 +59,8 @@ namespace Volian.Controls.Library
|
|||||||
//private int _minSplitColWidth = 10;
|
//private int _minSplitColWidth = 10;
|
||||||
//private int _minSplitRowHeight = 20;
|
//private int _minSplitRowHeight = 20;
|
||||||
private E_ViewMode _vwMode = E_ViewMode.Edit;
|
private E_ViewMode _vwMode = E_ViewMode.Edit;
|
||||||
public E_ViewMode VwMode
|
[XmlIgnore]
|
||||||
|
internal E_ViewMode VwMode
|
||||||
{
|
{
|
||||||
get { return _vwMode; }
|
get { return _vwMode; }
|
||||||
set
|
set
|
||||||
@ -86,6 +88,27 @@ namespace Volian.Controls.Library
|
|||||||
get { return _ROID; }
|
get { return _ROID; }
|
||||||
set { _ROID = value; }
|
set { _ROID = value; }
|
||||||
}
|
}
|
||||||
|
private float? _DPI = null;
|
||||||
|
public float? DPI
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_DPI == null)
|
||||||
|
_DPI = 120;
|
||||||
|
return _DPI;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (DPI != value)
|
||||||
|
{
|
||||||
|
_DPI = value;
|
||||||
|
}
|
||||||
|
if (value == 120)
|
||||||
|
Console.WriteLine("Test");
|
||||||
|
if(!(TableCellEditor is StepRTB))
|
||||||
|
Console.WriteLine("{0}",TableCellEditor.GetType().Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
#region Grid Initialize
|
#region Grid Initialize
|
||||||
|
|
||||||
public VlnFlexGrid()
|
public VlnFlexGrid()
|
||||||
@ -152,16 +175,118 @@ namespace Volian.Controls.Library
|
|||||||
// //Rows[Row].Height += (mh - h);
|
// //Rows[Row].Height += (mh - h);
|
||||||
// ////AdjustGridControlSize();
|
// ////AdjustGridControlSize();
|
||||||
//}
|
//}
|
||||||
private int GetCellHeight(int row, int col)
|
private int GetCellHeight(int row, int col)
|
||||||
{
|
|
||||||
int height = 0;
|
|
||||||
CellRange cr = GetMergedRange(row, col);
|
|
||||||
for (int r = cr.r1; r <= cr.r2; r++)
|
|
||||||
{
|
{
|
||||||
height += (Rows[r].Height == -1) ? Rows.DefaultSize -3 : Rows[r].Height - 3;
|
return GetRangeHeight(GetMergedRange(row, col))-3;
|
||||||
|
}
|
||||||
|
public int GetRangeHeight(CellRange cr)
|
||||||
|
{
|
||||||
|
int height = 0;
|
||||||
|
for (int r = cr.r1; r <= cr.r2; r++)
|
||||||
|
height += (Rows[r].Height == -1) ? Rows.DefaultSize : Rows[r].Height;
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
public int GetRangeTop(CellRange cr)
|
||||||
|
{
|
||||||
|
int top = 0;
|
||||||
|
for (int r = 0; r < cr.r1; r++)
|
||||||
|
top += (Rows[r].Height == -1) ? Rows.DefaultSize : Rows[r].Height;
|
||||||
|
return top;
|
||||||
|
}
|
||||||
|
public int GetRangeWidth(CellRange cr)
|
||||||
|
{
|
||||||
|
int width = 0;
|
||||||
|
for (int c = cr.c1; c <= cr.c2; c++)
|
||||||
|
width += (Cols[c].Width == -1) ? Cols.DefaultSize : Cols[c].Width;
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
public int GetRangeLeft(CellRange cr)
|
||||||
|
{
|
||||||
|
int left = 0;
|
||||||
|
for (int c = 0; c < cr.c1; c++)
|
||||||
|
left += (Cols[c].Width == -1) ? Cols.DefaultSize : Cols[c].Width;
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
public int GetRangeRowsMin(CellRange cr)
|
||||||
|
{
|
||||||
|
int rowsMin = 1 + cr.r2 - cr.r1;
|
||||||
|
for (int c = cr.c1; c <= cr.c2; c++)
|
||||||
|
{
|
||||||
|
int rows = 0;
|
||||||
|
for (int r = cr.r1; r <= cr.r2; r++)
|
||||||
|
{
|
||||||
|
CellRange chk = GetMergedRange(r, c);
|
||||||
|
if (chk.r1 == r && chk.c1 == c)
|
||||||
|
rows++;
|
||||||
|
}
|
||||||
|
rowsMin = Math.Min(rowsMin, rows);
|
||||||
|
}
|
||||||
|
return rowsMin;
|
||||||
|
}
|
||||||
|
public int GetRangeRowsMax(CellRange cr)
|
||||||
|
{
|
||||||
|
int rowsMax = 0;
|
||||||
|
for (int c = cr.c1; c <= cr.c2; c++)
|
||||||
|
{
|
||||||
|
int rows = 0;
|
||||||
|
for (int r = cr.r1; r <= cr.r2; r++)
|
||||||
|
{
|
||||||
|
CellRange chk = GetMergedRange(r, c);
|
||||||
|
if (chk.r1 == r && chk.c1 == c)
|
||||||
|
rows++;
|
||||||
|
}
|
||||||
|
rowsMax = Math.Max(rowsMax, rows);
|
||||||
|
}
|
||||||
|
return rowsMax;
|
||||||
|
}
|
||||||
|
public int GetRangeColsMin(CellRange cr)
|
||||||
|
{
|
||||||
|
int colsMin = 1 + cr.c2 - cr.c1;
|
||||||
|
for (int r = cr.r1; r <= cr.r2; r++)
|
||||||
|
{
|
||||||
|
int cols = 0;
|
||||||
|
for (int c = cr.c1; c <= cr.c2; c++)
|
||||||
|
{
|
||||||
|
CellRange chk = GetMergedRange(r, c);
|
||||||
|
if (chk.r1 == r && chk.c1 == c)
|
||||||
|
cols++;
|
||||||
|
}
|
||||||
|
colsMin = Math.Min(colsMin, cols);
|
||||||
|
}
|
||||||
|
return colsMin;
|
||||||
|
}
|
||||||
|
public int GetRangeColsMax(CellRange cr)
|
||||||
|
{
|
||||||
|
int colsMax = 0;
|
||||||
|
for (int c = cr.c1; c <= cr.c2; c++)
|
||||||
|
{
|
||||||
|
int cols = 0;
|
||||||
|
for (int r = cr.r1; r <= cr.r2; r++)
|
||||||
|
{
|
||||||
|
CellRange chk = GetMergedRange(r, c);
|
||||||
|
if (chk.r1 == r && chk.c1 == c)
|
||||||
|
cols++;
|
||||||
|
}
|
||||||
|
colsMax = Math.Max(colsMax, cols);
|
||||||
|
}
|
||||||
|
return colsMax;
|
||||||
|
}
|
||||||
|
public string GetRangeRowList(CellRange cr)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
string sep = "";
|
||||||
|
for (int r = cr.r1; r <= cr.r2; r++)
|
||||||
|
{
|
||||||
|
CellRange crm = GetMergedRange(r, cr.c1);
|
||||||
|
if (crm.r1 == r)
|
||||||
|
{
|
||||||
|
sb.Append(sep + r.ToString());
|
||||||
|
sep = ".";
|
||||||
|
}
|
||||||
|
r = crm.r2;
|
||||||
|
}
|
||||||
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
return height;
|
|
||||||
}
|
|
||||||
private int GetCellWidth(int row, int col)
|
private int GetCellWidth(int row, int col)
|
||||||
{
|
{
|
||||||
int width = 0;
|
int width = 0;
|
||||||
@ -444,7 +569,6 @@ 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())
|
||||||
@ -452,11 +576,12 @@ namespace Volian.Controls.Library
|
|||||||
// 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;
|
||||||
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);
|
string rtfText = this.GetDataDisplay(e.Row, e.Col).Replace(@"\~",@"\u160?");
|
||||||
if (rtfText.StartsWith(@"{\rtf"))
|
if (rtfText.StartsWith(@"{\rtf"))
|
||||||
{
|
{
|
||||||
// it does, so draw background
|
// it does, so draw background
|
||||||
@ -469,7 +594,7 @@ namespace Volian.Controls.Library
|
|||||||
_rtf.Rtf = rtfText;
|
_rtf.Rtf = rtfText;
|
||||||
_rtf.ForeColor = e.Style.ForeColor;
|
_rtf.ForeColor = e.Style.ForeColor;
|
||||||
_rtf.BackColor = e.Style.BackColor;
|
_rtf.BackColor = e.Style.BackColor;
|
||||||
_rtf.Render(e.Graphics, e.Bounds);
|
_rtf.Render(e.Graphics, new Rectangle(e.Bounds.X+1,e.Bounds.Y,e.Bounds.Width-3,e.Bounds.Height));
|
||||||
//CellRange cr = GetCellRange(e.Row, e.Col);
|
//CellRange cr = GetCellRange(e.Row, e.Col);
|
||||||
//Console.WriteLine("ownerDraw UserData [{0},{1}] = {2}", cr.r1, cr.c1, _rtf.ContentsRectangle.Height);
|
//Console.WriteLine("ownerDraw UserData [{0},{1}] = {2}", cr.r1, cr.c1, _rtf.ContentsRectangle.Height);
|
||||||
//cr.UserData = _rtf.ContentsRectangle.Height;
|
//cr.UserData = _rtf.ContentsRectangle.Height;
|
||||||
@ -2889,6 +3014,11 @@ namespace Volian.Controls.Library
|
|||||||
public void MakeSelectionEven(int r1,int c1, int r2, int c2)
|
public void MakeSelectionEven(int r1,int c1, int r2, int c2)
|
||||||
{
|
{
|
||||||
if (c1 < 0 || c2 < 0 || r1 < 0 || r2 < 0) return; // if there is no selection don't bother
|
if (c1 < 0 || c2 < 0 || r1 < 0 || r2 < 0) return; // if there is no selection don't bother
|
||||||
|
CellRange cr = GetEvenSelection(r1, c1, r2, c2);
|
||||||
|
Select(cr);
|
||||||
|
}
|
||||||
|
public CellRange GetEvenSelection(int r1, int c1, int r2, int c2)
|
||||||
|
{
|
||||||
int cMinNew = MinimumColumn(r1, c1); // Get the left column of the top row
|
int cMinNew = MinimumColumn(r1, c1); // Get the left column of the top row
|
||||||
int cMaxNew = MaximumColumn(r1, c2); // Get the right column of the top row
|
int cMaxNew = MaximumColumn(r1, c2); // Get the right column of the top row
|
||||||
int rMinNew = MinimumRow(r1, c1); // Get the top row of the left column
|
int rMinNew = MinimumRow(r1, c1); // Get the top row of the left column
|
||||||
@ -2927,7 +3057,8 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (cMinNew < cMin || cMaxNew > cMax || rMinNew < rMin || rMaxNew > rMax);
|
while (cMinNew < cMin || cMaxNew > cMax || rMinNew < rMin || rMaxNew > rMax);
|
||||||
Select(rMinNew, cMinNew, rMaxNew, cMaxNew);
|
CellRange cr = GetCellRange(rMinNew, cMinNew, rMaxNew, cMaxNew);
|
||||||
|
return cr;
|
||||||
}
|
}
|
||||||
private int MinimumColumn(int r, int c)
|
private int MinimumColumn(int r, int c)
|
||||||
{
|
{
|
||||||
@ -3154,7 +3285,7 @@ namespace Volian.Controls.Library
|
|||||||
{
|
{
|
||||||
string tmp = _owner[row, col].ToString();
|
string tmp = _owner[row, col].ToString();
|
||||||
if (tmp.StartsWith(@"{\rtf"))
|
if (tmp.StartsWith(@"{\rtf"))
|
||||||
Rtf = tmp;
|
Rtf = tmp.Replace(@"\~",@"\u160?");
|
||||||
else
|
else
|
||||||
Text = tmp;
|
Text = tmp;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user