当前位置: 首页>>代码示例>>C#>>正文


C# IDesignerHost.GetDesigner方法代码示例

本文整理汇总了C#中IDesignerHost.GetDesigner方法的典型用法代码示例。如果您正苦于以下问题:C# IDesignerHost.GetDesigner方法的具体用法?C# IDesignerHost.GetDesigner怎么用?C# IDesignerHost.GetDesigner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDesignerHost的用法示例。


在下文中一共展示了IDesignerHost.GetDesigner方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SelectWizard

 private static void SelectWizard(IComponent wizardControl, IDesignerHost host)
 {
     if (wizardControl == null)
     {
         return;
     }
     if (host == null)
     {
         return;
     }
     while (true)
     {
         WizardDesigner designer = (WizardDesigner) host.GetDesigner(wizardControl);
         if (designer == null)
         {
             return;
         }
         ISelectionService service = (ISelectionService) host.GetService(typeof (ISelectionService));
         if (service == null)
         {
             return;
         }
         object[] components = new object[] {wizardControl};
         service.SetSelectedComponents(components, SelectionTypes.Replace);
         return;
     }
 }
开发者ID:amedinarcr,项目名称:fop,代码行数:27,代码来源:WizardStepCollectionEditor.cs

示例2: AddChildComponents

 private void AddChildComponents(IComponent component, IContainer container, IDesignerHost host)
 {
     Control control = this.GetControl(component);
     if (control != null)
     {
         Control control2 = control;
         Control[] array = new Control[control2.Controls.Count];
         control2.Controls.CopyTo(array, 0);
         IContainer container2 = null;
         for (int i = 0; i < array.Length; i++)
         {
             ISite site = array[i].Site;
             if (site != null)
             {
                 string name = site.Name;
                 if (container.Components[name] != null)
                 {
                     name = null;
                 }
                 container2 = site.Container;
                 if (container2 != null)
                 {
                     container2.Remove(array[i]);
                 }
                 if (name != null)
                 {
                     container.Add(array[i], name);
                 }
                 else
                 {
                     container.Add(array[i]);
                 }
                 if (array[i].Parent != control2)
                 {
                     control2.Controls.Add(array[i]);
                 }
                 else
                 {
                     int childIndex = control2.Controls.GetChildIndex(array[i]);
                     control2.Controls.Remove(array[i]);
                     control2.Controls.Add(array[i]);
                     control2.Controls.SetChildIndex(array[i], childIndex);
                 }
                 IComponentInitializer designer = host.GetDesigner(component) as IComponentInitializer;
                 if (designer != null)
                 {
                     designer.InitializeExistingComponent(null);
                 }
                 this.AddChildComponents(array[i], container, host);
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:53,代码来源:ParentControlDesigner.cs

示例3: 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;
        }
开发者ID:salim18,项目名称:DemoProject2,代码行数:34,代码来源:ToolboxItem.cs

示例4: CreateComponentsCore

		protected virtual IComponent[] CreateComponentsCore (IDesignerHost host, IDictionary defaultValues)
		{
			IComponent[] components = CreateComponentsCore (host);
			foreach (Component c in components) {
				IComponentInitializer initializer = host.GetDesigner (c) as IComponentInitializer;
				initializer.InitializeNewComponent (defaultValues);
			}
			return components;
		} 
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:9,代码来源:ToolboxItem.cs

示例5: SerializeDesignerStates

        internal static void SerializeDesignerStates(IDesignerHost designerHost, BinaryWriter writer)
        {
            writer.Write(designerHost.Container.Components.Count);
            foreach (IComponent component in designerHost.Container.Components)
            {
                // write activity identifier
                writer.Write(component.Site.Name);

                //placeholder for length
                int activityDataLengthPosition = (int)writer.BaseStream.Length;

                writer.Write((int)0);

                ActivityDesigner designer = designerHost.GetDesigner(component) as ActivityDesigner;

                if (designer != null)
                {
                    int activityDataPosition = (int)writer.BaseStream.Length;

                    // write activity data
                    ((IPersistUIState)designer).SaveViewState(writer);

                    // place length
                    writer.Seek(activityDataLengthPosition, SeekOrigin.Begin);
                    writer.Write((int)writer.BaseStream.Length - activityDataPosition);
                    writer.Seek(0, SeekOrigin.End);
                }
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:29,代码来源:DesignerHelpers.cs

示例6: DeserializeDesignerStates

 internal static bool DeserializeDesignerStates(IDesignerHost designerHost, BinaryReader reader)
 {
     int num = reader.ReadInt32();
     bool flag = num != designerHost.Container.Components.Count;
     for (int i = 0; i < num; i++)
     {
         string str = reader.ReadString();
         int num3 = reader.ReadInt32();
         if (designerHost.Container.Components[str] != null)
         {
             ActivityDesigner designer = designerHost.GetDesigner(designerHost.Container.Components[str]) as ActivityDesigner;
             if (designer != null)
             {
                 ((IPersistUIState) designer).LoadViewState(reader);
             }
             else
             {
                 flag = true;
                 Stream baseStream = reader.BaseStream;
                 baseStream.Position += num3;
             }
         }
         else
         {
             flag = true;
             Stream stream2 = reader.BaseStream;
             stream2.Position += num3;
         }
     }
     return flag;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:31,代码来源:DesignerHelpers.cs

示例7: IsSupportedBy

        //utility, gets a root designer from an IDesignerHost and calls IsSupportedBy (object) on it
        public virtual bool IsSupportedBy(IDesignerHost host)
        {
            if (host == null)
                throw new ArgumentException ("IDesignerHost must not be null.");
            IComponent comp = host.RootComponent;
            if (comp == null)
                throw new ArgumentException ("Host does not have a root component.");
            IDesigner des = host.GetDesigner (comp);
            if (des == null)
                throw new ArgumentException ("Host does not have a root designer.");

            return IsSupportedBy (des);
        }
开发者ID:mono,项目名称:aspeditor,代码行数:14,代码来源:ItemToolboxNode.cs

示例8: CreateComponentsCore

 protected override IComponent[] CreateComponentsCore(IDesignerHost host, IDictionary defaultValues)
 {
     Control control;
     IDesignerSerializationService service = (IDesignerSerializationService) host.GetService(typeof(IDesignerSerializationService));
     if (service == null)
     {
         return null;
     }
     ICollection is2 = service.Deserialize(this.serializationData);
     ArrayList list = new ArrayList();
     foreach (object obj2 in is2)
     {
         if ((obj2 != null) && (obj2 is IComponent))
         {
             list.Add(obj2);
         }
     }
     IComponent[] array = new IComponent[list.Count];
     list.CopyTo(array, 0);
     ArrayList components = null;
     if (defaultValues == null)
     {
         defaultValues = new Hashtable();
     }
     control = control = defaultValues["Parent"] as Control;
     if (control != null)
     {
         ParentControlDesigner designer = host.GetDesigner(control) as ParentControlDesigner;
         if (designer != null)
         {
             Rectangle empty = Rectangle.Empty;
             foreach (IComponent component in array)
             {
                 Control control2 = component as Control;
                 if (((control2 != null) && (control2 != control)) && (control2.Parent == null))
                 {
                     if (empty.IsEmpty)
                     {
                         empty = control2.Bounds;
                     }
                     else
                     {
                         empty = Rectangle.Union(empty, control2.Bounds);
                     }
                 }
             }
             defaultValues.Remove("Size");
             foreach (IComponent component2 in array)
             {
                 Control newChild = component2 as Control;
                 Form form = newChild as Form;
                 if (((newChild != null) && ((form == null) || !form.TopLevel)) && (newChild.Parent == null))
                 {
                     defaultValues["Offset"] = new Size(newChild.Bounds.X - empty.X, newChild.Bounds.Y - empty.Y);
                     designer.AddControl(newChild, defaultValues);
                 }
             }
         }
     }
     ComponentTray tray = (ComponentTray) host.GetService(typeof(ComponentTray));
     if (tray != null)
     {
         foreach (IComponent component3 in array)
         {
             ComponentTray.TrayControl trayControlFromComponent = tray.GetTrayControlFromComponent(component3);
             if (trayControlFromComponent != null)
             {
                 if (components == null)
                 {
                     components = new ArrayList();
                 }
                 components.Add(trayControlFromComponent);
             }
         }
         if (components != null)
         {
             tray.UpdatePastePositions(components);
         }
     }
     return array;
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:81,代码来源:OleDragDropHandler.cs

示例9: Initialize

 private void Initialize(ArrayList dragComponents, IDesignerHost host)
 {
     Control c = null;
     if ((dragComponents != null) && (dragComponents.Count > 0))
     {
         c = dragComponents[0] as Control;
     }
     Control rootComponent = host.RootComponent as Control;
     Rectangle clipBounds = new Rectangle(0, 0, rootComponent.ClientRectangle.Width, rootComponent.ClientRectangle.Height);
     clipBounds.Inflate(-1, -1);
     if (c != null)
     {
         this.dragOffset = this.behaviorService.ControlToAdornerWindow(c);
     }
     else
     {
         this.dragOffset = this.behaviorService.MapAdornerWindowPoint(rootComponent.Handle, Point.Empty);
         if ((rootComponent.Parent != null) && rootComponent.Parent.IsMirrored)
         {
             this.dragOffset.Offset(-rootComponent.Width, 0);
         }
     }
     if (c != null)
     {
         ControlDesigner controlDesigner = host.GetDesigner(c) as ControlDesigner;
         bool flag = false;
         if (controlDesigner == null)
         {
             controlDesigner = TypeDescriptor.CreateDesigner(c, typeof(IDesigner)) as ControlDesigner;
             if (controlDesigner != null)
             {
                 controlDesigner.ForceVisible = false;
                 controlDesigner.Initialize(c);
                 flag = true;
             }
         }
         this.AddSnapLines(controlDesigner, this.targetHorizontalSnapLines, this.targetVerticalSnapLines, true, c != null);
         if (flag)
         {
             controlDesigner.Dispose();
         }
     }
     foreach (IComponent component in host.Container.Components)
     {
         if (this.AddChildCompSnaplines(component, dragComponents, clipBounds, c))
         {
             ControlDesigner designer = host.GetDesigner(component) as ControlDesigner;
             if (designer != null)
             {
                 if (this.AddControlSnaplinesWhenResizing(designer, component as Control, c))
                 {
                     this.AddSnapLines(designer, this.horizontalSnapLines, this.verticalSnapLines, false, c != null);
                 }
                 int num = designer.NumberOfInternalControlDesigners();
                 for (int i = 0; i < num; i++)
                 {
                     ControlDesigner designer3 = designer.InternalControlDesigner(i);
                     if (((designer3 != null) && this.AddChildCompSnaplines(designer3.Component, dragComponents, clipBounds, c)) && this.AddControlSnaplinesWhenResizing(designer3, designer3.Component as Control, c))
                     {
                         this.AddSnapLines(designer3, this.horizontalSnapLines, this.verticalSnapLines, false, c != null);
                     }
                 }
             }
         }
     }
     this.verticalDistances = new int[this.verticalSnapLines.Count];
     this.horizontalDistances = new int[this.horizontalSnapLines.Count];
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:68,代码来源:DragAssistanceManager.cs

示例10: CreateComponentsCore

 protected override IComponent[] CreateComponentsCore(IDesignerHost host)
 {
     IComponent[] sourceArray = base.CreateComponentsCore(host);
     Control component = null;
     ControlDesigner parent = null;
     TabStrip strip = null;
     IComponentChangeService service = (IComponentChangeService) host.GetService(typeof(IComponentChangeService));
     if ((sourceArray.Length > 0) && (sourceArray[0] is TabStrip))
     {
         strip = sourceArray[0] as TabStrip;
         ITreeDesigner designer2 = host.GetDesigner(strip) as ITreeDesigner;
         parent = designer2.Parent as ControlDesigner;
         if (parent != null)
         {
             component = parent.Control;
         }
     }
     if (host != null)
     {
         TabPageSwitcher switcher = null;
         DesignerTransaction transaction = null;
         try
         {
             try
             {
                 transaction = host.CreateTransaction("add tabswitcher");
             }
             catch (CheckoutException exception)
             {
                 if (exception != CheckoutException.Canceled)
                 {
                     throw exception;
                 }
                 return sourceArray;
             }
             MemberDescriptor member = TypeDescriptor.GetProperties(parent)["Controls"];
             switcher = host.CreateComponent(typeof(TabPageSwitcher)) as TabPageSwitcher;
             if (service != null)
             {
                 service.OnComponentChanging(component, member);
                 service.OnComponentChanged(component, member, null, null);
             }
             Dictionary<string, object> properties = new Dictionary<string, object>();
             properties["Location"] = new Point(strip.Left, strip.Bottom + 3);
             properties["TabStrip"] = strip;
             this.SetProperties(switcher, properties, host);
         }
         finally
         {
             if (transaction != null)
             {
                 transaction.Commit();
             }
         }
         if (switcher != null)
         {
             IComponent[] destinationArray = new IComponent[sourceArray.Length + 1];
             Array.Copy(sourceArray, destinationArray, sourceArray.Length);
             destinationArray[destinationArray.Length - 1] = switcher;
             return destinationArray;
         }
     }
     return sourceArray;
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:64,代码来源:TabStripToolboxItem.cs

示例11: GetAssociatedComponents

 internal static void GetAssociatedComponents(IComponent component, IDesignerHost host, ArrayList list)
 {
     if (host != null)
     {
         ComponentDesigner designer = host.GetDesigner(component) as ComponentDesigner;
         if (designer != null)
         {
             foreach (IComponent component2 in designer.AssociatedComponents)
             {
                 if (component2.Site != null)
                 {
                     list.Add(component2);
                     GetAssociatedComponents(component2, host, list);
                 }
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:18,代码来源:DesignerUtils.cs

示例12: CreateInstance

 internal static object CreateInstance(System.Type itemType, IDesignerHost host, string name)
 {
     object obj2 = null;
     if (typeof(IComponent).IsAssignableFrom(itemType) && (host != null))
     {
         obj2 = host.CreateComponent(itemType, name);
         if (host != null)
         {
             IComponentInitializer designer = host.GetDesigner((IComponent) obj2) as IComponentInitializer;
             if (designer != null)
             {
                 designer.InitializeNewComponent(null);
             }
         }
     }
     if (obj2 == null)
     {
         obj2 = TypeDescriptor.CreateInstance(host, itemType, null, null);
     }
     return obj2;
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:21,代码来源:CollectionEditor.cs

示例13: GetPaintingBounds

 private static Rectangle GetPaintingBounds(IDesignerHost designerHost, ToolStripItem item)
 {
     Rectangle empty = Rectangle.Empty;
     ToolStripItemDesigner designer = designerHost.GetDesigner(item) as ToolStripItemDesigner;
     if (designer != null)
     {
         empty = designer.GetGlyphBounds();
         ToolStripDesignerUtils.GetAdjustedBounds(item, ref empty);
         empty.Inflate(1, 1);
         empty.Width--;
         empty.Height--;
     }
     return empty;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:14,代码来源:ToolStripItemBehavior.cs

示例14: DeserializeDesignerStates

        internal static bool DeserializeDesignerStates(IDesignerHost designerHost, BinaryReader reader)
        {
            int componentCount = reader.ReadInt32();
            bool outdated = (componentCount != designerHost.Container.Components.Count);

            for (int loop = 0; loop < componentCount; loop++)
            {
                string componentName = reader.ReadString();
                int length = reader.ReadInt32();

                if (designerHost.Container.Components[componentName] != null)
                {
                    ActivityDesigner designer = designerHost.GetDesigner(designerHost.Container.Components[componentName]) as ActivityDesigner;

                    if (designer != null)
                    {
                        ((IPersistUIState)designer).LoadViewState(reader);
                    }
                    else
                    {
                        outdated = true;
                        reader.BaseStream.Position += length; // skip activity data
                    }

                }
                else
                {
                    outdated = true;
                    reader.BaseStream.Position += length; // skip activity data
                }
            }

            return outdated;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:34,代码来源:DesignerHelpers.cs

示例15: GetDirectives

 private static string GetDirectives(IDesignerHost designerHost)
 {
     string registerDirectives = string.Empty;
     WebFormsReferenceManager referenceManager = null;
     if (designerHost.RootComponent != null)
     {
         WebFormsRootDesigner designer = designerHost.GetDesigner(designerHost.RootComponent) as WebFormsRootDesigner;
         if (designer != null)
         {
             referenceManager = designer.ReferenceManager;
         }
     }
     if (referenceManager == null)
     {
         IWebFormReferenceManager service = (IWebFormReferenceManager) designerHost.GetService(typeof(IWebFormReferenceManager));
         if (service != null)
         {
             registerDirectives = service.GetRegisterDirectives();
         }
         return registerDirectives;
     }
     StringBuilder builder = new StringBuilder();
     foreach (string str2 in referenceManager.GetRegisterDirectives())
     {
         builder.Append(str2);
     }
     return builder.ToString();
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:28,代码来源:ControlSerializer.cs


注:本文中的IDesignerHost.GetDesigner方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。