protected bool IsItemContainerSupported(ToolboxItemContainer container, IDesignerHost host) { if (container == null) { throw new ArgumentNullException("container"); } if (host == null) { throw new ArgumentNullException("host"); } ICollection creatorCollection = this.GetCreatorCollection(host); this._lastState = host.GetService(typeof(DesignerToolboxInfo)) as DesignerToolboxInfo; if (this._lastState == null) { this._lastState = new DesignerToolboxInfo(this, host); host.AddService(typeof(DesignerToolboxInfo), this._lastState); } switch (GetFilterSupport(container.GetFilter(creatorCollection), this._lastState.Filter)) { case FilterSupport.NotSupported: return(false); case FilterSupport.Supported: return(true); case FilterSupport.Custom: if (this._lastState.ToolboxUser == null) { break; } return(this._lastState.ToolboxUser.GetToolSupported(container.GetToolboxItem(creatorCollection))); } return(false); }
public override bool Equals(object obj) { ToolboxItemContainer container = obj as ToolboxItemContainer; if (container == this) { return(true); } if (container == null) { return(false); } if (((this._toolboxItem != null) && (container._toolboxItem != null)) && this._toolboxItem.Equals(container._toolboxItem)) { return(true); } if (((this._dataObject != null) && (container._dataObject != null)) && this._dataObject.Equals(container._dataObject)) { return(true); } ToolboxItem toolboxItem = this.GetToolboxItem(null); ToolboxItem item2 = container.GetToolboxItem(null); return(((toolboxItem != null) && (item2 != null)) && toolboxItem.Equals(item2)); }
ToolboxItem IToolboxService.GetSelectedToolboxItem() { ToolboxItemContainer selectedItemContainer = this.SelectedItemContainer; if (selectedItemContainer != null) { return(selectedItemContainer.GetToolboxItem(this.GetCreatorCollection(null))); } return(null); }
void IToolboxService.AddToolboxItem(ToolboxItem toolboxItem) { if (toolboxItem == null) { throw new ArgumentNullException("toolboxItem"); } ToolboxItemContainer container = this.CreateItemContainer(toolboxItem, null); if (container != null) { this.GetItemContainers(this.SelectedCategory).Add(container); } }
ToolboxItem IToolboxService.GetSelectedToolboxItem(IDesignerHost host) { if (host == null) { throw new ArgumentNullException("host"); } ToolboxItemContainer selectedItemContainer = this.SelectedItemContainer; if (selectedItemContainer != null) { return(selectedItemContainer.GetToolboxItem(this.GetCreatorCollection(host))); } return(null); }
void IToolboxService.AddLinkedToolboxItem(ToolboxItem toolboxItem, IDesignerHost host) { if (toolboxItem == null) { throw new ArgumentNullException("toolboxItem"); } if (host == null) { throw new ArgumentNullException("host"); } ToolboxItemContainer container = this.CreateItemContainer(toolboxItem, host); if (container != null) { this.GetItemContainers(this.SelectedCategory).Add(container); } }
ToolboxItem IToolboxService.DeserializeToolboxItem(object serializedObject) { if (serializedObject == null) { throw new ArgumentNullException("serializedObject"); } IDataObject dataObject = serializedObject as IDataObject; if (dataObject == null) { dataObject = new DataObject(serializedObject); } ToolboxItemContainer container = this.CreateItemContainer(dataObject); if (container != null) { return(container.GetToolboxItem(this.GetCreatorCollection(null))); } return(null); }
bool IToolboxService.IsSupported(object serializedObject, IDesignerHost host) { if (serializedObject == null) { throw new ArgumentNullException("serializedObject"); } if (host == null) { throw new ArgumentNullException("host"); } IDataObject dataObject = serializedObject as IDataObject; if (dataObject == null) { dataObject = new DataObject(serializedObject); } if (!this.IsItemContainer(dataObject, host)) { return(false); } ToolboxItemContainer container = this.CreateItemContainer(dataObject); return(this.IsItemContainerSupported(container, host)); }
protected virtual bool IsItemContainer(IDataObject dataObject, IDesignerHost host) { if (dataObject == null) { throw new ArgumentNullException("dataObject"); } if (ToolboxItemContainer.ContainsFormat(dataObject)) { return(true); } ICollection creatorCollection = this.GetCreatorCollection(host); if (creatorCollection != null) { foreach (ToolboxItemCreator creator in creatorCollection) { if (dataObject.GetDataPresent(creator.Format)) { return(true); } } } return(false); }
/// <summary> /// Given a toolbox item "unique ID" and a data format identifier, returns the content of /// the data format. /// </summary> /// <param name="itemId">The unique ToolboxItem to retrieve data for</param> /// <param name="format">The desired format of the resulting data</param> public virtual object GetToolboxItemData(string itemId, DataFormats.Format format) { DslDesign::ModelingToolboxItem item = null; global::System.Resources.ResourceManager resourceManager = global::Microsoft.Practices.ServiceFactory.HostDesigner.HostDesignerDomainModel.SingletonResourceManager; global::System.Globalization.CultureInfo resourceCulture = global::System.Globalization.CultureInfo.CurrentUICulture; System.Windows.Forms.IDataObject tbxDataObj; //get the toolbox item item = GetToolboxItem(itemId); if (item != null) { ToolboxItemContainer container = new ToolboxItemContainer(item); tbxDataObj = container.ToolboxData; if (tbxDataObj.GetDataPresent(format.Name)) { return tbxDataObj.GetData(format.Name); } else { string invalidFormatString = resourceManager.GetString("UnsupportedToolboxFormat", resourceCulture); throw new InvalidOperationException(string.Format(resourceCulture, invalidFormatString, format.Name)); } } string errorFormatString = resourceManager.GetString("UnresolvedToolboxItem", resourceCulture); throw new InvalidOperationException(string.Format(resourceCulture, errorFormatString, itemId)); }
protected bool IsItemContainerSupported(ToolboxItemContainer container, IDesignerHost host) { throw new NotImplementedException(); }
protected bool IsItemContainerSupported (ToolboxItemContainer container, IDesignerHost host) { throw new NotImplementedException (); }
/// <include file='doc\Package.uex' path='docs/doc[@for="Package.GetToolboxItemData"]' /> /// <devdoc> /// Given a toolbox item "unique ID" and a data format identifier, returns the content of /// the data format. If this is not implemented, the shell will fall back to a call to /// IVsPackage.ResetDefaults (which invokes the ToolboxInitialized or ToolboxUpgraded /// event). /// </devdoc> protected virtual object GetToolboxItemData(string itemId, DataFormats.Format format) { if (string.IsNullOrEmpty(itemId)) { throw new ArgumentNullException("itemId"); } // Try cache first System.Windows.Forms.IDataObject tbxDataObj; if (_tbxItemDataCache.TryGetValue(itemId, out tbxDataObj)) { if (tbxDataObj.GetDataPresent(format.Name)) { return tbxDataObj.GetData(format.Name); } else { throw new InvalidOperationException(string.Format(Resources.Culture, Resources.Toolbox_UnsupportedFormat, format.Name)); } } string typeName; string assemblyName; int idx = itemId.IndexOf(","); if (idx == -1) { Debug.Fail("Invalid toolbox item ID: " + itemId); throw new InvalidOperationException(string.Format(Resources.Culture, Resources.Toolbox_InvalidItemId, itemId)); } else { typeName = itemId.Substring(0, idx).Trim(); assemblyName = itemId.Substring(idx + 1).Trim(); } if (assemblyName.IndexOf(",") == -1) { // Must use the assembly enumeration service to locate the assembly. Microsoft.VisualStudio.AssemblyEnumerationService enumSvc = new Microsoft.VisualStudio.AssemblyEnumerationService(this); foreach (AssemblyName an in enumSvc.GetAssemblyNames(assemblyName)) { assemblyName = an.FullName; break; } } Assembly a = Assembly.Load(assemblyName); Debug.Assert(a != null, "Assembly " + assemblyName + " not found on machine"); if (a != null) { Type t = a.GetType(typeName); Debug.Assert(t != null, "Type " + itemId + " not found on machine"); if (t != null) { ToolboxItem item = ToolboxService.GetToolboxItem(t); Debug.Assert(item != null, "Tool " + assemblyName + ":" + itemId + " does not offer a toolbox item"); if (item != null) { ToolboxItemContainer container = new ToolboxItemContainer(item); tbxDataObj = container.ToolboxData; // Missed in cache, so save it in cache now _tbxItemDataCache.Add(itemId, tbxDataObj); if (tbxDataObj.GetDataPresent(format.Name)) { return tbxDataObj.GetData(format.Name); } else { throw new InvalidOperationException(string.Format(Resources.Culture, Resources.Toolbox_UnsupportedFormat, format.Name)); } } } } throw new InvalidOperationException(string.Format(Resources.Culture, Resources.Toolbox_ItemNotFound, itemId)); }
protected bool IsItemContainerSupported(ToolboxItemContainer container, IDesignerHost host) { throw null; }