protected virtual void OnDropped(OlvDropEventArgs args) { if (this.Dropped != null) { this.Dropped(this, args); } }
private void ProjectTreeView_CanDrop(object sender, BrightIdeasSoftware.OlvDropEventArgs e) { e.Effect = DragDropEffects.None; if (e.DropTargetItem != null && e.DataObject is BrightIdeasSoftware.OLVDataObject dataObj) { var targetNode = e.DropTargetItem.RowObject as ProjectTreeNode; var elementNodes = dataObj.ModelObjects.OfType <ProjectElementNode>().ToList(); if (e.DropTargetLocation == DropTargetLocation.Item) { if (elementNodes.All(x => x.CanDropOn(targetNode))) { e.Effect = DragDropEffects.Move; } } else if (e.DropTargetLocation == DropTargetLocation.BelowItem) { if (elementNodes.All(x => x.CanDropAfter(targetNode))) { e.Effect = DragDropEffects.Move; } } else if (e.DropTargetLocation == DropTargetLocation.AboveItem) { if (elementNodes.All(x => x.CanDropBefore(targetNode))) { e.Effect = DragDropEffects.Move; } } } }
protected virtual void OnCanDrop(OlvDropEventArgs args) { if (this.CanDrop != null) { this.CanDrop(this, args); } }
protected virtual void CalculateDropTarget(OlvDropEventArgs args, Point pt) { BrightIdeasSoftware.DropTargetLocation none = BrightIdeasSoftware.DropTargetLocation.None; int index = -1; int num2 = 0; if (this.CanDropOnBackground) { none = BrightIdeasSoftware.DropTargetLocation.Background; } OlvListViewHitTestInfo info = this.ListView.OlvHitTest(pt.X, pt.Y); if ((info.Item != null) && this.CanDropOnItem) { none = BrightIdeasSoftware.DropTargetLocation.Item; index = info.Item.Index; if ((info.SubItem != null) && this.CanDropOnSubItem) { num2 = info.Item.SubItems.IndexOf(info.SubItem); } } if (this.CanDropBetween && (this.ListView.GetItemCount() > 0)) { if (none == BrightIdeasSoftware.DropTargetLocation.Item) { if ((pt.Y - 3) <= info.Item.Bounds.Top) { none = BrightIdeasSoftware.DropTargetLocation.AboveItem; } if ((pt.Y + 3) >= info.Item.Bounds.Bottom) { none = BrightIdeasSoftware.DropTargetLocation.BelowItem; } } else { info = this.ListView.OlvHitTest(pt.X, pt.Y + 3); if (info.Item != null) { index = info.Item.Index; none = BrightIdeasSoftware.DropTargetLocation.AboveItem; } else { info = this.ListView.OlvHitTest(pt.X, pt.Y - 3); if (info.Item != null) { index = info.Item.Index; none = BrightIdeasSoftware.DropTargetLocation.BelowItem; } } } } args.DropTargetLocation = none; args.DropTargetIndex = index; args.DropTargetSubItemIndex = num2; }
private static Tuple <Title, Title> GetModelsFromDropEvent(BrightIdeasSoftware.OlvDropEventArgs e) { var dataObject = e.DataObject as BrightIdeasSoftware.OLVDataObject; Title source = null; Title destination = null; if (dataObject != null) { source = dataObject.ModelObjects.Count > 0 ? dataObject.ModelObjects[0] as Title : null; destination = e.DropTargetItem == null ? null : e.DropTargetItem.RowObject as Title; } return(new Tuple <Title, Title>(source, destination)); }
protected virtual void UpdateAfterCanDropEvent(OlvDropEventArgs args) { this.DropTargetIndex = args.DropTargetIndex; this.DropTargetLocation = args.DropTargetLocation; this.DropTargetSubItemIndex = args.DropTargetSubItemIndex; if (this.Billboard != null) { Point mouseLocation = args.MouseLocation; mouseLocation.Offset(5, 5); if ((this.Billboard.Text != this.dropEventArgs.InfoMessage) || (this.Billboard.Location != mouseLocation)) { this.Billboard.Text = this.dropEventArgs.InfoMessage; this.Billboard.Location = mouseLocation; this.ListView.Invalidate(); } } }
/// <summary> /// Update the state of our sink to reflect the information that /// may have been written into the drop event args. /// </summary> /// <param name="args"></param> protected virtual void UpdateAfterCanDropEvent(OlvDropEventArgs args) { DropTargetIndex = args.DropTargetIndex; DropTargetLocation = args.DropTargetLocation; DropTargetSubItemIndex = args.DropTargetSubItemIndex; if (Billboard != null) { Point pt = args.MouseLocation; pt.Offset(5, 5); if (Billboard.Text != dropEventArgs.InfoMessage || Billboard.Location != pt) { Billboard.Text = dropEventArgs.InfoMessage; Billboard.Location = pt; ListView.Invalidate(); } } }
private void tlvGroupedFiles_Dropped(object sender, OlvDropEventArgs e) { var target = (tlvBranch)e.DropTargetItem.RowObject; var index = -1; var toRefresh = new HashSet<tlvBranch>(); if (target.Data is SpectrumSource) { index = target.Parent.Children.IndexOf(target); target = target.Parent; } if (e.DataObject.GetType().ToString() == "System.Windows.Forms.DataObject") { var sources = new List<tlvBranch>(); foreach (ListViewItem item in lvNonGroupedFiles.SelectedItems) sources.Add((tlvBranch)item.Tag); //var sources = from ListViewItem item in lvNonGroupedFiles.SelectedItems // select (tlvBranch) item.Tag; foreach (var source in sources) { if (index >= 0) target.Children.Insert(index, source); else target.Children.Add(source); source.Parent = target; } toRefresh.Add(target); var usedItems = from ListViewItem item in lvNonGroupedFiles.SelectedItems select item; foreach (var item in usedItems) lvNonGroupedFiles.Items.Remove(item); } else if (e.DataObject is OLVDataObject) { var dragging = e.DataObject as OLVDataObject; var sources = from tlvBranch item in dragging.ModelObjects where item.Data is SpectrumSource select item; var groups = from tlvBranch item in dragging.ModelObjects where (item.Data is SpectrumSourceGroup && (item.Data as SpectrumSourceGroup).Name != "\\") select item; var sourcesToIgnore = new List<tlvBranch>(); foreach (var group in groups) { //find and ignore spectra in group getListOfSprectrumSourcesRecursively(group, ref sourcesToIgnore); group.Parent.Children.Remove(group); toRefresh.Add(group.Parent); group.Parent = target; if (target.Children.Any()) target.Children.Insert(0, group); else target.Children.Add(group); } sources = from tlvBranch s in sources where !sourcesToIgnore.Contains(s) select s; foreach (var source in sources) { source.Parent.Children.Remove(source); toRefresh.Add(source.Parent); source.Parent = target; if (index >= 0) target.Children.Insert(index, source); else target.Children.Add(source); } toRefresh.Add(target); tlvGroupedFiles.Expand(target); } foreach (var item in toRefresh) tlvGroupedFiles.RefreshObject(item); OrganizeNode(target); }
private void objectListView1_Dropped(object sender, OlvDropEventArgs e) { Console.WriteLine("dropped"); updateModelList(); refreshContestantListView(); }
private void HandleDropped(object sender, OlvDropEventArgs e) { // This will only be triggered if HandleModelDropped doesn't set Handled to true. // In practice, this will only be called when the source of the drag is not an ObjectListView DataObject data = e.DataObject as DataObject; if (data == null || String.IsNullOrEmpty(data.GetText())) return; TreeListView treeListView = e.ListView as TreeListView; if (treeListView == null) return; ModelWithChildren newModel = new ModelWithChildren { Label = data.GetText(), DataForChildren = new ArrayList {"A", "B ", "C", "D", "E"} }; switch (e.DropTargetLocation) { case DropTargetLocation.AboveItem: break; case DropTargetLocation.BelowItem: break; case DropTargetLocation.Background: treeListView.AddObject(newModel); break; case DropTargetLocation.Item: ModelWithChildren targetModel = e.DropTargetItem.RowObject as ModelWithChildren; if (targetModel != null) { newModel.Parent = targetModel; targetModel.Children.Add(newModel); treeListView.RefreshObject(targetModel); } break; default: return; } }
private void tlvGroupedFiles_CanDrop(object sender, OlvDropEventArgs e) { if (e.DataObject.GetType().ToString() == "System.Windows.Forms.DataObject") e.Effect = DragDropEffects.Move; else if (e.DataObject is OLVDataObject && e.DropTargetItem != null && (e.DropTargetItem.RowObject is tlvBranch && ((e.DropTargetItem.RowObject as tlvBranch).Data is SpectrumSourceGroup || (e.DropTargetItem.RowObject as tlvBranch).Data is SpectrumSource))) { var target = e.DropTargetItem.RowObject as tlvBranch; var dragging = (e.DataObject as OLVDataObject).ModelObjects; var isValid = true; foreach (var item in dragging) { if (checkIfDestGroupAChildNodeOfMe(target,item as tlvBranch)) { isValid = false; break; } } if (isValid) e.Effect = DragDropEffects.Move; else e.Effect = DragDropEffects.None; } else e.Effect = DragDropEffects.None; }
/// <summary> /// Shows when an object can and cannot be dropped in the list view /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void olvCraftList_CanDrop(object sender, OlvDropEventArgs e) { // If object is a file, allow copy if (e.DragEventArgs.Data.GetDataPresent(DataFormats.FileDrop, false)) e.Effect = DragDropEffects.Copy; }
private void HandleCanDrop(object sender, OlvDropEventArgs e) { // This will only be triggered if HandleModelCanDrop doesn't set Handled to true. // In practice, this will only be called when the source of the drag is not an ObjectListView IDataObject data = e.DataObject as IDataObject; if (data == null || !data.GetDataPresent(DataFormats.UnicodeText)) return; string str = data.GetData(DataFormats.UnicodeText) as string; e.Effect = String.IsNullOrEmpty(str) ? DragDropEffects.None : DragDropEffects.Copy; switch (e.DropTargetLocation) { case DropTargetLocation.AboveItem: case DropTargetLocation.BelowItem: e.InfoMessage = "Cannot drop between items -- because I haven't written the logic :)"; break; case DropTargetLocation.Background: e.InfoMessage = "Drop here to create a new root item called '" + str + "'"; break; case DropTargetLocation.Item: e.InfoMessage = "Drop here to create a new child item called '" + str + "'"; break; default: return; } }
/// <summary> /// /// </summary> /// <param name="args"></param> protected virtual void OnCanDrop(OlvDropEventArgs args) { if (this.CanDrop != null) this.CanDrop(this, args); }
// Forward events from the drop sink to the control itself void dropSink_CanDrop(object sender, OlvDropEventArgs e) { this.OnCanDrop(e); }
// Forward events from the drop sink to the control itself private void dropSink_CanDrop(object sender, OlvDropEventArgs e) { OnCanDrop(e); }
/// <summary> /// When the mouse is at the given point, what should the target of the drop be? /// </summary> /// <remarks>This method should update the DropTarget* members of the given arg block</remarks> /// <param name="pt">The mouse point, in client co-ordinates</param> protected virtual void CalculateDropTarget(OlvDropEventArgs args, Point pt) { const int SMALL_VALUE = 3; DropTargetLocation location = DropTargetLocation.None; int targetIndex = -1; int targetSubIndex = 0; if (this.CanDropOnBackground) location = DropTargetLocation.Background; // Which item is the mouse over? // If it is not over any item, it's over the background. ListViewHitTestInfo info = this.ListView.HitTest(pt.X, pt.Y); if (info.Item != null && this.CanDropOnItem) { location = DropTargetLocation.Item; targetIndex = info.Item.Index; if (info.SubItem != null && this.CanDropOnSubItem) targetSubIndex = info.Item.SubItems.IndexOf(info.SubItem); } // Check to see if the mouse is "between" rows. // ("between" is somewhat loosely defined) if (this.CanDropBetween && this.ListView.GetItemCount() > 0) { // If the mouse is over an item, check to see if it is near the top or bottom if (location == DropTargetLocation.Item) { if (pt.Y - SMALL_VALUE <= info.Item.Bounds.Top) location = DropTargetLocation.AboveItem; if (pt.Y + SMALL_VALUE >= info.Item.Bounds.Bottom) location = DropTargetLocation.BelowItem; } else { // Is there an item a little below the mouse? // If so, we say the drop point is above that row info = this.ListView.HitTest(pt.X, pt.Y + SMALL_VALUE); if (info.Item != null) { targetIndex = info.Item.Index; location = DropTargetLocation.AboveItem; } else { // Is there an item a little above the mouse? info = this.ListView.HitTest(pt.X, pt.Y - SMALL_VALUE); if (info.Item != null) { targetIndex = info.Item.Index; location = DropTargetLocation.BelowItem; } } } } args.DropTargetLocation = location; args.DropTargetIndex = targetIndex; args.DropTargetSubItemIndex = targetSubIndex; }
/// <summary> /// Handles when external files are dropped into the list view /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void olvCraftList_Dropped(object sender, OlvDropEventArgs e) { if (!e.DragEventArgs.Data.GetDataPresent(DataFormats.FileDrop, false)) return; // File system list of paths of files dropped into the list view var files = ((string[])e.DragEventArgs.Data.GetData(DataFormats.FileDrop)).ToList(); _craftFileHandler.CopyNewCraftToSave(files, cbDefaultSave.Text); UpdateList(); }
private void olv_CanDrop(object sender, OlvDropEventArgs e) { e.Effect = DragDropEffects.All; }
private void ProjectTreeView_Dropped(object sender, BrightIdeasSoftware.OlvDropEventArgs e) { if (e.DataObject is BrightIdeasSoftware.OLVDataObject dataObj) { var elementNodes = dataObj.ModelObjects.OfType <ProjectElementNode>().ToList(); var targetNode = e.DropTargetItem.RowObject as ProjectTreeNode; var targetElement = (targetNode as ProjectElementNode)?.Element; var movedNodes = new List <ProjectElementNode>(); ProjectManager.StartBatchChanges(); foreach (var elemTypeGroup in elementNodes.GroupBy(x => x.ElementType)) { var draggedElement = elemTypeGroup.Select(x => x.Element).ToList(); IElementCollection targetCollection = null; if (targetNode is ElementCollectionNode elemCollectionNode && elemCollectionNode.CollectionType == elemTypeGroup.Key) { targetCollection = elemCollectionNode.Collection; } else if (elemTypeGroup.Key == typeof(ModelMeshReference) && targetElement is SurfaceComponent surface) { targetCollection = surface.Meshes; } else if (targetElement is PartBone bone) { if (elemTypeGroup.Key == typeof(PartCollision)) { targetCollection = bone.Collisions; } else if (elemTypeGroup.Key == typeof(PartConnection)) { targetCollection = bone.Connections; } } else if (targetElement.GetElementType() == elemTypeGroup.Key) { targetCollection = targetElement.GetParentCollection(); } if (targetCollection != null) { using (FlagManager.UseFlag("DragDropping")) { if (targetElement != null && (e.DropTargetLocation == DropTargetLocation.BelowItem || e.DropTargetLocation == DropTargetLocation.AboveItem) && targetCollection.Contains(targetElement)) { int targetIndex = targetCollection.IndexOf(targetElement); if (e.DropTargetLocation == DropTargetLocation.AboveItem) { draggedElement.ForEach(x => x.TryRemove()); targetCollection.InsertAllAt(targetIndex, draggedElement); } else { draggedElement.ForEach(x => x.TryRemove()); targetCollection.InsertAllAt(targetIndex + 1, draggedElement); } } else { draggedElement.ForEach(x => x.TryRemove()); targetCollection.AddRange(draggedElement); } movedNodes.AddRange(elemTypeGroup); } } }
private void olv_Dropped(object sender, OlvDropEventArgs e) { string pathAndFilename = DragDropFile(e.DataObject); if (!string.IsNullOrWhiteSpace(pathAndFilename)) { string extension = Path.GetExtension(pathAndFilename); if (string.IsNullOrEmpty(extension)) { UntypedFileDropped(pathAndFilename); } else { TypedFileDropped(pathAndFilename, extension); } } }
private void ProjectTreeView_Dropped(object sender, BrightIdeasSoftware.OlvDropEventArgs e) { if (e.DataObject is BrightIdeasSoftware.OLVDataObject dataObj) { var elementNodes = dataObj.ModelObjects.OfType <ProjectElementNode>().ToList(); var elemType = elementNodes.FirstOrDefault()?.Element.GetType(); if (elementNodes.All(x => x.Element.GetType() == elemType)) { if (elemType == typeof(ModelMeshReference)) { var meshRefElems = elementNodes.Select(x => x.Element).OfType <ModelMeshReference>().ToList(); var targetNode = e.DropTargetItem.RowObject as ProjectTreeNode; var targetElement = (targetNode as ProjectElementNode)?.Element; IElementCollection targetCollection = null; if (targetNode is ProjectElementNode targetElemNode) { if (targetElemNode.Element is SurfaceComponent surfaceComponent) { targetCollection = surfaceComponent.Meshes; } else if (targetElemNode.Element is ModelMeshReference modelRef) { var parentComponent = modelRef.Parent as SurfaceComponent; targetCollection = parentComponent.Meshes; if (parentComponent is FemaleStudModel femaleStud && femaleStud.ReplacementMeshes.Contains(modelRef)) { targetCollection = femaleStud.ReplacementMeshes; } } } else if (targetNode is ElementCollectionNode elemCollectionNode) { if (elemCollectionNode.CollectionType == elemType) { targetCollection = elemCollectionNode.Collection; } } if (targetCollection != null) { using (FlagManager.UseFlag("DragDropping")) { ProjectManager.StartBatchChanges(); if (targetElement != null && e.DropTargetLocation == DropTargetLocation.AboveItem) { int itemIndex = targetCollection.IndexOf(targetElement); meshRefElems.ForEach(x => x.TryRemove()); targetCollection.InsertAllAt(itemIndex, meshRefElems); } else if (targetElement != null && e.DropTargetLocation == DropTargetLocation.BelowItem) { int itemIndex = targetCollection.IndexOf(targetElement); meshRefElems.ForEach(x => x.TryRemove()); targetCollection.InsertAllAt(itemIndex + 1, meshRefElems); } else { meshRefElems.ForEach(x => x.TryRemove()); targetCollection.AddRange(meshRefElems); } ProjectManager.EndBatchChanges(); } SetSelectedNodes(elementNodes); } } } } }
/// <summary> /// When the mouse is at the given point, what should the target of the drop be? /// </summary> /// <remarks>This method should update the DropTarget* members of the given arg block</remarks> /// <param name="pt">The mouse point, in client co-ordinates</param> protected virtual void CalculateDropTarget(OlvDropEventArgs args, Point pt) { const int SMALL_VALUE = 3; DropTargetLocation location = DropTargetLocation.None; int targetIndex = -1; int targetSubIndex = 0; if (this.CanDropOnBackground) { location = DropTargetLocation.Background; } // Which item is the mouse over? // If it is not over any item, it's over the background. ListViewHitTestInfo info = this.ListView.HitTest(pt.X, pt.Y); if (info.Item != null && this.CanDropOnItem) { location = DropTargetLocation.Item; targetIndex = info.Item.Index; if (info.SubItem != null && this.CanDropOnSubItem) { targetSubIndex = info.Item.SubItems.IndexOf(info.SubItem); } } // Check to see if the mouse is "between" rows. // ("between" is somewhat loosely defined) if (this.CanDropBetween && this.ListView.GetItemCount() > 0) { // If the mouse is over an item, check to see if it is near the top or bottom if (location == DropTargetLocation.Item) { if (pt.Y - SMALL_VALUE <= info.Item.Bounds.Top) { location = DropTargetLocation.AboveItem; } if (pt.Y + SMALL_VALUE >= info.Item.Bounds.Bottom) { location = DropTargetLocation.BelowItem; } } else { // Is there an item a little below the mouse? // If so, we say the drop point is above that row info = this.ListView.HitTest(pt.X, pt.Y + SMALL_VALUE); if (info.Item != null) { targetIndex = info.Item.Index; location = DropTargetLocation.AboveItem; } else { // Is there an item a little above the mouse? info = this.ListView.HitTest(pt.X, pt.Y - SMALL_VALUE); if (info.Item != null) { targetIndex = info.Item.Index; location = DropTargetLocation.BelowItem; } } } } args.DropTargetLocation = location; args.DropTargetIndex = targetIndex; args.DropTargetSubItemIndex = targetSubIndex; }
private void treeListView1_CanDrop(object sender, OlvDropEventArgs e) { BrightIdeasSoftware.OLVDataObject data = e.DataObject as BrightIdeasSoftware.OLVDataObject; FTPDirectory da = (FTPDirectory)data.ModelObjects[0]; e.Effect = DragDropEffects.Move; //MessageBox.Show(da.Name); }
private void dropSink_Dropped(object sender, OlvDropEventArgs e) { OnDropped(e); }
private void treeListView1_Dropped(object sender, OlvDropEventArgs e) { FTP par = (FTP)this.ParentForm; FolderControl oppositeFolderControl; if(this == par.folderControl1) { oppositeFolderControl = par.folderControl2; }else{ oppositeFolderControl = par.folderControl1; } BrightIdeasSoftware.OLVDataObject data = e.DataObject as BrightIdeasSoftware.OLVDataObject; FTPDirectory location = (FTPDirectory) e.DropTargetItem.RowObject; string pathOfFile = null; string pathToGo = null; foreach (FTPDirectory ftp in (List<FTPDirectory>)data.ModelObjects.Cast<FTPDirectory>().ToList()) { pathOfFile = ftp.Path; pathToGo = (location).Path + "\\" + ftp.Name; // MessageBox.Show(pathToGo); if (IsRemote && !oppositeFolderControl.IsRemote) //Local Server to Remote Client { log.Text+=("\nStart transfer of " + ftp.Name+". From LOCAL to "+client.GetComputerName()+"."); pathToGo = pathToGo.Replace("\\", "\\\\"); if (Directory.Exists(pathOfFile))//if folder { //gotta check in this dir for other dirs SendFolder(ftp, client, pathToGo, par); } else { Messaging.SendCommand("RemoteAcceptFTP(" + client.GetPort() + ",'" + pathToGo + "', " + new FileInfo(pathOfFile).Length + ");", client.GetClientSocket()); //Messaging.RemoteAcceptFTP(client.GetClientSocket(), pathToGo); Messaging.FTPFile(pathOfFile, client.GetClientSocket()); log.Text += ("\nFile successfully sent.\n"); par.Refresh(); } } else if (IsRemote && oppositeFolderControl.IsRemote) //Client to client { if (ftp.IsFile) { log.Text += ("\nStart transfer of " + ftp.Name + ". From CLIENT to " + client.GetComputerName() + "."); pathToGo = pathToGo.Replace("\\", "\\\\"); oppositeFolderControl.client.SendFileToOtherClient(pathOfFile, ftp.kbSize, pathToGo, client); } else { SendFolderToClient(ftp, pathOfFile, pathToGo, client, oppositeFolderControl); log.Text += ftp.Name + " sent"; } } else //Client to Server { log.Text += ("\nStart transfer of " + ftp.Name + ". From " + client.GetComputerName() + " to LOCAL."); //pathToGo = pathToGo.Replace("\\", "\\\\"); pathOfFile = pathOfFile.Replace("\\", "\\\\"); Messaging.SendCommand("RemoteSendFTP(" + client.GetPort() + ", '" + pathOfFile + "');", client.GetClientSocket()); //Messaging.RemoteSendFTP(client.GetClientSocket(), pathOfFile); Messaging.LocalAcceptFTP(client.GetClientSocket(), pathToGo, ftp.kbSize); log.Text += ("\nFile successfully sent.\n"); par.Refresh(); } } }
/// <summary> /// Update the state of our sink to reflect the information that /// may have been written into the drop event args. /// </summary> /// <param name="args"></param> protected virtual void UpdateAfterCanDropEvent(OlvDropEventArgs args) { this.DropTargetIndex = args.DropTargetIndex; this.DropTargetLocation = args.DropTargetLocation; this.DropTargetSubItemIndex = args.DropTargetSubItemIndex; if (this.Billboard != null) { Point pt = args.MouseLocation; pt.Offset(5, 5); if (this.Billboard.Text != this.dropEventArgs.InfoMessage || this.Billboard.Location != pt) { this.Billboard.Text = this.dropEventArgs.InfoMessage; this.Billboard.Location = pt; this.ListView.Invalidate(); } } }
private void fdlvDetalle_Dropped(object sender, OlvDropEventArgs e) { e.Handled = true; OLVDataObject o = e.DataObject as OLVDataObject; if (o != null) { OLVListItem target = e.DropTargetItem; bool targetModelo = false; if (target != null) { DataRowView drv = (DataRowView)target.RowObject; if (drv.Row["LIDO_ID"].ToString() == "N") { targetModelo = true; } } foreach (var model in o.ModelObjects) { if (model is odts.PresupuestoVentaBloque) { bool permitir = true; foreach (odts.PresupuestoVentaDetalle d in ((odts.PresupuestoVentaBloque)model).Detalle) { if (EsArticuloDuplicado(d.ArtiId1)) { permitir = false; break; } } if (permitir) { // Copiar presupuesto DataTable dt = (DataTable)this.fdlvDetalle.DataSource; odts.PresupuestoVentaBloque bloque = (odts.PresupuestoVentaBloque)model; foreach (odts.PresupuestoVentaDetalle d in ((odts.PresupuestoVentaBloque)model).Detalle) { DataRow dr = dt.NewRow(); dr["DOCU_ID"] = this.Documento; dr["PEDID_ID"] = this.Numero; dr["ESTDOC_ID"] = "N"; dr["LIDO_ID"] = d.TipoLinea; dr["DOCU_ID_ORIGEN"] = bloque.DocuId; dr["DOCU_NUMERO_ORIGEN"] = bloque.PresuvId; dr["DOCU_LINEA_ORIGEN"] = d.Linea; dr["DOCU_SUBLINEA_ORIGEN"] = d.Sublinea; dr["PEDIDL_FLUJOC"] = "0"; dr["PEDIDL_FLUJOL"] = "0"; dr["PEDIDL_FECHAD_APLIC"] = string.Empty; dr["PEDIDL_FECHAH_APLIC"] = string.Empty; int linea = CalcularNuevaLinea(); dr["PEDIDL_LINEA"] = linea; if (d.TipoLinea == "N") dr["PEDIDL_SUBLINEA"] = 0; else dr["PEDIDL_SUBLINEA"] = d.Sublinea; dr["PEDIDL_DESCRIPCION"] = d.DetalleDescripcion; dr["PEDIDL_CANTIDAD"] = 1; dr["UNID_ID"] = "UN"; dr["PEDIDL_PRECIO"] = d.Precio; if (d.DescuentoId.HasValue) dr["GRDE_ID"] = d.DescuentoId; else dr["GRDE_ID"] = DBNull.Value; dr["COMP_ID"] = this._CompId; dr["ARTI_ID1"] = d.ArtiId1; dr["DEPA_ID"] = d.DepartamentoId; dt.Rows.Add(dr); if (d is odts.DetalleModelo) { foreach (odts.DetalleDeterminacion dd in (d as odts.DetalleModelo).Determinaciones) { DataRow drd = dt.NewRow(); drd["DOCU_ID"] = this.Documento; drd["PEDID_ID"] = this.Numero; drd["ESTDOC_ID"] = "N"; drd["DOCU_ID_ORIGEN"] = bloque.DocuId; drd["DOCU_NUMERO_ORIGEN"] = bloque.PresuvId; drd["DOCU_LINEA_ORIGEN"] = d.Linea; drd["DOCU_SUBLINEA_ORIGEN"] = d.Sublinea; drd["PEDIDL_FLUJOC"] = "0"; drd["PEDIDL_FLUJOL"] = "0"; drd["PEDIDL_FECHAD_APLIC"] = string.Empty; drd["PEDIDL_FECHAH_APLIC"] = string.Empty; drd["LIDO_ID"] = dd.TipoLinea; drd["PEDIDL_LINEA"] = linea; drd["PEDIDL_SUBLINEA"] = dd.Sublinea; drd["PEDIDL_DESCRIPCION"] = dd.DetalleDescripcion; drd["PEDIDL_CANTIDAD"] = 1; drd["UNID_ID"] = "UN"; drd["PEDIDL_PRECIO"] = dd.Precio; if (dd.DescuentoId.HasValue) drd["GRDE_ID"] = dd.DescuentoId; else drd["GRDE_ID"] = DBNull.Value; drd["COMP_ID"] = this._CompId; drd["ARTI_ID1"] = dd.ArtiId1; drd["DEPA_ID"] = dd.DepartamentoId; dt.Rows.Add(drd); } } } } else { e.Effect = DragDropEffects.None; e.InfoMessage = "Hay artículos repetidos"; } } else if (model is Almacen.odts.ArticuloModelo && target == null) { if (!EsArticuloDuplicado(((Almacen.odts.ArticuloModelo)model).ArtiId1)) { // Añadir modelo al acta Almacen.odts.ArticuloModelo modelo = (Almacen.odts.ArticuloModelo)model; DataTable dt = (DataTable)this.fdlvDetalle.DataSource; DataRow dr = dt.NewRow(); dr["DOCU_ID"] = this.Documento; dr["PEDID_ID"] = this.Numero; dr["ESTDOC_ID"] = "N"; dr["DOCU_ID_ORIGEN"] = DBNull.Value; dr["DOCU_NUMERO_ORIGEN"] = DBNull.Value; dr["DOCU_LINEA_ORIGEN"] = DBNull.Value; dr["PEDIDL_FLUJOC"] = "1"; dr["PEDIDL_FLUJOL"] = "1"; dr["PEDIDL_FECHAD_APLIC"] = string.Empty; dr["PEDIDL_FECHAH_APLIC"] = string.Empty; dr["LIDO_ID"] = "N"; int linea = CalcularNuevaLinea(); dr["PEDIDL_LINEA"] = linea; dr["PEDIDL_SUBLINEA"] = 0; dr["PEDIDL_DESCRIPCION"] = modelo.Descripcion; dr["PEDIDL_CANTIDAD"] = 1; dr["UNID_ID"] = "UN"; object[] precio = null; if (this.MediadorClieId == 0) precio = ctx.GetPrecioArticuloByCliente(modelo.ArtiId1, this.ClienteId, this.Documento, usuario); else precio = ctx.GetPrecioArticuloByCliente(modelo.ArtiId1, this.MediadorClieId, this.Documento, usuario); dr["PEDIDL_PRECIO"] = precio[0] != null ? precio[0] : 0; dr["GRDE_ID"] = precio[1] != null ? precio[1] : DBNull.Value; dr["COMP_ID"] = this._CompId; dr["ARTI_ID1"] = modelo.ArtiId1; dr["DEPA_ID"] = modelo.DepartamentoId; dt.Rows.Add(dr); List<odts.DetalleDeterminacion> asociados = GetAsociados(new List<odts.DetalleDeterminacion>(), modelo.ArtiId1); foreach (odts.PresupuestoVentaDetalle a in asociados) { if (!EsArticuloDuplicado(a.ArtiId1)) { DataRow drd = dt.NewRow(); drd["DOCU_ID"] = this.Documento; drd["PEDID_ID"] = this.Numero; drd["ESTDOC_ID"] = "N"; drd["DOCU_ID_ORIGEN"] = DBNull.Value; drd["DOCU_NUMERO_ORIGEN"] = DBNull.Value; drd["DOCU_LINEA_ORIGEN"] = DBNull.Value; drd["PEDIDL_FLUJOC"] = "1"; drd["PEDIDL_FLUJOL"] = "1"; drd["PEDIDL_FECHAD_APLIC"] = string.Empty; drd["PEDIDL_FECHAH_APLIC"] = string.Empty; drd["LIDO_ID"] = "N+"; drd["PEDIDL_LINEA"] = linea; drd["PEDIDL_SUBLINEA"] = CalcularNuevaSublinea(linea); drd["PEDIDL_DESCRIPCION"] = a.DetalleDescripcion; drd["PEDIDL_CANTIDAD"] = 1; drd["UNID_ID"] = "UN"; object[] precio1 = null; if (this.MediadorClieId == 0) precio1 = ctx.GetPrecioArticuloByCliente(a.ArtiId1, this.ClienteId, this.Documento, usuario); else precio1 = ctx.GetPrecioArticuloByCliente(a.ArtiId1, this.MediadorClieId, this.Documento, usuario); drd["PEDIDL_PRECIO"] = precio1[0] != null ? precio1[0] : 0; drd["GRDE_ID"] = precio1[1] != null ? precio1[1] : DBNull.Value; drd["COMP_ID"] = this._CompId; drd["ARTI_ID1"] = a.ArtiId1; drd["DEPA_ID"] = a.DepartamentoId; dt.Rows.Add(drd); } } } else { e.Effect = DragDropEffects.None; e.InfoMessage = "Hay artículos repetidos"; } } else if (model is Almacen.odts.ArticuloModelo && targetModelo) { e.Effect = DragDropEffects.Copy; e.InfoMessage = "Añadir las determinaciones de un modelo a otro modelo"; } else if (model is Almacen.odts.ArticuloDeterminacion && targetModelo) { if (!EsArticuloDuplicado(((Almacen.odts.ArticuloDeterminacion)model).ArtiId1)) { // Añadir determinacion al acta Almacen.odts.ArticuloDeterminacion determinacion = (Almacen.odts.ArticuloDeterminacion)model; DataRow drModelo = ((DataRowView)e.DropTargetItem.RowObject).Row; int lineaModelo = (int)drModelo["PEDIDL_LINEA"]; DataTable dt = (DataTable)this.fdlvDetalle.DataSource; DataRow dr = dt.NewRow(); dr["DOCU_ID"] = this.Documento; dr["PEDID_ID"] = this.Numero; dr["ESTDOC_ID"] = "N"; dr["DOCU_ID_ORIGEN"] = DBNull.Value; dr["DOCU_NUMERO_ORIGEN"] = DBNull.Value; dr["DOCU_LINEA_ORIGEN"] = DBNull.Value; dr["PEDIDL_FLUJOC"] = "1"; dr["PEDIDL_FLUJOL"] = "1"; dr["PEDIDL_FECHAD_APLIC"] = string.Empty; dr["PEDIDL_FECHAH_APLIC"] = string.Empty; dr["LIDO_ID"] = "N+"; dr["PEDIDL_LINEA"] = lineaModelo; dr["PEDIDL_SUBLINEA"] = CalcularNuevaSublinea(lineaModelo); dr["PEDIDL_DESCRIPCION"] = determinacion.Descripcion; dr["PEDIDL_CANTIDAD"] = 1; dr["UNID_ID"] = "UN"; object[] precio = null; if (this.MediadorClieId == 0) precio = ctx.GetPrecioArticuloByCliente(determinacion.ArtiId1, this.ClienteId, this.Documento, usuario); else precio = ctx.GetPrecioArticuloByCliente(determinacion.ArtiId1, this.MediadorClieId, this.Documento, usuario); dr["PEDIDL_PRECIO"] = precio[0] != null ? precio[0] : 0; dr["GRDE_ID"] = precio[1] != null ? precio[1] : DBNull.Value; dr["COMP_ID"] = this._CompId; dr["ARTI_ID1"] = determinacion.ArtiId1; dr["DEPA_ID"] = determinacion.DepartamentoId; dt.Rows.Add(dr); List<odts.DetalleDeterminacion> asociados = GetAsociados(new List<odts.DetalleDeterminacion>(), determinacion.ArtiId1); foreach (odts.PresupuestoVentaDetalle a in asociados) { if (!EsArticuloDuplicado(a.ArtiId1)) { DataRow drd = dt.NewRow(); drd["DOCU_ID"] = this.Documento; drd["PEDID_ID"] = this.Numero; drd["ESTDOC_ID"] = "N"; drd["DOCU_ID_ORIGEN"] = DBNull.Value; drd["DOCU_NUMERO_ORIGEN"] = DBNull.Value; drd["DOCU_LINEA_ORIGEN"] = DBNull.Value; drd["PEDIDL_FLUJOC"] = "1"; drd["PEDIDL_FLUJOL"] = "1"; drd["PEDIDL_FECHAD_APLIC"] = string.Empty; drd["PEDIDL_FECHAH_APLIC"] = string.Empty; drd["LIDO_ID"] = "N+"; drd["PEDIDL_LINEA"] = lineaModelo; drd["PEDIDL_SUBLINEA"] = CalcularNuevaSublinea(lineaModelo); drd["PEDIDL_DESCRIPCION"] = a.DetalleDescripcion; drd["PEDIDL_CANTIDAD"] = 1; drd["UNID_ID"] = "UN"; object[] precio1 = null; if (this.MediadorClieId == 0) precio1 = ctx.GetPrecioArticuloByCliente(a.ArtiId1, this.ClienteId, this.Documento, usuario); else precio1 = ctx.GetPrecioArticuloByCliente(a.ArtiId1, this.MediadorClieId, this.Documento, usuario); drd["PEDIDL_PRECIO"] = precio1[0] != null ? precio1[0] : 0; drd["GRDE_ID"] = precio1[1] != null ? precio1[1] : DBNull.Value; drd["COMP_ID"] = this._CompId; drd["ARTI_ID1"] = a.ArtiId1; drd["DEPA_ID"] = a.DepartamentoId; dt.Rows.Add(drd); } } } else { e.Effect = DragDropEffects.None; e.InfoMessage = "Hay artículos repetidos"; } } else if (model is Almacen.odts.ArticuloDeterminacion && target != null && !targetModelo) { if (!EsArticuloDuplicado(((Almacen.odts.ArticuloDeterminacion)model).ArtiId1)) { // Añadir determinacion al acta Almacen.odts.ArticuloDeterminacion determinacion = (Almacen.odts.ArticuloDeterminacion)model; DataRow drModelo = ((DataRowView)e.DropTargetItem.RowObject).Row; int lineaModelo = (int)drModelo["PEDIDL_LINEA"]; DataTable dt = (DataTable)this.fdlvDetalle.DataSource; DataRow dr = dt.NewRow(); dr["DOCU_ID"] = this.Documento; dr["PEDID_ID"] = this.Numero; dr["ESTDOC_ID"] = "N"; dr["DOCU_ID_ORIGEN"] = DBNull.Value; dr["DOCU_NUMERO_ORIGEN"] = DBNull.Value; dr["DOCU_LINEA_ORIGEN"] = DBNull.Value; dr["PEDIDL_FLUJOC"] = "1"; dr["PEDIDL_FLUJOL"] = "1"; dr["PEDIDL_FECHAD_APLIC"] = string.Empty; dr["PEDIDL_FECHAH_APLIC"] = string.Empty; dr["LIDO_ID"] = "N+"; dr["PEDIDL_LINEA"] = lineaModelo; dr["PEDIDL_SUBLINEA"] = CalcularNuevaSublinea(lineaModelo); dr["PEDIDL_DESCRIPCION"] = determinacion.Descripcion; dr["PEDIDL_CANTIDAD"] = 1; dr["UNID_ID"] = "UN"; object[] precio = null; if (this.MediadorClieId == 0) precio = ctx.GetPrecioArticuloByCliente(determinacion.ArtiId1, this.ClienteId, this.Documento, usuario); else precio = ctx.GetPrecioArticuloByCliente(determinacion.ArtiId1, this.MediadorClieId, this.Documento, usuario); dr["PEDIDL_PRECIO"] = precio[0] != null ? precio[0] : 0; dr["GRDE_ID"] = precio[1] != null ? precio[1] : DBNull.Value; dr["COMP_ID"] = this._CompId; dr["ARTI_ID1"] = determinacion.ArtiId1; dr["DEPA_ID"] = determinacion.DepartamentoId; dt.Rows.Add(dr); List<odts.DetalleDeterminacion> asociados = GetAsociados(new List<odts.DetalleDeterminacion>(), determinacion.ArtiId1); foreach (odts.PresupuestoVentaDetalle a in asociados) { if (!EsArticuloDuplicado(a.ArtiId1)) { DataRow drd = dt.NewRow(); drd["DOCU_ID"] = this.Documento; drd["PEDID_ID"] = this.Numero; drd["ESTDOC_ID"] = "N"; drd["DOCU_ID_ORIGEN"] = DBNull.Value; drd["DOCU_NUMERO_ORIGEN"] = DBNull.Value; drd["DOCU_LINEA_ORIGEN"] = DBNull.Value; drd["PEDIDL_FLUJOC"] = "1"; drd["PEDIDL_FLUJOL"] = "1"; drd["PEDIDL_FECHAD_APLIC"] = string.Empty; drd["PEDIDL_FECHAH_APLIC"] = string.Empty; drd["LIDO_ID"] = "N+"; drd["PEDIDL_LINEA"] = lineaModelo; drd["PEDIDL_SUBLINEA"] = CalcularNuevaSublinea(lineaModelo); drd["PEDIDL_DESCRIPCION"] = a.DetalleDescripcion; drd["PEDIDL_CANTIDAD"] = 1; drd["UNID_ID"] = "UN"; object[] precio1 = null; if (this.MediadorClieId == 0) precio1 = ctx.GetPrecioArticuloByCliente(a.ArtiId1, this.ClienteId, this.Documento, usuario); else precio1 = ctx.GetPrecioArticuloByCliente(a.ArtiId1, this.MediadorClieId, this.Documento, usuario); drd["PEDIDL_PRECIO"] = precio1[0] != null ? precio1[0] : 0; drd["GRDE_ID"] = precio1[1] != null ? precio1[1] : DBNull.Value; drd["COMP_ID"] = this._CompId; drd["ARTI_ID1"] = a.ArtiId1; drd["DEPA_ID"] = a.DepartamentoId; dt.Rows.Add(drd); } } } else { e.Handled = false; } } // Intercambiar 2 determinaciones else if (model is DataRowView && target != null && !targetModelo) { DataRow destino = ((DataRowView)target.RowObject).Row; DataRow origen = ((DataRowView)model).Row; IntercambiaFilas(origen, destino); } else { e.Effect = DragDropEffects.None; e.InfoMessage = "Este movimiento no está permitido"; } } } }
/// <summary> /// /// </summary> /// <param name="args"></param> protected virtual void OnDropped(OlvDropEventArgs args) { if (this.Dropped != null) this.Dropped(this, args); }
protected override void OnCanDrop(OlvDropEventArgs args) { base.OnCanDrop(args); _form.HostCanDrop(args); }
void dropSink_Dropped(object sender, OlvDropEventArgs e) { this.OnDropped(e); }
protected override void OnDropped(OlvDropEventArgs args) { DropTargetHelper.Drop(args.DataObject as DataObject, new Point(args.MouseLocation.X, args.MouseLocation.Y), DragDropEffects.None); _form.HostDropped(args); }