private ToolboxItemCreatorCallback FindToolboxItemCreator(IDataObject dataObj, IDesignerHost host, out string foundFormat) { foundFormat = string.Empty; ToolboxItemCreatorCallback creator = null; if (customCreators != null) { IEnumerator keys = customCreators.Keys.GetEnumerator(); while (keys.MoveNext()) { string key = (string)keys.Current; string[] keyParts = key.Split(new char[] { ',' }); string format = keyParts[0]; if (dataObj.GetDataPresent(format)) { // Check to see if the host matches. if (keyParts.Length == 1 || (host != null && host.GetHashCode().ToString().Equals(keyParts[1]))) { creator = (ToolboxItemCreatorCallback)customCreators[format]; foundFormat = format; break; } } } } return(creator); }
public bool IsToolboxItem(object data, IDesignerHost host) { IDataObject dataObject = data as IDataObject; if (dataObject == null) { return(false); } if (dataObject.GetDataPresent(typeof(ToolboxItem))) { return(true); } else { string format; ToolboxItemCreatorCallback creator = FindToolboxItemCreator(dataObject, host, out format); if (creator != null) { return(true); } } return(false); }
// Adds a "Text" data format creator to the toolbox that creates // a textbox from a text fragment pasted to the toolbox. private void AddTextTextBoxCreator() { ts = (IToolboxService)GetService(typeof(IToolboxService)); if (ts != null) { ToolboxItemCreatorCallback textCreator = new ToolboxItemCreatorCallback(this.CreateTextBoxForText); try { ts.AddCreator( textCreator, "Text", (IDesignerHost)GetService(typeof(IDesignerHost))); creatorAdded = true; } catch (Exception ex) { MessageBox.Show( ex.ToString(), "Exception Information"); } } }
public void AddCreator(ToolboxItemCreatorCallback creator, string format, IDesignerHost host) { if (creator == null || format == null) { throw new ArgumentNullException(creator == null ? "creator" : "format"); } if (customCreators == null) { customCreators = new Hashtable(); } else { string key = format; if (host != null) { key += ", " + host.GetHashCode().ToString(); } if (customCreators.ContainsKey(key)) { throw new Exception("There is already a creator registered for the format '" + format + "'."); } } customCreators[format] = creator; }
void IToolboxService.AddCreator(ToolboxItemCreatorCallback creator, string format, IDesignerHost host) { if (creator == null) { throw new ArgumentNullException("creator"); } if (format == null) { throw new ArgumentNullException("format"); } if (host == null) { throw new ArgumentNullException("host"); } if (this._designerCreators == null) { this._designerCreators = new Hashtable(); } ArrayList list = this._designerCreators[host] as ArrayList; if (list == null) { list = new ArrayList(4); this._designerCreators[host] = list; } list.Add(new ToolboxItemCreator(creator, format)); this._lastMergedHost = null; this._lastMergedCreators = null; }
/// <summary> /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed. /// <example> /// toolboxitemcreatorcallback.BeginInvoke(serializedObject, format, callback); /// </example> /// </summary> public static IAsyncResult BeginInvoke(this ToolboxItemCreatorCallback toolboxitemcreatorcallback, Object serializedObject, String format, AsyncCallback callback) { if (toolboxitemcreatorcallback == null) { throw new ArgumentNullException("toolboxitemcreatorcallback"); } return(toolboxitemcreatorcallback.BeginInvoke(serializedObject, format, callback, null)); }
public void AddCreator(ToolboxItemCreatorCallback creator, string format, IDesignerHost host) { if (host == null) { this.creators.Add(format, creator); } else { IDictionary dictionary = (IDictionary)this.creatorsByHost[host]; if (dictionary == null) { dictionary = new HybridDictionary(); this.creatorsByHost.Add(host, dictionary); } dictionary[format] = creator; } }
void IToolboxService.AddCreator(ToolboxItemCreatorCallback creator, string format) { if (creator == null) { throw new ArgumentNullException("creator"); } if (format == null) { throw new ArgumentNullException("format"); } if (this._globalCreators == null) { this._globalCreators = new ArrayList(); } this._globalCreators.Add(new ToolboxItemCreator(creator, format)); this._lastMergedHost = null; this._lastMergedCreators = null; }
/// <summary> /// Adds a new toolbox item creator. /// </summary> /// <param name="creator"> /// A <see cref="System.Drawing.Design.ToolboxItemCreatorCallback"> /// that can create a component when the toolbox item /// is invoked. </param> /// <param name="format"> /// The data format this creator responds to. If a creator responds /// to more than one format, call AddCreator more than once. It is /// an error to add more than one creator for the same format. /// </param> /// <param name="host"> /// The designer host to associate with the creator. If this parameter /// is set to a null reference (Nothing in Visual Basic), this creator /// will be available to all designers. If a designer host is supplied, /// the creator will only be available to designers using the specified /// host. /// </param> /// <remarks> /// A toolbox item creator is used to handle data formats other than /// the standard native format of the toolbox service. Typically, the /// standard toolbox service format should be used, because it provides /// ample opportunity for customization in an object-oriented way. /// However, there are times when a legacy data format may need to be /// supported. A toolbox item creator is the mechanism by which these /// legacy data formats may be converted into toolbox items. /// <para> /// This implemetation does add the specified creator to a collection, /// but at this time I have no idea what to do with it! /// </para> /// </remarks> public void AddCreator(ToolboxItemCreatorCallback creator, string format, IDesignerHost host) { LoggingService.DebugFormatted("\tDefaultToolboxService:AddCreator({0}, {1}, {2})", creator, format, host); if (host == null) { creators.Add(format, creator); } else { IDictionary creatorsDict = (IDictionary)creatorsByHost[host]; if (creatorsDict == null) { creatorsDict = new HybridDictionary(); creatorsByHost.Add(host, creatorsDict); } creatorsDict[format] = creator; } }
public ToolboxItem DeserializeToolboxItem(object data, IDesignerHost host) { IDataObject dataObject = data as IDataObject; if (dataObject == null) { return(null); } ToolboxItem t = (ToolboxItem)dataObject.GetData(typeof(ToolboxItem)); if (t == null) { string format; ToolboxItemCreatorCallback creator = FindToolboxItemCreator(dataObject, host, out format); if (creator != null) { return(creator(dataObject, format)); } } return(t); }
public override void Initialize(IComponent component) { this.initializing = true; base.Initialize(component); this.initializing = false; PropertyDescriptor descriptor = TypeDescriptor.GetProperties(base.Component.GetType())["BackColor"]; if (((descriptor != null) && (descriptor.PropertyType == typeof(System.Drawing.Color))) && !descriptor.ShouldSerializeValue(base.Component)) { this.Control.BackColor = SystemColors.Control; } IDesignerHost serviceProvider = (IDesignerHost) this.GetService(typeof(IDesignerHost)); IExtenderProviderService ex = (IExtenderProviderService) this.GetService(typeof(IExtenderProviderService)); if (ex != null) { this.designerExtenders = new DesignerExtenders(ex); } if (serviceProvider != null) { serviceProvider.Activated += new EventHandler(this.OnDesignerActivate); serviceProvider.Deactivated += new EventHandler(this.OnDesignerDeactivate); ServiceCreatorCallback callback = new ServiceCreatorCallback(this.OnCreateService); serviceProvider.AddService(typeof(IEventHandlerService), callback); this.frame = new DesignerFrame(component.Site); IOverlayService frame = this.frame; serviceProvider.AddService(typeof(IOverlayService), frame); serviceProvider.AddService(typeof(ISplitWindowService), this.frame); this.behaviorService = new BehaviorService(base.Component.Site, this.frame); serviceProvider.AddService(typeof(BehaviorService), this.behaviorService); this.selectionManager = new SelectionManager(serviceProvider, this.behaviorService); serviceProvider.AddService(typeof(SelectionManager), this.selectionManager); serviceProvider.AddService(typeof(ToolStripAdornerWindowService), callback); IComponentChangeService service = (IComponentChangeService) this.GetService(typeof(IComponentChangeService)); if (service != null) { service.ComponentAdded += new ComponentEventHandler(this.OnComponentAdded); service.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged); service.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemoved); } this.inheritanceUI = new InheritanceUI(); serviceProvider.AddService(typeof(InheritanceUI), this.inheritanceUI); InheritanceService serviceInstance = new DocumentInheritanceService(this); serviceProvider.AddService(typeof(IInheritanceService), serviceInstance); manager = serviceProvider.GetService(typeof(IDesignerSerializationManager)) as IDesignerSerializationManager; serviceInstance.AddInheritedComponents(component, component.Site.Container); manager = null; this.inheritanceService = serviceInstance; if (this.Control.IsHandleCreated) { this.OnCreateHandle(); } IPropertyValueUIService service5 = (IPropertyValueUIService) component.Site.GetService(typeof(IPropertyValueUIService)); if (service5 != null) { this.designBindingValueUIHandler = new DesignBindingValueUIHandler(); service5.AddPropertyValueUIHandler(new PropertyValueUIHandler(this.designBindingValueUIHandler.OnGetUIValueItem)); } IToolboxService service6 = (IToolboxService) serviceProvider.GetService(typeof(IToolboxService)); if (service6 != null) { this.toolboxCreator = new ToolboxItemCreatorCallback(this.OnCreateToolboxItem); service6.AddCreator(this.toolboxCreator, axClipFormat, serviceProvider); service6.AddCreator(this.toolboxCreator, OleDragDropHandler.DataFormat, serviceProvider); service6.AddCreator(this.toolboxCreator, OleDragDropHandler.NestedToolboxItemFormat, serviceProvider); } serviceProvider.LoadComplete += new EventHandler(this.OnLoadComplete); } this.commandSet = new ControlCommandSet(component.Site); this.frame.Initialize(this.Control); this.pbrsFwd = new PbrsForward(this.frame, component.Site); this.Location = new Point(0, 0); }
public void AddCreator(ToolboxItemCreatorCallback creator, string format) { AddCreator(creator, format, null); }
public void AddCreator(ToolboxItemCreatorCallback cb, String str) { //Console.WriteLine("TBS:addCreator "); }
public void AddCreator(ToolboxItemCreatorCallback creator, string format, IDesignerHost host) { // System.Console.WriteLine(" AddCreator for"); // System.Console.WriteLine("\t {0} / {1} / {2}",creator.ToString(),format,host.ToString()); }
public void AddCreator(ToolboxItemCreatorCallback creator, string format, IDesignerHost host) { }
public void AddCreator(ToolboxItemCreatorCallback creator, string format, IDesignerHost host) { // System.Console.WriteLine(" AddCreator for"); // System.Console.WriteLine("\t {0} / {1} / {2}",creator.ToString(),format,host.ToString()); }
/// <summary> /// Adds a new toolbox item creator. /// </summary> /// <param name="creator"> /// A <see cref="System.Drawing.Design.ToolboxItemCreatorCallback"> /// that can create a component when the toolbox item /// is invoked. </param> /// <param name="format"> /// The data format this creator responds to. If a creator responds /// to more than one format, call AddCreator more than once. It is /// an error to add more than one creator for the same format. /// </param> /// <param name="host"> /// The designer host to associate with the creator. If this parameter /// is set to a null reference (Nothing in Visual Basic), this creator /// will be available to all designers. If a designer host is supplied, /// the creator will only be available to designers using the specified /// host. /// </param> /// <remarks> /// A toolbox item creator is used to handle data formats other than /// the standard native format of the toolbox service. Typically, the /// standard toolbox service format should be used, because it provides /// ample opportunity for customization in an object-oriented way. /// However, there are times when a legacy data format may need to be /// supported. A toolbox item creator is the mechanism by which these /// legacy data formats may be converted into toolbox items. /// <para> /// This implemetation does add the specified creator to a collection, /// but at this time I have no idea what to do with it! /// </para> /// </remarks> public void AddCreator(ToolboxItemCreatorCallback creator, string format, IDesignerHost host) { LoggingService.DebugFormatted("\tDefaultToolboxService:AddCreator({0}, {1}, {2})", creator, format, host); if (host == null) { creators.Add(format, creator); } else { IDictionary creatorsDict = (IDictionary)creatorsByHost[host]; if (creatorsDict == null) { creatorsDict = new HybridDictionary(); creatorsByHost.Add(host, creatorsDict); } creatorsDict[format] =creator; } }
public void AddCreator(ToolboxItemCreatorCallback creator, string format) { AddCreator(creator, format, toolbox.GetDesignerHost()); }
void IToolboxService.AddCreator (ToolboxItemCreatorCallback creator, string format, IDesignerHost host) { throw new NotImplementedException (); }
public void AddCreator(ToolboxItemCreatorCallback creator, string format) { throw new NotImplementedException(); }
internal ToolboxItemCreator(ToolboxItemCreatorCallback callback, string format) { this._callback = callback; this._format = format; }
public void AddCreator(ToolboxItemCreatorCallback cb, String str) { //Console.WriteLine("TBS:addCreator "); }
public void AddCreator(ToolboxItemCreatorCallback creator, string format, IDesignerHost host) { if (creator == null || format == null) { throw new ArgumentNullException(creator == null ? "creator" : "format"); } if (customCreators == null) { customCreators = new Hashtable(); } else { string key = format; if (host != null) key += ", " + host.GetHashCode().ToString(); if (customCreators.ContainsKey(key)) { throw new Exception("There is already a creator registered for the format '" + format + "'."); } } customCreators[format] = creator; }
void IToolboxService.AddCreator(ToolboxItemCreatorCallback creator, string format, IDesignerHost host) { throw new NotImplementedException(); }
public void AddCreator(ToolboxItemCreatorCallback creator, string format) { }
public void AddCreator(ToolboxItemCreatorCallback creator, string format, IDesignerHost host) { // this method intentionally keep empty }
void IToolboxService.AddCreator(ToolboxItemCreatorCallback creator, string format) { }
public void AddCreator(ToolboxItemCreatorCallback creator, string format, IDesignerHost host) { throw new NotImplementedException( "Method not implemented"); }
public void AddCreator(ToolboxItemCreatorCallback creator, string format) { this.AddCreator(creator,format,null); }
public virtual void AddCreator(ToolboxItemCreatorCallback creator, string format, IDesignerHost host) { }
public virtual void AddCreator(ToolboxItemCreatorCallback creator, string format) { }
public void AddCreator (ToolboxItemCreatorCallback creator, string format, System.ComponentModel.Design.IDesignerHost host) { throw new NotImplementedException (); }
public void AddCreator(ToolboxItemCreatorCallback creator, string format, System.ComponentModel.Design.IDesignerHost host) { }
public void AddCreator(ToolboxItemCreatorCallback creator, string format, System.ComponentModel.Design.IDesignerHost host) { throw new NotImplementedException(); }
void IToolboxService.AddCreator(ToolboxItemCreatorCallback creator, string format) { }
public void AddCreator(ToolboxItemCreatorCallback creator, string format) { AddCreator(creator, format, toolbox.GetDesignerHost()); }
void IToolboxService.AddCreator(ToolboxItemCreatorCallback creator, string format, IDesignerHost host) { throw null; }
//- Add a creator that will convert non-standard tools in the specified format into ToolboxItems. void IToolboxService.AddCreator(ToolboxItemCreatorCallback creator, string format) { // UNIMPLEMENTED - We aren't handling any non-standard tools here. Our toolset is constant. //throw new NotImplementedException(); }
protected override void Dispose(bool disposing) { if (disposing) { IDesignerHost host = (IDesignerHost) this.GetService(typeof(IDesignerHost)); if (host != null) { ToolStripAdornerWindowService service = (ToolStripAdornerWindowService) this.GetService(typeof(ToolStripAdornerWindowService)); if (service != null) { service.Dispose(); host.RemoveService(typeof(ToolStripAdornerWindowService)); } host.Activated -= new EventHandler(this.OnDesignerActivate); host.Deactivated -= new EventHandler(this.OnDesignerDeactivate); if (this.componentTray != null) { ISplitWindowService service2 = (ISplitWindowService) this.GetService(typeof(ISplitWindowService)); if (service2 != null) { service2.RemoveSplitWindow(this.componentTray); this.componentTray.Dispose(); this.componentTray = null; } host.RemoveService(typeof(ComponentTray)); } IComponentChangeService service3 = (IComponentChangeService) this.GetService(typeof(IComponentChangeService)); if (service3 != null) { service3.ComponentAdded -= new ComponentEventHandler(this.OnComponentAdded); service3.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged); service3.ComponentRemoved -= new ComponentEventHandler(this.OnComponentRemoved); } if (this.undoEngine != null) { this.undoEngine.Undoing -= new EventHandler(this.OnUndoing); this.undoEngine.Undone -= new EventHandler(this.OnUndone); } if (this.toolboxCreator != null) { IToolboxService service4 = (IToolboxService) this.GetService(typeof(IToolboxService)); if (service4 != null) { service4.RemoveCreator(axClipFormat, host); service4.RemoveCreator(OleDragDropHandler.DataFormat, host); service4.RemoveCreator(OleDragDropHandler.NestedToolboxItemFormat, host); } this.toolboxCreator = null; } } if (this.menuEditorService != null) { host.RemoveService(typeof(IMenuEditorService)); this.menuEditorService = null; } ISelectionService service5 = (ISelectionService) this.GetService(typeof(ISelectionService)); if (service5 != null) { service5.SelectionChanged -= new EventHandler(this.OnSelectionChanged); } if (this.behaviorService != null) { this.behaviorService.Dispose(); this.behaviorService = null; } if (this.selectionManager != null) { this.selectionManager.Dispose(); this.selectionManager = null; } if (this.componentTray != null) { if (host != null) { ISplitWindowService service6 = (ISplitWindowService) this.GetService(typeof(ISplitWindowService)); if (service6 != null) { service6.RemoveSplitWindow(this.componentTray); } } this.componentTray.Dispose(); this.componentTray = null; } if (this.pbrsFwd != null) { this.pbrsFwd.Dispose(); this.pbrsFwd = null; } if (this.frame != null) { this.frame.Dispose(); this.frame = null; } if (this.commandSet != null) { this.commandSet.Dispose(); this.commandSet = null; } if (this.inheritanceService != null) { this.inheritanceService.Dispose(); this.inheritanceService = null; } if (this.inheritanceUI != null) { this.inheritanceUI.Dispose(); this.inheritanceUI = null; } if (this.designBindingValueUIHandler != null) { IPropertyValueUIService service7 = (IPropertyValueUIService) this.GetService(typeof(IPropertyValueUIService)); if (service7 != null) { service7.RemovePropertyValueUIHandler(new PropertyValueUIHandler(this.designBindingValueUIHandler.OnGetUIValueItem)); service7 = null; } this.designBindingValueUIHandler.Dispose(); this.designBindingValueUIHandler = null; } if (this.designerExtenders != null) { this.designerExtenders.Dispose(); this.designerExtenders = null; } if (this.axTools != null) { this.axTools.Clear(); } if (host != null) { host.RemoveService(typeof(BehaviorService)); host.RemoveService(typeof(ToolStripAdornerWindowService)); host.RemoveService(typeof(SelectionManager)); host.RemoveService(typeof(IInheritanceService)); host.RemoveService(typeof(IEventHandlerService)); host.RemoveService(typeof(IOverlayService)); host.RemoveService(typeof(ISplitWindowService)); host.RemoveService(typeof(InheritanceUI)); } } base.Dispose(disposing); }
internal ToolboxItemCreator(ToolboxItemCreatorCallback callback, string format) { this._callback = callback; this._format = format; }
public void AddCreator(ToolboxItemCreatorCallback creator, string format) { throw new NotImplementedException(); }
public void AddCreator(ToolboxItemCreatorCallback creator, string format, IDesignerHost host) { toolbox.AddCreator(creator, format, host); }