本文整理汇总了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;
}
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例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];
}
示例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;
}
示例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);
}
}
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}