Ejemplo n.º 1
0
        static string GetMemberCaption(IMemberInfo memberInfo)
        {
            string memberCaption = null;

            var displayNameAttr =
                memberInfo.FindAttribute <DisplayNameAttribute>();

            if (displayNameAttr != null)
            {
                memberCaption = displayNameAttr.DisplayName;
            }

            if (string.IsNullOrEmpty(memberCaption))
            {
                var attribute = memberInfo.FindAttribute <XafDisplayNameAttribute>();
                if (attribute != null)
                {
                    memberCaption = attribute.DisplayName;
                }
            }
            if (string.IsNullOrEmpty(memberCaption))
            {
                memberCaption = memberInfo.DisplayName;
            }
            if (string.IsNullOrEmpty(memberCaption))
            {
                memberCaption = CaptionHelper.ConvertCompoundName(memberInfo.Name);
            }
            return(memberCaption);
        }
        public UserViewVariantsController()
        {
            userViewVariantsCore = new SingleChoiceAction(this, STR_UserViewVariants_Id, PredefinedCategory.View)
            {
                ImageName        = STR_UserViewVariants_Image,
                PaintStyle       = ActionItemPaintStyle.CaptionAndImage,
                Caption          = CaptionHelper.ConvertCompoundName(STR_UserViewVariants_Id),
                ItemType         = SingleChoiceActionItemType.ItemIsOperation,
                ShowItemsOnClick = true
            };
            ChoiceActionItem addViewVariantItem = new ChoiceActionItem(STR_NewViewVariant_Id, CaptionHelper.ConvertCompoundName(STR_NewViewVariant_Id), STR_NewViewVariant_Id)
            {
                ImageName = STR_NewViewVariant_Image
            };
            ChoiceActionItem removeViewVariantItem = new ChoiceActionItem(STR_DeleteViewVariant_Id, CaptionHelper.ConvertCompoundName(STR_DeleteViewVariant_Id), STR_DeleteViewVariant_Id)
            {
                ImageName = STR_DeleteViewVariant_Image
            };
            ChoiceActionItem editViewVariantItem = new ChoiceActionItem(STR_EditViewVariant_Id, CaptionHelper.ConvertCompoundName(STR_EditViewVariant_Id), STR_EditViewVariant_Id)
            {
                ImageName = STR_EditViewVariant_Image
            };

            userViewVariantsCore.Items.Add(addViewVariantItem);
            userViewVariantsCore.Items.Add(editViewVariantItem);
            userViewVariantsCore.Items.Add(removeViewVariantItem);
            userViewVariantsCore.Execute += UserViewVariants_Execute;
        }
Ejemplo n.º 3
0
        private void GenerateNestedDetailViewLayout(IModelDetailView modelDetailView)
        {
            List <IModelViewItem> items = new List <IModelViewItem>();

            foreach (IModelViewItem item in modelDetailView.Items)
            {
                items.Add(item);
            }
            foreach (IModelViewItem itemR in items)
            {
                itemR.Remove();
            }
            int index = 0;

            foreach (string propertyName in CustomLayoutHelper.Instance.GetViewVisibleProperties(modelDetailView.Id))
            {
                IModelPropertyEditor editor = modelDetailView.Items.AddNode <IModelPropertyEditor>(propertyName);
                editor.ImmediatePostData = true;
                editor.Index             = index++;
                editor.PropertyName      = propertyName;
                if (string.IsNullOrEmpty(((IModelViewItem)editor).Caption))
                {
                    ((IModelViewItem)editor).Caption = CaptionHelper.ConvertCompoundName(propertyName);
                }
            }
        }
        private IModelLayoutGroup AddEditorToTabbedGroup(IModelTabbedGroup rootTabNode, string tabId, IModelPropertyEditor editor, FlowDirection direction)
        {
            IModelLayoutGroup rootTabPageNode = (IModelLayoutGroup)rootTabNode[tabId];

            if (rootTabPageNode == null)
            {
                rootTabPageNode           = rootTabNode.AddNode <IModelLayoutGroup>(tabId);
                rootTabPageNode.Caption   = CaptionHelper.ConvertCompoundName(tabId);
                rootTabPageNode.Direction = direction;
            }
            AddLayoutItemNode(rootTabPageNode, editor);
            return(rootTabPageNode);
        }
Ejemplo n.º 5
0
        // TODO: remove dependency on Session
        public void CopyObjectsToWorksheet(Session session, System.Collections.ICollection objs)
        {
            // clear existing values
            Clear();

            // headings
            Type objType = null;

            foreach (var obj in objs)
            {
                objType = obj.GetType();
            }
            if (objType == null)
            {
                return;
            }

            var classInfo = session.GetClassInfo(objType);

            int h = 1;

            foreach (var memberInfo in classInfo.Members
                     .Where(x => x.HasAttribute(typeof(ExcelReportFieldAttribute))))
            {
                _worksheet.Cells[1, h++].Value = string.IsNullOrEmpty(memberInfo.DisplayName) ?
                                                 CaptionHelper.ConvertCompoundName(memberInfo.Name)
                    : memberInfo.DisplayName;
            }

            // data
            int r = 2;

            foreach (IXPObject obj in objs)
            {
                int c = 1;
                foreach (var memberInfo in obj.ClassInfo.Members
                         .Where(x => x.HasAttribute(typeof(ExcelReportFieldAttribute))))
                {
                    _worksheet.Cells[r, c++].Value = memberInfo.GetValue(obj);
                }
                r++;
            }
        }
Ejemplo n.º 6
0
 public static string CompoundName(this object obj) => CaptionHelper.ConvertCompoundName($"{obj}");
Ejemplo n.º 7
0
 public static string CompoundName(this object obj) => CaptionHelper.ConvertCompoundName($"{obj}".Replace("_", ""));
Ejemplo n.º 8
0
 public static string CompoundName(this object obj)
 => $"{obj}".Split('.').Select(s => CaptionHelper.ConvertCompoundName(s.Split('_').Select(s1 => s1.FirstCharacterToUpper()).Join(""))).Join(".");