//--------------------------------------------------------------------------- public bool GenereItem( object obj, double fLat, double fLong, CMapLayer layer) { CResultAErreur result = CResultAErreur.True; CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(this.m_mapItemGenerator); if (FormuleCondition != null && !(FormuleCondition is C2iExpressionVrai)) { result = FormuleCondition.Eval(ctx); if (!result || result.Data == null) { return(false); } bool?bResult = CUtilBool.BoolFromString(result.Data.ToString()); if (bResult == null || !bResult.Value) { return(false); } } string strLibelle = ""; if (FormuleToolTip != null) { result = FormuleToolTip.Eval(ctx); if (result && result.Data != null) { strLibelle = result.Data.ToString(); } } IMapItem item = null; if (MarkerType != EMapMarkerType.none) { item = new CMapItemSimple(layer, fLat, fLong, MarkerType); } else if (Image != null) { if (layer.Database.GetImage(m_strImageId) == null) { layer.Database.AddImage(m_strImageId, Image); } item = new CMapItemImage(layer, fLat, fLong, m_strImageId); } else { item = new CMapItemSimple(layer, fLat, fLong, EMapMarkerType.green); } item.Tag = obj; item.ToolTip = strLibelle; item.PermanentToolTip = PermanentToolTip; if (ItemGenerator.ActionSurClick != null) { item.MouseClicked += new MapItemClickEventHandler(OnMouseClick); } return(true); }
internal void OnChangeVariable(IVariableDynamique variable) { CDefinitionProprieteDynamique defProp = new CDefinitionProprieteDynamiqueVariableDynamique(variable as CVariableDynamique); if (FormuleSelectionObjet != null) { foreach (C2iExpressionChamp expChamp in FormuleSelectionObjet.ExtractExpressionsType(typeof(C2iExpressionChamp))) { CDefinitionProprieteDynamiqueVariableDynamique defVar = expChamp.DefinitionPropriete as CDefinitionProprieteDynamiqueVariableDynamique; if (defVar != null && defVar.IdChamp == variable.IdVariable) { expChamp.DefinitionPropriete = defProp; } } } if (FormuleCondition != null) { foreach (C2iExpressionChamp expChamp in FormuleCondition.ExtractExpressionsType(typeof(C2iExpressionChamp))) { CDefinitionProprieteDynamiqueVariableDynamique defVar = expChamp.DefinitionPropriete as CDefinitionProprieteDynamiqueVariableDynamique; if (defVar != null && defVar.IdChamp == variable.IdVariable) { expChamp.DefinitionPropriete = defProp; } } } foreach (CMacroObjetValeur mv in Valeurs) { mv.OnChangeVariable(variable); } }
//----------------------------------------------------- internal CResultAErreur Execute(CContexteExecutionMacro contexteExecution) { CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(Macro); CObjetDonneeAIdNumerique cible = null; CResultAErreur result = CResultAErreur.True; if (FormuleCondition != null) { result = FormuleCondition.Eval(ctx); if (!result) { return(result); } if (!(result.Data is bool)) { return(result); } if (!(bool)result.Data) { return(result); } } switch (TypeOperation.Code) { case CTypeOperationSurObjet.TypeOperation.Ajout: CObjetDonneeAIdNumeriqueAuto objAuto = Activator.CreateInstance(m_typeObjet, new object[] { contexteExecution.ContexteDonnee }) as CObjetDonneeAIdNumeriqueAuto; if (objAuto != null) { objAuto.CreateNewInCurrentContexte(); } cible = objAuto; break; case CTypeOperationSurObjet.TypeOperation.Aucune: break; case CTypeOperationSurObjet.TypeOperation.Modification: case CTypeOperationSurObjet.TypeOperation.Suppression: result = FormuleSelectionObjet.Eval(ctx); if (!result) { return(result); } if (result) { cible = result.Data as CObjetDonneeAIdNumerique; } break; default: break; } if (cible != null) { Macro.SetValeurChamp(IdVariableAssociee, cible); } Macro.SetValeurChamp(Macro.VariableCurrentElement, cible); foreach (CMacroObjetValeur valeur in Valeurs) { valeur.Execute(cible); } return(result); }