This commit is contained in:
@@ -12,9 +12,11 @@ using VEPROMS.CSLA.Library;
|
||||
|
||||
namespace Volian.Controls.Library
|
||||
{
|
||||
|
||||
public delegate void StepRTBEvent(object sender, EventArgs args);
|
||||
public delegate void StepRTBCursorKeysEvent(object sender, KeyEventArgs args);
|
||||
public delegate void StepRTBCursorMovementEvent(object sender, StepRTBCursorMovementEventArgs args);
|
||||
public delegate void StepRTBModeChangeEvent(object sender, StepRTBModeChangeEventArgs args);
|
||||
//public delegate void StepRTBMouseWheelEvent(object sender, MouseEventArgs args);
|
||||
public partial class StepRTB : RichTextBox , IStepRTB
|
||||
{
|
||||
@@ -44,6 +46,13 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
if (CursorMovement != null) CursorMovement(sender, args);
|
||||
}
|
||||
public event StepRTBModeChangeEvent ModeChange;
|
||||
private void OnModeChange(object sender, StepRTBModeChangeEventArgs args)
|
||||
{
|
||||
//_MyModeChangeEventArgs = args;
|
||||
if (ModeChange != null) ModeChange(sender, args);
|
||||
else MessageBox.Show("StepRTB - no mode change defined");
|
||||
}
|
||||
//public event StepRTBMouseWheelEvent MouseWheel;
|
||||
//private void OnMouseWheel(object sender, MouseEventArgs args)
|
||||
//{
|
||||
@@ -91,7 +100,12 @@ namespace Volian.Controls.Library
|
||||
get { return _MyStepItem; }
|
||||
set { _MyStepItem = value; }
|
||||
}
|
||||
private bool _IsDirty = false;
|
||||
// _IsDirty compares the original rtf to the current rtf from the
|
||||
// richtextbox to see if a change was made.
|
||||
private bool _IsDirty
|
||||
{
|
||||
get { return _origRTF != Rtf; }
|
||||
}
|
||||
private bool _InitializingRTB;
|
||||
private IContainer _Container = null;
|
||||
private string _MyClassName=string.Empty;
|
||||
@@ -128,10 +142,11 @@ namespace Volian.Controls.Library
|
||||
if (value != null)
|
||||
{
|
||||
RTBFillIn(!ViewRTB);
|
||||
//ViewRTB = MyStepItem.MyStepPanel.PanelViewEditMode == E_ViewMode.View;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _origRTF;
|
||||
public void RTBFillIn(bool edit)
|
||||
{
|
||||
_InitializingRTB = true;
|
||||
@@ -156,9 +171,10 @@ namespace Volian.Controls.Library
|
||||
RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT);
|
||||
AddRtfText(vlntxt.StartText);
|
||||
AddRtfStyles();
|
||||
// set readonly based on initial modes, however, these may change if
|
||||
// user selected view mode.
|
||||
ReadOnly = !(EpMode == E_EditPrintMode.Edit && VwMode == E_ViewMode.Edit);
|
||||
_InitializingRTB = false;
|
||||
_IsDirty = false;
|
||||
if (!ReadOnly && !edit) ReadOnly = true;
|
||||
ClearUndo();
|
||||
RightMargin = Width;
|
||||
// figure out if needs outlined, depends on table/figure type
|
||||
@@ -184,7 +200,9 @@ namespace Volian.Controls.Library
|
||||
indchar++;
|
||||
}
|
||||
AddEventHandlers();
|
||||
}
|
||||
}
|
||||
_origRTF = Rtf;
|
||||
_InitializingRTB = false;
|
||||
_MyItemInfo.MyConfig.PropertyChanged += new PropertyChangedEventHandler(MyConfig_PropertyChanged);
|
||||
}
|
||||
private bool _ProcessKeystrokes = true;
|
||||
@@ -356,15 +374,21 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
#endregion
|
||||
#region ApplicationSupport
|
||||
public void ToggleViewEdit()
|
||||
public void ToggleEditView()
|
||||
{
|
||||
ItemInfo tmp = MyItemInfo;
|
||||
MyItemInfo = null;
|
||||
SaveText();
|
||||
//ItemInfo tmp = MyItemInfo;
|
||||
//MyItemInfo = null;
|
||||
ReadOnly = !ReadOnly;
|
||||
EpMode = ReadOnly ? E_EditPrintMode.Print : E_EditPrintMode.Edit;
|
||||
VwMode = ReadOnly ? E_ViewMode.View : E_ViewMode.Edit;
|
||||
ViewRTB = ReadOnly;
|
||||
Clear();
|
||||
MyItemInfo = tmp;
|
||||
RTBFillIn(!ViewRTB);
|
||||
//MyItemInfo = tmp;
|
||||
SelectionStart = 0;
|
||||
SelectionLength = 0;
|
||||
OnModeChange(this, new StepRTBModeChangeEventArgs(ViewRTB?E_ViewMode.View:E_ViewMode.Edit));
|
||||
}
|
||||
public void InsertRO(string value, string link)
|
||||
{
|
||||
@@ -482,16 +506,14 @@ namespace Volian.Controls.Library
|
||||
public void SaveText()
|
||||
{
|
||||
if (ReadOnly) return;
|
||||
if (ViewRTB) return;
|
||||
if (!_IsDirty) return;
|
||||
if (_IsDirty)
|
||||
bool success = _origDisplayText.Save((RichTextBox)this);
|
||||
if (success)
|
||||
{
|
||||
bool success = _origDisplayText.Save((RichTextBox)this);
|
||||
if (success)
|
||||
{
|
||||
FindAllLinks();
|
||||
_IsDirty = false;
|
||||
ClearUndo();
|
||||
}
|
||||
FindAllLinks();
|
||||
_origRTF = Rtf;
|
||||
ClearUndo();
|
||||
}
|
||||
}
|
||||
public void SaveConfig()
|
||||
@@ -793,10 +815,14 @@ namespace Volian.Controls.Library
|
||||
if (LinkModifyRO != null) LinkModifyRO(sender, args);
|
||||
}
|
||||
#endregion
|
||||
#region TextOrContents
|
||||
#region TextAndContentsEvents
|
||||
void StepRTB_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
_IsDirty = true;
|
||||
if (_InitializingRTB) return;
|
||||
// Was setting _IsDirty to true here, but this was getting called from
|
||||
// 'dotnetbar' when text was NOT Changed. So _IsDirty was made into
|
||||
// a property and compared original rtf versus current richtextbox's
|
||||
// rtf.
|
||||
FindAllLinks();
|
||||
}
|
||||
void StepRTB_ContentsResized(object sender, ContentsResizedEventArgs e)
|
||||
@@ -1449,8 +1475,8 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
string str = Text;
|
||||
_LinkLocations = new List<LinkLocation>();
|
||||
MatchCollection matches = Regex.Matches(str, "<START](.*?)[[]END>");
|
||||
MatchCollection matchesRtf = Regex.Matches(Rtf, "<START](.*?)[[]END>");
|
||||
MatchCollection matches = Regex.Matches(str, @"<START](.*?)[[]END>", RegexOptions.Singleline);
|
||||
MatchCollection matchesRtf = Regex.Matches(Rtf, "<START](.*?)[[]END>", RegexOptions.Singleline);
|
||||
LinkLocation thisLink = null;
|
||||
for (int i = 0; i < matches.Count; i++) //each (Match match in matches)
|
||||
{
|
||||
@@ -1881,7 +1907,14 @@ namespace Volian.Controls.Library
|
||||
lastIndex = m.Index + m.Length; // Calculate the beginning of the remaining text
|
||||
}
|
||||
sb.Append(line.Substring(lastIndex)); // Append the text following the last link
|
||||
return sb.ToString();
|
||||
string result = sb.ToString();
|
||||
MatchCollection mcEnd = Regex.Matches(line, @"#Link.*?\[END>");
|
||||
result = result.Replace(@"<START]", "");
|
||||
if (mcEnd.Count > 0)
|
||||
{
|
||||
result = result.Substring(0, mcEnd[0].Index - 1) + result.Substring(mcEnd[0].Index + mcEnd[0].Length);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private void ReplaceLinesInTable(bool withBorder)
|
||||
{
|
||||
@@ -1892,7 +1925,9 @@ namespace Volian.Controls.Library
|
||||
string lineAbove = RemoveLinkComments(Lines[row-1]);
|
||||
string lineBelow = RemoveLinkComments(Lines[row+1]);
|
||||
int rowOffset = GetFirstCharIndexFromLine(row);
|
||||
MatchCollection matchCollection = Regex.Matches(line, @"<START\](.*?)#Link.*?\[END>");
|
||||
MatchCollection matchCollection = Regex.Matches(line, @"<START\](.*?)#Link.*?\[END>"); //, RegexOptions.Singleline);
|
||||
if (matchCollection.Count == 0) matchCollection = Regex.Matches(line, @"<START\]");
|
||||
if (matchCollection.Count == 0) matchCollection = Regex.Matches(line, @"#Link.*?\[END>");
|
||||
Match match = matchCollection.Count > 0 ? matchCollection[0] : null;
|
||||
int matchOffset = 0;
|
||||
for (int col = 1; col < rowWidth - 1; col++)
|
||||
@@ -1969,6 +2004,19 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
public partial class StepRTBModeChangeEventArgs : EventArgs
|
||||
{
|
||||
private E_ViewMode _ViewMode;
|
||||
public E_ViewMode ViewMode
|
||||
{
|
||||
get { return _ViewMode; }
|
||||
set { _ViewMode = value; }
|
||||
}
|
||||
public StepRTBModeChangeEventArgs(E_ViewMode vmode)
|
||||
{
|
||||
_ViewMode = vmode;
|
||||
}
|
||||
}
|
||||
public class StepRTBCursorMovementEventArgs
|
||||
{
|
||||
private Point _CursorLocation;
|
||||
|
Reference in New Issue
Block a user