Example #1
0
        /// <summary>
        /// Procédure déclenchée en fin d'un drag and drop
        /// </summary>
        private void lstAction_DragDrop(object sender, DragEventArgs e)
        {
            // Get the tree.
            TreeView tree = (TreeView)sender;

            // Get the screen point.
            System.Drawing.Point pt = new System.Drawing.Point(e.X, e.Y);

            // Convert to a point in the TreeView's coordinate system.
            pt = tree.PointToClient(pt);

            // Get the node underneath the mouse.
            TreeNode NodDest = tree.GetNodeAt(pt);
            TreeNode nodSrc  = (TreeNode)e.Data.GetData(typeof(TreeNode));

            if (NodDest == nodSrc)
            {
                return;
            }                                 //Système anti-bouclage

            //Prise en compte du changement en base
            //Recherche d'un lien du NodSrc
            if (!(nodSrc.Tag is null))
            {
                Acces.Supprimer_Lien((Lien)nodSrc.Tag); Console.Ajouter("Suppression du lien");
            }
        private void lstObjectif_DragDrop(object sender, DragEventArgs e)
        {
            // Get the tree.
            TreeView tree = (TreeView)sender;

            // Get the screen point.
            System.Drawing.Point pt = new System.Drawing.Point(e.X, e.Y);

            // Convert to a point in the TreeView's coordinate system.
            pt = tree.PointToClient(pt);

            // Get the node underneath the mouse.
            TreeNode NodDest = tree.GetNodeAt(pt);

            TreeNode nodSrc = (TreeNode)e.Data.GetData(typeof(TreeNode));

            if (NodDest == nodSrc)
            {
                return;
            }                                 //Système anti-bouclage

            //Prise en compte du changement en base
            //Recherche d'un lien du NodSrc
            if (!(nodSrc.Tag is null))
            {
                Lien k = Acces.Donner_LienParent(((Lien)nodSrc.Tag).ID);
                Acces.Supprimer_Lien(k);
            }

            //Création du lien
            Lien p = new Lien()
            {
                Acces = Acces
            };

            p.Element1_Type = Acces.type_OBJECTIF.ID;
            p.Element1_ID   = int.Parse(NodDest.Name);
            p.Element1_Code = ((Objectif)Acces.Trouver_Element(Acces.type_OBJECTIF, p.Element1_ID)).Code;
            p.Element2_Type = Acces.type_OBJECTIF.ID;
            p.Element2_ID   = int.Parse(nodSrc.Name);
            p.Element2_Code = ((Objectif)Acces.Trouver_Element(Acces.type_OBJECTIF, p.Element2_ID)).Code;
            p.Element0_Type = Acces.type_PLAN.ID; //SYSTEME
            p.Element0_ID   = 1;                  //SYSTEME
            p.Element0_Code = "SYSTEME";          //SYSTEME
            p.ordre         = p.Donner_Ordre() + 1;

            p.Ajouter();
            Acces.Ajouter_Lien(p);

            TreeNode nd = new TreeNode();

            nd = (TreeNode)nodSrc.Clone();
            NodDest.Nodes.Add(nd);
            lstObjectif.SelectedNode = nd;

            TreeNode[] Nods = lstObjectif.Nodes.Find(nodSrc.Name.ToString(), true);

            try { Nods[0].Remove(); } catch { }
        }