Added logic to support doing an Add Next or Add Previous on a Table

This commit is contained in:
John Jenko 2015-05-13 17:25:15 +00:00
parent a5f930391a
commit 7cb179f085

View File

@ -974,12 +974,30 @@ namespace Volian.Controls.Library
{ {
SaveContents(); SaveContents();
ItemInfo newItemInfo = MyItemInfo.InsertSiblingAfter(text); ItemInfo newItemInfo = MyItemInfo.InsertSiblingAfter(text);
AddGridIfNeeded(newItemInfo);
DoAddSiblingAfter(newItemInfo, updateStatus); DoAddSiblingAfter(newItemInfo, updateStatus);
} }
// This logic allows us to do an Insert Before and Insert After while on a Table
// if allowed by the format
private void AddGridIfNeeded(ItemInfo newItemInfo)
{
if (this is GridItem)
{
GridItem gi = this as GridItem;
VlnFlexGrid fg = new VlnFlexGrid(gi.MyFlexGrid.Rows.Count, gi.MyFlexGrid.Cols.Count);
using (Item itm = newItemInfo.Get())
{
itm.MyContent.MyGrid.Data = fg.GetXMLData();
itm.Save();
}
}
}
public void AddSiblingAfter(int? type, bool updateStatus) public void AddSiblingAfter(int? type, bool updateStatus)
{ {
SaveContents(); SaveContents();
ItemInfo newItemInfo = MyItemInfo.InsertSiblingAfter("", "", type); ItemInfo newItemInfo = MyItemInfo.InsertSiblingAfter("", "", type);
AddGridIfNeeded(newItemInfo);
DoAddSiblingAfter(newItemInfo, updateStatus); DoAddSiblingAfter(newItemInfo, updateStatus);
} }
private void DoAddSiblingAfter(ItemInfo newItemInfo, bool updateStatus) private void DoAddSiblingAfter(ItemInfo newItemInfo, bool updateStatus)
@ -1012,7 +1030,7 @@ namespace Volian.Controls.Library
{ {
SaveContents(); SaveContents();
ItemInfo newItemInfo = MyItemInfo.InsertSiblingBefore("", "",type); ItemInfo newItemInfo = MyItemInfo.InsertSiblingBefore("", "",type);
AddGridIfNeeded(newItemInfo);
DoAddSiblingBefore(newItemInfo, updateStatus); DoAddSiblingBefore(newItemInfo, updateStatus);
} }
public void AddSiblingBefore(string text, bool updateSelection) public void AddSiblingBefore(string text, bool updateSelection)
@ -1025,6 +1043,7 @@ namespace Volian.Controls.Library
// any updates from the richtextbox text. // any updates from the richtextbox text.
SaveContents(); SaveContents();
ItemInfo newItemInfo = MyItemInfo.InsertSiblingBefore(text); ItemInfo newItemInfo = MyItemInfo.InsertSiblingBefore(text);
AddGridIfNeeded(newItemInfo);
DoAddSiblingBefore(newItemInfo, updateSelection); DoAddSiblingBefore(newItemInfo, updateSelection);
} }
public void DoAddSiblingBefore(ItemInfo newItemInfo, bool updateSelection) public void DoAddSiblingBefore(ItemInfo newItemInfo, bool updateSelection)