public static void CreateAppearanceRuleNode(IModelClass modelClass, string id, string properties, EditorState editorState, string criteria, ViewType viewType, string methodName, int?index, ViewItemVisibility visibility)
        {
            if (modelClass is IModelConditionalAppearance)
            {
                IModelConditionalAppearance appearance = modelClass as IModelConditionalAppearance;
                IModelAppearanceRule        targetRule = appearance.AppearanceRules.AddNode <IModelAppearanceRule>(id);
                targetRule.TargetItems = properties;
                switch (editorState)
                {
                case EditorState.Default:
                    if (!String.IsNullOrEmpty(methodName))
                    {
                        throw new ArgumentException(MethodNameMemberPresentErrorsMessage + "\r\nIn class: " + modelClass.Name + " Attribute.Id=" + id);
                    }
                    break;

                case EditorState.Disabled:
                    targetRule.Enabled = false;
                    break;

                case EditorState.Hidden:
                    targetRule.Visibility = visibility;
                    break;
                }
                targetRule.Criteria = criteria;
                targetRule.Method   = methodName;
                targetRule.Context  = viewType.ToString();
                targetRule.Index    = index;
                if (id.Contains(LayoutItemRuleTargetItemTypeMark))
                {
                    targetRule.AppearanceItemType = AppearanceItemType.LayoutItem.ToString();
                }
                else
                {
                    targetRule.AppearanceItemType = AppearanceItemType.ViewItem.ToString();
                }
            }
        }
Exemple #2
0
 protected void Convert(IModelConditionalFormatting targetnode, IModelApplication application, IModelObjectView view) {
     IModelConditionalFormatting ruleList = (IModelConditionalFormatting)targetnode;
     if (ruleList.ConditionalFormatting == null) {
         return;
     }
     foreach (IModelConditionalFormattingRule node in ruleList.ConditionalFormatting) {
         if (((ModelNode)node).IsNewNode && view.ModelClass != null) {
             IModelClass modelClass = ConditionalEditorStateConverter.GetModelClassNode(((ModelNode)node).Application, view.ModelClass.Name);
             if (modelClass is IModelConditionalAppearance) {
                 IModelConditionalAppearance appearance = modelClass as IModelConditionalAppearance;
                 IModelAppearanceRule targetRule = appearance.AppearanceRules.AddNode<IModelAppearanceRule>(view.Id + node.Id);
                 targetRule.Criteria = node.Criteria;
                 targetRule.Priority = node.Priority;
                 targetRule.AppearanceItemType = AppearanceItemType.ViewItem.ToString();
                 targetRule.Context = "ListView";
                 string targetItems = "";
                 if (targetnode is IModelListView) {
                     targetItems = "*";
                 }
                 else if (targetnode is IModelColumn) {
                     targetItems = ((IModelColumn)targetnode).Id;
                 }
                 targetRule.TargetItems = targetItems;
                 foreach (IModelConditionalFormattingTarget target in node) {
                     if (target.Name == "Foreground") {
                         targetRule.FontColor = (Color)target.Color;
                     }
                     else if (target.Name == "Background") {
                         targetRule.BackColor = (Color)target.Color;
                     }
                 }
             }
             node.Remove();
         }
     }
 }