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
        /// <summary>
        /// Helper class for single property change.
        /// Raises the items properties updated event.
        /// </summary>
        private void OnItemPropertiesChanged(string[] properties, IMenuItemProxy item)
        {
            // TODO - cache property values so that we don't send unnessasary events
            var menuItem = new com.canonical.dbusmenu.MenuItem();

            menuItem.id         = mMenuItemList.IndexOf(item);
            menuItem.properties = new Dictionary <string, object>();
            foreach (var property in properties)
            {
                menuItem.properties.Add(property, item.GetValue(property));
            }
            OnItemsPropertiesUpdated(new[] { menuItem }, null);
            OnLayoutUpdated(mMenuItemList.IndexOf(item));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Helper class for single property change.
 /// Raises the items properties updated event.
 /// </summary>
 private void OnItemPropertyChanged(string property, IMenuItemProxy item)
 {
     OnItemPropertiesChanged(new string[] { property }, item);
 }