public void CreateControle( CCreateur2iFormulaireV2 createur, C2iWnd wnd, Control parent, IFournisseurProprietesDynamiques fournisseurProprietes) { C2iWndTabControl tabControl = wnd as C2iWndTabControl; if (tabControl == null) { return; } Ombre = false; CCreateur2iFormulaireV2.AffecteProprietesCommunes(tabControl, this); parent.Controls.Add(this); List <IControleWndFor2iWnd> ctrlsFils = new List <IControleWndFor2iWnd>(); foreach (C2iWndTabPage page in tabControl.TabPages) { IControleWndFor2iWnd fils = createur.CreateControle(page, this, fournisseurProprietes); ctrlsFils.Add(fils); if (fils.Control != null) { TabPages.Add((Crownwood.Magic.Controls.TabPage)fils.Control); } fils.WndContainer = this; } m_controlesFils = ctrlsFils.ToArray(); m_wndAssociee = wnd; }
public static CContexteEvaluationExpression GetContexteEval( IControleWndFor2iWnd ctrl, object objetPrincipal) { return(new CContexteEvaluationExpression( GetObjetForEvalFormuleParametrage(ctrl, objetPrincipal))); }
// //////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Création des contrôles windows /// </summary> /// <param name="controlParent"></param> /// <param name="wndParent"></param> /// <param name="tooltip"></param> /// <returns></returns> public virtual CResultAErreur CreateControlePrincipalEtChilds( Control controlParent, C2iWnd wndParent, IFournisseurProprietesDynamiques fournisseur) { using (CWaitCursor waiter = new CWaitCursor()) { controlParent.SuspendDrawing(); CResultAErreur result = CResultAErreur.True; m_controlesPrincipaux.Clear(); IControleWndFor2iWnd ctrlPrincipal = CreateControle(wndParent, controlParent, fournisseur); if (ctrlPrincipal != null && ctrlPrincipal.Control != null) { C2iWndFenetre fen = wndParent as C2iWndFenetre; if (fen != null && fen.AutoSize) { ctrlPrincipal.Control.Dock = DockStyle.Top; } else { ctrlPrincipal.Control.Dock = DockStyle.Fill; } } if (ctrlPrincipal != null) { m_controlesPrincipaux.Add(ctrlPrincipal); } controlParent.ResumeDrawing(); return(result); } }
private static CResultAErreur DeclencheEvenement( IControleWndFor2iWnd ctrl, CHandlerEvenementParFormule handler) { CResultAErreur result = CResultAErreur.True; try { if (handler.FormuleEvenement != null) { IControleWndFor2iWnd ctrlParent = ctrl; while (ctrlParent.WndContainer != null && !ctrlParent.IsRacineForEvenements) { ctrlParent = ctrlParent.WndContainer as IControleWndFor2iWnd; } CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(new CEncaspuleurControleWndForFormules(ctrlParent)); result = handler.FormuleEvenement.Eval(ctx); if (ctrl.Control != null) { ctrl.Control.Refresh(); } } } catch (Exception e) { result.EmpileErreur(new CErreurException(e)); } return(result); }
////////////////////////////////////////////////////////////////////////////////////// private void CallAfterChangeElementEdite(IControleWndFor2iWnd controleForWnd) { if (controleForWnd != null) { if (controleForWnd.Control != null) { AfterChangeElementEdite(controleForWnd.Control, controleForWnd.WndAssociee, ElementEdite); } foreach (IControleWndFor2iWnd ctrlFils in controleForWnd.Childs) { CallAfterChangeElementEdite(ctrlFils); } } }
//---------------------------------------------------------------------------------------- public bool OnEventSurControle(string strIdEvent, object sender) { IControleWndFor2iWnd ctrl = m_runtime as IControleWndFor2iWnd; if (ctrl != null) { CResultAErreur result = CUtilControlesWnd.DeclencheEvenement(strIdEvent, ctrl); if (result.Data is bool) { return((bool)result.Data); } } return(true); }
public static CResultAErreur DeclencheEvenement( string strIdEvenement, IControleWndFor2iWnd ctrl) { CHandlerEvenementParFormule handler = null; if (ctrl != null && ctrl.WndAssociee != null) { handler = ctrl.WndAssociee.GetHandler(strIdEvenement); if (handler != null) { return(CUtilControlesWnd.DeclencheEvenement(ctrl, handler)); } } return(CResultAErreur.True); }
//----------------------------------------------- public virtual IControleWndFor2iWnd[] CreateChilds(C2iWnd wnd, Control parent, IFournisseurProprietesDynamiques fournisseurProprietes) { List <IControleWndFor2iWnd> controles = new List <IControleWndFor2iWnd>(); foreach (C2iWnd fille in wnd.Childs) { IControleWndFor2iWnd ctrl = CreateControle(fille, parent, fournisseurProprietes); if (ctrl != null) { controles.Add(ctrl); if (ctrl.Control != null) { PositionneAvecAncres(ctrl.Control, parent, fille, wnd); Control control = ctrl.Control; switch (fille.DockStyle) { case EDockStyle.None: control.Dock = DockStyle.None; break; case EDockStyle.Top: control.Dock = DockStyle.Top; break; case EDockStyle.Bottom: control.Dock = DockStyle.Bottom; break; case EDockStyle.Left: control.Dock = DockStyle.Left; break; case EDockStyle.Right: control.Dock = DockStyle.Right; break; case EDockStyle.Fill: control.Dock = DockStyle.Fill; break; } } } } //parent.ResumeDrawing(); return(controles.ToArray()); }
//------------------------------------------------------------------------ public void CreateControle(CCreateur2iFormulaireV2 createur, C2iWnd wnd, System.Windows.Forms.Control parent, sc2i.expression.IFournisseurProprietesDynamiques fournisseurProprietes) { C2iWndZoneMultiple zone = wnd as C2iWndZoneMultiple; if (zone != null) { if (zone.UseChildOptimization) { m_controleAlloue = new CWndFor2iZoneMultipleCustomList(); } else { m_controleAlloue = new CWndFor2iZoneMultiple(); } m_controleAlloue.CreateControle(createur, wnd, parent, fournisseurProprietes); } }
public static object GetObjetForEvalFormuleParametrage( IControleWndFor2iWnd ctrl, object objetPrincipal) { if (ctrl == null) { return(objetPrincipal); } IControleWndFor2iWnd ctrlParent = ctrl; while (ctrlParent.WndContainer != null && !ctrlParent.IsRacineForEvenements) { ctrlParent = ctrlParent.WndContainer as IControleWndFor2iWnd; } return(new CDefinitionMultiSourceForExpression( objetPrincipal, new CSourceSupplementaire("CurrentWindow", new CEncaspuleurControleWndForFormules(ctrlParent)))); }
//----------------------------------------------- public virtual IControleWndFor2iWnd CreateControle( C2iWnd wnd, Control parent, IFournisseurProprietesDynamiques fournisseurProprietes) { m_fournisseurProprietes = fournisseurProprietes; if (wnd == null) { return(null); } if (m_tooltip == null && m_componentContainer != null) { m_tooltip = new ToolTip(m_componentContainer); } Type tpControle = null; if (!m_dicWndToEditeur.TryGetValue(wnd.GetType(), out tpControle)) { return(null); } object objControle = Activator.CreateInstance(tpControle); IControleWndFor2iWnd ctrl = objControle as IControleWndFor2iWnd; if (ctrl == null) { return(null); } ctrl.CreateControle(this, wnd, parent, fournisseurProprietes); if (ctrl != null && ctrl.Control != null) { if (AfterCreateControl != null) { AfterCreateControl(ctrl.Control, wnd, ElementEdite); } } if (ctrl.Control != null && ctrl.Control.Parent != null) { ctrl.Control.BringToFront(); m_tooltip.SetToolTip(ctrl.Control, wnd.HelpText); } return(ctrl); }
//----------------------------------------------------------- public override void UpdateVisibilityEtEnable(IControleWndFor2iWnd ctrl, object elementEdite) { base.UpdateVisibilityEtEnable(ctrl, elementEdite); //Récupère la restriction sur le type édité /*CSessionClient session = CSessionClient.GetSessionForIdSession(m_nIdSession); * if (session != null && ElementEdite != null) * { * IInfoUtilisateur user = session.GetInfoUtilisateur(); * if (user != null) * { * int? nIdVersion = null; * IObjetAContexteDonnee objetAContexte = ElementEdite as IObjetAContexteDonnee; * if (objetAContexte != null) * nIdVersion = objetAContexte.ContexteDonnee.IdVersionDeTravail; * CListeRestrictionsUtilisateurSurType restrictions = user.GetListeRestrictions(nIdVersion); * ctrl.AppliqueRestriction(restrictions); * } * }*/ }
//------------------------------------------------------------ public void SetError(string strErreur) { if (m_controleWnd == null) { return; } Control ctrl = m_controleWnd.Control; IControleWndFor2iWnd ctrlWnd = m_controleWnd; while (ctrlWnd != null && !typeof(IWndErrorProvider).IsAssignableFrom(ctrlWnd.GetType())) { ctrlWnd = ctrlWnd.WndContainer as IControleWndFor2iWnd; } IWndErrorProvider provider = ctrlWnd as IWndErrorProvider; if (provider != null && provider.ErrorProvider != null) { provider.ErrorProvider.SetError(ctrl, strErreur); } }
public bool Init( IControleWndFor2iWnd conteneurSousFormulaire, C2iWnd sousFormulaire, CCreateur2iFormulaireV2 createur) { if (sousFormulaire == null) { return(false); } if (sousFormulaire == m_sousFormulaire) { return(true); } m_createur = createur; m_sousFormulaire = sousFormulaire; CreateSousFormulaire(conteneurSousFormulaire); m_controlePrincipal.OnChangeParentModeEdition(!LockEdition); m_createur.UpdateVisibilityEtEnable(m_controlePrincipal, m_elementEdite); return(true); }
private void CreateSousFormulaire(IControleWndFor2iWnd conteneur) { this.SuspendDrawing(); if (m_bAdjustSizeToFormulaire) { Size = m_sousFormulaire.Size; } //Supprime les anciens contrôles ArrayList lstControles = new ArrayList(Controls); foreach (Control ctrl in lstControles) { ctrl.Visible = false; Controls.Remove(ctrl); ctrl.Dispose(); } m_controlePrincipal = m_createur.CreateControle(m_sousFormulaire, this, m_createur.FournisseurProprietes); m_controlePrincipal.WndContainer = conteneur; //if (m_controlePrincipal.Control != null) // Enabled = m_controlePrincipal.Control.Enabled; if (m_controlePrincipal.Control != null) { m_controlePrincipal.Control.Dock = m_bAdjustSizeToFormulaire?DockStyle.Top:DockStyle.Fill; } if (m_controlePrincipal.Control != null) { m_controlePrincipal.Control.SizeChanged += new EventHandler(Control_SizeChanged); m_controlePrincipal.Control.VisibleChanged += new EventHandler(Control_SizeChanged); } if (m_controlePrincipal.Control != null) { m_controlePrincipal.Control.EnabledChanged += new EventHandler(Control_EnabledChanged); } this.ResumeDrawing(); }
//----------------------------------------------- public virtual void UpdateVisibilityEtEnable(IControleWndFor2iWnd ctrl, object elementEdite) { if (m_fournisseurProprietes == null || ctrl == null) { return; } C2iWnd wnd = ctrl.WndAssociee as C2iWnd; if (wnd != null && ctrl.Control != null) { try { CResultAErreur result = CResultAErreur.True; CContexteEvaluationExpression contexteEvaluation = CUtilControlesWnd.GetContexteEval( ctrl, elementEdite); if (wnd.Visiblity != null) { result = wnd.Visiblity.Eval(contexteEvaluation); bool bVisible = true; if (result && result.Data != null) { if (result.Data.ToString() == "0" || result.Data.ToString().ToUpper() == "FALSE") { bVisible = false; } } ctrl.Control.Visible = bVisible; } if (wnd.Enabled != null) { result = wnd.Enabled.Eval(contexteEvaluation); bool bEnable = true; if (wnd.LockMode == C2iWnd.ELockMode.EnableOnEdit) { bEnable = !m_bLockEdition; } if (wnd.LockMode == C2iWnd.ELockMode.DisableOnEdit) { bEnable = m_bLockEdition; } if (result && result.Data != null) { if (result.Data.ToString() == "0" || result.Data.ToString().ToUpper() == "FALSE") { bEnable = false; } } if (ctrl.Control is IControlALockEdition) { ((IControlALockEdition)ctrl.Control).LockEdition = !bEnable; } else { ctrl.Control.Enabled = bEnable; } } } catch { } } foreach (IControleWndFor2iWnd ctrlFils in ctrl.Childs) { UpdateVisibilityEtEnable(ctrlFils, elementEdite); } }
public CEncaspuleurControleWndForFormules(IControleWndFor2iWnd controleWnd) { m_controleWnd = controleWnd; }