Use the TreeView timer to select the newly created step when a step is added from the TreeView. This assures that it will get focus.

Changed OnChange to be called for a specific instance
Don't select newly created Step if it was created from the TreeView
Adjust the locations of steps properly if a caution or note is deleted
Reduce repeated setup of the RTF data in a step
Add an event that fires after the Step is added from the TreeView so that the newly created step can get focus
This commit is contained in:
Rich
2010-12-02 22:23:50 +00:00
parent d01b27c80d
commit 5b70652cb4
8 changed files with 80 additions and 34 deletions

View File

@@ -363,7 +363,7 @@ namespace Volian.Controls.Library
}
return false;
}
public bool InsertStepItem(ItemInfo myItemInfo, string text, E_InsertType insertType, E_FromType fromType, int type)
public bool InsertStepItem(ItemInfo myItemInfo, string text, E_InsertType insertType, E_FromType fromType, int type,bool updateSelection)
{
CleanUpClosedItems();
ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item
@@ -378,10 +378,10 @@ namespace Volian.Controls.Library
switch (insertType)
{
case E_InsertType.Before:
stpitm.AddSiblingBefore(text);
stpitm.AddSiblingBefore(text,updateSelection);
break;
case E_InsertType.After:
stpitm.AddSiblingAfter(text);
stpitm.AddSiblingAfter(text,updateSelection);
break;
case E_InsertType.Child:
stpitm.AddChild(text, fromType, type);

View File

@@ -1219,21 +1219,21 @@ namespace Volian.Controls.Library
/// </summary>
public void AddSiblingAfter()
{
AddSiblingAfter("");
AddSiblingAfter("",true);
}
public void AddSiblingAfter(string text)
public void AddSiblingAfter(string text,bool updateStatus)
{
MyStepRTB.SaveText();
ItemInfo newItemInfo = MyItemInfo.InsertSiblingAfter(text);
DoAddSiblingAfter(newItemInfo);
DoAddSiblingAfter(newItemInfo, updateStatus);
}
public void AddSiblingAfter(int? type)
public void AddSiblingAfter(int? type, bool updateStatus)
{
MyStepRTB.SaveText();
ItemInfo newItemInfo = MyItemInfo.InsertSiblingAfter("","",type);
DoAddSiblingAfter(newItemInfo);
DoAddSiblingAfter(newItemInfo,updateStatus);
}
private void DoAddSiblingAfter(ItemInfo newItemInfo)
private void DoAddSiblingAfter(ItemInfo newItemInfo, bool updateStatus)
{
StepItem newStepItem = null;
switch (_MyChildRelation)
@@ -1251,14 +1251,15 @@ namespace Volian.Controls.Library
break;
}
//StepItem newStepItem = ActiveParent.AddChildAfter(newItemInfo, );
_MyStepPanel.SelectedStepRTB = newStepItem.MyStepRTB;//Update Screen
if(updateStatus)
_MyStepPanel.SelectedStepRTB = newStepItem.MyStepRTB;//Update Screen
}
private static int _WatchThis = 1;
public void AddSiblingBefore()
{
AddSiblingBefore("");
AddSiblingBefore("",true);
}
public void AddSiblingBefore(string text)
public void AddSiblingBefore(string text, bool updateSelection)
{
// Save RTB text before creating a new item because the process of creating
// a new item will save a change to iteminfo excluding text changes. This
@@ -1283,7 +1284,8 @@ namespace Volian.Controls.Library
default: // Need debug
break;
}
_MyStepPanel.SelectedStepRTB = newStepItem.MyStepRTB;//Update Screen
if(updateSelection)
_MyStepPanel.SelectedStepRTB = newStepItem.MyStepRTB;//Update Screen
}
public void AddChild(E_FromType fromType, int type)
{

View File

@@ -363,10 +363,35 @@ namespace Volian.Controls.Library
}
if (shouldDelete)
{
float oldTop = lastRTB.MyStepItem.Top;
StepItem newFocus = lastRTB.MyStepItem.DeleteItem();
float newTop = newFocus.Top;
lastRTB.MyStepItem.Dispose();
newFocus.SetAllTabs();
newFocus.AdjustLocation();
// If the step being deleted appears above the step to recieve focus, find another step
// to use so that the steps are positioned properly (vertically)
if (oldTop < newTop)
{
if (newFocus.MyParentStepItem != null)
{
if (newFocus.Top > newFocus.MyParentStepItem.Top)
newFocus.MyParentStepItem.AdjustLocation();
else if (newFocus.MyParentStepItem.MyPreviousStepItem != null &&
newFocus.Top > newFocus.MyParentStepItem.MyPreviousStepItem.Top)
newFocus.MyParentStepItem.MyPreviousStepItem.AdjustLocation();
else if (newFocus.MyParentStepItem.MyParentStepItem != null &&
newFocus.Top > newFocus.MyParentStepItem.MyParentStepItem.Top)
newFocus.MyParentStepItem.MyParentStepItem.AdjustLocation();
else
newFocus.AdjustLocation();
}
else if (newFocus.MyPreviousStepItem != null)
newFocus.MyPreviousStepItem.AdjustLocation();
else
newFocus.AdjustLocation();
}
else
newFocus.AdjustLocation();
}
else
{

View File

@@ -714,17 +714,25 @@ namespace Volian.Controls.Library
}
#endregion
#region AddRtfTextAndStyles
private string _LastRtf = "";
private void AddRtfText(string txt)
{
//Console.WriteLine("ItemID:{0}", MyItemInfo.ItemID);
//if(MyItemInfo.ItemID==10256)
// Volian.Base.Library.vlnStackTrace.ShowStackLocal("ItemID:{0}", MyItemInfo.ItemID.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() + "}";
string newRtf = selectedRtfSB.ToString() + "}";
if(newRtf != _LastRtf)
{
//Console.WriteLine("ItemID:{0}\r\nOld:'{1}'\r\nNew:'{2}'\r\n", MyItemInfo.ItemID, Rtf, newRtf);
this.ContentsResized -=new ContentsResizedEventHandler(StepRTB_ContentsResized);
Text = "";
this.ContentsResized += new ContentsResizedEventHandler(StepRTB_ContentsResized);
SelectedRtf = _LastRtf = newRtf;
}
FindAllLinks();
}
private void AddFontTable(StringBuilder selectedRtfSB)

View File

@@ -238,7 +238,7 @@ namespace Volian.Controls.Library
StepItem hlsStepItem = _MyStepItem;
while (!hlsStepItem.MyItemInfo.IsHigh)
hlsStepItem = hlsStepItem.ActiveParent;
hlsStepItem.AddSiblingAfter((int ?)contenttype);
hlsStepItem.AddSiblingAfter((int ?)contenttype,true);
}
else
{

View File

@@ -307,6 +307,14 @@ namespace Volian.Controls.Library
{
if (NodeNew != null) NodeNew(sender, args);
}
/// <summary>
/// Raised after a new step is added.
/// </summary>
public event vlnTreeViewEvent NodeInsert;
private void OnNodeInsert(object sender, vlnTreeEventArgs args)
{
if (NodeInsert != null) NodeInsert(sender, args);
}
public event vlnTreeViewEvent NodeSelectionChange;
private void OnNodeSelectionChange(object sender, vlnTreeEventArgs args)
{
@@ -969,6 +977,7 @@ namespace Volian.Controls.Library
SelectedNode = tn;
OnNodeNew(this, new vlnTreeEventArgs(SelectedNode));
Refresh();
OnNodeInsert(this, new vlnTreeEventArgs(SelectedNode));
}
}