/// <summary>
        /// Creates or identifies the element that is used to display the given item.
        /// </summary>
        /// <param name="item">The item to get the container for.</param>
        /// <param name="itemCollection">The parent's <see cref="ItemCollection"/>.</param>
        /// <returns>The element that is used to display the given item.</returns>
        protected virtual RadTabItem GetContainerForItem( object item, ItemCollection itemCollection )
        {
            if ( itemCollection == null )
            {
                throw new ArgumentNullException ( "itemCollection" );
            }
            var container = item as RadTabItem;
            if ( container != null && ( ( bool )container.GetValue ( IsGeneratedProperty ) ) == false )
            {
                return container;
            }

            return itemCollection.Cast<RadTabItem> ()
                .Where ( tabItem => ( bool )tabItem.GetValue ( IsGeneratedProperty ) )
                .FirstOrDefault ( tabItem => tabItem.Content == item );
        }
Beispiel #2
0
        private void UpdateMenu(ItemCollection globalItems, ItemCollection selfItems, IList<MenuItem> addedItems)
        {
            if (globalItems == null)
                return;

            if (selfItems == null)
                return;

            foreach (MenuItem self in selfItems)
            {
                var results = globalItems.Cast<MenuItem>().Where<MenuItem>(item => item.HasHeader && self.HasHeader && (self.Header == item.Header));
                int count = results.Count<MenuItem>();
                if (count == 0)
                {
                    globalItems.Add(self);
                    AddSelfCommand2List(addedItems, self);
                }
                else if (count > 1)
                    throw new MenuItemConflictException("Menu item: " + self.Header);
                else
                {
                    MenuItem item = results.First<MenuItem>();
                    if (self.HasItems)
                    {
                        if (self.HasItems)
                            UpdateMenu(item.Items, self.Items, addedItems);
                        else if (!item.HasItems)
                        {
                            foreach (MenuItem sub in self.Items)
                            {
                                item.Items.Add(sub);
                                if (sub.Command != null)
                                    addedItems.Add(sub);
                            }
                        }
                    }

                }
            }
        }
Beispiel #3
0
        protected internal override string GetSummary(ItemCollection items)
        {
            var mp = this._meta.PropertyMeta.ManagedProperty;

            var sum = items.Cast<object>().Sum(item =>
            {
                var e = item as Entity;
                var value = e.GetProperty(mp);
                return Convert.ToDouble(value);
            });

            return sum.ToString();
        }
Beispiel #4
0
 MenuItem Find(ItemCollection items, string header)
 {
     return items.Cast<MenuItem>()
         .FirstOrDefault(i => i.Header.ToString() == header);
 }