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

@@ -140,9 +140,9 @@ namespace Volian.Controls.Library
string text = prefix + OriginalText + suffix;
_MyFormat = itemInfo.ActiveFormat;
bool tableShouldBeOutlined = (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit) &&
(_FieldToEdit == E_FieldToEdit.StepText || _FieldToEdit == E_FieldToEdit.Text) &&
(!itemInfo.IsSection && !itemInfo.IsProcedure) && (itemInfo.IsTable || itemInfo.IsFigure);
bool tableShouldBeOutlined = false; //(epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit) &&
//(_FieldToEdit == E_FieldToEdit.StepText || _FieldToEdit == E_FieldToEdit.Text) &&
//(!itemInfo.IsSection && !itemInfo.IsProcedure) && (itemInfo.IsTable || itemInfo.IsFigure);
bool wordsShouldBeReplaced = epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit;
if (_MyFormat == null)
Console.WriteLine(this._MyItemInfo.MyItemInfoUnique);
@@ -1160,6 +1160,10 @@ namespace Volian.Controls.Library
break;
case 'l':
if (Regex.IsMatch(token, @"^\\line ?$")) return token;
if (Regex.IsMatch(token, @"^\\li[-0-9]+ ?$")) return token; // line indent
break;
case 'f':
if (Regex.IsMatch(token, @"^\\fi[-0-9]+ ?$")) return token; // first line indent
break;
case 'p':
if (Regex.IsMatch(token, @"^\\par ?$")) return "\r\n";

View File

@@ -201,11 +201,13 @@ namespace Volian.Controls.Library
{
MyFlexGrid.Styles["Focus"].ForeColor = MyFlexGrid.Styles["Focus"].BackColor =
MyFlexGrid.Styles["Highlight"].ForeColor = MyFlexGrid.Styles["Highlight"].BackColor = Color.SkyBlue;
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetRibbonForGridCellIndent();
}
else
{
MyFlexGrid.Styles["Focus"].ForeColor = MyFlexGrid.Styles["Highlight"].ForeColor = Color.Black;
MyFlexGrid.Styles["Focus"].BackColor = MyFlexGrid.Styles["Highlight"].BackColor = Color.LightCyan;
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetRibbonForGridCellIndentClear();
}
}
private string _OrigRtf; // used to store original rtf to allow for 'escape' key restore

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();

View File

@@ -449,7 +449,7 @@ namespace Volian.Controls.Library
bool allow = (_MyStepRTB.TextLength > 0 && (MyEditItem == null || MyEditItem.MyStepPanel.VwMode == E_ViewMode.Edit));
// turn ribbon items on/off base on whether there is text in the edit window
rbnSiblings.Enabled = rbnBreaks.Enabled = rbnStepParts.Enabled = allow;
rbnSiblings.Enabled = rbnParagraph.Enabled = rbnStepParts.Enabled = allow;
// only turn on the Insert Before/After and the CopyStep buttons if on a step part
btnInsAftH.Enabled = btnInsBefH.Enabled = btnInsAfter.Enabled = btnInsBefore.Enabled = btnCpyStp.Enabled =
allow && !(MyItemInfo.IsProcedure || MyItemInfo.IsSection || MyItemInfo.IsFigure || MyItemInfo.IsTable || MyItemInfo.IsRNOPart);
@@ -1118,6 +1118,8 @@ namespace Volian.Controls.Library
}
btnInsPgBrk.Enabled = MyItemInfo.IsHigh;
btnPageBreak.Enabled = MyItemInfo.IsHigh; // edit context menu
btnIndent.Checked = (_MyStepRTB.EditMode && _MyStepRTB.SelectionHangingIndent != 0);
btnEditMode.Checked = btnCMEditMode1.Checked = MyEditItem.MyStepPanel.VwMode == E_ViewMode.View;
// if on procedure, 'Delete' buttons should be disabled.
btnDelelete.Enabled = btnDelStep.Enabled = !MyItemInfo.IsProcedure;
@@ -1493,12 +1495,22 @@ namespace Volian.Controls.Library
}
private void btnIndent_Click(object sender, EventArgs e)
{
StartGridEditing(SelectionOption.Start);
_MyStepRTB.InsertIndent(MyEditItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IndentToken);
if (MyItemInfo.IsProcedure || MyItemInfo.IsSection) return;
// For now, use the button as a toggle, i.e. if indent is on - turn it off. If indent is off, use the current cursor location to
// turn it on. Later, we may want to allow for multiple indents using the DisplayTags panel.
if (_MyStepRTB.SelectionHangingIndent != 0)
_MyStepRTB.SelectionHangingIndent = 0;
else
_MyStepRTB.SelectionHangingIndent = _MyStepRTB.GetPositionFromCharIndex(_MyStepRTB.SelectionStart).X;
btnIndent.Checked = _MyStepRTB.SelectionHangingIndent != 0;
}
private void btnCMIndent_Click(object sender, EventArgs e)
{
_MyStepRTB.InsertIndent(MyEditItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IndentToken);
if (_MyStepRTB.SelectionHangingIndent != 0)
_MyStepRTB.SelectionHangingIndent = 0;
else
_MyStepRTB.SelectionHangingIndent = _MyStepRTB.GetPositionFromCharIndex(_MyStepRTB.SelectionStart).X;
btnIndent.Checked = _MyStepRTB.SelectionHangingIndent != 0;
}
#endregion
#region Home Tab
@@ -2841,6 +2853,15 @@ namespace Volian.Controls.Library
btnTblDgnPaste.Enabled = ((VlnFlexGrid.MyCopyInfo.MyCopiedFlexGrid != null) && enable);
btnTblDgnSplitCells.Enabled = enable;
}
public void SetRibbonForGridCellIndent()
{
if (_MyStepRTB != null)
btnIndent.Checked = _MyStepRTB.SelectionHangingIndent != 0;
}
public void SetRibbonForGridCellIndentClear()
{
btnIndent.Checked = false;
}
public void SetRibbonForGrid()
{
// for paste, see if there is clipboard data, & if so, of a type we can use.

File diff suppressed because it is too large Load Diff