本文整理汇总了C#中IDesignerHost.DestroyComponent方法的典型用法代码示例。如果您正苦于以下问题:C# IDesignerHost.DestroyComponent方法的具体用法?C# IDesignerHost.DestroyComponent怎么用?C# IDesignerHost.DestroyComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDesignerHost
的用法示例。
在下文中一共展示了IDesignerHost.DestroyComponent方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Transaction_RemovePage
private object Transaction_RemovePage(IDesignerHost theHost, object theParam)
{
if (this.mySelectedPage != null)
{
MemberDescriptor member = TypeDescriptor.GetProperties(this.DesignedControl)["Controls"];
base.RaiseComponentChanging(member);
try
{
theHost.DestroyComponent(this.mySelectedPage);
}
catch
{
}
base.RaiseComponentChanged(member, null, null);
}
return null;
}
示例2: DestroyInstance
/// <summary>
/// Destroy instance of an object using the provided designer host.
/// </summary>
/// <param name="instance">Reference to item for destroying.</param>
/// <param name="host">Designer host used if provided.</param>
public static void DestroyInstance(object instance, IDesignerHost host)
{
IComponent component = instance as IComponent;
if (component != null)
{
// Use designer to remove component if possible
if (host != null)
host.DestroyComponent(component);
else
component.Dispose();
}
else
{
// Fallback to calling any exposed dispose method
IDisposable disposable = instance as IDisposable;
if (disposable != null)
disposable.Dispose();
}
}
示例3: Transaction_RemoveTab
private object Transaction_RemoveTab(IDesignerHost host, object parameter)
{
// Tab Control
NeoTabWindow tabControl = (NeoTabWindow)parameter;
MemberDescriptor md = TypeDescriptor.GetProperties(tabControl)["Controls"];
RaiseComponentChanging(md);
host.DestroyComponent(tabControl.SelectedTab);
RaiseComponentChanged(md, null, null);
return parameter;
}
示例4: RemoveRecursive
public void RemoveRecursive(IContainsRibbonComponents item, IDesignerHost service)
{
if (item == null || service == null) return;
foreach (Component c in item.GetAllChildComponents())
{
if (c is IContainsRibbonComponents)
{
RemoveRecursive(c as IContainsRibbonComponents, service);
}
service.DestroyComponent(c);
}
}
示例5: CreateComponentsCore
/// <include file='doc\ToolboxItem.uex' path='docs/doc[@for="ToolboxItem.CreateComponentsCore1"]/*' />
/// <devdoc>
/// Creates objects from the type contained in this toolbox item. If designerHost is non-null
/// this will also add them to the designer.
/// </devdoc>
protected virtual IComponent[] CreateComponentsCore(IDesignerHost host, IDictionary defaultValues) {
IComponent[] components = CreateComponentsCore(host);
if (host != null) {
for (int i = 0; i < components.Length; i++) {
IComponentInitializer init = host.GetDesigner(components[i]) as IComponentInitializer;
if (init != null) {
bool removeComponent = true;
try {
init.InitializeNewComponent(defaultValues);
removeComponent = false;
}
finally
{
if (removeComponent) {
for (int index = 0; index < components.Length; index++) {
host.DestroyComponent(components[index]);
}
}
}
}
}
}
return components;
}
示例6: Transaction_RemovePage
private object Transaction_RemovePage(IDesignerHost theHost, object theParam)
{
if (mySelectedPage == null)
return null;
MultiPaneControl aCtl = DesignedControl;
MemberDescriptor aMember_Controls = TypeDescriptor.GetProperties(aCtl)["Controls"];
RaiseComponentChanging(aMember_Controls);
try
{
theHost.DestroyComponent(mySelectedPage);
// NOTE: we don't process anything here because processing will
// be performed in Handler_ComponentRemoving
}
catch { }
RaiseComponentChanged(aMember_Controls, null, null);
return null;
}
示例7: DestroySubItems
protected virtual void DestroySubItems(BaseItem parent, IDesignerHost dh)
{
if(parent is ControlContainerItem)
{
if(((ControlContainerItem)parent).Control!=null)
{
Control c=((ControlContainerItem)parent).Control;
((ControlContainerItem)parent).Control=null;
dh.DestroyComponent(c);
}
}
else if(parent is DockContainerItem)
{
if(((DockContainerItem)parent).Control!=null)
{
Control c=((DockContainerItem)parent).Control;
((DockContainerItem)parent).Control=null;
dh.DestroyComponent(c);
}
}
BaseItem[] subitems=new BaseItem[parent.SubItems.Count];
parent.SubItems.CopyTo(subitems,0);
foreach(BaseItem item in subitems)
{
DestroySubItems(item,dh);
dh.DestroyComponent(item);
}
}
示例8: DestroyComponent
/// <summary>
/// Destroys the component
/// </summary>
/// <param name="oDesignerHost">The designer instance interface</param>
internal void DestroyComponent(IDesignerHost oDesignerHost)
{
// destroy subnodes
foreach (Node oSubNode in Nodes.ToNodeArray())
oSubNode.DestroyComponent(oDesignerHost);
if (this.Panel != null)
{
if (GetTreeView() != null)
GetTreeView().Controls.Remove(this.Panel);
oDesignerHost.DestroyComponent(this.Panel);
this.Panel = null;
}
// destroys the component
oDesignerHost.DestroyComponent(this);
}
示例9: DestroyComponentNoRemove
/// <summary>
/// Destroys the component
/// </summary>
/// <param name="oDesignerHost">The designer instance interface</param>
internal void DestroyComponentNoRemove(IDesignerHost oDesignerHost)
{
// destroy subnodes
Node [] aNodes = Nodes.ToNodeArray();
foreach (Node oNode in aNodes)
oNode.DestroyComponentNoRemove(oDesignerHost);
// destroys the component
oDesignerHost.DestroyComponent(this);
}
示例10: DeletePage
internal static void DeletePage(WizardPage page, IDesignerHost dh, IComponentChangeService cc)
{
if (page == null || !(page.Parent is Wizard))
return;
Wizard w = page.Parent as Wizard;
DesignerTransaction dt = dh.CreateTransaction();
try
{
if (cc != null)
cc.OnComponentChanging(w, TypeDescriptor.GetProperties(w)["WizardPages"]);
w.WizardPages.Remove(page);
if (cc != null)
cc.OnComponentChanged(w, TypeDescriptor.GetProperties(w)["WizardPages"], null, null);
dh.DestroyComponent(page);
}
catch
{
dt.Cancel();
}
finally
{
if (!dt.Canceled)
dt.Commit();
}
}
示例11: DestroyObjectGraphFromDesignerHost
internal static void DestroyObjectGraphFromDesignerHost(IDesignerHost designerHost, Activity activity)
{
if (designerHost == null)
throw new ArgumentNullException("designerHost");
if (activity == null)
throw new ArgumentNullException("activity");
designerHost.DestroyComponent(activity);
if (activity is CompositeActivity)
{
foreach (Activity activity2 in GetNestedActivities(activity as CompositeActivity))
designerHost.DestroyComponent(activity2);
}
}
示例12: DeletePage
internal static void DeletePage(WizardPage page, IDesignerHost dh, IComponentChangeService cc)
{
if (page == null || !(page.Parent is PageSlider))
return;
PageSlider slider = (PageSlider)page.Parent;
DesignerTransaction dt = dh.CreateTransaction("Deleting page");
try
{
if (cc != null)
cc.OnComponentChanging(slider, TypeDescriptor.GetProperties(slider)["Controls"]);
slider.Controls.Remove(page);
if (cc != null)
cc.OnComponentChanged(slider, TypeDescriptor.GetProperties(slider)["Controls"], null, null);
dh.DestroyComponent(page);
}
catch
{
dt.Cancel();
}
finally
{
if (!dt.Canceled)
dt.Commit();
}
}
示例13: RemoveFromDesigner
public void RemoveFromDesigner(IDesignerHost designer, Activity workflow)
{
if (workflow != null)
{
designer.DestroyComponent(workflow);
if (workflow is CompositeActivity)
{
List<Activity> children = new List<Activity>();
GetChildActivities(workflow as CompositeActivity, children);
foreach (Activity child in children)
{
designer.DestroyComponent(child);
}
}
}
}
示例14: CreateComponentsCore
protected virtual IComponent[] CreateComponentsCore(IDesignerHost host, IDictionary defaultValues)
{
IComponent[] componentArray = this.CreateComponentsCore(host);
if (host != null)
{
for (int i = 0; i < componentArray.Length; i++)
{
IComponentInitializer designer = host.GetDesigner(componentArray[i]) as IComponentInitializer;
if (designer != null)
{
bool flag = true;
try
{
designer.InitializeNewComponent(defaultValues);
flag = false;
}
finally
{
if (flag)
{
for (int j = 0; j < componentArray.Length; j++)
{
host.DestroyComponent(componentArray[j]);
}
}
}
}
}
}
return componentArray;
}