- Added tools to find Symbol Characters in Word Documents

- If the range does not have any characters return an empty string
Refresh Most Recent Items when the office button is pressed
Added OrdinalChanged Event
Used OrdinalChanged Event rather than MyContent.Changed Event when Ordinal is updated.
Use OrdinalChanged Event to update Tree Node
Refresh MRU list as items are added
Use OrdinalChanged Event to update Step Tab
- RTBFillIn changed to only update the RTB when the contents change
- AdjustSizeForContents changed to raise the HeightChanged event when the Height changes
Update the treeview tabs even if the step is not open.
This commit is contained in:
Rich 2010-12-01 20:03:06 +00:00
parent b3b3f5e518
commit bb3844538c
9 changed files with 174 additions and 30 deletions

View File

@ -325,7 +325,106 @@ namespace LBWordLibrary
return null;
}
}
/// <summary>
/// Debug Tool - Return a string containing a list of the fonts that have symbol characters.
/// </summary>
public string FontsHaveSymbolCharacters
{
get
{
string sep = "";
StringBuilder sb = new StringBuilder();
List<string> fonts=new List<string>();
LBRange myRange = Range();
myRange = myRange.GoTo(LBWdGoToItem.wdGoToPercent, LBWdGoToDirection.wdGoToLast, 100);
myRange.Start = 0;
int end = myRange.End;
string myText = GetRangeText(myRange);
//return _RegFindSymbol.IsMatch(myText);
MatchCollection problems = _RegFindSymbol.Matches(myText);
int offset = 0;
foreach (Match problem in problems)
{
myRange.Start = problem.Index + offset;
myRange.End = problem.Index + problem.Length + offset;
int newOffset = FindRangeOffset(myRange, problem, offset, end);
if (!fonts.Contains(myRange.Font.Name))
{
fonts.Add(myRange.Font.Name);
sb.Append(sep + "'" + myRange.Font.Name + "'");
sep = ",";
}
offset = newOffset;
}
if (sb.Length > 0) return sb.ToString();
return null;
}
}
/// <summary>
/// Debug Tool - Return a list of symbol characters using VESYMB font.
/// </summary>
public string FontsHaveSymbolCharacters2
{
get
{
try
{
Dictionary<string, List<int>> fonts = new Dictionary<string, List<int>>();
LBRange myRange = Range();
myRange = myRange.GoTo(LBWdGoToItem.wdGoToPercent, LBWdGoToDirection.wdGoToLast, 100);
myRange.Start = 0;
int end = myRange.End;
string myText = GetRangeText(myRange);
//return _RegFindSymbol.IsMatch(myText);
MatchCollection problems = _RegFindSymbol.Matches(myText);
int offset = 0;
foreach (Match problem in problems)
{
myRange.Start = problem.Index + offset;
myRange.End = problem.Index + problem.Length + offset;
int newOffset = FindRangeOffset(myRange, problem, offset, end);
string sFont = myRange.Font.Name;
if (sFont.ToUpper().StartsWith("VESYM"))
{
if (!fonts.ContainsKey(sFont))
{
fonts.Add(sFont, new List<int>());
}
List<int> symbols = fonts[sFont];
string myTextSymb = GetRangeText(myRange);
foreach (char c in myTextSymb)
{
if (!symbols.Contains((int)c))
symbols.Add((int)c);
}
}
offset = newOffset;
}
if (fonts.Count > 0)
{
string sep = "";
StringBuilder sb = new StringBuilder();
foreach (string font in fonts.Keys)
{
sb.Append(sep + "'" + font + "'");
sep = ",";
foreach (int i in fonts[font])
{
sb.Append(sep);
sb.Append(i);
}
}
return sb.ToString();
}
}
catch (Exception ex)
{
Console.WriteLine("{0},{1},{2}", ex.GetType().Name, ex.Message, ex.StackTrace);
}
return null;
}
}
/// <summary>
/// Checks to see if the document contains symbol characters
/// </summary>
@ -429,7 +528,10 @@ namespace LBWordLibrary
string text="";
try
{
text = myRange.Text;
if (myRange.Start == myRange.End)// If Start and End equal return an empty string.
text = "";
else
text = myRange.Text;
}
catch (Exception ex)
{

View File

@ -241,6 +241,7 @@ namespace VEPROMS
ctrlAnnotationDetails.SetupAnnotations(displaySearch1);
SetupButtons();
displayBookMarks.MyDisplayTabControl = tc; // allows bookmark selection to bring up steps/docs
office2007StartButton1.MouseDown +=new MouseEventHandler(office2007StartButton1_MouseDown);
}
void _MyMRIList_AfterRemove(object sender)
@ -1402,6 +1403,11 @@ namespace VEPROMS
{
lblResolution.Text = string.Format("Resolution {0} x {1}", Size.Width, Size.Height);
}
private void office2007StartButton1_MouseDown(object sender, MouseEventArgs e)
{
// Refresh the MostRecentlyUsedList
_MyMRIList.Refresh();
SetupMRU();
}
}
}

