Esempio n. 1
0
        //------------------------------------------------------
        /// <summary>
        /// Ajoute un predecesseur et crée le lien projet
        /// </summary>
        /// <param name="element"></param>
        public CResultAErreur AddPredecesseur(IElementDeGantt element)
        {
            CResultAErreur result = CResultAErreur.True;

            if (!m_listePredecesseurs.Contains(element))
            {
                CElementDeGanttProjet eltThis         = this as CElementDeGanttProjet;
                CElementDeGanttProjet eltPredecesseur = element as CElementDeGanttProjet;
                if (eltThis != null && eltPredecesseur != null)
                {
                    CLienDeProjet lien = eltThis.ProjetAssocie.AddPredecessor(eltPredecesseur.ProjetAssocie);
                    if (lien != null)
                    {
                        m_listePredecesseurs.Add(eltPredecesseur);
                    }

                    /*new CLienDeProjet(eltThis.ProjetAssocie.ContexteDonnee);
                     * lien.CreateNewInCurrentContexte();
                     * lien.ProjetA = eltPredecesseur.ProjetAssocie;
                     * lien.ProjetB = eltThis.ProjetAssocie;
                     * result = lien.ControleCoherenceLien();
                     * if (!result)
                     * lien.CancelCreate();
                     * else
                     * m_listePredecesseurs.Add(element);
                     * eltPredecesseur.ProjetAssocie.OptimizeDates(eltPredecesseur.ProjetAssocie.DateDebutGantt);*/
                }
            }
            return(result);
        }
Esempio n. 2
0
        public static CParametreTriGantt GetParametreTriGantt(IElementDeGantt eltGantt)
        {
            if (eltGantt == null)
            {
                return(null);
            }
            string strCle = "Gantt sort";

            strCle += "-" + eltGantt.GanttBarId;
            string strSer = new CTimosAppRegistre().GetValue("preferences\\Gantt", strCle, "");

            if (strSer != "")
            {
                CStringSerializer  serializer = new CStringSerializer(strSer, ModeSerialisation.Lecture);
                CParametreTriGantt tri        = null;
                try
                {
                    if (serializer.TraiteObject <CParametreTriGantt>(ref tri))
                    {
                        return(tri);
                    }
                }
                catch { }
            }
            return(null);
        }
Esempio n. 3
0
        private void FillChilds(TreeNode node, CParametreTriGantt parametreTri)
        {
            m_bIsFilling = true;
            node.Nodes.Clear();
            IElementDeGantt eltParent = node.Tag as IElementDeGantt;

            if (parametreTri == null)
            {
                parametreTri = CTimosAppRegistre.GetParametreTriGantt(eltParent);
            }
            eltParent.SortChilds(parametreTri);
            List <TreeNode> lstToAdd = new List <TreeNode>();

            foreach (IElementDeGantt elt in eltParent.ElementsFils)
            {
                TreeNode nodeFils = CreateNode(elt);
                lstToAdd.Add(nodeFils);
                if (elt is CElementDeGanttProjet && ((CElementDeGanttProjet)elt).ProjetAssocie.TypeProjet.DefaultExpand)
                {
                    nodeFils.Expand();
                }
            }
            node.Nodes.AddRange(lstToAdd.ToArray());
            m_bIsFilling = false;
        }
 //-----------------------------------------------
 public CElementDeGanttMetaProjet(IElementDeGantt elementParent, CMetaProjet metaProjet)
     : base(elementParent)
 {
     m_metaProjet  = metaProjet;
     PctAvancement = metaProjet.PctAvancement;
     Poids         = 1;
 }
Esempio n. 5
0
        //------------------------------------------------------
        public void AddPredecesseurSansCreation(IElementDeGantt element)
        {
            m_listePredecesseurs.Add(element);

            /*if ( !m_listePredecesseurs.Contains ( element ))
             *  m_listePredecesseurs.Add(element);*/
        }
Esempio n. 6
0
 /// <summary>
 /// Retourne les limites X d'un élément de gantt
 /// </summary>
 /// <param name="element"></param>
 /// <returns></returns>
 public int[] GetXBounds(IElementDeGantt element)
 {
     return(new int[] {
         GetX(element.DateDebut),
         GetX(element.DateFin)
     });
 }
Esempio n. 7
0
 // Remonte l'événement du CGanttBar
 private void m_zoneBarres_OnMoveElementDeGantt(IElementDeGantt element)
 {
     if (OnMoveElementDeGantt != null)
     {
         OnMoveElementDeGantt(element);
     }
 }
