protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); int itwi = Width / TargetCount; for (int i = 0; i < TargetCount; i++) { GraphicsState oldstate = e.Graphics.Save(); DragObjectContainer obj = m_memory[i]; int x0 = itwi * i; e.Graphics.Clip = new Region(new Rectangle(x0, 0, itwi, Height)); e.Graphics.DrawRectangle(Pens.Black, x0 + 2, 2, itwi - 4, Height - 4); if (obj != null) { int imwi = 0; if (obj.Image != null) { e.Graphics.DrawImage(obj.Image, x0 + 3, 3); imwi = obj.Image.Width; } if (obj.Title != null) { e.Graphics.DrawString(obj.Title, Font, Brushes.Black, x0 + imwi + 4, 4); } } else { e.Graphics.DrawString(Texts.Get("s_drag_and_drop_here"), Font, Brushes.Black, x0 + 4, 4); } e.Graphics.Restore(oldstate); } }
private void listView1_DragOver(object sender, DragEventArgs e) { try { var pt = listView1.PointToClient(new Point(e.X, e.Y)); ListViewItem dropItem = listView1.GetItemAt(pt.X, pt.Y); DragObjectContainer cnt = (DragObjectContainer)e.Data.GetData(typeof(DragObjectContainer)); if (cnt != null && dropItem != null && cnt.Data is AppObject[]) { var appobj = (AppObject)dropItem.Tag; if (appobj.AllowDragDrop((AppObject[])cnt.Data)) { e.Effect = DragDropEffects.Copy; } else { e.Effect = DragDropEffects.None; } } } catch (Exception ex) { Errors.Report(ex); } }
private void tree_DragOver(object sender, DragEventArgs e) { try { TreeNode dropNode = tree.GetNodeAt(tree.PointToClient(new Point(e.X, e.Y))); DragObjectContainer cnt = (DragObjectContainer)e.Data.GetData(typeof(DragObjectContainer)); if (cnt != null && dropNode != null && cnt.Data is AppObject[]) { if (((DATreeNode)dropNode).m_node.AllowDragDrop((AppObject[])cnt.Data)) { e.Effect = DragDropEffects.Copy; } else { e.Effect = DragDropEffects.None; } } string[] files = (string[])e.Data.GetData("FileDrop"); if (files != null) { e.Effect = DragDropEffects.Copy; } } catch (Exception ex) { Errors.Report(ex); } }
private void panel1_DragDrop(object sender, DragEventArgs e) { DragObjectContainer obj = (DragObjectContainer)e.Data.GetData(typeof(DragObjectContainer)); if (obj != null) { var appobjs = obj.Data as AppObject[]; if (appobjs != null) { foreach (var appobj in appobjs) { var tsrc = appobj.TableSource; if (tsrc != null) { AddTable(tsrc); } //var tbl = appobj as TableAppObject; //if (tbl != null) //{ // AddTable(tbl.DbObjectName); //} } } } var name = (FullDatabaseRelatedName)e.Data.GetData(typeof(FullDatabaseRelatedName)); if (name != null) { AddTable(name); } }
protected override void OnDragDrop(DragEventArgs drgevent) { base.OnDragDrop(drgevent); DragObjectContainer obj = (DragObjectContainer)drgevent.Data.GetData(typeof(DragObjectContainer)); if (obj != null) { int index = GetMemoryIndex(drgevent); if (index >= 0 && index < TargetCount) { m_memory[index] = obj; } Refresh(); } }
protected override void OnDragOver(DragEventArgs drgevent) { base.OnDragOver(drgevent); DragObjectContainer obj = (DragObjectContainer)drgevent.Data.GetData(typeof(DragObjectContainer)); if (obj != null) { int index = GetMemoryIndex(drgevent); if (index >= 0 && index < TargetCount) { drgevent.Effect = DragDropEffects.Copy; } } }
private void listView1_DragDrop(object sender, DragEventArgs e) { try { var pt = listView1.PointToClient(new Point(e.X, e.Y)); ListViewItem dropItem = listView1.GetItemAt(pt.X, pt.Y); DragObjectContainer cnt = (DragObjectContainer)e.Data.GetData(typeof(DragObjectContainer)); if (cnt != null && dropItem != null && cnt.Data is AppObject[]) { var appobj = (AppObject)dropItem.Tag; AppObject[] draggedObjs = (AppObject[])cnt.Data; appobj.DragDrop(draggedObjs); } } catch (Exception ex) { Errors.Report(ex); } }
private void listView1_ItemDrag(object sender, ItemDragEventArgs e) { //var appobj = ((ListViewItem)e.Item).Tag as AppObject; //if (appobj == null) return; var objs = GetSelectedObjects(); if (objs.Count == 0) { return; } try { //DoDragDrop(DragObjectContainer.Create(new AppObject[] { appobj }), DragDropEffects.Copy); DoDragDrop(DragObjectContainer.Create(objs.ToArray()), DragDropEffects.Copy); } catch (Exception ex) { Errors.Report(ex); } }
private void tree_ItemDrag(object sender, ItemDragEventArgs e) { if (!TreeBehaviour.AllowDragDrop) { return; } var appobjs = new List <AppObject>(((DATreeNode)e.Item).m_node.GetValidAppObjects()); if (appobjs.Count == 0) { return; } try { DoDragDrop(DragObjectContainer.Create(appobjs.ToArray()), DragDropEffects.Copy); } catch (Exception ex) { Errors.Report(ex); } }
private void panel1_DragOver(object sender, DragEventArgs e) { DragObjectContainer obj = (DragObjectContainer)e.Data.GetData(typeof(DragObjectContainer)); if (obj != null) { var appobjs = obj.Data as AppObject[]; foreach (var appobj in appobjs) { if (appobj.TableSource != null) { e.Effect = DragDropEffects.Copy; break; } } } if (e.Data.GetData(typeof(FullDatabaseRelatedName)) != null) { e.Effect = DragDropEffects.Copy; } }
private void tree_DragDrop(object sender, DragEventArgs e) { if (!TreeBehaviour.AllowDragDrop) { return; } try { TreeNode dropNode = tree.GetNodeAt(tree.PointToClient(new Point(e.X, e.Y))); DragObjectContainer cnt = (DragObjectContainer)e.Data.GetData(typeof(DragObjectContainer)); if (cnt != null && dropNode != null && cnt.Data is AppObject[]) { ITreeNode targetNode = ((DATreeNode)dropNode).m_node; AppObject[] draggedObjs = (AppObject[])cnt.Data; targetNode.DragDrop(draggedObjs); //MacroManager.DragDropNode(targetNode, draggedObjs); } try { IDataObject obj = e.Data; string[] files = (string[])obj.GetData("FileDrop"); foreach (string f in files) { string fn = IOTool.GetUniqueFileName(Path.Combine(Root.FileSystemPath, Path.GetFileNameWithoutExtension(f) + ".lnk")); using (StreamWriter sw = new StreamWriter(fn)) sw.Write(f); RefreshRoot(); MacroManager.DropFileIntoTree(tree, f); } } catch (Exception) { } tree.SelectedNode = dropNode; } catch (Exception ex) { Errors.Report(ex); } }
public static DragObjectContainer Create(AppObject[] objs) { DragObjectContainer res = new DragObjectContainer(objs, objs[0].ToString(), objs[0].Image); return(res); }