//--------------------------------------------------------------------------
 private void m_lnkDeleteModeleAffectation_LinkClicked(object sender, EventArgs e)
 {
     if (m_wndListeAffectations.SelectedItems.Count == 1)
     {
         ListViewItem item = m_wndListeAffectations.SelectedItems[0];
         CModeleAffectationUtilisateurs modele = item.Tag as CModeleAffectationUtilisateurs;
         if (modele != null)
         {
             if (MessageBox.Show(I.T("Delete assignment template @1 ?|20083", modele.Libelle),
                                 "",
                                 MessageBoxButtons.YesNo,
                                 MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 CResultAErreur result = modele.Delete();
                 if (!result)
                 {
                     CFormAlerte.Afficher(result.Erreur);
                 }
                 else
                 {
                     m_wndListeAffectations.Items.Remove(item);
                 }
             }
         }
     }
 }
        /// //////////////////////////////////////////////////
        public override CResultAErreur VerifieDonnees(sc2i.data.CObjetDonnee objet)
        {
            CResultAErreur result = CResultAErreur.True;
            CModeleAffectationUtilisateurs modeleAffectationUtilisateurs = objet as CModeleAffectationUtilisateurs;

            if (modeleAffectationUtilisateurs != null)
            {
                if (modeleAffectationUtilisateurs.Libelle.Length == 0)
                {
                    result.EmpileErreur(I.T("Assignment template must have a label|20010"));
                }
            }
            return(result);
        }
        public static bool EditeModele(CModeleAffectationUtilisateurs modele)
        {
            CFormEditeModeleAffectationPopup form = new CFormEditeModeleAffectationPopup();

            if (!modele.IsNew())
            {
                modele.BeginEdit();
            }
            form.m_modele = modele;
            bool bResult = form.ShowDialog() == DialogResult.OK;

            form.Dispose();
            return(bResult);
        }
        private void m_wndListeAffectations_ItemDrag(object sender, ItemDragEventArgs e)
        {
            ListViewItem item = e.Item as ListViewItem;

            if (item == null)
            {
                return;
            }
            CModeleAffectationUtilisateurs modele = item.Tag as CModeleAffectationUtilisateurs;

            if (modele != null)
            {
                DoDragDrop(new CReferenceObjetDonneeDragDropData(modele), DragDropEffects.Link);
            }
        }
 //--------------------------------------------------------------------------
 private void m_lnkEditModeleAffectation_LinkClicked(object sender, EventArgs e)
 {
     if (m_wndListeAffectations.SelectedItems.Count == 1)
     {
         ListViewItem item = m_wndListeAffectations.SelectedItems[0];
         CModeleAffectationUtilisateurs modele = item.Tag as CModeleAffectationUtilisateurs;
         if (modele != null)
         {
             if (CFormEditeModeleAffectationPopup.EditeModele(modele))
             {
                 FillItemModeleAffectation(item, modele);
             }
         }
     }
 }
        //--------------------------------------------------------------------------
        private void m_lnkAddModeleAffectation_LinkClicked(object sender, EventArgs e)
        {
            CModeleAffectationUtilisateurs modele = new CModeleAffectationUtilisateurs(CSc2iWin32DataClient.ContexteCourant);

            modele.CreateNew();
            modele.Libelle = m_txtFiltreAffectations.Text;
            if (CFormEditeModeleAffectationPopup.EditeModele(modele))
            {
                ListViewItem item = new ListViewItem();
                FillItemModeleAffectation(item, modele);
                m_wndListeAffectations.Items.Add(item);
                item.Selected = true;
                m_wndListeAffectations.EnsureVisible(item.Index);
            }
        }
示例#7
0
        /// //////////////////////////////////////////////////
        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);
        }
 //--------------------------------------------------------------------------
 private void FillItemModeleAffectation(ListViewItem item, CModeleAffectationUtilisateurs modele)
 {
     item.Text       = modele.Libelle;
     item.Tag        = modele;
     item.ImageIndex = 0;
 }