Esempio n. 8
0
        public void Init(IBaseGantt baseGantt)
        {
            IElementDeGantt eltSel = SelectedElement;

            m_base = baseGantt;
            IElementAUniteGanttParDefaut eltAUniteDefaut = GetElementUniteDefault();

            if (eltAUniteDefaut != null)
            {
                Parametre.Unit          = eltAUniteDefaut.UniteParDefaut;
                Parametre.PrecisionUnit = eltAUniteDefaut.PrecisionParDefault;
            }


            m_zoneTemps.AllowChangeDefaultUnit =
                eltAUniteDefaut != null &&
                !m_extModeEdition.ModeEdition &&
                CUtilUtilisateur.UtilisateurConnecteIsAdministrateur(CSc2iWin32DataClient.ContexteCourant);



            m_arbre.Init(m_base, Parametre.DateDebut, Parametre.CalcDateFin(m_panelTimeEtBarres.ClientSize.Width));
            m_zoneTemps.ParametreAffichage = Parametre;
            m_zoneBarres.Init(Parametre, m_base, m_zoneTemps, m_arbre);
            SelectedElement = eltSel;
        }
Esempio n. 9
0
 // Remonte l'événement pour controls parents
 private void m_gantt_OnMoveElementDeGantt(IElementDeGantt element)
 {
     if (OnMoveElementDeGantt != null)
     {
         OnMoveElementDeGantt(element);
     }
 }
Esempio n. 10
0
 //----------------------------------------------------
 public CIconeGantt GetIcone(IElementDeGantt element)
 {
     if (m_formuleCondition != null && Image != null)
     {
         CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(element);
         CResultAErreur result             = m_formuleCondition.Eval(ctx);
         if (result)
         {
             if (result.Data is bool && (bool)result.Data)
             {
                 string strTooltip = "";
                 if (Tooltip != null)
                 {
                     result = Tooltip.Eval(ctx);
                     if (result)
                     {
                         strTooltip = result.Data.ToString();
                     }
                 }
                 return(new CIconeGantt(Image, strTooltip));
             }
         }
     }
     return(null);
 }
