This commit is contained in:
parent
729c39a503
commit
7704e926df
@ -12,6 +12,7 @@ using System.IO;
|
||||
using System.Text;
|
||||
using VEPROMS.CSLA.Library;
|
||||
using System.Text.RegularExpressions;
|
||||
using Volian.Controls.Library;
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
@ -21,6 +22,8 @@ namespace DataLoader
|
||||
{
|
||||
//if (ProcNumber + "|" + stpseq == "082-002CD|A=S")
|
||||
// Console.WriteLine("here");
|
||||
//if (stpseq == "A;S#")
|
||||
// Console.WriteLine("here");
|
||||
Content content = null;
|
||||
Item item = null;
|
||||
|
||||
@ -101,7 +104,12 @@ namespace DataLoader
|
||||
stptext = MigrateTrans(cn, stptext, seqcvt, content, pth);
|
||||
stptext = stptext.TrimEnd(" ".ToCharArray());
|
||||
}
|
||||
string fixStpText = FixStepText(stptext);
|
||||
//string fixStpText = FixStepText(stptext,content.Type);
|
||||
string fixStpText = "";
|
||||
if (IsATable(content.Type))
|
||||
fixStpText = ConvertTableToGrid(stptext,content,fmt);
|
||||
else
|
||||
fixStpText = FixStepText(stptext);
|
||||
if (fixStpText != stptext)
|
||||
{
|
||||
txtdirty = true;
|
||||
@ -297,6 +305,87 @@ namespace DataLoader
|
||||
return stepText;
|
||||
}
|
||||
|
||||
//private Font GridFont = new Font("Courier New", 10);
|
||||
|
||||
//private Regex _RemoveComments = new Regex(@"\\v .*?\\v0 ");
|
||||
private Regex _RemoveComments = new Regex(@"\\v .*?\\v0( |$)");
|
||||
private string ConvertTableToGrid(string stepText, Content content, FormatInfo fmt)
|
||||
{
|
||||
string savethis = stepText;
|
||||
string strGrid = "";
|
||||
VlnFlexGrid grd = new VlnFlexGrid(1, 1);
|
||||
//VE_Font vefont = content.MyFormat.PlantFormat.FormatData.StepDataList.Table.Font;
|
||||
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"
|
||||
stepText = FixStepText(stepText);
|
||||
stepText = stepText.Replace(@"\u8209?", "-");
|
||||
stepText = stepText.Replace(@"\u9474?", "|");
|
||||
stepText = stepText.Replace(@"\u8805?", "\xf2"); //greater than or equal
|
||||
stepText = stepText.Replace(@"\'b0", "\xB0");
|
||||
stepText = stepText.Replace(@"\up2 ", "\x9566");
|
||||
stepText = stepText.Replace(@"\up0 ", "\x9567");
|
||||
stepText = stepText.Replace(@"\ulnone", "\xBB");
|
||||
stepText = stepText.Replace(@"\ul", "\xAB");
|
||||
stepText = stepText.Replace(@"\{", "{");
|
||||
stepText = stepText.Replace(@"\}", "}");
|
||||
//stepText = stepText.Replace("\\b0", "\x2553");
|
||||
//stepText = stepText.Replace("\\b", "\x2552");
|
||||
stepText = stepText.Replace(@"\b0", "\xD6");
|
||||
stepText = stepText.Replace(@"\b", "\xD5");
|
||||
//stepText = stepText.Replace(@"\u160?", "\xA0"); //hard space
|
||||
stepText = stepText.Replace(@"\u160?", "\xFF"); //hard space xFF is used in 16-bit proms
|
||||
stepText = stepText.Replace(@"\u916?", "\x7F"); // delta
|
||||
//Console.WriteLine("B4 Parse Orig Text: '{0}'", savethis);
|
||||
//Console.WriteLine("B4 Parse sym repl: '{0}'", stepText);
|
||||
grd.ParseTableFromText(_RemoveComments.Replace(stepText, ""));
|
||||
//grd.ParseTableFromText(_RemoveComments.Replace((stepText.Replace(@"\u8209?", "-")).Replace("\\'b0", "\xB0"), ""));
|
||||
//grd.ParseTableFromText(_RemoveComments.Replace((stepText.Replace(@"\u8209?", "-")).Replace("\\par", "\n"), ""));
|
||||
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();
|
||||
sw.Close();
|
||||
}
|
||||
return strGrid;
|
||||
}
|
||||
//private void FixSymbolsInGridTable(Content content, ItemInfo ii)
|
||||
//{
|
||||
// VlnFlexGrid grd = new VlnFlexGrid(1, 1);
|
||||
// using (TextReader stringreader = new StringReader(content.MyGrid.Data))
|
||||
// {
|
||||
// grd.ReadXml(stringreader);
|
||||
// stringreader.Close();
|
||||
// }
|
||||
// for (int r = 0; r < grd.Rows.Count; r++)
|
||||
// for (int c = 0; c < grd.Cols.Count; c++)
|
||||
// {
|
||||
// StepRTB trtb = new StepRTB();
|
||||
// trtb = grd[r, c];
|
||||
// DisplayText dt = new DisplayText(trtb.Rtf, true);
|
||||
// grd[r, c] = dt.OriginalText;
|
||||
// }
|
||||
//}
|
||||
private bool IsATable(int? contenttype)
|
||||
{
|
||||
bool rtnval = false;
|
||||
switch (contenttype)
|
||||
{
|
||||
case 20008: // Centered table
|
||||
case 20010: // AER table
|
||||
case 20033: // AER table without boarder
|
||||
case 20034: // Centered table without boarder
|
||||
rtnval = true;
|
||||
break;
|
||||
}
|
||||
return rtnval;
|
||||
}
|
||||
|
||||
//private static bool AddContentDetail(Content content, int type, string strn)
|
||||
//{
|
||||
// if (strn != null && strn.Trim() != "" )
|
||||
|
@ -424,7 +424,8 @@ namespace DataLoader
|
||||
// superscript next is 0x18
|
||||
// subscript next is 0x19
|
||||
// bold next is 0x13
|
||||
s2 = Regex.Replace(s2, @"\x17([^\x17 ]*?)(?:[\x17]|(?= )|\Z)(.*?)", @"\ul $1\ulnone $2");
|
||||
s2 = Regex.Replace(s2, @"\x17([A-Za-z0-9]+)", @"\ul $1\ulnone ");
|
||||
//s2 = Regex.Replace(s2, @"\x17([^\x17 ]*?)(?:[\x17]|(?= )|\Z)(.*?)", @"\ul $1\ulnone $2");
|
||||
//s2 = Regex.Replace(s2, @"\x18([^\x18 ]*?)(?:[\x18]|(?= )|\Z)(.*?)", @"\super $1\nosupersub $2");
|
||||
//s2 = Regex.Replace(s2, @"\x19([^\x19 ]*?)(?:[\x19]|(?= )|\Z)(.*?)", @"\sub $1\nosupersub $2");
|
||||
s2 = Regex.Replace(s2, @"\x18([^\x18 ]*?)(?:[\x18]|(?= )|\Z)(.*?)", @"\up2 $1\up0 $2");
|
||||
|
@ -61,6 +61,12 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
void MyFlexGrid_Resize(object sender, EventArgs e)
|
||||
{
|
||||
if (MyItemInfo != null && MyItemInfo.ItemID == 14)
|
||||
{
|
||||
//Console.WriteLine("{0},{1},{2}", MyFlexGrid.Height, MyStepRTB.ContentsRectangle.Height,MyFlexGrid.Rows[0].Height);
|
||||
if (MyFlexGrid.Height < MyStepRTB.ContentsRectangle.Height)
|
||||
MyFlexGrid.Height = 4 + MyStepRTB.ContentsRectangle.Height;
|
||||
}
|
||||
this.Size = new Size(MyFlexGrid.Width + GridMargin, MyFlexGrid.Height + GridMargin);
|
||||
AdjustTableWidthAndLocation();
|
||||
AdjustLocation();
|
||||
|
@ -19,6 +19,8 @@ namespace Volian.Controls.Library
|
||||
public static extern int SendMessage(HandleRef hWndlock, Messages wMsg, RTBSelection wParam, ref CharFormat2 cf2);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern int SendMessage(HandleRef hWndlock, Messages wMsg, int wParam, ref ParaFormat2 pf2);
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
private static extern int GetWindowLong (IntPtr hWin, int index);
|
||||
#region RTB Messages
|
||||
// EM_AUTOURLDETECT - An EM_AUTOURLDETECT message enables or disables automatic detection of URLs by a rich edit control.
|
||||
// EM_CANPASTE - The EM_CANPASTE message determines whether a rich edit control can paste a specified clipboard format.
|
||||
@ -114,6 +116,10 @@ namespace Volian.Controls.Library
|
||||
|
||||
|
||||
const int WM_USER = 0x0400;
|
||||
const int GWL_STYLE = -16;
|
||||
const int WS_HSCROLL = 0x100000;
|
||||
const int WS_VSCROLL = 0x200000;
|
||||
|
||||
#endregion
|
||||
#region Enums
|
||||
public enum Messages : int
|
||||
@ -762,6 +768,16 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
#endregion
|
||||
#region Static Methods
|
||||
public static bool HasVertScroll(Control ctl)
|
||||
{
|
||||
int dwstyle = GetWindowLong(ctl.Handle, GWL_STYLE);
|
||||
return (dwstyle & WS_VSCROLL) != 0;
|
||||
}
|
||||
public static bool HasHorzScroll(Control ctl)
|
||||
{
|
||||
int dwstyle = GetWindowLong(ctl.Handle, GWL_STYLE);
|
||||
return (dwstyle & WS_HSCROLL) != 0;
|
||||
}
|
||||
public static void SetScrollLocation(RichTextBox richTextBox, Point point)
|
||||
{
|
||||
if (SendMessage(new HandleRef(richTextBox, richTextBox.Handle), Messages.EM_SETSCROLLPOS, 0, ref point) == 0)
|
||||
|
@ -141,6 +141,22 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
#endregion
|
||||
#region Properties and Variables
|
||||
public bool HasVScroll
|
||||
{
|
||||
get
|
||||
{
|
||||
return RTBAPI.HasVertScroll(this);
|
||||
}
|
||||
|
||||
}
|
||||
public bool HasHScroll
|
||||
{
|
||||
get
|
||||
{
|
||||
return RTBAPI.HasHorzScroll(this);
|
||||
}
|
||||
|
||||
}
|
||||
private bool _EditMode = true;
|
||||
/// <summary>
|
||||
/// Allows insert of links. If false, don't allow selection of links.
|
||||
@ -184,7 +200,7 @@ namespace Volian.Controls.Library
|
||||
set { _FieldToEdit = value; }
|
||||
}
|
||||
private string _RtfPrefix; // contains Font table and styles (bold/underline/italics) for rtb from step style
|
||||
public string RtfPrefix
|
||||
public string RtfPrefixForSymbols
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -197,6 +213,19 @@ namespace Volian.Controls.Library
|
||||
return _RtfPrefix + @"\f1\fs" + FormatFont.SizeInPoints * 2 + " ";
|
||||
}
|
||||
}
|
||||
public string RtfPrefix
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_RtfPrefix == null)
|
||||
{
|
||||
StringBuilder selectedRtfSB = new StringBuilder();
|
||||
AddFontTable(selectedRtfSB, FormatFont, FontIsFixed(FormatFont));
|
||||
_RtfPrefix = selectedRtfSB.ToString();
|
||||
}
|
||||
return _RtfPrefix;
|
||||
}
|
||||
}
|
||||
// August 5, 2009 - KBR & RHM:
|
||||
// Insert/Overwrite will be developed later if needed. various issues
|
||||
// were found during initial development that made its scope larger than
|
||||
@ -783,6 +812,18 @@ namespace Volian.Controls.Library
|
||||
FindAllLinks();
|
||||
if (txt == "") SelectionFont = FormatFont;
|
||||
}
|
||||
public void SetTableGridCellRTFPrefix(Font myfont)
|
||||
{
|
||||
if (_FormatFont == null)
|
||||
_FormatFont = myfont;
|
||||
|
||||
if (_RtfPrefix == null)
|
||||
{
|
||||
StringBuilder selectedRtfSB = new StringBuilder();
|
||||
AddFontTable(selectedRtfSB, myfont, FontIsFixed(myfont));
|
||||
_RtfPrefix = selectedRtfSB.ToString();
|
||||
}
|
||||
}
|
||||
private static void AddFontTable(StringBuilder selectedRtfSB, Font myFont, bool isFixed)
|
||||
{
|
||||
StringBuilder sbbeg = new StringBuilder();
|
||||
@ -851,7 +892,7 @@ namespace Volian.Controls.Library
|
||||
// See comments in AddRtf(string str) to explain the font style setting
|
||||
RTBAPI.E_FontStyle fs = RTBAPI.GetFontStyle(this);
|
||||
int position = SelectionStart;
|
||||
SelectedRtf = RtfPrefix + str + @"}";
|
||||
SelectedRtf = RtfPrefixForSymbols + str + @"}";
|
||||
Select(position, 1);
|
||||
RTBAPI.SetFontStyle(this, fs);
|
||||
Select(position + 1, 0);
|
||||
@ -2555,14 +2596,14 @@ namespace Volian.Controls.Library
|
||||
Select(rowOffset + col, 1);
|
||||
string charToBeReplaced = SelectedText;
|
||||
if (Text.Length > (rowOffset + col + 7) && Text.Substring(rowOffset + col + 1, 6) != "#Link:")
|
||||
SelectedRtf = RtfPrefix + TableCharsU[tableCharIndx] + "?}";
|
||||
SelectedRtf = RtfPrefixForSymbols + TableCharsU[tableCharIndx] + "?}";
|
||||
else
|
||||
{
|
||||
SelectionStart++;
|
||||
int lenComment = 1 + SelectionStart - (rowOffset + col);
|
||||
//Console.WriteLine("{0},{1},{2}", rowOffset + col, SelectionStart, SelectionLength);
|
||||
Select(rowOffset + col, 0);
|
||||
SelectedRtf = RtfPrefix + TableCharsU[tableCharIndx] + "?}";
|
||||
SelectedRtf = RtfPrefixForSymbols + TableCharsU[tableCharIndx] + "?}";
|
||||
Select(rowOffset + col, lenComment);
|
||||
//Console.WriteLine("'{0}',{1},{2},{3}", SelectedText, lenComment, SelectionLength, SelectionStart);
|
||||
//Console.WriteLine("'{0}'", SelectedRtf);
|
||||
|
@ -19,6 +19,20 @@ namespace Volian.Controls.Library
|
||||
public delegate void VlnFlexGridCursorMovementEvent(object sender, VlnFlexGridCursorMovementEventArgs args);
|
||||
public partial class VlnFlexGrid : C1.Win.C1FlexGrid.C1FlexGrid
|
||||
{
|
||||
public bool HasVScroll
|
||||
{
|
||||
get
|
||||
{
|
||||
return RTBAPI.HasVertScroll(this);
|
||||
}
|
||||
}
|
||||
public bool HasHScroll
|
||||
{
|
||||
get
|
||||
{
|
||||
return RTBAPI.HasHorzScroll(this);
|
||||
}
|
||||
}
|
||||
public event VlnFlexGridEvent OpenAnnotations;
|
||||
public void OnOpenAnnotations(object sender, EventArgs args)
|
||||
{
|
||||
@ -82,42 +96,42 @@ namespace Volian.Controls.Library
|
||||
// _tableCellEditor.ContentsResized += new ContentsResizedEventHandler(_tableCellEditor_ContentsResized);
|
||||
//}
|
||||
|
||||
void _tableCellEditor_ContentsResized(object sender, ContentsResizedEventArgs e)
|
||||
{
|
||||
if (_tableCellEditor._initializingEdit) return;
|
||||
CellRange cr = GetMergedRange(Row, Col);
|
||||
int oH = cr.UserData == null? 0 : (int)cr.UserData;
|
||||
int nH = _tableCellEditor.ContentsRectangle.Height;
|
||||
int Hadj = (nH - oH);
|
||||
cr.UserData = _tableCellEditor.ContentsRectangle.Height;
|
||||
int cellHeight = GetCellHeight(Row,Col);
|
||||
int cellheightNLines = cellHeight / (Rows.DefaultSize - 3);
|
||||
int nHNLines = nH / (Rows.DefaultSize - 3);
|
||||
if (Hadj != 0)
|
||||
{
|
||||
int curHeight = (Rows[Row].Height == -1) ? Rows.DefaultSize : Rows[Row].Height;
|
||||
//if (Hadj > 0 && cellHeight <= oH)
|
||||
if (Hadj > 0 && cellheightNLines < nHNLines)
|
||||
curHeight += (Rows.DefaultSize - 3);
|
||||
if (Hadj < 0 && CanReduceRow())
|
||||
curHeight -= (Rows.DefaultSize-3);
|
||||
Rows[Row].Height = curHeight;
|
||||
AdjustGridControlSize();
|
||||
}
|
||||
//cr.UserData = _tableCellEditor.ContentsRectangle.Height;
|
||||
//int mh = GetMaxRowHeight();
|
||||
////Rows[Row].Height = mh + 2;
|
||||
//int h = 0;
|
||||
//if (cr.r1 == cr.r2 && cr.c1 == cr.c2)
|
||||
// h = Rows[Row].Height - 2;
|
||||
//else
|
||||
//{
|
||||
// for (int r = cr.r1; r <= cr.r2; r++)
|
||||
// h += Rows[r].Height - 2;
|
||||
//}
|
||||
//Rows[Row].Height += (mh - h);
|
||||
////AdjustGridControlSize();
|
||||
}
|
||||
//void _tableCellEditor_ContentsResized(object sender, ContentsResizedEventArgs e)
|
||||
//{
|
||||
// if (_tableCellEditor._initializingEdit) return;
|
||||
// CellRange cr = GetMergedRange(Row, Col);
|
||||
// int oH = cr.UserData == null? 0 : (int)cr.UserData;
|
||||
// int nH = _tableCellEditor.ContentsRectangle.Height;
|
||||
// int Hadj = (nH - oH);
|
||||
// cr.UserData = _tableCellEditor.ContentsRectangle.Height;
|
||||
// int cellHeight = GetCellHeight(Row,Col);
|
||||
// int cellheightNLines = cellHeight / (Rows.DefaultSize - 3);
|
||||
// int nHNLines = nH / (Rows.DefaultSize - 3);
|
||||
// if (Hadj != 0)
|
||||
// {
|
||||
// int curHeight = (Rows[Row].Height == -1) ? Rows.DefaultSize : Rows[Row].Height;
|
||||
// //if (Hadj > 0 && cellHeight <= oH)
|
||||
// if (Hadj > 0 && cellheightNLines < nHNLines)
|
||||
// curHeight += (Rows.DefaultSize - 3);
|
||||
// if (Hadj < 0 && CanReduceRow())
|
||||
// curHeight -= (Rows.DefaultSize-3);
|
||||
// Rows[Row].Height = curHeight;
|
||||
// AdjustGridControlSize();
|
||||
// }
|
||||
// //cr.UserData = _tableCellEditor.ContentsRectangle.Height;
|
||||
// //int mh = GetMaxRowHeight();
|
||||
// ////Rows[Row].Height = mh + 2;
|
||||
// //int h = 0;
|
||||
// //if (cr.r1 == cr.r2 && cr.c1 == cr.c2)
|
||||
// // h = Rows[Row].Height - 2;
|
||||
// //else
|
||||
// //{
|
||||
// // for (int r = cr.r1; r <= cr.r2; r++)
|
||||
// // h += Rows[r].Height - 2;
|
||||
// //}
|
||||
// //Rows[Row].Height += (mh - h);
|
||||
// ////AdjustGridControlSize();
|
||||
//}
|
||||
private int GetCellHeight(int row, int col)
|
||||
{
|
||||
int height = 0;
|
||||
@ -128,30 +142,54 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
return height;
|
||||
}
|
||||
private bool CanReduceRow()
|
||||
private int BlankRowSpace()
|
||||
{
|
||||
int curRowHeight = (Rows[Row].Height == -1) ? Rows.DefaultSize - 3 : Rows[Row].Height -3;
|
||||
int curRowHeight = (Rows[Row].Height == -1) ? Rows.DefaultSize - 3 : Rows[Row].Height - 3;
|
||||
int curRowHeightNLines = curRowHeight / (Rows.DefaultSize - 3);
|
||||
bool bReduce = (curRowHeight > (Rows.DefaultSize - 3));
|
||||
if (bReduce)
|
||||
if (curRowHeight <= (Rows.DefaultSize - 3)) return 0; // never have row less than default height
|
||||
int blankRowSpace = curRowHeight;
|
||||
for (int c = 0; c < Cols.Count; c++)
|
||||
{
|
||||
for (int c = 0; c < Cols.Count; c++)
|
||||
CellRange cr = GetMergedRange(Row, c);
|
||||
if (Row >= cr.r1 && Row <= cr.r2)
|
||||
{
|
||||
CellRange cr = GetMergedRange(Row, c);
|
||||
if (Row >= cr.r1 && Row <= cr.r2)
|
||||
{
|
||||
int mergeCellHeightNLines = GetCellHeight(Row, c) / (Rows.DefaultSize - 3);
|
||||
//int ud = (cr.UserData == null) ? 0 : (int)cr.UserData;
|
||||
//if ((c != Col) && curRowHeight <= ud && ud >= mergeCellHeight)
|
||||
// bReduce = false;
|
||||
int ud = ((cr.UserData == null) ? 0 : (int)cr.UserData) / (Rows.DefaultSize - 3);
|
||||
if ((c != Col) && curRowHeightNLines <= ud && ud >= mergeCellHeightNLines)
|
||||
bReduce = false;
|
||||
}
|
||||
int cellHeight = GetCellHeight(Row, c);
|
||||
//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);
|
||||
blankRowSpace = Math.Min(blankRowSpace, Math.Max(0,cellHeight - dataHeight));
|
||||
}
|
||||
}
|
||||
return bReduce;
|
||||
//Console.WriteLine("BlankRowSpace {0}", blankRowSpace);
|
||||
return blankRowSpace;
|
||||
}
|
||||
//private bool CanReduceRow()
|
||||
//{
|
||||
// int curRowHeight = (Rows[Row].Height == -1) ? Rows.DefaultSize - 3 : Rows[Row].Height -3;
|
||||
// int curRowHeightNLines = curRowHeight / (Rows.DefaultSize - 3);
|
||||
// bool bReduce = (curRowHeight > (Rows.DefaultSize - 3));
|
||||
// if (bReduce)
|
||||
// {
|
||||
// for (int c = 0; c < Cols.Count; c++)
|
||||
// {
|
||||
// CellRange cr = GetMergedRange(Row, c);
|
||||
// if (Row >= cr.r1 && Row <= cr.r2)
|
||||
// {
|
||||
// int mergeCellHeightNLines = GetCellHeight(Row, c) / (Rows.DefaultSize - 3);
|
||||
// //int ud = (cr.UserData == null) ? 0 : (int)cr.UserData;
|
||||
// //if ((c != Col) && curRowHeight <= ud && ud >= mergeCellHeight)
|
||||
// // bReduce = false;
|
||||
// int ud = ((cr.UserData == null) ? 0 : (int)cr.UserData) / (Rows.DefaultSize - 3);
|
||||
// if ((c != Col) && curRowHeightNLines <= ud && ud >= mergeCellHeightNLines)
|
||||
// bReduce = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// //Console.WriteLine("canreduce {0}, {1}", Row, bReduce);
|
||||
// return bReduce;
|
||||
//}
|
||||
//private int GetMaxRowHeight()
|
||||
//{
|
||||
// int maxRTFHeight = _minRowSplitHeight; //Rows.DefaultSize;// the smallest a row can be
|
||||
@ -215,7 +253,8 @@ namespace Volian.Controls.Library
|
||||
|
||||
|
||||
_tableCellEditor = new TableCellEditor(this);
|
||||
_tableCellEditor.ContentsResized += new ContentsResizedEventHandler(_tableCellEditor_ContentsResized);
|
||||
//_tableCellEditor.ContentsResized += new ContentsResizedEventHandler(_tableCellEditor_ContentsResized);
|
||||
_tableCellEditor.HeightChanged += new StepRTBEvent(_tableCellEditor_HeightChanged);
|
||||
_clpbrdCpyPste = new TableClipBoardFuncts();
|
||||
|
||||
//this.Enter += new System.EventHandler(this.Grid_Enter);
|
||||
@ -233,8 +272,48 @@ namespace Volian.Controls.Library
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
void _tableCellEditor_HeightChanged(object sender, EventArgs args)
|
||||
{
|
||||
if (_tableCellEditor._initializingEdit || !_tableCellEditor.Visible) return;
|
||||
int curHeight = GetCellHeight(Row, Col);//(Rows[Row].Height == -1) ? Rows.DefaultSize : Rows[Row].Height;
|
||||
CellRange cr = GetMergedRange(Row, Col);
|
||||
int oH = cr.UserData == null ? curHeight : (int)cr.UserData;
|
||||
int nH = _tableCellEditor.Height; //.ContentsRectangle.Height;
|
||||
int Hadj = (nH - curHeight);//oH);
|
||||
cr.UserData = _tableCellEditor.Height; //.ContentsRectangle.Height;
|
||||
//int cellHeight = GetCellHeight(Row, Col);
|
||||
//int cellheightNLines = cellHeight / (Rows.DefaultSize - 3);
|
||||
//int nHNLines = nH / (Rows.DefaultSize - 3);
|
||||
if (Hadj != 0)
|
||||
{
|
||||
//if (Hadj > 0 && cellHeight <= oH)
|
||||
//if (Hadj > 0 && cellheightNLines < nHNLines)
|
||||
// curHeight += (Rows.DefaultSize - 3);
|
||||
//if (Hadj < 0 && CanReduceRow())
|
||||
// curHeight -= (Rows.DefaultSize - 3);
|
||||
int blankRowSpace = BlankRowSpace();
|
||||
if (Hadj < 0)
|
||||
Hadj = -Math.Min(-Hadj, blankRowSpace);
|
||||
//if (Hadj > 0)
|
||||
// Console.WriteLine("r {0}, nh {1}, curh{2}", Row, nH, curHeight);
|
||||
if (Hadj != 0)
|
||||
{
|
||||
Rows[Row].Height += Hadj;//= curHeight;
|
||||
AdjustGridControlSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
@ -350,6 +429,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawCellBorder(Graphics graphics, Rectangle rectangle, int row, int col)
|
||||
{
|
||||
int x1 = rectangle.Left;
|
||||
@ -548,7 +628,7 @@ namespace Volian.Controls.Library
|
||||
|
||||
this.Size = new Size(wid + difW, height + difH);
|
||||
}
|
||||
this.Refresh();
|
||||
//this.Refresh();
|
||||
}
|
||||
|
||||
public void AdjustGridHeightWidth(int r, int c)
|
||||
@ -557,23 +637,36 @@ namespace Volian.Controls.Library
|
||||
string tstr = null;
|
||||
bool dummyCharWidth = false;
|
||||
bool AllowWidthShrink = false;
|
||||
trtb.SetTableGridCellRTFPrefix(this.Font);
|
||||
trtb.Clear();
|
||||
tstr = (string)this[r, c];
|
||||
trtb.Font = this.Font;
|
||||
//trtb.Rtf = trtb.RtfPrefixForSymbols;
|
||||
if (tstr != null && tstr.Length > 0)
|
||||
{
|
||||
string tsave = tstr;
|
||||
if (tstr.StartsWith(@"{\rtf"))
|
||||
trtb.Rtf = tstr; // already RTF text
|
||||
else
|
||||
trtb.Text = tstr; // this will convert regular text to RTF text
|
||||
|
||||
//if (trtb.Rtf.Contains("SimSun"))
|
||||
// Console.WriteLine("here's SimSun! :-)");
|
||||
// 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);
|
||||
|
||||
// this will convert the special characters for Bold, Underline, and Italics
|
||||
// into RTF commands
|
||||
trtb.Rtf = ConvertTableText(trtb.Rtf);
|
||||
//VE_Font vf = new VE_Font(this.Font.FontFamily.Name, (int)this.Font.Size, E_Style.None);
|
||||
trtb.Rtf = trtb.RtfPrefix + ConvertTableText(trtb.Rtf) + "}";
|
||||
string fromRTF = trtb.Rtf;
|
||||
trtb.Rtf = trtb.RtfPrefix + ConvertTableText(tstr) + "}";
|
||||
string fromStr = trtb.Rtf;
|
||||
if (fromRTF.Contains("SimSun"))
|
||||
Console.WriteLine("SimSun");
|
||||
else
|
||||
Compare(fromRTF, fromStr, tsave);
|
||||
//ConvertTableText(trtb);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -589,6 +682,7 @@ namespace Volian.Controls.Library
|
||||
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);
|
||||
@ -665,6 +759,46 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
|
||||
private void Compare(string fromRTF, string fromStr, string rawstr)
|
||||
{
|
||||
int istart = fromRTF.IndexOf(" ",fromRTF.IndexOf("viewkind"));
|
||||
int jstart = fromStr.IndexOf(" ",fromStr.IndexOf("viewkind"));
|
||||
for (int i = istart; i < fromRTF.Length; i++)
|
||||
{
|
||||
int j = i - istart + jstart;
|
||||
//else if (fromRTF[i] != fromStr[j])
|
||||
if (fromRTF[i] != fromStr[j])
|
||||
{
|
||||
if (fromRTF.Substring(i, 1) == @"~" && fromStr.Substring(j, 3) == @"'a0")
|
||||
{
|
||||
//i++;
|
||||
jstart += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("fromStr:\r\n'{0}'\r\nfromRTF:\r\n'{1}'", fromStr, fromRTF);
|
||||
ShowRawString(rawstr, "rawstr");
|
||||
Console.WriteLine("Str:'{0}' , RTF:'{1}'", fromStr.Substring(j, 10), fromRTF.Substring(i, 10));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowRawString(string str, string title)
|
||||
{
|
||||
Console.WriteLine("Raw Start --{0}:\n", title);
|
||||
foreach (char c in str)
|
||||
{
|
||||
int ic= (int)c;
|
||||
if (c!='\n'&&( ic > 126 || ic < 32))
|
||||
Console.Write("<<{0:x4}>>", ic);
|
||||
else
|
||||
Console.Write(c);
|
||||
}
|
||||
Console.WriteLine("\n-- Raw End:{0}", title);
|
||||
}
|
||||
|
||||
private void Grid_AfterResize(object sender, C1.Win.C1FlexGrid.RowColEventArgs e)
|
||||
{
|
||||
this.AdjustGridControlSize();
|
||||
@ -716,30 +850,123 @@ namespace Volian.Controls.Library
|
||||
|
||||
}
|
||||
|
||||
//private string ConvertTableText(string str, VE_Font vf)
|
||||
private string ConvertTableText(string str)
|
||||
{
|
||||
string rtn = "";
|
||||
string rtn = str;
|
||||
//ShowRawString(str,"ConvertTableText IN");
|
||||
if (!str.StartsWith(@"{\rtf"))
|
||||
{
|
||||
rtn = rtn.Replace("\n", "\\par\r\n");
|
||||
rtn = rtn.Replace("\xF2", @"\f1 \u8805?\f0 "); //greater than or equal
|
||||
rtn = rtn.Replace("\x7F", @"\f1 \u916?\f0 "); // delta
|
||||
if (rtn.Contains("\xFF"))
|
||||
rtn = rtn.Replace("\xFF", @"\u160?");
|
||||
//rtn = rtn.Replace(@"\'a0", @"\u160?");
|
||||
//rtn = rtn.Replace("\xff", @"\u160?");
|
||||
//rtn = rtn.Replace("\xA0", @"\u160?");
|
||||
// underline On
|
||||
rtn = rtn.Replace("\xab", @"\ul");
|
||||
// underline Off
|
||||
rtn = rtn.Replace("\xbb", @"\ulnone");
|
||||
//rtn = rtn.Replace("\xef\xe6", @"\up2 ");
|
||||
//rtn = rtn.Replace("\xef\xe7", @"\up0 ");
|
||||
rtn = rtn.Replace("\x9566", @"\up2 ");
|
||||
rtn = rtn.Replace("\x9567", @"\up0 ");
|
||||
rtn = rtn.Replace("{", @"\{");
|
||||
rtn = rtn.Replace("}", @"\}");
|
||||
rtn = rtn.Replace("\xd5", @"\b");
|
||||
rtn = rtn.Replace("\xd6", @"\b0");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Underline next word
|
||||
rtn = SomethingNextWord(rtn, @"\'17", @"\ul ", @"\ulnone ");
|
||||
|
||||
// Underline next word
|
||||
rtn = SomethingNextWord(str, @"\'17", @"\ul ", @"\ulnone ");
|
||||
// Bold next word
|
||||
rtn = SomethingNextWord(rtn, @"\'13", @"\b ", @"\b0 ");
|
||||
|
||||
// Bold next word
|
||||
rtn = SomethingNextWord(rtn, @"\'13", @"\b ", @"\b0 ");
|
||||
// Italics On
|
||||
rtn = rtn.Replace(@"\'1B4", @"\i ");
|
||||
|
||||
// Italics On
|
||||
rtn = rtn.Replace(@"\'1B4", @"\i ");
|
||||
// Italics Off
|
||||
rtn = rtn.Replace(@"\'1B5", @"\i0 ");
|
||||
|
||||
// Italics Off
|
||||
rtn = rtn.Replace(@"\'1B5", @"\i0 ");
|
||||
// underline On
|
||||
rtn = rtn.Replace(@"\'ab", @"\ul");
|
||||
// underline Off
|
||||
rtn = rtn.Replace(@"\'bb", @"\ulnone");
|
||||
|
||||
// underline On
|
||||
rtn = rtn.Replace(@"\'ab", @"\ul ");
|
||||
// underline Off
|
||||
rtn = rtn.Replace(@"\'bb", @"\ulnone ");
|
||||
rtn = rtn.Replace(@"\'ef\'e6", @"\up2 ");
|
||||
rtn = rtn.Replace(@"\'ef\'e7", @"\up0 ");
|
||||
rtn = rtn.Replace(@"\'f2", @"\f1 \u8805?\f0 "); //greater than or equal
|
||||
//rtn = rtn.Replace("\xB0 ", @"\'b0 ");
|
||||
//rtn = rtn.Replace("\x2552", "\\b ");
|
||||
//rtn = rtn.Replace("\x2553", "\\b0 ");
|
||||
rtn = rtn.Replace(@"\'d5", @"\b");
|
||||
rtn = rtn.Replace(@"\'d6", @"\b0");
|
||||
//rtn = rtn.Replace("\xA0", @"\u160?");
|
||||
//rtn = rtn.Replace(@"\'a0", @"\u160?");
|
||||
rtn = rtn.Replace(@"\'ff", @"\u160?");
|
||||
//rtn = rtn.Replace("\xFF", @"\u160?");
|
||||
//rtn = rtn.Replace(@"\~", @"\u160?");
|
||||
rtn = rtn.Replace("\x7F", @"\f1 \u916?\f0 "); // delta
|
||||
}
|
||||
|
||||
//ShowRawString(rtn, "ConvertTableText OUT");
|
||||
return rtn;
|
||||
}
|
||||
|
||||
//private void ConvertTableText(StepRTB srtb)
|
||||
//{
|
||||
// string[] symb = { @"\'f2"};
|
||||
// string str = srtb.Rtf;
|
||||
|
||||
// // Underline next word
|
||||
// str = SomethingNextWord(str, @"\'17", @"\ul ", @"\ulnone ");
|
||||
|
||||
// // Bold next word
|
||||
// str = SomethingNextWord(str, @"\'13", @"\b ", @"\b0 ");
|
||||
|
||||
// // Italics On
|
||||
// str = str.Replace(@"\'1B4", @"\i ");
|
||||
|
||||
// // Italics Off
|
||||
// str = str.Replace(@"\'1B5", @"\i0 ");
|
||||
|
||||
// // underline On
|
||||
// str = str.Replace(@"\'ab", @"\ul");
|
||||
// // underline Off
|
||||
// str = str.Replace(@"\'bb", @"\ulnone");
|
||||
|
||||
// str = str.Replace(@"\'ef\'e6", @"\up2 ");
|
||||
// str = str.Replace(@"\'ef\'e7", @"\up0 ");
|
||||
// str = str.Replace(@"\'d5", @"\b");
|
||||
// str = str.Replace(@"\'d6", @"\b0");
|
||||
// str = str.Replace("\xA0", @"\u160?");
|
||||
// str = str.Replace("\x7F", @"\u916?");
|
||||
// VE_Font vf = new VE_Font(this.Font.FontFamily.Name,(int)this.Font.Size,E_Style.None);
|
||||
// DisplayText dt = new DisplayText(str,vf, true);
|
||||
|
||||
// srtb.Rtf = str;
|
||||
// //srtb.SelectionStart = 0;
|
||||
// //foreach (string s in symb)
|
||||
// //{
|
||||
// // int idx = srtb.Rtf.LastIndexOf(s, srtb.Rtf.Length-1);
|
||||
// // while (idx >= 0)
|
||||
// // {
|
||||
// // srtb.Rtf = srtb.Rtf.Remove(idx, s.Length);
|
||||
// // srtb.SelectionStart = idx;
|
||||
// // srtb.InsertSymbol(s);
|
||||
// // idx = srtb.Rtf.LastIndexOf(s,idx);
|
||||
// // }
|
||||
// //}
|
||||
// //rtn = rtn.Replace("\xf2 ", @"\u8805?"); //greater than or equal
|
||||
// //rtn = rtn.Replace("\xA0", @"\u160?");
|
||||
// //rtn = rtn.Replace("\x7F", @"\u916?");
|
||||
|
||||
//}
|
||||
|
||||
// This converts Underline or bold next word character to the corresponding on/off commands
|
||||
private static string SomethingNextWord(string str, string nxtwordcmd, string cmdOn, string cmdOff)
|
||||
{
|
||||
@ -1711,13 +1938,18 @@ namespace Volian.Controls.Library
|
||||
// get the cell text in the first cell of the merged grouping of cells
|
||||
// we will append the newly parsed text to this cell's text.
|
||||
int rw = curRow;
|
||||
while (rw - 1 > 0 && tci[rw - 1, curCol].MergeRowBellow) rw--;
|
||||
string jstr = (string)this[rw, curCol];
|
||||
while (rw - 1 >= 0 && tci[rw - 1, curCol].MergeRowBellow) rw--;
|
||||
int cl = curCol;
|
||||
while (cl - 1 >= 0 && tci[rw, cl-1].MergeColRight) cl--;
|
||||
//string jstr = (string)this[rw, curCol];
|
||||
string jstr = (string)this[rw, cl];
|
||||
if (jstr == null)
|
||||
jstr = tstr;
|
||||
else
|
||||
jstr += "\n" + tstr; // multi line cell
|
||||
this[rw, curCol] = jstr;
|
||||
jstr += ((cl==curCol)? "\n" : "") + tstr; // multi line cell
|
||||
//jstr += "\n" + tstr; // multi line cell
|
||||
//this[rw, curCol] = jstr;
|
||||
this[rw, cl] = jstr;
|
||||
// take a peek at the start of the next piece of table text to parse
|
||||
// if it starts with a '-' char, then flag to merge the columns up to
|
||||
// this point with the same columns in the next row
|
||||
@ -1754,14 +1986,19 @@ namespace Volian.Controls.Library
|
||||
// get the cell text in the first cell of the merged grouping of cells
|
||||
// we will append the newly parsed text to this cell's text.
|
||||
int rw = curRow;
|
||||
while (rw - 1 > 0 && tci[rw - 1, curCol].MergeRowBellow) rw--;
|
||||
string jstr = (string)this[rw, curCol];
|
||||
while (rw - 1 >= 0 && tci[rw - 1, curCol].MergeRowBellow) rw--;
|
||||
int cl = curCol;
|
||||
while (cl - 1 >= 0 && tci[rw, cl-1].MergeColRight) cl--;
|
||||
//string jstr = (string)this[rw, curCol];
|
||||
string jstr = (string)this[rw, cl];
|
||||
if (jstr == null)
|
||||
jstr = tstr;
|
||||
else
|
||||
jstr += "\n" + tstr; // multi line cell
|
||||
jstr += ((cl == curCol) ? "\n" : "") + tstr; // multi line cell
|
||||
//jstr += "\n" + tstr; // multi line cell
|
||||
|
||||
this[rw, curCol] = jstr;
|
||||
//this[rw, curCol] = jstr;
|
||||
this[rw, cl] = jstr;
|
||||
}
|
||||
else if (tstr.Length > 0) // parsed text is all dash characters
|
||||
{
|
||||
@ -1808,13 +2045,18 @@ namespace Volian.Controls.Library
|
||||
// get the cell text in the first cell of the merged grouping of cells
|
||||
// we will append the newly parsed text to this cell's text.
|
||||
int rw = curRow;
|
||||
while (rw - 1 > 0 && tci[rw - 1, curCol].MergeRowBellow) rw--;
|
||||
string jstr = (string)this[rw, curCol];
|
||||
while (rw - 1 >= 0 && tci[rw - 1, curCol].MergeRowBellow) rw--;
|
||||
int cl = curCol;
|
||||
while (cl - 1 >= 0 && tci[rw, cl-1].MergeColRight) cl--;
|
||||
//string jstr = (string)this[rw, curCol];
|
||||
string jstr = (string)this[rw, cl];
|
||||
if (jstr == null)
|
||||
jstr = tstr;
|
||||
else
|
||||
jstr += "\n" + tstr; // multi line cell
|
||||
this[rw, curCol] = jstr;
|
||||
jstr += ((cl == curCol) ? "\n" : "") + tstr; // multi line cell
|
||||
//jstr += "\n" + tstr; // multi line cell
|
||||
//this[rw, curCol] = jstr;
|
||||
this[rw, cl] = jstr;
|
||||
}
|
||||
}
|
||||
} while (idx != -1);
|
||||
@ -2217,6 +2459,7 @@ namespace Volian.Controls.Library
|
||||
AutoSize = false;
|
||||
BackColor = Color.SkyBlue;
|
||||
BorderStyle = BorderStyle.None;
|
||||
ScrollBars = RichTextBoxScrollBars.None;
|
||||
|
||||
_initializingEdit = false;
|
||||
_pendingKey = (char)0;
|
||||
@ -2226,7 +2469,7 @@ namespace Volian.Controls.Library
|
||||
this.CursorMovement += new StepRTBCursorMovementEvent(TableCellEditor_CursorMovement);
|
||||
this.CursorKeyPress += new StepRTBCursorKeysEvent(TableCellEditor_CursorKeyPress);
|
||||
this.Leave += new EventHandler(_editor_Leave);
|
||||
this.HeightChanged += new StepRTBEvent(_HeightChanged);
|
||||
//this.HeightChanged += new StepRTBEvent(_HeightChanged);
|
||||
}
|
||||
|
||||
// start editing: move to cell and activate
|
||||
@ -2261,13 +2504,15 @@ namespace Volian.Controls.Library
|
||||
|
||||
Size sz = new Size(rc.Width, rc.Height);
|
||||
|
||||
this.Size = sz;
|
||||
//this.Size = sz;
|
||||
this.Width = rc.Width;
|
||||
|
||||
// make editor visible
|
||||
Visible = true;
|
||||
|
||||
// and get the focus
|
||||
Select();
|
||||
//Select();
|
||||
Focus();
|
||||
_initializingEdit = false;
|
||||
}
|
||||
|
||||
@ -2350,10 +2595,10 @@ namespace Volian.Controls.Library
|
||||
_owner.Invalidate();
|
||||
_owner.AdjustGridControlSize();
|
||||
}
|
||||
void _HeightChanged(object sender, EventArgs args)
|
||||
{
|
||||
_owner.Invalidate();
|
||||
}
|
||||
//void _HeightChanged(object sender, EventArgs args)
|
||||
//{
|
||||
// _owner.Invalidate();
|
||||
//}
|
||||
|
||||
// save key that started the editing mode
|
||||
public void SetPendingKey(char chr)
|
||||
|
Loading…
x
Reference in New Issue
Block a user