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()); }
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); }