Esempio n. 11
0
 //------------------------------------------------------
 public bool RespectePredecesseur(IElementDeGantt predecesseur)
 {
     if (DateDebut < predecesseur.DateFin)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 12
0
 public CGanttElementEventArgs(IElementDeGantt elementGantt,
                               Point mouseScreenPos,
                               MouseButtons buttons)
 {
     ElementGantt   = elementGantt;
     MouseScreenPos = mouseScreenPos;
     MouseButtons   = buttons;
 }
Esempio n. 13
0
 //----------------------------------------------------------------
 private void CGanttBar_MouseMove(object sender, MouseEventArgs e)
 {
     if (!m_bDragEnCours)
     {
         IElementDeGantt elt = GetElementAt(new Point(e.X, e.Y));
         if (elt != null && !LockEdition)
         {
             if (elt.MoveAutorise)
             {
                 Cursor = Cursors.NoMoveHoriz;
             }
             else
             {
                 Cursor = Cursors.No;
             }
         }
         else
         {
             Point pt = new Point(e.X, e.Y);
             KeyValuePair <IElementDeGantt, Rectangle>?kv = m_dicElementGanttToRectangleAccesDirect.FirstOrDefault
                                                            (
                 k => k.Value.Contains(pt)
                                                            );
             if (kv != null && kv.Value.Key != null)
             {
                 Cursor = Cursors.Hand;
             }
             else
             {
                 if (ModifierKeys == Keys.Control && !LockEdition)
                 {
                     Cursor = (Cursor) new Cursor(new MemoryStream(Resources.CurseurLienProjet));
                 }
                 else
                 {
                     Cursor = Cursors.Arrow;
                 }
             }
         }
         if (!LockEdition && Math.Abs(e.X - m_nXStartDrag) > 3 && MouseButtons == MouseButtons.Left)
         {
             elt = GetElementAt(new Point(m_nXStartDrag, m_nYStartDrag));
             if (elt != null && elt.MoveAutorise)
             {
                 m_bDragEnCours  = true;
                 SelectedElement = elt;
                 CalculImageDragDrop();
                 Capture = true;
             }
         }
     }
     if (m_bDragEnCours && MouseButtons == MouseButtons.Left)
     {
         DrawImageDragDrop();
         DrawRectDragDrop(e.X);
     }
 }
Esempio n. 14
0
 private void FillNode(TreeNode node, IElementDeGantt elt)
 {
     try
     {
         node.Text = elt.Libelle;
         node.Tag  = elt;
     }
     catch { }
 }
Esempio n. 15
0
 //-----------------------------------------------
 public CElementDeGanttProjet(IElementDeGantt elementParent, CProjet projet)
     : base(elementParent)
 {
     m_projet = projet;
     if (projet.TypeProjet != null)
     {
         Image = projet.TypeProjet.Image;
     }
     SetPctAvancementSansCalculDeParent(projet.PctAvancement);
     SetPoidSansCalculDeParent(Poids = projet.Poids);
 }
Esempio n. 16
0
 public void RefreshNode(IElementDeGantt elt)
 {
     if (elt != null)
     {
         TreeNode node = null;
         if (m_dicNodes.TryGetValue(elt, out node))
         {
             FillNode(node, elt);
         }
     }
 }
Esempio n. 17
0
 //-------------------------------------------------------
 public string GetTexte(IElementDeGantt element)
 {
     if (FormuleTexte != null)
     {
         CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(element);
         CResultAErreur result             = FormuleTexte.Eval(ctx);
         if (result)
         {
             return(result.Data.ToString());
         }
     }
     return(null);
 }
Esempio n. 18
0
 //----------------------------------------------------------------------------------
 public DateTime?GetDateFromExpression(IElementDeGantt element, C2iExpression formule)
 {
     if (formule != null)
     {
         CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(element);
         CResultAErreur result             = formule.Eval(ctx);
         if (result && result.Data is DateTime)
         {
             return((DateTime)result.Data);
         }
     }
     return(null);
 }
Esempio n. 19
0
        //------------------------------------------------------------------------
        private void RenumerotteElements(TreeNodeCollection nodes)
        {
            int nIndex = 0;

            foreach (TreeNode node in nodes)
            {
                IElementDeGantt elt = node.Tag as IElementDeGantt;
                if (elt.CanBeSortedInParent)
                {
                    elt.IndexTri = nIndex++;
                }
            }
        }
Esempio n. 20
0
            //-------------------------------------------------------
            public CIconeGantt[] GetIcones(IElementDeGantt element)
            {
                List <CIconeGantt> lst = new List <CIconeGantt>();

                foreach (IParametreIconeGantt parametre in ParametresIcones)
                {
                    CIconeGantt icone = parametre.GetIcone(element);
                    if (icone != null)
                    {
                        lst.Add(icone);
                    }
                }
                return(lst.ToArray());
            }
Esempio n. 21
0
            public Color?GetCouleurTerminee(IElementDeGantt element)
            {
                if (m_couleurTermineeAsConstante != null)
                {
                    return(m_couleurTermineeAsConstante);
                }

                bool  bIsConstante = false;
                Color?c            = GetCouleur(element, FormuleCouleurTerminee, ref bIsConstante);;

                if (bIsConstante)
                {
                    m_couleurTermineeAsConstante = c;
                }
                return(c);
            }
Esempio n. 22
0
        private TreeNode CreateNode(IElementDeGantt elt)
        {
            TreeNode node = new TreeNode();

            FillNode(node, elt);
            m_dicNodes[elt] = node;
            foreach (IElementDeGantt eltDraw in elt.ElementsADessinerSurLaLigne)
            {
                m_dicNodes[eltDraw] = node;
            }
            if (elt.ElementsFils.Count() != 0)
            {
                node.Nodes.Add(new TreeNode());
            }
            return(node);
        }
Esempio n. 23
0
        protected void Refresh(IElementDeGantt elt)
        {
            if (m_fournisseurY == null)
            {
                return;
            }
            int[] ys = m_fournisseurY.GetYBounds(elt);
            if (ys == null)
            {
                return;
            }
            Rectangle rct = new Rectangle(0, ys[0], ClientSize.Width,
                                          ys[1] - ys[0]);

            Invalidate(rct);
        }
Esempio n. 24
0
        private TreeNode CreateNodeAndHierarchie(IElementDeGantt eltGantt)
        {
            TreeNode nodeParent = null;

            if (eltGantt.ElementParent != null)
            {
                nodeParent = CreateNodeAndHierarchie(eltGantt.ElementParent);
            }
            if (nodeParent != null && !nodeParent.IsExpanded)
            {
                nodeParent.Expand();
            }
            TreeNode node = null;

            m_dicNodes.TryGetValue(eltGantt, out node);
            return(node);
        }
Esempio n. 25
0
 void m_menuSortBy_Click(object sender, EventArgs e)
 {
     if (m_treeNodeMenuContextuel != null)
     {
         CParametreTriGantt parametre = CTimosAppRegistre.GetParametreTriGantt(m_treeNodeMenuContextuel.Tag as IElementDeGantt);
         if (CFormTriGantt.GetParametre(ref parametre))
         {
             IElementDeGantt elt = m_treeNodeMenuContextuel.Tag as IElementDeGantt;
             CTimosAppRegistre.SetParametreTriGantt(elt, parametre);
             FillChilds(m_treeNodeMenuContextuel, parametre);
             if (OnChangePosition != null)
             {
                 OnChangePosition(this, null);
             }
         }
     }
 }
 //-----------------------------------------------------------------
 public CIconeGantt GetIcone(IElementDeGantt element)
 {
     if (element.EstTermine)
     {
         string strTooltip = "";
         if (Tooltip != null)
         {
             CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(element);
             CResultAErreur result             = Tooltip.Eval(ctx);
             if (result)
             {
                 strTooltip = result.Data.ToString();
             }
         }
         return(new CIconeGantt(Image, strTooltip));
     }
     return(null);
 }
Esempio n. 27
0
        public int[] GetYBounds(IElementDeGantt element)
        {
            TreeNode node = null;

            if (!m_dicNodes.TryGetValue(element, out node))
            {
                return(null);
            }
            Rectangle rct = node.Bounds;

            if (rct.Height == 0)
            {
                return(null);
            }
            return(new int[] {
                rct.Top, rct.Bottom
            });
        }
Esempio n. 28
0
        private void CGanttTree_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            if (m_bIsFilling)
            {
                return;
            }
            Pen   pen  = new Pen(ForeColor);
            Color back = BackColor;

            if (e.Node == SelectedNode)
            {
                back = SelectedBackColor;
            }
            Brush br = new SolidBrush(back);

            e.Graphics.FillRectangle(br, new Rectangle(e.Bounds.Left, e.Bounds.Top, ClientSize.Width, ItemHeight));
            br.Dispose();
            e.Graphics.DrawLine(pen, 0, e.Bounds.Top, ClientSize.Width, e.Bounds.Top);
            e.Graphics.DrawLine(pen, 0, e.Bounds.Bottom, ClientSize.Width, e.Bounds.Bottom);
            pen.Dispose();
            if (e.Node == SelectedNode)
            {
                e.Node.BackColor = SelectedBackColor;
                e.Node.ForeColor = SelectedForeColor;
            }
            else
            {
                e.Node.BackColor = Color.Transparent;
                e.Node.ForeColor = ForeColor;
            }
            br = new SolidBrush(e.Node.ForeColor);
            IElementDeGantt elt      = e.Node.Tag as IElementDeGantt;
            int             nOffestX = 0;

            if (elt != null && elt.Image != null)
            {
                e.Graphics.DrawImageUnscaled(elt.Image, e.Bounds.Left, e.Bounds.Top + e.Bounds.Height / 2 - elt.Image.Height / 2);
                nOffestX += elt.Image.Width;
            }
            SizeF rctText = e.Graphics.MeasureString(e.Node.Text, Font);

            e.Graphics.DrawString(e.Node.Text, Font, br, e.Bounds.Left + nOffestX, e.Bounds.Top + e.Bounds.Height / 2 - ((int)rctText.Height / 2));
            br.Dispose();
        }
