示例#1
0
        DataTemplate GetDataTemplate(int viewTypeId)
        {
            AdapterListItem item = null;

            foreach (var ali in _listItems)
            {
                if (viewTypeId == ali.Index)
                {
                    item = ali;
                    break;
                }
            }

            DataTemplate dataTemplate = ShellController.GetFlyoutItemDataTemplate(item.Element);

            if (item.Element is IMenuItemController)
            {
                if (DefaultMenuItemTemplate != null && Shell.MenuItemTemplate == dataTemplate)
                {
                    dataTemplate = DefaultMenuItemTemplate;
                }
            }
            else
            {
                if (DefaultItemTemplate != null && Shell.ItemTemplate == dataTemplate)
                {
                    dataTemplate = DefaultItemTemplate;
                }
            }

            var template = dataTemplate.SelectDataTemplate(item.Element, Shell);

            return(template);
        }
 protected override void PostReadIDOs(int index = 0)
 {
     base.PostReadIDOs(index);
     foreach (AdapterList ListTemp in AdapterListTemplate)
     {
         if (ListTemp.ObjIndex != index)
         {
             continue;
         }
         AdapterList colonList = new AdapterList
         {
             KeyName = ListTemp.KeyName
         };
         foreach (string key in ListTemp.ObjectList.Keys) //go through adapter items
         {
             AdapterListItem obj       = ListTemp.ObjectList[key];
             AdapterListItem colonItem = new AdapterListItem
             {
                 Name           = obj.Name,
                 Label          = obj.Label,
                 LayoutID       = obj.LayoutID,
                 Value          = obj.Value,
                 ValueType      = obj.ValueType,
                 DisplayedValue = obj.DisplayedValue,
                 Key            = obj.Key,
                 ActivityType   = obj.ActivityType
             };
             colonList.Add(colonItem);
         }
         AdapterLists.Add(colonList);
     }
 }
示例#3
0
        protected virtual List <AdapterListItem> GenerateItemList()
        {
            var result = new List <AdapterListItem>();

            _listItems = _listItems ?? result;

            List <List <Element> > grouping = ((IShellController)_shellContext.Shell).GenerateFlyoutGrouping();

            if (_flyoutGroupings == grouping)
            {
                return(_listItems);
            }

            _flyoutGroupings = grouping;

            bool skip = true;

            foreach (var sublist in grouping)
            {
                bool first = !skip;
                foreach (var element in sublist)
                {
                    AdapterListItem toAdd = null;
                    foreach (var existingItem in _listItems)
                    {
                        if (existingItem.Element == element)
                        {
                            existingItem.DrawTopLine = first;
                            toAdd = existingItem;
                        }
                    }

                    toAdd = toAdd ?? new AdapterListItem(element, first);
                    result.Add(toAdd);
                    first = false;
                }
                skip = false;
            }

            return(result);
        }
        protected override void PostReadIDOs(int index = 0)
        {
            base.PostReadIDOs(index);

            //foreach (BaseBusinessObject o in
            for (int i = 0; i < BusinessObjects[index].GetRowCount(); i++) //go through IDO rows
            {
                foreach (AdapterList ListTemp in AdapterListTemplate)
                {
                    bool skip = false;
                    if (ListTemp.ObjIndex != index)
                    {
                        continue;
                    }
                    AdapterList colonList = new AdapterList
                    {
                        KeyName = ListTemp.KeyName
                    };
                    foreach (string key in ListTemp.ObjectList.Keys) //go through adapter items
                    {
                        AdapterListItem obj = ListTemp.ObjectList[key];

                        //check if the field need to be hide when repeat displaying
                        if (BusinessObjects[index].IsDuplicatedCol(key))
                        {
                            if (i > 0 && BusinessObjects[index].GetPropertyValue(obj.Name, i) == BusinessObjects[index].GetPropertyValue(obj.Name, i - 1))
                            {
                                skip = true;
                                continue;
                            }
                        }

                        AdapterListItem colonItem = new AdapterListItem
                        {
                            Name           = obj.Name,
                            Label          = obj.Label,
                            LayoutID       = obj.LayoutID,
                            ValueType      = obj.ValueType,
                            DisplayedValue = obj.DisplayedValue,
                            Key            = obj.Key,
                            ActivityType   = obj.ActivityType
                        };
                        if (!string.IsNullOrEmpty(obj.Name))
                        {
                            switch (obj.ValueType)
                            {
                            case AdapterListItem.ValueTypes.String:
                                colonItem.Value          = BusinessObjects[index].GetPropertyValue(obj.Name, i);
                                colonItem.DisplayedValue = GetPropertyDisplayedValue(BusinessObjects[index], index, obj.Name, i);
                                break;

                            case AdapterListItem.ValueTypes.Int:
                                colonItem.Value          = BusinessObjects[index].GetPropertyInt(obj.Name, i);
                                colonItem.DisplayedValue = GetPropertyDisplayedValue(BusinessObjects[index], index, obj.Name, i);
                                break;

                            case AdapterListItem.ValueTypes.Decimal:
                                colonItem.Value          = string.Format("{0:###,###,###,###,##0.00######}", BusinessObjects[index].GetPropertyDecimalValue(obj.Name, i));
                                colonItem.DisplayedValue = GetPropertyDisplayedValue(BusinessObjects[index], index, obj.Name, i);
                                break;

                            case AdapterListItem.ValueTypes.Date:
                                colonItem.Value          = BusinessObjects[index].GetPropertyValue(obj.Name, i);
                                colonItem.DisplayedValue = GetPropertyDisplayedValue(BusinessObjects[index], index, obj.Name, i);
                                break;

                            case AdapterListItem.ValueTypes.DateTime:
                                colonItem.Value          = BusinessObjects[index].GetPropertyValue(obj.Name, i);
                                colonItem.DisplayedValue = GetPropertyDisplayedValue(BusinessObjects[index], index, obj.Name, i);
                                break;

                            case AdapterListItem.ValueTypes.Bitmap:
                                colonItem.Value          = BusinessObjects[index].GetPropertyBitmap(obj.Name, i);
                                colonItem.DisplayedValue = GetPropertyDisplayedValue(BusinessObjects[index], index, obj.Name, i);
                                break;

                            case AdapterListItem.ValueTypes.Boolean:
                                colonItem.Value          = BusinessObjects[index].GetPropertyBoolean(obj.Name, i);
                                colonItem.DisplayedValue = GetPropertyDisplayedValue(BusinessObjects[index], index, obj.Name, i);
                                break;

                            default:
                                colonItem.Value = null;
                                break;
                            }
                        }
                        colonList.ObjectList.Add(key, colonItem);
                    }
                    if (!skip)
                    {
                        AdapterLists.Add(colonList);
                    }
                }
            }
        }