private void CExplorateurObjets_DrawNode(object sender, DrawTreeNodeEventArgs e) { Rectangle rctTotal = Rectangle.Intersect(ClientRectangle, new Rectangle(e.Bounds.Left, e.Bounds.Top, Size.Width, e.Bounds.Height)); Rectangle rctText = new Rectangle(rctTotal.Left, rctTotal.Top, m_nFieldSize, rctTotal.Height); e.Graphics.DrawString(e.Node.Text, Font, Brushes.Black, rctText); CTreeViewData data = e.Node.Tag as CTreeViewData; if (data != null) { if (data.Valeur != null) { object val = data.Valeur; if (e.Node.Nodes.Count > 0)//complexe { val = DescriptionFieldAttribute.GetDescription(val); } Rectangle rct = new Rectangle(rctText.Right, rctText.Top, rctTotal.Width - rctText.Width, rctTotal.Height); StringFormat format = new StringFormat(); e.Graphics.DrawString(val.ToString(), Font, Brushes.Black, rct, format); format.Dispose(); } } e.Graphics.DrawLine(Pens.LightGray, 0, rctTotal.Top, Size.Width, rctTotal.Top); }
//--------------------------------------- public void InitForModule(CModuleParametrage module, CContexteDonnee contexte) { CTreeViewNodeKeeper keeper = new CTreeViewNodeKeeper(this); m_contexte = contexte; m_moduleAffiche = module; BeginUpdate(); Nodes.Clear(); Dictionary <string, List <CRelationElement_ModuleParametrage> > dicTypeToObjets = new Dictionary <string, List <CRelationElement_ModuleParametrage> >(); List <string> lstTypes = new List <string>(); if (m_moduleAffiche != null) { foreach (CRelationElement_ModuleParametrage rel in m_moduleAffiche.RelationsElements) { if (rel.ElementLie != null) { string strType = DynamicClassAttribute.GetNomConvivial(rel.ElementLie.GetType()); List <CRelationElement_ModuleParametrage> lst = null; if (!dicTypeToObjets.TryGetValue(strType, out lst)) { lstTypes.Add(strType); lst = new List <CRelationElement_ModuleParametrage>(); dicTypeToObjets[strType] = lst; } lst.Add(rel); } } lstTypes.Sort(); foreach (string strType in lstTypes) { TreeNode nodeType = new TreeNode(strType); nodeType.SelectedImageIndex = 0; nodeType.ImageIndex = 0; nodeType.Tag = null; Nodes.Add(nodeType); List <CRelationElement_ModuleParametrage> lst = null; if (dicTypeToObjets.TryGetValue(strType, out lst)) { foreach (CRelationElement_ModuleParametrage rel in lst) { CObjetDonnee obj = rel.ElementLie; string strDesc = DescriptionFieldAttribute.GetDescription(obj); if (strDesc.Trim().Length == 0) { strDesc = obj.DescriptionElement; } TreeNode node = new TreeNode(strDesc); node.Tag = rel; node.ImageIndex = 1; node.SelectedImageIndex = 1; nodeType.Nodes.Add(node); } } } } EndUpdate(); keeper.Apply(this); }
public string ConvertObjectValueToStringForGrid(object valeur) { if (valeur is CObjetDonnee) { DescriptionFieldAttribute.GetDescription((CObjetDonnee)valeur); } return(""); }
private void UpdateLibelleElement(IElementAIntervention element) { string strVal = DescriptionFieldAttribute.GetDescription(element); if (strVal == null || strVal == "") { strVal = element.DescriptionElement; } m_lnkElementAIntervention.Text = strVal; }
public string ConvertObjectValueToStringForGrid(object valeur) { if (valeur is CObjetDonnee) { return(DescriptionFieldAttribute.GetDescription((CObjetDonnee)valeur)); } if (valeur != null) { string strVal = valeur.ToString(); if (valeur is double || valeur is int) { strVal = AppliqueSeparateurMilliers(strVal); } if (ChampCustom != null && ChampCustom.IsChoixParmis()) { strVal = ChampCustom.GetDisplayValue(valeur); } return(strVal); } return(""); }
//------------------------------------------------------------------------------- private void FillListeEntites() { ListViewItem item = m_wndListeResumée.SelectedItems.Count == 1 ? m_wndListeResumée.SelectedItems[0] : null; m_wndListeItems.BeginUpdate(); m_wndListeItems.Items.Clear(); if (item != null && item.Tag is DataTable) { DataTable table = item.Tag as DataTable; m_lblTypeEntite.Text = item.Text; foreach (DataRow row in table.Rows) { CObjetDonnee objet = Activator.CreateInstance(CContexteDonnee.GetTypeForTable(table.TableName), new object[] { row }) as CObjetDonnee; ListViewItem listItem = new ListViewItem(DescriptionFieldAttribute.GetDescription(objet)); listItem.Tag = objet; listItem.ImageIndex = row.RowState == DataRowState.Added ? 0 : (row.RowState == DataRowState.Modified ? 1 : 2); m_wndListeItems.Items.Add(listItem); } } m_wndListeItems.EndUpdate(); }