Esempio n. 29
0
 //------------------------------------------------------------------------
 private void CGanttTree_DragDrop(object sender, DragEventArgs e)
 {
     UndrawZoneDestDragDrop();
     if (e.Data.GetDataPresent(typeof(TreeNode)) && !LockEdition)
     {
         TreeNode nodeMoved = e.Data.GetData(typeof(TreeNode)) as TreeNode;
         Point    pt        = PointToClient(new Point(e.X, e.Y));
         TreeNode nodeDest  = null;
         bool     bAfter    = false;
         GetDestDragDrop(nodeMoved, pt, ref nodeDest, ref bAfter);
         if (nodeDest != null)
         {
             TreeNodeCollection nodes = nodeDest.Parent != null ? nodeDest.Parent.Nodes : Nodes;
             int nIndexMoved          = nodes.IndexOf(nodeMoved);
             nodes.Remove(nodeMoved);
             int nIndexDest = nodes.IndexOf(nodeDest) + (bAfter ? 1 : 0);
             if (nIndexDest != nIndexMoved)
             {
                 if (nIndexDest >= nodes.Count)
                 {
                     nodes.Add(nodeMoved);
                 }
                 else
                 {
                     nodes.Insert(nIndexDest, nodeMoved);
                 }
                 RenumerotteElements(nodes);
                 SelectedNode = nodeMoved;
                 if (OnChangePosition != null)
                 {
                     OnChangePosition(this, null);
                 }
                 IElementDeGantt parent = nodeMoved.Tag as IElementDeGantt;
                 if (parent != null)
                 {
                     parent = parent.ElementParent;
                 }
                 CTimosAppRegistre.SetParametreTriGantt(parent, null);
             }
         }
     }
 }
Esempio n. 30
0
        public static void SetParametreTriGantt(IElementDeGantt eltGantt, CParametreTriGantt parametre)
        {
            if (eltGantt == null)
            {
                return;
            }
            string strCle = "Gantt sort";

            strCle += "-" + eltGantt.GanttBarId;
            string strSer = "";

            if (parametre != null)
            {
                CStringSerializer serializer = new CStringSerializer(ModeSerialisation.Ecriture);
                if (serializer.TraiteObject <CParametreTriGantt>(ref parametre))
                {
                    strSer = serializer.String;
                }
            }
            new CTimosAppRegistre().SetValue("preferences\\Gantt", strCle, strSer);
        }