Save the UserID when a Grid is changed.
Disable Drag and Drop for Steps, since this code was not working properly. Changed logic to handle folders with identical names. The user is informed, and the code no longer crashes.
This commit is contained in:
parent
eb92e89186
commit
9c8cfe9920
@ -640,12 +640,14 @@ namespace Volian.Controls.Library
|
||||
//if (itm.MyContent.Text != searchableText)
|
||||
//{
|
||||
itm.MyContent.Text = searchableText;
|
||||
itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID;
|
||||
itm.MyContent.DTS = DateTime.Now;
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
itm.MyContent.Text = searchableText;
|
||||
itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID;
|
||||
itm.MyContent.DTS = DateTime.Now;
|
||||
}
|
||||
if (!MyFlexGrid.IsRoTable)itm.MyContent.Text = searchableText;
|
||||
|
@ -1682,6 +1682,11 @@ namespace Volian.Controls.Library
|
||||
MessageBox.Show("Cannot drag/drop a grouping node.");
|
||||
return;
|
||||
}
|
||||
if (iidrag != null && !iidrag.IsProcedure && !iidrag.IsSection)
|
||||
{
|
||||
MessageBox.Show("Cannot drag/drop steps (for now).","Under Construction", MessageBoxButtons.OK, MessageBoxIcon.Hand);
|
||||
return;
|
||||
}
|
||||
// don't put up message, message kept coming up on any selection of node (to copy, properties, etc)
|
||||
//if (iidrag != null && iidrag.IsStep) return;
|
||||
if (SetupDragCursor(_dragImageList, dragNode))
|
||||
@ -2018,6 +2023,12 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
return (veTreeNode.VEObject.GetType() == typeof(FolderInfo));
|
||||
}
|
||||
private Exception RootException(Exception ex)
|
||||
{
|
||||
while (ex.InnerException != null)
|
||||
ex = ex.InnerException;
|
||||
return ex;
|
||||
}
|
||||
private void tv_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
|
||||
{
|
||||
try
|
||||
@ -2027,12 +2038,6 @@ namespace Volian.Controls.Library
|
||||
int index = _LastDropLocation.Index + (_LastDropLocation.Position == DropPosition.After ? 1 : 0);
|
||||
int myIndex = index;
|
||||
if (dragNode.Parent == _LastDropLocation.DropNode && dragNode.Index <= _LastDropLocation.Index) index--;
|
||||
if (e.Effect == DragDropEffects.Move)// If Move Remove drag node from parent
|
||||
dragNode.Remove();
|
||||
else
|
||||
dragNode = Clone(dragNode);
|
||||
_LastDropLocation.DropNode.Nodes.Insert(index, dragNode);
|
||||
this.SelectedNode = dragNode;
|
||||
FolderInfo fdragi = ((VETreeNode)dragNode).VEObject as FolderInfo;
|
||||
FolderInfo fdropi = ((VETreeNode)_LastDropLocation.DropNode).VEObject as FolderInfo;
|
||||
if (fdragi != null && fdropi != null && fdropi.FolderDocVersionCount==0)
|
||||
@ -2040,10 +2045,23 @@ namespace Volian.Controls.Library
|
||||
using (Folder fdrag = fdragi.Get())
|
||||
{
|
||||
using (Folder fdrop = fdropi.Get())
|
||||
{
|
||||
try
|
||||
{
|
||||
fdrag.ManualOrder = fdropi.NewManualOrder(myIndex);
|
||||
fdrag.MyParent = fdrop;
|
||||
fdrag.Save();
|
||||
MoveNode(e, dragNode, index);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex = RootException(ex);
|
||||
if (ex.Message.Contains("Cannot insert duplicate key row in object 'dbo.Folders' with unique index 'IX_UniqueChildFolders'"))
|
||||
MessageBox.Show("You cannot have two folders with the same name here!",
|
||||
"Duplicate Folder Name", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
else
|
||||
_MyLog.WarnFormat("{0} - {1}", ex.GetType().Name, ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -2060,6 +2078,7 @@ namespace Volian.Controls.Library
|
||||
if (pdropi != null && pdragi.ActiveParent == pdropi.ActiveParent)
|
||||
{
|
||||
pdragi.MoveProcedure(pdragi.ActiveParent, myIndex);
|
||||
MoveNode(e, dragNode, index);
|
||||
return;
|
||||
}
|
||||
DocVersionInfo dvdropi = ((VETreeNode)_LastDropLocation.DropNode).VEObject as DocVersionInfo;
|
||||
@ -2067,6 +2086,7 @@ namespace Volian.Controls.Library
|
||||
if (dvdropi != null && dvdragpar.VersionID == dvdropi.VersionID)
|
||||
{
|
||||
pdragi.MoveProcedure(dvdropi, myIndex);
|
||||
MoveNode(e, dragNode, index);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2080,6 +2100,7 @@ namespace Volian.Controls.Library
|
||||
if (sdropi != null && sdragi.ActiveParent == sdropi.ActiveParent)
|
||||
{
|
||||
sdragi.MoveSection(sdragi, myIndex);
|
||||
MoveNode(e, dragNode, index);
|
||||
return;
|
||||
}
|
||||
pdropi = ((VETreeNode)_LastDropLocation.DropNode).VEObject as ProcedureInfo;
|
||||
@ -2087,6 +2108,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
sdragi.MoveSection(pdropi, myIndex);
|
||||
sdragi.Moving = true;
|
||||
MoveNode(e, dragNode, index);
|
||||
OnNodeSelect(dragNode, new vlnTreeEventArgs(dragNode));
|
||||
return;
|
||||
}
|
||||
@ -2101,18 +2123,21 @@ namespace Volian.Controls.Library
|
||||
if (stdropi != null && stdragi.ActiveParent == stdropi.ActiveParent)
|
||||
{
|
||||
stdragi.MoveStep(stdragi.ActiveParent, myIndex);
|
||||
MoveNode(e, dragNode, index);
|
||||
return;
|
||||
}
|
||||
sdropi = ((VETreeNode)_LastDropLocation.DropNode).VEObject as SectionInfo;
|
||||
if (sdropi != null && stdragi.MyParent.ItemID == sdropi.ItemID)
|
||||
{
|
||||
stdragi.MoveStep(stdragi.ActiveParent, myIndex);
|
||||
MoveNode(e, dragNode, index);
|
||||
return;
|
||||
}
|
||||
// the following handles items under the app nodes of 'steps', 'notes', 'cautions', etc.
|
||||
if (sdropi == null && dragNode.Parent == _LastDropLocation.DropNode)
|
||||
{
|
||||
stdragi.MoveStep(stdragi.ActiveParent, myIndex);
|
||||
MoveNode(e, dragNode, index);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2122,6 +2147,17 @@ namespace Volian.Controls.Library
|
||||
if(_MyLog.IsErrorEnabled)_MyLog.Error("tv_DragDrop", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveNode(System.Windows.Forms.DragEventArgs e, TreeNode dragNode, int index)
|
||||
{
|
||||
if (e.Effect == DragDropEffects.Move)// If Move Remove drag node from parent
|
||||
dragNode.Remove();
|
||||
// Copy method has been removed
|
||||
//else
|
||||
// dragNode = Clone(dragNode);
|
||||
_LastDropLocation.DropNode.Nodes.Insert(index, dragNode);
|
||||
this.SelectedNode = dragNode;
|
||||
}
|
||||
// private void DumpMembers(object o)
|
||||
// {
|
||||
// Type t = o.GetType();
|
||||
@ -2151,17 +2187,17 @@ namespace Volian.Controls.Library
|
||||
ExpandMatch(tmp,tn);
|
||||
return tmp;
|
||||
}
|
||||
private void tv_DragDropOld(object sender, System.Windows.Forms.DragEventArgs e)
|
||||
{
|
||||
TreeNode dragNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");// Get the drag node
|
||||
DragHelper.ImageList_DragLeave(this.Handle);
|
||||
TreeNode cloneNode = (TreeNode)dragNode.Clone();// copy the source node
|
||||
ExpandMatch(cloneNode, dragNode);
|
||||
_LastDropLocation.DropNode.Nodes.Insert(_LastDropLocation.Index + (_LastDropLocation.Position == DropPosition.After ? 1 : 0), cloneNode);
|
||||
if (e.Effect == DragDropEffects.Move)// If Move Remove drag node from parent
|
||||
dragNode.Remove();
|
||||
this.SelectedNode = cloneNode;
|
||||
}
|
||||
//private void tv_DragDropOld(object sender, System.Windows.Forms.DragEventArgs e)
|
||||
//{
|
||||
// TreeNode dragNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");// Get the drag node
|
||||
// DragHelper.ImageList_DragLeave(this.Handle);
|
||||
// TreeNode cloneNode = (TreeNode)dragNode.Clone();// copy the source node
|
||||
// ExpandMatch(cloneNode, dragNode);
|
||||
// _LastDropLocation.DropNode.Nodes.Insert(_LastDropLocation.Index + (_LastDropLocation.Position == DropPosition.After ? 1 : 0), cloneNode);
|
||||
// if (e.Effect == DragDropEffects.Move)// If Move Remove drag node from parent
|
||||
// dragNode.Remove();
|
||||
// this.SelectedNode = cloneNode;
|
||||
//}
|
||||
private void tv_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
|
||||
{
|
||||
DragHelper.ImageList_DragEnter(this.Handle, e.X - this.Left, e.Y - this.Top);
|
||||
|
Loading…
x
Reference in New Issue
Block a user