This commit is contained in:
2022-07-02 21:21:56 +00:00
parent d36888acdc
commit e438fc7f65
2 changed files with 181 additions and 0 deletions

View File

@@ -185,6 +185,7 @@
//
// gridAya
//
this.gridAya.AllowDrop = true;
this.gridAya.AllowUserToAddRows = false;
this.gridAya.AllowUserToDeleteRows = false;
this.gridAya.AllowUserToResizeRows = false;
@@ -212,10 +213,18 @@
this.gridAya.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.gridAya.Size = new System.Drawing.Size(370, 533);
this.gridAya.TabIndex = 4;
this.gridAya.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.gridAya_CellClick);
this.gridAya.SelectionChanged += new System.EventHandler(this.grid_SelectionChanged);
this.gridAya.DragDrop += new System.Windows.Forms.DragEventHandler(this.gridAya_DragDrop);
this.gridAya.DragEnter += new System.Windows.Forms.DragEventHandler(this.gridAya_DragEnter);
this.gridAya.DragOver += new System.Windows.Forms.DragEventHandler(this.gridAya_DragOver);
this.gridAya.MouseDown += new System.Windows.Forms.MouseEventHandler(this.gridAya_MouseDown);
this.gridAya.MouseMove += new System.Windows.Forms.MouseEventHandler(this.gridAya_MouseMove);
this.gridAya.MouseUp += new System.Windows.Forms.MouseEventHandler(this.gridAya_MouseUp);
//
// gridQB
//
this.gridQB.AllowDrop = true;
this.gridQB.AllowUserToAddRows = false;
this.gridQB.AllowUserToDeleteRows = false;
this.gridQB.AllowUserToResizeRows = false;
@@ -243,6 +252,12 @@
this.gridQB.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.gridQB.Size = new System.Drawing.Size(381, 533);
this.gridQB.TabIndex = 5;
this.gridQB.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.gridQB_CellClick);
this.gridQB.DragDrop += new System.Windows.Forms.DragEventHandler(this.gridQB_DragDrop);
this.gridQB.DragEnter += new System.Windows.Forms.DragEventHandler(this.gridQB_DragEnter);
this.gridQB.MouseDown += new System.Windows.Forms.MouseEventHandler(this.gridQB_MouseDown);
this.gridQB.MouseMove += new System.Windows.Forms.MouseEventHandler(this.gridQB_MouseMove);
this.gridQB.MouseUp += new System.Windows.Forms.MouseEventHandler(this.gridQB_MouseUp);
//
// splitContainer1
//

View File

@@ -56,6 +56,7 @@ namespace AyaNovaQBI
{
Initialize();
gridAya.ClearSelection();
gridQB.ClearSelection();
}
/// <summary>
@@ -392,6 +393,171 @@ namespace AyaNovaQBI
#region Drag n drop
public class QBNameID
{
public string Name { get; set; }
public string ID { get; set; }
}
List<QBNameID> SelectedQBItems = new List<QBNameID>();
public class AyaNameID
{
public string Name { get; set; }
public long ID { get; set; }
}
List<AyaNameID> SelectedAyaItems = new List<AyaNameID>();
private bool m_dragging = false;
Rectangle dragBoxFromMouseDown;
int rowIndexFromMouseDown;
int rowIndexOfItemUnderMouseToDrop;
#region AyaGrid
private void gridAya_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
return;
//Only do this if the user is positioned over a row
rowIndexFromMouseDown = gridAya.HitTest(e.X, e.Y).RowIndex;
if ((rowIndexFromMouseDown != -1))
{
SelectedAyaItems.Clear();
if (gridAya.SelectedRows.Count > 0 && !gridAya.SelectedRows[0].IsNewRow)
{
foreach (DataGridViewRow r in gridAya.SelectedRows)
{
SelectedAyaItems.Add(new AyaNameID { Name = (string)r.Cells[0].Value, ID = (long)r.Cells[1].Value });
}
//Size dragSize = SystemInformation.DragSize;
//dragBoxFromMouseDown = new Rectangle(new Point(e.X - (dragSize.Width / 2), e.Y - (dragSize.Height / 2)), dragSize);
m_dragging = true;
}
}
else
{
// dragBoxFromMouseDown = Rectangle.Empty;
}
}
private void gridAya_MouseUp(object sender, MouseEventArgs e)
{
m_dragging = false;
}
private void gridAya_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left
&& m_dragging
&& SelectedAyaItems.Count > 0)
{
gridAya.DoDragDrop(null, DragDropEffects.Link);
}
//if (((e.Button == MouseButtons.Left)))
//{
// if (((dragBoxFromMouseDown != Rectangle.Empty)
// && !dragBoxFromMouseDown.Contains(e.X, e.Y)))
// {
// DragDropEffects dropEffect = gridAya.DoDragDrop(gridAya.Rows[rowIndexFromMouseDown], DragDropEffects.Move);
// }
//}
}
private void gridAya_DragOver(object sender, DragEventArgs e)
{
// e.Effect = DragDropEffects.Move;
}
private void gridAya_DragEnter(object sender, DragEventArgs e)
{
if (SelectedQBItems.Count > 0)
{
e.Effect = DragDropEffects.Link;
}
else
e.Effect = DragDropEffects.None;
}
private void gridAya_DragDrop(object sender, DragEventArgs e)
{
MessageBox.Show("STUB: aya drop data happened");
//Point clientPoint = gridAya.PointToClient(new Point(e.X, e.Y));
//rowIndexOfItemUnderMouseToDrop = gridAya.HitTest(clientPoint.X, clientPoint.Y).RowIndex;
//if ((e.Effect == DragDropEffects.Move))
//{
// DataGridViewRow rowToMove = (DataGridViewRow)e.Data.GetData(typeof(DataGridViewRow));
// object[] celldata = new object[gridAya.ColumnCount];
// for (int col = 0; (col
// <= (rowToMove.Cells.Count - 1)); col++)
// {
// celldata[col] = rowToMove.Cells[col].Value;
// }
// //DataRow row = bsPeople.NewRow();
// //row.ItemArray = celldata;
// //bsPeople.Rows.InsertAt(row, rowIndexOfItemUnderMouseToDrop);
// //rowToMove.DataGridView.Rows.Remove(rowToMove);
//}
}
private void gridAya_CellClick(object sender, DataGridViewCellEventArgs e)
{
}
#endregion ayagrid
#region QBGrid
private void gridQB_MouseDown(object sender, MouseEventArgs e)
{
}
private void gridQB_MouseUp(object sender, MouseEventArgs e)
{
}
private void gridQB_MouseMove(object sender, MouseEventArgs e)
{
}
private void gridQB_DragEnter(object sender, DragEventArgs e)
{
}
private void gridQB_DragDrop(object sender, DragEventArgs e)
{
}
private void gridQB_CellClick(object sender, DataGridViewCellEventArgs e)
{
}
#endregion qbgrid
#endregion drag and drop
/*
* Simplified, no drag and drop just pick and choose with clicks
* A menu to select the ayanova object type which then populates the ayanova items grid of that type showing: