using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Drawing; using MercatorUi; using MercatorApi; using MercatorExtensions; using System.Linq; namespace Billing { public class Customizer : MercatorUi.ICustomizers.IFormLoadCustomizer, MercatorUi.ICustomizers.IFormClosedCustomizer, MercatorUi.ICustomizers.IStringUpdater { string MercatorUi.ICustomizers.IStringUpdater.StringUpdate(string stringToModify) { string id = Api.StrExtract(stringToModify, "/*<ID>", "</ID>*/"); if (id == "BILLING_ACTIONSTREE_PARENTS_DEVIS") // requête pour le niveau "parent" { stringToModify = stringToModify.Replace("actions.users,", "actions.users,actions.contact,"); } else if (id == "BILLING_ACTIONSTREE_CHILDS_DEVIS") // requête pour le niveau "enfant" { stringToModify = stringToModify.Replace("actions.users,", "actions.users,actions.contact,"); } return stringToModify; } public void FormLoadCustomize(Form form) { MercatorUi.Forms.Billing.BillingForm billingForm = (MercatorUi.Forms.Billing.BillingForm)form; List<Control> l = billingForm.FindMovableControlsByType(typeof(MercatorUi.Forms.Sig.SigObjects.ActionsTree)); if (l.Any()) { MercatorUi.Forms.Sig.SigObjects.ActionsTree actionTree = (MercatorUi.Forms.Sig.SigObjects.ActionsTree)l[0]; actionTree.ActionsTreeControl.AddingNode += ActionsTreeControl_AddingNode; } } public void FormClosedCustomize(Form form) { MercatorUi.Forms.Billing.BillingForm billingForm = (MercatorUi.Forms.Billing.BillingForm)form; List<Control> l = billingForm.FindMovableControlsByType(typeof(MercatorUi.Forms.Sig.SigObjects.ActionsTree)); if (l.Any()) { MercatorUi.Forms.Sig.SigObjects.ActionsTree actionTree = (MercatorUi.Forms.Sig.SigObjects.ActionsTree)l[0]; actionTree.ActionsTreeControl.AddingNode -= ActionsTreeControl_AddingNode; } } void ActionsTreeControl_AddingNode(object sender, MercatorUi.Forms.Sig.SigClasses.ActionsTreeControl.AddingNodeEventArgs e) { MercatorUi.Forms.Sig.SigClasses.ActionsTreeControl actionsTreeControl = (MercatorUi.Forms.Sig.SigClasses.ActionsTreeControl)sender; if (actionsTreeControl.Tree.Columns.Count == 8) // 8 = le nombre de colonnes en standard - ce code ne sera exécuté qu'une seule fois { DevComponents.AdvTree.ColumnHeader colContact = new DevComponents.AdvTree.ColumnHeader(_Divers.Iif_langue(Globals.Langue, "Contact", "Contactpersoon", "Contact")); colContact.SortingEnabled = false; colContact.Width.Absolute = 200; actionsTreeControl.Tree.Columns.Add(colContact); } _Divers.AddCellsToNode(e.Node, 1); // comme on a ajouté une colonne, il faut ajouter une Cell à chaque noeud e.Node.Cells[8].Text = e.Node.Dr["contact"].ToString(); if (e.NodeType == MercatorUi.Forms.Sig.SigClasses.ActionsTreeControl.NodeEnum.Parent) e.Node.Cells[8].Text = "Parent=" + e.Node.Dr["contact"].ToString(); else e.Node.Cells[8].Text = "Enfant=" + e.Node.Dr["contact"].ToString(); } } }