/// <summary> /// Sets the value of the AssociatedToolbarItem attached property to a specified TreeViewItem. /// </summary> /// <param name="element">The TreeViewItem to which the attached property is written.</param> /// <param name="value">The needed AssociatedToolbarItem value.</param> internal static void SetAssociatedToolbarItem(TreeViewItem element, AddToolbarItem value) { if (element == null) { throw new ArgumentNullException("element"); } element.SetValue(AssociatedToolbarItemProperty, value); }
internal static ButtonDisplayInfo CreateButtonDisplayInfoForToolbarItem(AddToolbarItem item) { ButtonDisplayInfo bdi = new ButtonDisplayInfo(); bdi.Description = item.Description; // If no icon location is available, default to a "screwdriver and wrench" image by default if (!String.IsNullOrEmpty(item.IconUrl)) { bdi.Icon = item.IconUrl; } else { bdi.Icon = GetDefaultIconUrl(item.ToolbarItemType); } bdi.Label = item.Name; return bdi; }
internal static AddToolbarItem CreateToolbarItemForType(Type t) { // Get all custom attributes associated with this type but do not gather those that might be obtained // via inheritance. object[] attrs = t.GetCustomAttributes(false); // Create object to store information AddToolbarItem cmd = new AddToolbarItem(); // Process each attribute, looking for the ones we care about and if found, extract information and continue // to the next attribute. foreach (object att in attrs) { ESRI.ArcGIS.Client.Extensibility.CategoryAttribute catAttribute = att as ESRI.ArcGIS.Client.Extensibility.CategoryAttribute; if (catAttribute != null) { cmd.Category = catAttribute.Category; continue; } ESRI.ArcGIS.Client.Extensibility.DisplayNameAttribute nameAttribute = att as ESRI.ArcGIS.Client.Extensibility.DisplayNameAttribute; if (nameAttribute != null) { cmd.Name = nameAttribute.Name; continue; } ESRI.ArcGIS.Client.Extensibility.DescriptionAttribute descAttribute = att as ESRI.ArcGIS.Client.Extensibility.DescriptionAttribute; if (descAttribute != null) { cmd.Description = descAttribute.Description; continue; } ESRI.ArcGIS.Client.Extensibility.DefaultIconAttribute iconAttribute = att as ESRI.ArcGIS.Client.Extensibility.DefaultIconAttribute; if (iconAttribute != null) { cmd.IconUrl = iconAttribute.DefaultIcon; continue; } } return cmd; }
internal static AddToolbarItem CreateToolbarItemForType(Type t) { // Get all custom attributes associated with this type but do not gather those that might be obtained // via inheritance. object[] attrs = t.GetCustomAttributes(false); // Create object to store information AddToolbarItem cmd = new AddToolbarItem(); // Process each attribute, looking for the ones we care about and if found, extract information and continue // to the next attribute. foreach (object att in attrs) { ESRI.ArcGIS.Client.Extensibility.CategoryAttribute catAttribute = att as ESRI.ArcGIS.Client.Extensibility.CategoryAttribute; if (catAttribute != null) { cmd.Category = catAttribute.Category; continue; } ESRI.ArcGIS.Client.Extensibility.DisplayNameAttribute nameAttribute = att as ESRI.ArcGIS.Client.Extensibility.DisplayNameAttribute; if (nameAttribute != null) { cmd.Name = nameAttribute.Name; continue; } ESRI.ArcGIS.Client.Extensibility.DescriptionAttribute descAttribute = att as ESRI.ArcGIS.Client.Extensibility.DescriptionAttribute; if (descAttribute != null) { cmd.Description = descAttribute.Description; continue; } ESRI.ArcGIS.Client.Extensibility.DefaultIconAttribute iconAttribute = att as ESRI.ArcGIS.Client.Extensibility.DefaultIconAttribute; if (iconAttribute != null) { cmd.IconUrl = iconAttribute.DefaultIcon; continue; } } return(cmd); }
internal static ButtonDisplayInfo CreateButtonDisplayInfoForToolbarItem(AddToolbarItem item) { ButtonDisplayInfo bdi = new ButtonDisplayInfo(); bdi.Description = item.Description; // If no icon location is available, default to a "screwdriver and wrench" image by default if (!String.IsNullOrEmpty(item.IconUrl)) { bdi.Icon = item.IconUrl; } else { bdi.Icon = GetDefaultIconUrl(item.ToolbarItemType); } bdi.Label = item.Name; return(bdi); }
/// <summary> /// Processes a type that implements the ICommand interface, it detects various special attributes to determine /// if they should appear in the generated list of commands that can be added to the toolbar. /// </summary> /// <param name="t">The type to process.</param> private void ProcessType(Type t) { AddToolbarItem cmd = ToolbarManagement.CreateToolbarItemForType(t); // If it assumed that a command MUST have the DisplayName attribute properly assigned and thus we consider // these valid items for our generated list. if (!String.IsNullOrEmpty(cmd.Name)) { // If the command does not specify a category, then group all of these into the "Uncategorized" category // so they are grouped together if (String.IsNullOrEmpty(cmd.Category)) { cmd.Category = "Uncategorized"; } // Store the type in the object so it can be dynamically created when needed later cmd.ToolbarItemType = t; AvailableItems.Add(cmd); } }