//------------------------------------------------- private void m_wndListeUndrawn_ItemDrag(object sender, ItemDragEventArgs e) { ListViewItem item = e.Item as ListViewItem; if (item == null) { return; } CTypeEtapeWorkflow typeEtape = item.Tag as CTypeEtapeWorkflow; if (typeEtape != null) { CDummyObjetWorkflowPourCreation dummy = new CDummyObjetWorkflowPourCreation(typeEtape); CDonneeDragDropObjetGraphique donnee = new CDonneeDragDropObjetGraphique(Name, dummy); DoDragDrop(donnee, DragDropEffects.Copy); InitListeUndrawns(); } }
/// ////////////////////////////////////////////////// protected override void Editeur_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { if (ObjetEdite == null) { return; } if (LockEdition) { return; } if (e.Data.GetDataPresent(typeof(CReferenceObjetDonnee))) { CReferenceObjetDonnee reference = e.Data.GetData(typeof(CReferenceObjetDonnee)) as CReferenceObjetDonnee; if (reference.TypeObjet == typeof(CModeleAffectationUtilisateurs)) { Point pt = PointToClient(new Point(e.X, e.Y)); Point ptLogique = GetLogicalPointFromDisplay(pt); CWorkflowEtapeDessin dessinEtape = ObjetEdite.SelectionnerElementDuDessus(ptLogique) as CWorkflowEtapeDessin; if (dessinEtape != null) { CModeleAffectationUtilisateurs modele = reference.GetObjet(CSc2iWin32DataClient.ContexteCourant) as CModeleAffectationUtilisateurs; if (modele != null) { CParametresAffectationEtape parametres = modele.ParametresAffectation; if (parametres != null) { CParametresInitialisationEtape parametre = dessinEtape.Initializations; CParametresAffectationEtape parAff = parametre.Affectations; if (parAff != null) { if (MessageBox.Show(I.T("Replace current assignments(Yes) or add new assignemnts(No) ?|20135"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { parAff = new CParametresAffectationEtape(); } parAff.AddFormules(parametres.Formules); parametre.Affectations = parAff; dessinEtape.Initializations = parametre; e.Effect = DragDropEffects.Link; Refresh(); return; } } } } } } List <CDonneeDragDropObjetGraphique> datas = GetDragDropData(e.Data); if (datas == null || datas.Count == 0) { return; } List <I2iObjetGraphique> candidats = new List <I2iObjetGraphique>(); foreach (CRectangleDragForObjetGraphique rct in RectsDrags) { candidats.Add(rct.ObjetGraphique); } Point ptLocal = GetLogicalPointFromDisplay(PointToClient(new Point(e.X, e.Y))); I2iObjetGraphique parent = ObjetEdite.SelectionnerElementConteneurDuDessus(ptLocal, candidats); parent = DessinWorkflow;; if (parent == null) { e.Effect = DragDropEffects.None; } else { List <I2iObjetGraphique> nouveaux = new List <I2iObjetGraphique>(); foreach (CRectangleDragForObjetGraphique rct in RectsDrags) { rct.RectangleDrag = rct.Datas.GetDragDropPosition(ptLocal); rct.RectangleDrag = GetRectangleSelonModesActives(rct.RectangleDrag, ptLocal); // rct.RectangleDrag.Offset((int)(AutoScrollPosition.X / Echelle), (int)(AutoScrollPosition.Y / Echelle)); //Si dummy de création (type de bloc), création d'une nouvelle étape I2iObjetGraphique objetGraphique = rct.Datas.ObjetDragDrop; CDummyObjetWorkflowPourCreation dummyCreation = objetGraphique as CDummyObjetWorkflowPourCreation; if (dummyCreation != null) { CTypeEtapeWorkflow typeEtape = dummyCreation.TypeEtape; if (typeEtape == null) { typeEtape = new CTypeEtapeWorkflow(DessinWorkflow.TypeWorkflow.ContexteDonnee); typeEtape.CreateNewInCurrentContexte(); typeEtape.Workflow = DessinWorkflow.TypeWorkflow; typeEtape.Bloc = Activator.CreateInstance(dummyCreation.TypeBloc, new object[] { typeEtape }) as CBlocWorkflow; } CWorkflowEtapeDessin graphEtape = new CWorkflowEtapeDessin(); graphEtape.TypeEtape = typeEtape; objetGraphique = graphEtape; objetGraphique.Size = dummyCreation.Size; } JusteBeforePositionneSurApresDragDrop(objetGraphique); bool bParentIsInSelec = objetGraphique.Parent != null && candidats.Contains(objetGraphique.Parent); bool bHasMove = false; if (e.Effect == DragDropEffects.Copy) { Dictionary <Type, object> dicObjetsPourCloner = new Dictionary <Type, object>(); AddObjectsForClonerSerializer(dicObjetsPourCloner); objetGraphique = (I2iObjetGraphique)objetGraphique.GetCloneAMettreDansParent(parent, dicObjetsPourCloner); if (objetGraphique == null || !parent.AddChild(objetGraphique)) { e.Effect = DragDropEffects.None; objetGraphique.CancelClone(); continue; } else { objetGraphique.Parent = parent; nouveaux.Add(objetGraphique); } bHasMove = true; } else { bHasMove = true; if (objetGraphique.Parent != parent) { if (objetGraphique.Parent != null) { if (!bParentIsInSelec) { objetGraphique.Parent.RemoveChild(objetGraphique); } } else { nouveaux.Add(objetGraphique); } if (!bParentIsInSelec) { if (!parent.AddChild(objetGraphique)) { e.Effect = DragDropEffects.None; continue; } else { objetGraphique.Parent = parent; } } } } if (!bParentIsInSelec && bHasMove) { Point ptDrop = new Point(rct.RectangleDrag.Left, rct.RectangleDrag.Top); objetGraphique.PositionAbsolue = ptDrop; } } if (nouveaux.Count > 0) { RefreshSelectionChanged = false; Selection.Clear(); Selection.AddRange(nouveaux); RefreshSelectionChanged = true; DeclencheAfterAddElements(nouveaux); Refresh(); } } ElementModifie(); EnDeplacement = false; Dessiner(true, true); }