View File

@ -297,7 +297,19 @@ namespace VEPROMS.CSLA.Library
// return ii._ItemID == _ItemID;
// return false;
//}
public event ItemInfoEvent OrdinalChanged;
private void OnOrdinalChange()
{
if (OrdinalChanged != null) OrdinalChanged(this);
}
public static void OnOrdinalChange(int itemID)
{
ConvertListToDictionary();
string key = itemID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key))
foreach (ItemInfo item in _CacheByPrimaryKey[key])
item.OnOrdinalChange();
}
public bool IsFirstSubStep
{
get

View File

@ -749,13 +749,13 @@ namespace VEPROMS.CSLA.Library
key = null;
foreach (ItemInfo item in items)
{
//Console.WriteLine("ResetOrdinal item = {0}, ordinal = {1}", item, item.Ordinal);
item._Ordinal = null;
item._TagsSetup = false;
item.MyContent.ShowChange();
//item.MyContent.ShowChange(); // Replaced with OnOrdinalChange below
if (key == null && item.NextItem != null)
key = item.NextItem.ItemID.ToString();
}
ItemInfo.OnOrdinalChange(items[0].ItemID); // After _Ordinal reset trigger event
}
}
public void ResetOrdinal()

View File

@ -342,12 +342,18 @@ namespace VEPROMS.CSLA.Library
{
myItemInfo.Deleted += new ItemInfoEvent(myItemInfo_Deleted);
myItemInfo.ChildrenDeleted += new ItemInfoEvent(myItemInfo_ChildrenDeleted);
myItemInfo.MyContent.Changed += new ContentInfoEvent(MyContent_Changed);
myItemInfo.MyContent.Changed += new ContentInfoEvent(NodeText_Changed);
myItemInfo.OrdinalChanged += new ItemInfoEvent(NodeText_Changed);
myItemInfo.NewSiblingAfter += new ItemInfoInsertEvent(myItemInfo_NewSiblingAfter);
myItemInfo.NewSiblingBefore += new ItemInfoInsertEvent(myItemInfo_NewSiblingBefore);
myItemInfo.NewChild += new ItemInfoInsertEvent(myItemInfo_NewChild);
}
}
void NodeText_Changed(object sender)
{
//ItemInfo myItemInfo = sender as ItemInfo;
Text = _VEObject.ToString();
}
public VETreeNode(IVEDrillDownReadOnly o)
: base(o.ToString())
{
@ -358,7 +364,8 @@ namespace VEPROMS.CSLA.Library
{
myItemInfo.Deleted += new ItemInfoEvent(myItemInfo_Deleted);
myItemInfo.ChildrenDeleted += new ItemInfoEvent(myItemInfo_ChildrenDeleted);
myItemInfo.MyContent.Changed += new ContentInfoEvent(MyContent_Changed);
myItemInfo.MyContent.Changed += new ContentInfoEvent(NodeText_Changed);
myItemInfo.OrdinalChanged += new ItemInfoEvent(NodeText_Changed);
myItemInfo.NewSiblingAfter += new ItemInfoInsertEvent(myItemInfo_NewSiblingAfter);
myItemInfo.NewSiblingBefore += new ItemInfoInsertEvent(myItemInfo_NewSiblingBefore);
myItemInfo.NewChild += new ItemInfoInsertEvent(myItemInfo_NewChild);
@ -438,12 +445,6 @@ namespace VEPROMS.CSLA.Library
if (this.Parent != null) // Only do this if the node has a parent - RHM 20100106
this.Parent.Nodes.Insert(Index + 1, (new VETreeNode(args.ItemInserted)));
}
void MyContent_Changed(object sender)
{
ContentInfo myContent = sender as ContentInfo;
ItemInfo myItemInfo = myContent.ContentItems[0];
Text = _VEObject.ToString();
}
public VETreeNode(string s)
: base(s)
{

View File

@ -23,6 +23,7 @@ namespace Volian.Controls.Library
}
public new MostRecentItem Add(MostRecentItem myMRI)
{
Refresh();
MostRecentItem tmp = null;
// Look for the ItemID
foreach (MostRecentItem mri in this)
@ -42,6 +43,11 @@ namespace Volian.Controls.Library
myMRI.MyItemInfo.BeforeDelete += new ItemInfoEvent(MyItemInfo_BeforeDelete);
return myMRI;
}
public void Refresh()
{
foreach (MostRecentItem mri in this)
mri.Refresh();
}
// delete the item from the most recently used list. This event gets handled
// when a delete item occurs.
@ -105,6 +111,7 @@ namespace Volian.Controls.Library
public System.Collections.Specialized.StringCollection ToSettings()
{
if (Count == 0) return null;
Refresh();
System.Collections.Specialized.StringCollection retval = new System.Collections.Specialized.StringCollection();
foreach (MostRecentItem mri in this)
retval.Add(mri.ToString());
@ -131,6 +138,10 @@ namespace Volian.Controls.Library
_ToolTip = GetToolTip(_MyItemInfo);
}
}
internal void Refresh()
{
MyItemInfo = MyItemInfo;
}
private int _ItemID;
public int ItemID
{

View File

@ -149,9 +149,13 @@ namespace Volian.Controls.Library
if (VlnSettings.StepTypeToolType)SetToolTip(_MyItemInfo.ToolTip);
ChangeBar = _MyItemInfo.HasChangeBar();
value.MyContent.Changed += new ContentInfoEvent(MyContent_Changed);
value.OrdinalChanged += new ItemInfoEvent(value_OrdinalChanged);
}
}
void value_OrdinalChanged(object sender)
{
TabFormat = null; // Reset Tab
}
private void SetToolTip(string tip)
{
DevComponents.DotNetBar.SuperTooltipInfo tpi = new DevComponents.DotNetBar.SuperTooltipInfo("", "", tip, null, null, DevComponents.DotNetBar.eTooltipColor.Lemon);
@ -169,7 +173,6 @@ namespace Volian.Controls.Library
// Update the text to reflect the content change
MyStepRTB.MyItemInfo.RefreshItemAnnotations();
MyStepRTB.MyItemInfo=MyStepRTB.MyItemInfo; // Reset Text
TabFormat = null; // Reset Tab
SetExpandAndExpander(MyItemInfo);
// TODO: Need code to update tabs ? not sure what this is - maybe for
// transitions?

View File

@ -201,7 +201,6 @@ namespace Volian.Controls.Library
}
}
_InitializingRTB = true;
_SelectedRtfSB.Remove(0, _SelectedRtfSB.Length);
DisplayText vlntxt = new DisplayText(_MyItemInfo, EpMode, VwMode, !edit, FieldToEdit, true);
//if (_origDisplayText != null && vlntxt.StartText == _origDisplayText.StartText)
//{
@ -222,9 +221,12 @@ namespace Volian.Controls.Library
// TODO: Release Mode
//Font = _origDisplayText.TextFont.WindowsFont; // font defined in plant's format
}
Text = ""; // Initialize text before add text
// RHM 20101201 - Don't reset the text. Calculate the text and compare it with the existing text in AddRTFText
//Text = ""; // Initialize text before add text
// IMPORTANT: SetLineSpacing must be set before Links, otherwise it
// was confusing the 'handle' of the rtf box.
//Console.WriteLine("'font',{0}", Font);
if(Text == "")SelectionFont = Font; // Initialize SelectionFont
RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT);
AddRtfText(vlntxt.StartText);
//AddRtfStyles();
@ -714,14 +716,18 @@ namespace Volian.Controls.Library
#region AddRtfTextAndStyles
private void AddRtfText(string txt)
{
AddFontTable();
_RtfPrefix = _SelectedRtfSB.ToString();
_SelectedRtfSB.Append(txt);
SelectedRtf = _SelectedRtfSB.ToString() + "}";
StringBuilder selectedRtfSB = new StringBuilder();
AddFontTable(selectedRtfSB);
_RtfPrefix = selectedRtfSB.ToString();
selectedRtfSB.Append(txt);
string newRTF = selectedRtfSB.ToString() + "}";
SelectAll();
if (SelectedRtf != newRTF)
SelectedRtf = newRTF;
//SelectedRtf = selectedRtfSB.ToString() + "}";
FindAllLinks();
}
private StringBuilder _SelectedRtfSB = new StringBuilder();
private void AddFontTable()
private void AddFontTable(StringBuilder selectedRtfSB)
{
StringBuilder sbbeg = new StringBuilder();
StringBuilder sbend = new StringBuilder();
@ -740,14 +746,14 @@ namespace Volian.Controls.Library
sbbeg.Append(@"\i");
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 + @"}}";
if (!FontIsFixed())
_SelectedRtfSB.Append(@"{\f1\fnil\fcharset0 Arial Unicode MS;}}{\colortbl ;\red255\green0\blue0;}");
selectedRtfSB.Append(@"{\f1\fnil\fcharset0 Arial Unicode MS;}}{\colortbl ;\red255\green0\blue0;}");
else
_SelectedRtfSB.Append(@"{\f1\fnil\fcharset0 VESymbFix;}}{\colortbl ;\red255\green0\blue0;}");
_SelectedRtfSB.Append("\r\n");
selectedRtfSB.Append(@"{\f1\fnil\fcharset0 VESymbFix;}}{\colortbl ;\red255\green0\blue0;}");
selectedRtfSB.Append("\r\n");
// 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" + Convert.ToInt32(this.Font.SizeInPoints * 2).ToString() + @" "); // \f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}";
selectedRtfSB.Append(@"\viewkind4\uc1\pard\sl-240\slmult0" + sbbeg.ToString() + @"\fs" + Convert.ToInt32(this.Font.SizeInPoints * 2).ToString() + @" "); // \f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}";
}
private bool FontIsFixed()
@ -906,8 +912,10 @@ namespace Volian.Controls.Library
Size szNew = new Size(((Text != "" && adjustWidth) ? widthNew : (widthNew > Width ? widthNew : Width)), heightNew);
if (this.Size != szNew)
{
int heightOld = Height;
this.Size = szNew;
OnHeightChanged(this, new EventArgs());
if (heightOld != Height)
OnHeightChanged(this, new EventArgs());
}
}
}

View File

@ -999,6 +999,7 @@ namespace Volian.Controls.Library
ShowBrokenRules(step.BrokenRulesCollection);
SetLastValues(StepInfo.Get(step.ItemID));
tn = new VETreeNode(_LastStepInfo);
_LastStepInfo.UpdateTransitionText();
TreeNode par = SelectedNode.Parent;
par.Nodes.Insert(tvindex + ((newtype == MenuSelections.StepBefore) ? 0 : 1), tn);
}