//-----------------------------------------------
        private void ShowMenuUnites()
        {
            CValeurUnite v = m_txtQuantité.UnitValue;

            if (v != null)
            {
                IUnite u = v.IUnite;
                if (u != null)
                {
                    List <IUnite> lst = new List <IUnite>(CGestionnaireUnites.GetUnites(u.Classe));
                    lst.Sort((x, y) => x.FacteurVersBase.CompareTo(y.FacteurVersBase));
                    m_menuUnites.Items.Clear();
                    foreach (IUnite unite in lst)
                    {
                        ToolStripMenuItem itemUnite = new ToolStripMenuItem(unite.LibelleCourt);
                        itemUnite.Tag = unite;
                        m_menuUnites.Items.Add(itemUnite);
                        if (unite.LibelleCourt == m_lblUniteCU.Text)
                        {
                            itemUnite.Checked = true;
                        }
                        itemUnite.Click += new EventHandler(itemUnite_Click);
                    }
                    m_menuUnites.Show(m_lblUniteCU, new Point(0, m_lblUniteCU.Height));
                }
            }
        }
Example #2
0
        //---------------------------------------------------------------------------
        private void m_menu_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            m_menuCouper.Enabled    = SelectionLength > 0;
            m_menuCopier.Enabled    = SelectionLength > 0;
            m_menuColler.Enabled    = Clipboard.GetData(DataFormats.Text) != null;
            m_menuSupprimer.Enabled = SelectionLength > 0;
            m_menuSelectAll.Enabled = Text.Length > 0;
            foreach (IDisposable dis in new ArrayList(m_menuConvertir.DropDownItems))
            {
                dis.Dispose();
            }
            m_menuConvertir.DropDownItems.Clear();
            IClasseUnite classe = null;

            if (UniteRacine != null)
            {
                classe = UniteRacine.Classe;
            }
            else
            {
                CValeurUnite v = this.UnitValue;
                if (v != null && v.Unite != null)
                {
                    IUnite uTmp = CGestionnaireUnites.GetUnite(v.Unite);
                    if (uTmp != null)
                    {
                        classe = uTmp.Classe;
                    }
                }
            }

            m_menuConvertir.Enabled = classe != null;


            if (classe != null && UnitValue != null)
            {
                foreach (IUnite unite in CGestionnaireUnites.GetUnites(classe))
                {
                    ToolStripMenuItem itemUnite = new ToolStripMenuItem(unite.LibelleLong);
                    itemUnite.Tag    = unite;
                    itemUnite.Click += new EventHandler(itemUnite_Click);
                    m_menuConvertir.DropDownItems.Add(itemUnite);
                }
                ToolStripTextBox box = new ToolStripTextBox();
                m_menuConvertir.DropDownItems.Add(box);
                box.KeyDown += new KeyEventHandler(formatBox_KeyDown);
            }
        }
Example #3
0
 private void C2iTextBoxNumeriqueAvecUnite_Validated(object sender, EventArgs e)
 {
     if (Text.Trim().Length > 0 && UnitValue == null)
     {
         IUnite        unite    = UniteRacine;
         StringBuilder blUnites = new StringBuilder();
         if (unite != null)
         {
             foreach (IUnite u in CGestionnaireUnites.GetUnites(unite.Classe))
             {
                 blUnites.Append(u.LibelleCourt);
                 blUnites.Append(" ");
             }
         }
         else
         {
             foreach (IClasseUnite classe in CGestionnaireUnites.Classes)
             {
                 IEnumerable <IUnite> lstUnites = CGestionnaireUnites.GetUnites(classe);
                 if (lstUnites.Count() > 0)
                 {
                     blUnites.Append(Environment.NewLine);
                     blUnites.Append(classe.Libelle + " : ");
                     foreach (IUnite u in lstUnites)
                     {
                         blUnites.Append(u.LibelleCourt);
                         blUnites.Append(',');
                     }
                     blUnites.Remove(blUnites.Length - 1, 1);
                 }
             }
         }
         m_error.SetError(this, I.T("Enter value using units @1|20014", blUnites.ToString()));
     }
     else
     {
         m_error.SetError(this, "");
         CValeurUnite valeur = UnitValue;
         if (valeur != null)
         {
             UnitValue = valeur;
         }
     }
 }