This commit is contained in:
Kathy Ruffing 2011-03-09 12:05:09 +00:00
parent 56d571fe88
commit 5ec5508d95
2 changed files with 146 additions and 21 deletions

View File

@ -34,6 +34,7 @@ namespace Volian.Controls.Library
// VlnFlexGrid // VlnFlexGrid
// //
this.Rows.DefaultSize = 19; this.Rows.DefaultSize = 19;
((System.ComponentModel.ISupportInitialize)(this)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);

View File

@ -19,8 +19,33 @@ namespace Volian.Controls.Library
{ {
public delegate void VlnFlexGridEvent(object sender, EventArgs args); public delegate void VlnFlexGridEvent(object sender, EventArgs args);
public delegate void VlnFlexGridCursorMovementEvent(object sender, VlnFlexGridCursorMovementEventArgs args); public delegate void VlnFlexGridCursorMovementEvent(object sender, VlnFlexGridCursorMovementEventArgs args);
public partial class VlnFlexGrid : C1.Win.C1FlexGrid.C1FlexGrid public partial class VlnFlexGrid : C1.Win.C1FlexGrid.C1FlexGrid
{ {
//[XmlElement("MyBorders")]
//[Browsable(false)]
//[EditorBrowsable(EditorBrowsableState.Never)]
//public string MyBorderDetailString
//{
// get
// {
// return _MyBorderDetail.ToString();
// }
// set
// {
// if (value != null)
// _MyBorderDetail = VlnBorderDetail.Get(value);
// else
// _MyBorderDetail = null;
// }
//}
//private VlnBorderDetail _MyBorderDetail;
//[XmlIgnore]
//public VlnBorderDetail MyBorderDetail
//{
// get { return _MyBorderDetail; }
// set { _MyBorderDetail = value; }
//}
[XmlIgnore]
public bool HasVScroll public bool HasVScroll
{ {
get get
@ -28,6 +53,7 @@ namespace Volian.Controls.Library
return RTBAPI.HasVertScroll(this); return RTBAPI.HasVertScroll(this);
} }
} }
[XmlIgnore]
public bool HasHScroll public bool HasHScroll
{ {
get get
@ -103,10 +129,6 @@ namespace Volian.Controls.Library
{ {
_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
@ -129,7 +151,6 @@ namespace Volian.Controls.Library
InitializeComponent(); InitializeComponent();
SetupGrid(1, 1); SetupGrid(1, 1);
} }
//public VlnFlexGrid(IContainer container) //public VlnFlexGrid(IContainer container)
//{ //{
// container.Add(this); // container.Add(this);
@ -417,7 +438,7 @@ namespace Volian.Controls.Library
this.Styles.EmptyArea.BackColor = Color.Transparent; this.Styles.EmptyArea.BackColor = Color.Transparent;
this.Styles.EmptyArea.Border.Style = BorderStyleEnum.None; this.Styles.EmptyArea.Border.Style = BorderStyleEnum.None;
this.Styles.Normal.Border.Color = Color.Black; this.Styles.Normal.Border.Color = Color.Black;
this.Styles.Normal.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.LeftCenter; this.Styles.Normal.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.LeftTop;
//SetupCellStyles(); //SetupCellStyles();
@ -456,7 +477,6 @@ namespace Volian.Controls.Library
TableCellEditor.EditMode = TableCellEditor.Visible; // need to comment out for compile for only jsj - 07FEB2011 TableCellEditor.EditMode = TableCellEditor.Visible; // need to comment out for compile for only jsj - 07FEB2011
} }
void _tableCellEditor_HeightChanged(object sender, EventArgs args) void _tableCellEditor_HeightChanged(object sender, EventArgs args)
{ {
if (_tableCellEditor._initializingEdit || !_tableCellEditor.Visible) return; if (_tableCellEditor._initializingEdit || !_tableCellEditor.Visible) return;
@ -522,7 +542,6 @@ namespace Volian.Controls.Library
} }
void VlnFlexGrid_KeyDown(object sender, KeyEventArgs e) void VlnFlexGrid_KeyDown(object sender, KeyEventArgs e)
{ {
switch (e.KeyCode) switch (e.KeyCode)
{ {
case Keys.Left: case Keys.Left:
@ -581,8 +600,6 @@ namespace Volian.Controls.Library
e.Style.BackColor = solid; e.Style.BackColor = solid;
// check whether the cell contains RTF // check whether the cell contains RTF
// TODO: Can we do DisplayText() in here??
//DisplayText(ItemInfo itemInfo, string text, bool colorLinks)
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)
@ -598,11 +615,35 @@ namespace Volian.Controls.Library
// 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 = Cols[e.Col].Width; _rtf.Width = e.Bounds.Width - 3;
_rtf.Rtf = rtfText; _rtf.Rtf = rtfText;
CellRange cr = GetMergedRange(e.Row, e.Col);
cr.UserData = _rtf.Height;
int hAdjust = 0;
int hDiff = e.Bounds.Height - _rtf.Height;
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;
}
}
_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,e.Bounds.Width-3,e.Bounds.Height)); _rtf.Render(e.Graphics, new Rectangle(e.Bounds.X+1,e.Bounds.Y + hAdjust,e.Bounds.Width-3,e.Bounds.Height));
//CellRange cr = GetCellRange(e.Row, e.Col); //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;
@ -688,9 +729,7 @@ namespace Volian.Controls.Library
this.BorderStyle = border; this.BorderStyle = border;
this.AdjustGridControlSize(); this.AdjustGridControlSize();
} }
public void ChangeCellAlign(CellRange cr, TextAlignEnum newAlign)
public void ChangeCellBorder(CellRange cr, BorderStyleEnum newBorder)
{ {
for (int rw = cr.r1; rw <= cr.r2; rw++) for (int rw = cr.r1; rw <= cr.r2; rw++)
for (int col = cr.c1; col <= cr.c2; col++) for (int col = cr.c1; col <= cr.c2; col++)
@ -698,11 +737,38 @@ namespace Volian.Controls.Library
CellRange tmp = this.GetCellRange(rw, col, rw, col); CellRange tmp = this.GetCellRange(rw, col, rw, col);
string StyleName = string.Format("R{0}C{1}Style", rw, col); string StyleName = string.Format("R{0}C{1}Style", rw, col);
CellStyle cs = this.Styles.Add(StyleName, tmp.Style); CellStyle cs = this.Styles.Add(StyleName, tmp.Style);
cs.TextAlign = newAlign;
tmp.Style = cs;
}
}
public void ChangeCellBorder(CellRange cr, BorderStyleEnum newBorder)
{
for (int rw = cr.r1; rw <= cr.r2; rw++)
for (int col = cr.c1; col <= cr.c2; col++)
{
CellRange tmp = this.GetCellRange(rw, col, rw, col);
string StyleName = string.Format("R{0}C{1}Style", rw, col);
CellStyle cs = null;
if (Styles.Contains(StyleName))
cs = Styles[StyleName];
else
cs = this.Styles.Add(StyleName, tmp.Style);
cs.Border.Style = newBorder; cs.Border.Style = newBorder;
tmp.Style = cs; tmp.Style = cs;
} }
} }
public void ListStyles()
{
for (int r = 0; r < Rows.Count; r++)
for (int c = 0; c < Cols.Count; c++)
{
CellRange cr = GetMergedRange(r, c);
if (cr.r1 == r && cr.c1 == c)
{
if (cr.Style != null) Console.WriteLine("{0}, {1}, {2}, {3}", r, c, cr.Style.Name, cr.Style.BackColor);
}
}
}
public void VerticalCenterText() public void VerticalCenterText()
{ {
StepRTB myStepRTB = new StepRTB(); StepRTB myStepRTB = new StepRTB();
@ -2151,6 +2217,47 @@ namespace Volian.Controls.Library
} }
#endregion //Clipboard #endregion //Clipboard
#region Selection
public bool SelectNextCell()
{
int r = this.Row;
int c = this.Col;
CellRange cr = GetMergedRange(r, c);
do
{
c = cr.c2 + 1;
if (c >= this.Cols.Count)
{
r = r + 1;
c = 0;
if (r >= this.Rows.Count) return false;
}
cr = GetMergedRange(r, c);
} while (r != cr.r1 || c != cr.c1);
Select(r, c);
return true;
}
public bool SelectPrevCell()
{
int r = this.Row;
int c = this.Col;
CellRange cr = GetMergedRange(r, c);
do
{
c = cr.c1 - 1;
if (c < 0)
{
r = r - 1;
c = this.Cols.Count-1;
if (r < 0) return false;
}
cr = GetMergedRange(r, c);
c = cr.c1;
} while (r != cr.r1);
Select(r, c);
return true;
}
#endregion
#region SearchableText #region SearchableText
public string GetSearchableText() public string GetSearchableText()
{ {
@ -2248,6 +2355,7 @@ namespace Volian.Controls.Library
this.Clear(); this.Clear();
this.MergedRanges.Clear(); this.MergedRanges.Clear();
this.ReadXml(ofd.FileName); this.ReadXml(ofd.FileName);
this.KeyActionTab = KeyActionEnum.MoveAcross;
this.AdjustGridControlSize(); this.AdjustGridControlSize();
rtn = ofd.SafeFileName; rtn = ofd.SafeFileName;
return rtn; return rtn;
@ -3084,6 +3192,25 @@ namespace Volian.Controls.Library
{ {
return GetMergedRange(r, c).r2; return GetMergedRange(r, c).r2;
} }
public Color StyleBackColor
{
get {return Styles.Normal.BackColor;}
set
{
Styles.Normal.BackColor = value;
Styles.Alternate.BackColor = value;
for (int c = 0; c < Cols.Count; c++)
for (int r = 0; r < Rows.Count; r++)
{
CellRange cr = GetMergedRange(r, c);
if (cr.Style != null && cr.Style.BackColor != value && cr.Style.Name != "Fixed")
{
cr.Style.BackColor = value;
//Console.WriteLine("{0}, {1}, {2}, {3}", r, c, cr.Style.Name, cr.Style.BackColor);
}
}
}
}
/// <summary> /// <summary>
/// Returns a list of cells or merged cells within the selection /// Returns a list of cells or merged cells within the selection
/// </summary> /// </summary>
@ -3642,13 +3769,10 @@ namespace Volian.Controls.Library
get { return _cpbrdCellRange; } get { return _cpbrdCellRange; }
set { _cpbrdCellRange = value; } set { _cpbrdCellRange = value; }
} }
public SelectedTableCells() public SelectedTableCells()
{ {
} }
} }
#endregion // TableClipBoardFuncts Class #endregion // TableClipBoardFuncts Class
public class VlnFlexGridCursorMovementEventArgs public class VlnFlexGridCursorMovementEventArgs
{ {