support for StepRTB on property pages
This commit is contained in:
@@ -4,13 +4,70 @@ using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Drawing;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
namespace Volian.Controls.Library
|
||||
{
|
||||
public class DisplayText
|
||||
{
|
||||
#region Properties
|
||||
private E_FieldToEdit _FieldToEdit;
|
||||
public E_FieldToEdit FieldToEdit
|
||||
{
|
||||
get { return _FieldToEdit; }
|
||||
set { _FieldToEdit = value; }
|
||||
}
|
||||
private ItemInfo _MyItemInfo;
|
||||
private string InfoText
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (FieldToEdit)
|
||||
{
|
||||
case E_FieldToEdit.StepText:
|
||||
case E_FieldToEdit.Text:
|
||||
return _MyItemInfo.MyContent.Text;
|
||||
break;
|
||||
case E_FieldToEdit.Number:
|
||||
return _MyItemInfo.MyContent.Number;
|
||||
break;
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
private Item _MyItem;
|
||||
private string EditText
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (FieldToEdit)
|
||||
{
|
||||
case E_FieldToEdit.StepText:
|
||||
case E_FieldToEdit.Text:
|
||||
return _MyItem.MyContent.Text;
|
||||
break;
|
||||
case E_FieldToEdit.Number:
|
||||
return _MyItem.MyContent.Number;
|
||||
break;
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (FieldToEdit)
|
||||
{
|
||||
case E_FieldToEdit.StepText:
|
||||
case E_FieldToEdit.Text:
|
||||
_MyItem.MyContent.Text = value;
|
||||
break;
|
||||
case E_FieldToEdit.Number:
|
||||
_MyItem.MyContent.Number = value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// list of 'pieces of text' for this item. Pieces include symbols, ros,
|
||||
// transitions & plain text.
|
||||
private List<displayTextElement> _DisplayTextElementList;
|
||||
@@ -47,13 +104,15 @@ namespace VEPROMS.CSLA.Library
|
||||
/// E_ViewMode vw_mode - view or edit.
|
||||
/// bool noEdit - flags whether to edit or not (used to set data in
|
||||
/// rtb as resolved replacewords for non-active rtb.
|
||||
/// E_FieldToEdit fieldToEdit - identifies the field to edit (number or text)
|
||||
/// </summary>
|
||||
public DisplayText(ItemInfo itemInfo, E_EditPrintMode epMode, E_ViewMode vwMode, bool noEdit)
|
||||
public DisplayText(ItemInfo itemInfo, E_EditPrintMode epMode, E_ViewMode vwMode, bool noEdit,E_FieldToEdit fieldToEdit)
|
||||
{
|
||||
_FieldToEdit = fieldToEdit;
|
||||
_MyItemInfo = itemInfo;
|
||||
OriginalText = itemInfo.MyContent.Text;
|
||||
OriginalText = InfoText;
|
||||
TextFont = GetItemFont();
|
||||
string text = _MyItemInfo.MyContent.Text;
|
||||
string text = InfoText;
|
||||
|
||||
// if in print mode, view mode, or non-active richtextbox do replace words. Only if in
|
||||
// actual edit mode are replace words left as is.
|
||||
@@ -132,10 +191,10 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
try
|
||||
{
|
||||
Item itm = _MyItemInfo.Get();
|
||||
_MyItem = _MyItemInfo.Get();
|
||||
// check for different text, i.e. text from this itm doesn't match
|
||||
// original text, a change occurred in database, but not from this user.
|
||||
if (OriginalText != itm.MyContent.Text)
|
||||
if (OriginalText != EditText)
|
||||
{
|
||||
Console.WriteLine("Save Failed because text changed outside of this edit session.");
|
||||
return false;
|
||||
@@ -155,30 +214,34 @@ namespace VEPROMS.CSLA.Library
|
||||
|
||||
// Compare ro/transition lists and delete or add any to the item for any ros/transitions that have been
|
||||
// added/deleted or modified.
|
||||
ProcessRoTranChanges(itm, origList);
|
||||
itm.MyContent.Text = DteToString();
|
||||
ProcessRoTranChanges(_MyItem, origList);
|
||||
EditText = DteToString();
|
||||
|
||||
// if new transitions/ros, we need to 'fix' the string in the embedded link to contain the
|
||||
// transition or usage record.
|
||||
Dictionary<int, ContentTransition> ctReplacements = BuildCtReplacements(itm.MyContent.ContentTransitions);
|
||||
Dictionary<int, ContentRoUsage> roUsgReplacements = BuildRoUsgReplacements(itm.MyContent.ContentRoUsages);
|
||||
itm.Save();
|
||||
Dictionary<int, ContentTransition> ctReplacements = BuildCtReplacements(_MyItem.MyContent.ContentTransitions);
|
||||
Dictionary<int, ContentRoUsage> roUsgReplacements = BuildRoUsgReplacements(_MyItem.MyContent.ContentRoUsages);
|
||||
_MyItem.Save();
|
||||
if (ctReplacements.Count > 0)
|
||||
{
|
||||
itm.MyContent.Text = FixCtReplacements(itm.MyContent.Text, ctReplacements);
|
||||
itm.Save();
|
||||
EditText = FixCtReplacements(EditText, ctReplacements);
|
||||
_MyItem.Save();
|
||||
}
|
||||
if (roUsgReplacements.Count > 0)
|
||||
{
|
||||
itm.MyContent.Text = FixRoUsgReplacements(itm.MyContent.Text, roUsgReplacements);
|
||||
itm.Save();
|
||||
EditText = FixRoUsgReplacements(EditText, roUsgReplacements);
|
||||
_MyItem.Save();
|
||||
}
|
||||
modtext = itm.MyContent.Text;
|
||||
modtext = EditText;
|
||||
}
|
||||
else
|
||||
{
|
||||
itm.MyContent.Text = modtext;
|
||||
itm.Save();
|
||||
EditText = modtext;
|
||||
foreach (Csla.Validation.BrokenRule br in _MyItem.MyContent.BrokenRulesCollection)
|
||||
{
|
||||
Console.WriteLine("{0} - {1}", br.Property, br.Description);
|
||||
}
|
||||
_MyItem.Save();
|
||||
}
|
||||
OriginalText = modtext;
|
||||
}
|
||||
|
Reference in New Issue
Block a user