B2015-103: indents (strip out rtf indent commands)

B2015-103:  indents (handle rtf indent commands)
B2015-103:  indents (set/clear ribbon button for indents)
B2015-103: setup rtf string for indents; display small identifying marks for indents
B2015-103: remove page break from ribbon; move indent; support new indent; support for table grid indent
B2015-103: Print for new indents in tables
B2015-103: Print for new indents in paragraphs
This commit is contained in:
2015-08-19 12:18:39 +00:00
parent 49dcdd4f4a
commit a58add8937
9 changed files with 1078 additions and 990 deletions

View File

@@ -474,7 +474,7 @@ namespace Volian.Controls.Library
RemoveEventHandlers();
OnAdjustTableWidth(this, new StepRTBTableWidthEventArgs(false));// View Mode
SelectAll();
if (SelectionHangingIndent !=0) SelectionHangingIndent = 0;
//if (SelectionHangingIndent !=0) SelectionHangingIndent = 0;
int indchar = 0;
string indentToken = MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IndentToken;
if (indentToken == null || indentToken=="0") indentToken = "\x5";
@@ -958,6 +958,16 @@ namespace Volian.Controls.Library
this.ContentsResized -= new ContentsResizedEventHandler(StepRTB_ContentsResized);
Text = "";
this.ContentsResized += new ContentsResizedEventHandler(StepRTB_ContentsResized);
// indents went from being handled by code support of an indent character (usually \05) to
// using rtf commands to fix various indent bugs including B2015-103). The following code
// puts the rtf indent characters that are stored at beginning of string into correct location
// of rtf header (have to be after the \pard). Otherwise the indents did not show up.
Match match = Regex.Match(txt,@"\\fi([-0-9]*) ?\\li([0-9]*)");
if (match.Success)
{
string indentStr = @"\fi" + match.Groups[1].Value + @"\li" + match.Groups[2].Value;
Rtf = Rtf.Replace(@"\pard", @"\pard" + indentStr);
}
SelectedRtf = _LastRtf = newRtf;
_lastReadOnly = ReadOnly;
}
@@ -976,6 +986,31 @@ namespace Volian.Controls.Library
_RtfPrefix = selectedRtfSB.ToString();
}
}
// The following code is used to display the little 'tic' marks to show indenting:
private const int WM_PAINT = 15;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_PAINT)
{
this.Invalidate();
base.WndProc(ref m);
if ((FieldToEdit == E_FieldToEdit.StepText) && (SelectionHangingIndent > 0 || SelectionIndent > 0) && (ActiveMode || MyItemInfo.IsTable))
{
using (Graphics g = Graphics.FromHwnd(this.Handle))
{
int size = 2;
g.DrawLine(Pens.DarkBlue, SelectionIndent, 0, SelectionIndent + size, 0);
g.DrawLine(Pens.DarkBlue, SelectionIndent, 2 * size, SelectionIndent, 0);
g.DrawLine(Pens.DarkBlue, SelectionHangingIndent, Height - 1, SelectionHangingIndent + size, Height - 1);
g.DrawLine(Pens.DarkBlue, SelectionHangingIndent, Height - 1 - 2 * size, SelectionHangingIndent, Height - 1);
}
}
}
else
{
base.WndProc(ref m);
}
}
private static void AddFontTable(StringBuilder selectedRtfSB, Font myFont, bool isFixed)
{
StringBuilder sbbeg = new StringBuilder();