Ejemplo n.º 1
0
        private MenuItemLayout CreateMenuItemLayout(IMenuItemProxy item,
                                                    int depth, int maxDepth,
                                                    string[] propertyNames)
        {
            var layout = new MenuItemLayout();

            layout.id         = mMenuItemList.IndexOf(item);
            layout.properties = new Dictionary <string, object>();
            foreach (var property in propertyNames)
            {
                try {
                    var value = item.GetValue(property);
                    if (!DefaultMenuItemProxy.IsDefaultValue(property, value))
                    {
                        layout.properties.Add(property, value);
                    }
                } catch (Exception ex) {
                    Debug.Fail(ex.ToString());
                }
            }
            var childList = new List <object>();

            if (maxDepth < 0 || depth < maxDepth)
            {
                foreach (var childItem in item.GetChildren())
                {
                    childList.Add(CreateMenuItemLayout(childItem, depth + 1,
                                                       maxDepth, propertyNames));
                }
            }
            layout.childeren = childList.ToArray();
            return(layout);
        }
Ejemplo n.º 2
0
        public com.canonical.dbusmenu.MenuItem[] GetGroupProperties(int[] ids,
                                                                    string[] propertyNames)
        {
#if DEBUG
            Console.WriteLine("GetGroupProperties - ids:{0}, propertyNames:{1}",
                              string.Join(", ", ids), string.Join(", ", propertyNames));
#endif
            if (propertyNames.Length == 0)
            {
                propertyNames = DefaultMenuItemProxy.GetAllDisplayNames();
            }
            var itemList = new List <com.canonical.dbusmenu.MenuItem>();
            foreach (var id in ids)
            {
                var item     = mMenuItemList[id];
                var menuItem = new com.canonical.dbusmenu.MenuItem();
                menuItem.id         = id;
                menuItem.properties = new Dictionary <string, object>();
                foreach (var property in propertyNames)
                {
                    try {
                        var value = item.GetValue(property);
                        if (!DefaultMenuItemProxy.IsDefaultValue(property, value))
                        {
                            menuItem.properties.Add(property, value);
                        }
                    } catch (Exception ex) {
                        Debug.Fail(ex.ToString());
                    }
                }
                itemList.Add(menuItem);
            }

            return(itemList.ToArray());
        }
Ejemplo n.º 3
0
        public void GetLayout(int parentId, int recursionDepth, string[] propertyNames,
                              out uint revision, out MenuItemLayout layout)
        {
#if DEBUG
            Console.WriteLine("GetLayout - parentId:{0}, " +
                              "recursionDepth:{1}, propertyNames:{2}",
                              parentId, recursionDepth,
                              string.Join(", ", propertyNames));
#endif
            if (propertyNames.Length == 0)
            {
                propertyNames = DefaultMenuItemProxy.GetAllDisplayNames();
            }

            revision = mRevision;

            var item = mMenuItemList[parentId];
            layout = CreateMenuItemLayout(item, 0, recursionDepth, propertyNames);
        }