public uint AddMenuItem(IDictionary <string, object> dict) { string uri = ""; if (dict.ContainsKey("uri")) { uri = (string)dict ["uri"]; } string title = ""; if (dict.ContainsKey("container-title")) { title = (string)dict ["container-title"]; } RemoteMenuEntry rem; if (uri.Length > 0) { rem = new RemoteFileMenuEntry(FileFactory.NewForUri(uri), title); AddToList(rem); } else { string label = ""; if (dict.ContainsKey("label")) { label = (string)dict ["label"]; } string iconName = ""; if (dict.ContainsKey("icon-name")) { iconName = (string)dict ["icon-name"]; } string iconFile = ""; if (dict.ContainsKey("icon-file")) { iconFile = (string)dict ["icon-file"]; } if (iconFile.Length > 0) { rem = new RemoteMenuEntry(label, iconFile, title); } else { rem = new RemoteMenuEntry(label, iconName, title); } rem.Clicked += HandleActivated; AddToList(rem); } return(rem.ID); }
private void AddToList(RemoteMenuEntry entry) { items [entry.ID] = entry; update_time [entry.ID] = DateTime.UtcNow; //TODO Insert items into list... this is stupid but whatever fix later foreach (MenuItem item in items.Values) { owner.RemoteMenuItems.Remove(item); } MenuListContainer _container = MenuListContainer.Footer + 1; var groupedItems = items.Values .GroupBy(rmi => rmi.Title) .OrderBy(g => g.Key); foreach (var itemGroup in groupedItems) { MenuListContainer container; switch (itemGroup.Key.ToLower()) { case "actions": container = MenuListContainer.Actions; break; case "relateditems": container = MenuListContainer.RelatedItems; break; case "windows": container = MenuListContainer.Windows; break; case "header": container = MenuListContainer.Header; break; case "footer": container = MenuListContainer.Footer; break; default: container = _container; owner.RemoteMenuItems.SetContainerTitle(container, itemGroup.Key); break; } foreach (RemoteMenuEntry item in itemGroup.OrderBy(i => i.ID)) { owner.RemoteMenuItems [container].Add(item); } _container++; } }
public ItemTuple GetItem(uint item) { if (!items.ContainsKey(item)) { return(new ItemTuple("", "", "")); } RemoteMenuEntry entry = items [item]; return(new ItemTuple(entry.Text, entry.Icon, entry.Title)); }
public void RemoveMenuItem(uint item) { if (items.ContainsKey(item)) { RemoteMenuEntry entry = items [item]; entry.Clicked -= HandleActivated; items.Remove(item); owner.RemoteMenuItems.Remove(entry); } }
private void AddToList (RemoteMenuEntry entry) { items [entry.ID] = entry; update_time [entry.ID] = DateTime.UtcNow; //TODO Insert items into list... this is stupid but whatever fix later foreach (MenuItem item in items.Values) owner.RemoteMenuItems.Remove (item); MenuListContainer _container = MenuListContainer.Footer + 1; var groupedItems = items.Values .GroupBy (rmi => rmi.Title) .OrderBy (g => g.Key); foreach (var itemGroup in groupedItems) { MenuListContainer container; switch (itemGroup.Key.ToLower ()) { case "actions": container = MenuListContainer.Actions; break; case "relateditems": container = MenuListContainer.RelatedItems; break; case "windows": container = MenuListContainer.Windows; break; case "header": container = MenuListContainer.Header; break; case "footer": container = MenuListContainer.Footer; break; default: container = _container; owner.RemoteMenuItems.SetContainerTitle (container, itemGroup.Key); break; } foreach (RemoteMenuEntry item in itemGroup.OrderBy (i => i.ID)) { owner.RemoteMenuItems [container].Add (item); } _container++; } }
public uint AddMenuItem (IDictionary<string, object> dict) { string uri = ""; if (dict.ContainsKey ("uri")) uri = (string) dict ["uri"]; string title = ""; if (dict.ContainsKey ("container-title")) title = (string) dict ["container-title"]; RemoteMenuEntry rem; if (uri.Length > 0) { rem = new RemoteFileMenuEntry (FileFactory.NewForUri (uri), title); AddToList (rem); } else { string label = ""; if (dict.ContainsKey ("label")) label = (string) dict ["label"]; string iconName = ""; if (dict.ContainsKey ("icon-name")) iconName = (string) dict ["icon-name"]; string iconFile = ""; if (dict.ContainsKey ("icon-file")) iconFile = (string) dict ["icon-file"]; if (iconFile.Length > 0) rem = new RemoteMenuEntry (label, iconFile, title); else rem = new RemoteMenuEntry (label, iconName, title); rem.Clicked += HandleActivated; AddToList (rem); } return rem.ID; }