This commit is contained in:
parent
09733595f3
commit
1db9494a43
@ -90,6 +90,7 @@ namespace Volian.Controls.Library
|
|||||||
{
|
{
|
||||||
get { return _origDisplayText.TextFont; }
|
get { return _origDisplayText.TextFont; }
|
||||||
}
|
}
|
||||||
|
public bool ViewRTB = true;
|
||||||
private ItemInfo _MyItemInfo;
|
private ItemInfo _MyItemInfo;
|
||||||
public ItemInfo MyItemInfo
|
public ItemInfo MyItemInfo
|
||||||
{
|
{
|
||||||
@ -99,35 +100,42 @@ namespace Volian.Controls.Library
|
|||||||
_MyItemInfo = value;
|
_MyItemInfo = value;
|
||||||
if (value != null)
|
if (value != null)
|
||||||
{
|
{
|
||||||
_InitializingRTB = true;
|
RTBFillIn(!ViewRTB);
|
||||||
DisplayText vlntxt = new DisplayText(_MyItemInfo, EpMode, VwMode);
|
|
||||||
_origDisplayText = vlntxt;
|
|
||||||
#if(DEBUG)
|
|
||||||
// Use Times New Roman for Debugging
|
|
||||||
Font = new Font("Times New Roman", 14, FontStyle.Regular);
|
|
||||||
//Font = _origDisplayText.TextFont.WindowsFont;
|
|
||||||
#elif(RELEASE)
|
|
||||||
Font = _origDisplayText.TextFont.WindowsFont; // font defined in plant's format
|
|
||||||
#else //DEMO
|
|
||||||
// Comment this out for DEMO to customer
|
|
||||||
// UN-Comment this for testing
|
|
||||||
//Font = _origDisplayText.TextFont.WindowsFont; // font defined in plant's format
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Text = ""; // Initialize text before add text
|
|
||||||
// IMPORTANT: SetLineSpacing must be set before Links, otherwise it
|
|
||||||
// was confusing the 'handle' of the rtf box.
|
|
||||||
RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT);
|
|
||||||
AddRtfText(vlntxt);
|
|
||||||
AddRtfStyles();
|
|
||||||
ReadOnly = !(EpMode == E_EditPrintMode.Edit && VwMode == E_ViewMode.Edit);
|
|
||||||
_InitializingRTB = false;
|
|
||||||
_IsDirty = false;
|
|
||||||
ClearUndo();
|
|
||||||
_MyItemInfo.MyConfig.PropertyChanged += new PropertyChangedEventHandler(MyConfig_PropertyChanged);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RTBFillIn(bool edit)
|
||||||
|
{
|
||||||
|
_InitializingRTB = true;
|
||||||
|
_SelectedRtfSB.Remove(0, _SelectedRtfSB.Length);
|
||||||
|
|
||||||
|
DisplayText vlntxt = new DisplayText(_MyItemInfo, EpMode, VwMode, !edit);
|
||||||
|
_origDisplayText = vlntxt;
|
||||||
|
#if(DEBUG)
|
||||||
|
// Use Times New Roman for Debugging
|
||||||
|
//Font = new Font("Times New Roman", 14, FontStyle.Regular);
|
||||||
|
Font = _origDisplayText.TextFont.WindowsFont;
|
||||||
|
#elif(RELEASE)
|
||||||
|
Font = _origDisplayText.TextFont.WindowsFont; // font defined in plant's format
|
||||||
|
#else //DEMO
|
||||||
|
// Comment this out for DEMO to customer
|
||||||
|
// UN-Comment this for testing
|
||||||
|
//Font = _origDisplayText.TextFont.WindowsFont; // font defined in plant's format
|
||||||
|
#endif
|
||||||
|
Text = ""; // Initialize text before add text
|
||||||
|
// IMPORTANT: SetLineSpacing must be set before Links, otherwise it
|
||||||
|
// was confusing the 'handle' of the rtf box.
|
||||||
|
RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT);
|
||||||
|
AddRtfText(vlntxt);
|
||||||
|
AddRtfStyles();
|
||||||
|
ReadOnly = !(EpMode == E_EditPrintMode.Edit && VwMode == E_ViewMode.Edit);
|
||||||
|
_InitializingRTB = false;
|
||||||
|
_IsDirty = false;
|
||||||
|
ClearUndo();
|
||||||
|
RightMargin = Width;
|
||||||
|
_MyItemInfo.MyConfig.PropertyChanged += new PropertyChangedEventHandler(MyConfig_PropertyChanged);
|
||||||
|
}
|
||||||
private bool _ProcessKeystrokes = true;
|
private bool _ProcessKeystrokes = true;
|
||||||
public bool ProcessKeystrokes
|
public bool ProcessKeystrokes
|
||||||
{
|
{
|
||||||
@ -244,7 +252,6 @@ namespace Volian.Controls.Library
|
|||||||
this.MouseDown += new MouseEventHandler(StepRTB_MouseDown);
|
this.MouseDown += new MouseEventHandler(StepRTB_MouseDown);
|
||||||
this.SelectionChanged +=new EventHandler(StepRTB_SelectionChanged);
|
this.SelectionChanged +=new EventHandler(StepRTB_SelectionChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyConfig_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
void MyConfig_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
SaveConfig();
|
SaveConfig();
|
||||||
@ -257,8 +264,6 @@ namespace Volian.Controls.Library
|
|||||||
void StepRTB_SelectionChanged(object sender, EventArgs e)
|
void StepRTB_SelectionChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_InitializingRTB) return;
|
if (_InitializingRTB) return;
|
||||||
//DebugSelection("SelectionChanged Event ");
|
|
||||||
if (SelectionStart == 40 && SelectionLength == 1) vlnStackTrace.ShowStack("SELECTIONCHANGED EVENT");
|
|
||||||
HandleSelectionChange();
|
HandleSelectionChange();
|
||||||
}
|
}
|
||||||
private bool _MouseDown = false;
|
private bool _MouseDown = false;
|
||||||
@ -285,7 +290,6 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
public void InsertRO(string value, string link)
|
public void InsertRO(string value, string link)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Before Insert Called: {0}", Rtf);
|
|
||||||
AddRtfLink(value, link);
|
AddRtfLink(value, link);
|
||||||
}
|
}
|
||||||
public void InsertTran(string value, string link)
|
public void InsertTran(string value, string link)
|
||||||
@ -298,17 +302,98 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
public void SetSelectedCase(char type)
|
public void SetSelectedCase(char type)
|
||||||
{
|
{
|
||||||
switch (type)
|
// do not change link text
|
||||||
|
RangeStatus rs = FindRangeStatus();
|
||||||
|
if (rs == RangeStatus.NoContainedLinks)
|
||||||
{
|
{
|
||||||
case 'l':
|
Console.WriteLine("Text = {0}, Rtf = {1}", Text, Rtf);
|
||||||
SelectedText = SelectedText.ToLower();
|
Console.WriteLine("SelectedRtf = {0}", SelectedRtf);
|
||||||
break;
|
switch (type)
|
||||||
case 'U':
|
{
|
||||||
SelectedText = SelectedText.ToUpper();
|
case 'l':
|
||||||
break;
|
string tmp=null;
|
||||||
case 'T':
|
for (int i = 0; i < SelectionLength; i++)
|
||||||
SelectedText = SelectedText.Substring(0, 1).ToUpper() + SelectedText.Substring(1, SelectedText.Length - 1).ToLower();
|
{
|
||||||
break;
|
char x = SelectedText[i];
|
||||||
|
if (Char.IsLetter(x))
|
||||||
|
{
|
||||||
|
Console.WriteLine("isletter: {0}", x);
|
||||||
|
x = char.ToLower(x);
|
||||||
|
}
|
||||||
|
tmp = string.Format("{0}{1}", tmp, x.ToString());
|
||||||
|
}
|
||||||
|
Console.WriteLine("Tolower: text = {0}", tmp);
|
||||||
|
SelectedText = tmp;
|
||||||
|
Console.WriteLine("Text = {0}, Rtf = {1}", Text, Rtf);
|
||||||
|
break;
|
||||||
|
case 'U':
|
||||||
|
SelectedText = SelectedText.ToUpper();
|
||||||
|
break;
|
||||||
|
case 'T':
|
||||||
|
SelectedText = SelectedText.Substring(0, 1).ToUpper() + SelectedText.Substring(1, SelectedText.Length - 1).ToLower();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int start = SelectionStart;
|
||||||
|
int ostart = SelectionStart;
|
||||||
|
int end = SelectionStart + SelectionLength;
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
while (start <= end)
|
||||||
|
{
|
||||||
|
bool processed = false;
|
||||||
|
foreach (LinkLocation ll in LinkLocations)
|
||||||
|
{
|
||||||
|
if (ll.Start >= start && ll.End <= end)
|
||||||
|
{
|
||||||
|
processed = true;
|
||||||
|
if (start < ll.Start)
|
||||||
|
{
|
||||||
|
SelectionStart = start;
|
||||||
|
SelectionLength = ll.Start - start;
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case 'l':
|
||||||
|
SelectedText = SelectedText.ToLower();
|
||||||
|
break;
|
||||||
|
case 'U':
|
||||||
|
SelectedText = SelectedText.ToUpper();
|
||||||
|
break;
|
||||||
|
case 'T':
|
||||||
|
sb.Append(Text.Substring(start, ll.Start - start).Substring(0, 1).ToUpper() + SelectedText.Substring(1, SelectedText.Length - 1).ToLower());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//sb.Append(Text.Substring(ll.Start, ll.End - ll.Start));
|
||||||
|
start = ll.End + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if none were processed, no more links, copy over any remaining text.
|
||||||
|
if (!processed)
|
||||||
|
{
|
||||||
|
SelectionStart = start;
|
||||||
|
SelectionLength = end-start;
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case 'l':
|
||||||
|
SelectedText = SelectedText.ToLower();
|
||||||
|
break;
|
||||||
|
case 'U':
|
||||||
|
SelectedText = SelectedText.ToUpper();
|
||||||
|
break;
|
||||||
|
case 'T':
|
||||||
|
//sb.Append(Text.Substring(start, ll.Start - start).Substring(0, 1).ToUpper() + SelectedText.Substring(1, SelectedText.Length - 1).ToLower());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
start = end + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SelectionStart = ostart;
|
||||||
|
SelectionLength = end - ostart;
|
||||||
|
//SelectedText = sb.ToString();
|
||||||
|
//FindAllLinks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -374,7 +459,7 @@ namespace Volian.Controls.Library
|
|||||||
sbend.Insert(0, @"\i0");
|
sbend.Insert(0, @"\i0");
|
||||||
}
|
}
|
||||||
_SelectedRtfSB.Append(@"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset2 " + this.Font.FontFamily.Name + @";}"); //}\f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}}";
|
_SelectedRtfSB.Append(@"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset2 " + this.Font.FontFamily.Name + @";}"); //}\f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}}";
|
||||||
_SelectedRtfSB.Append(@"{\f1\fnil\fcharset0 Arial Unicode MS;}}");
|
_SelectedRtfSB.Append(@"{\f1\fnil\fcharset0 Arial Unicode MS;}}"); // {\colortbl ;\red255\green0\blue0;}");
|
||||||
_SelectedRtfSB.Append("\r\n");
|
_SelectedRtfSB.Append("\r\n");
|
||||||
// use styles to construct rtf commands to insert into next line (where \b, etc is)
|
// use styles to construct rtf commands to insert into next line (where \b, etc is)
|
||||||
_SelectedRtfSB.Append(@"\viewkind4\uc1\pard\sl-240\slmult0" + sbbeg.ToString() + @"\fs" + this.Font.SizeInPoints * 2 + @" "); // \f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}";
|
_SelectedRtfSB.Append(@"\viewkind4\uc1\pard\sl-240\slmult0" + sbbeg.ToString() + @"\fs" + this.Font.SizeInPoints * 2 + @" "); // \f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}";
|
||||||
@ -422,6 +507,7 @@ namespace Volian.Controls.Library
|
|||||||
Select(position, 1);
|
Select(position, 1);
|
||||||
RTBAPI.SetFontStyle(this, fs);
|
RTBAPI.SetFontStyle(this, fs);
|
||||||
Select(position + 1, 0);
|
Select(position + 1, 0);
|
||||||
|
SelectionFont = _origDisplayText.TextFont.WindowsFont;
|
||||||
}
|
}
|
||||||
private string GetAddSymbolText(string symtxt)
|
private string GetAddSymbolText(string symtxt)
|
||||||
{
|
{
|
||||||
@ -434,8 +520,9 @@ namespace Volian.Controls.Library
|
|||||||
AddLink50(myDisplayLinkElement.Text, myDisplayLinkElement.Link);
|
AddLink50(myDisplayLinkElement.Text, myDisplayLinkElement.Link);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_SelectedRtfSB.Append(@"\f0\fs20 ");
|
//_SelectedRtfSB.Append(@"\f0\cf1 ");
|
||||||
_SelectedRtfSB.Append(myDisplayLinkElement.TextAndLink);
|
_SelectedRtfSB.Append(myDisplayLinkElement.TextAndLink); //.Replace(@"\u916?",@"\f1\u916?\f0 "));
|
||||||
|
//_SelectedRtfSB.Append(@"\cf0 ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void AddRtfLink(string linkUrl, string linkValue)
|
public void AddRtfLink(string linkUrl, string linkValue)
|
||||||
@ -787,7 +874,8 @@ namespace Volian.Controls.Library
|
|||||||
if (key == 0)
|
if (key == 0)
|
||||||
{
|
{
|
||||||
_SendBackSpace = true;
|
_SendBackSpace = true;
|
||||||
RtbSendKeys("{BS}"); // remove X
|
RtbSendKeys("{BS}"); // remove X
|
||||||
|
this.ClearUndo(); // undo was redisplay 'X' and then deleted text
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
DebugSelection("After BS");
|
DebugSelection("After BS");
|
||||||
}
|
}
|
||||||
@ -896,6 +984,8 @@ namespace Volian.Controls.Library
|
|||||||
if (e.Shift)
|
if (e.Shift)
|
||||||
{
|
{
|
||||||
int newstart = FindStart(); // find start of link ending on.
|
int newstart = FindStart(); // find start of link ending on.
|
||||||
|
// if not link, don't do special processing
|
||||||
|
if (newstart == SelectionStart - 1) return;
|
||||||
int len = SelectionLength + SelectionStart - newstart;
|
int len = SelectionLength + SelectionStart - newstart;
|
||||||
SetSelection(newstart, len);
|
SetSelection(newstart, len);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
@ -916,7 +1006,7 @@ namespace Volian.Controls.Library
|
|||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
// if shift-up & at selection had a link, handle this as special case.
|
// if shift-up & at selection had a link, handle this as special case.
|
||||||
if (e.Shift && SelectionLength>0)
|
if (e.Shift && SelectionLength > 0)
|
||||||
{
|
{
|
||||||
RangeStatus rs = FindRangeStatus();
|
RangeStatus rs = FindRangeStatus();
|
||||||
if (rs != RangeStatus.NoContainedLinks)
|
if (rs != RangeStatus.NoContainedLinks)
|
||||||
@ -930,7 +1020,9 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
HandleSelectionChange();
|
HandleSelectionChange();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Keys.Right:
|
case Keys.Right:
|
||||||
// If at beginning of box that starts with a link, don't worry about shift or not,
|
// If at beginning of box that starts with a link, don't worry about shift or not,
|
||||||
@ -1161,7 +1253,6 @@ namespace Volian.Controls.Library
|
|||||||
// try adding 7 to locEnd
|
// try adding 7 to locEnd
|
||||||
SetSelection(ll.Start, ll.Length + 7);
|
SetSelection(ll.Start, ll.Length + 7);
|
||||||
}
|
}
|
||||||
Console.WriteLine(string.Format("\nFindLink Start = {0}, Length = {1}\n", SelectionStart, SelectionLength));
|
|
||||||
return SelectionStart;
|
return SelectionStart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1258,6 +1349,7 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
private void IdentifyLinks()
|
private void IdentifyLinks()
|
||||||
{
|
{
|
||||||
|
if (_LinkLocations.Count == 0) return;
|
||||||
_IdentifyingLinks = true;
|
_IdentifyingLinks = true;
|
||||||
foreach (LinkLocation ll in _LinkLocations)
|
foreach (LinkLocation ll in _LinkLocations)
|
||||||
{
|
{
|
||||||
@ -1269,6 +1361,9 @@ namespace Volian.Controls.Library
|
|||||||
RTBAPI.SetCharFormat(this, RTBAPI.RTBSelection.SCF_SELECTION, charFormat);
|
RTBAPI.SetCharFormat(this, RTBAPI.RTBSelection.SCF_SELECTION, charFormat);
|
||||||
}
|
}
|
||||||
_IdentifyingLinks = false;
|
_IdentifyingLinks = false;
|
||||||
|
// changing selections causes 'undo' to be wrong, i.e. it highlights the last selected link.
|
||||||
|
// if there is way to pop the undo stack, that could be solution.
|
||||||
|
this.ClearUndo();
|
||||||
}
|
}
|
||||||
private LinkLocation FindBetweenLinks()
|
private LinkLocation FindBetweenLinks()
|
||||||
{
|
{
|
||||||
@ -1522,7 +1617,7 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
private LinkLocation _RangeStartLink = null;
|
private LinkLocation _RangeStartLink = null;
|
||||||
private LinkLocation _RangeEndLink = null;
|
private LinkLocation _RangeEndLink = null;
|
||||||
private RangeStatus FindRangeStatus()
|
public RangeStatus FindRangeStatus()
|
||||||
{
|
{
|
||||||
_RangeStartLink = null;
|
_RangeStartLink = null;
|
||||||
_RangeEndLink = null;
|
_RangeEndLink = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user