本文整理汇总了C#中IDesignerHost.CreateComponent方法的典型用法代码示例。如果您正苦于以下问题:C# IDesignerHost.CreateComponent方法的具体用法?C# IDesignerHost.CreateComponent怎么用?C# IDesignerHost.CreateComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDesignerHost
的用法示例。
在下文中一共展示了IDesignerHost.CreateComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateControlWithOnePage
public object CreateControlWithOnePage(IDesignerHost theHost, object theParam)
{
MultiPaneControl control = (MultiPaneControl) theHost.CreateComponent(typeof(MultiPaneControl));
MultiPanePage page = (MultiPanePage) theHost.CreateComponent(typeof(MultiPanePage));
control.Controls.Add(page);
return new IComponent[] { control };
}
示例2: CreateComponentsCore
/// <summary>
/// Creates a new instance of the NaviBar component with design time support
/// </summary>
/// <param name="host">The controls host</param>
/// <returns>The newly created component</returns>
protected override IComponent[] CreateComponentsCore(IDesignerHost host)
{
// Create the control
NaviBar naviBarCtrl = (NaviBar)host.CreateComponent(typeof(NaviBar));
NaviBand naviBandCtrl = (NaviBand)host.CreateComponent(typeof(NaviBand));
// Add a new button
naviBarCtrl.Controls.Add(naviBandCtrl);
return new IComponent[] { naviBarCtrl };
}
示例3: CreateControlWithOneTabPage
public object CreateControlWithOneTabPage(IDesignerHost host, object parameter)
{
// Tab Page
NeoTabPage tabPage = (NeoTabPage)host.CreateComponent(typeof(NeoTabPage));
tabPage.BackColor = System.Drawing.Color.Transparent;
// Tab Control
NeoTabWindow tabControl = (NeoTabWindow)parameter;
tabControl.Controls.Add(tabPage);
((ISupportInitialize)tabControl).EndInit();
using (System.Windows.Forms.FolderBrowserDialog fdialog =
new System.Windows.Forms.FolderBrowserDialog())
{
fdialog.RootFolder = Environment.SpecialFolder.MyComputer;
fdialog.Description = "Select application directory for control rendering.";
fdialog.ShowNewFolderButton = false;
if (fdialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string rootFolder = System.IO.Directory.GetCurrentDirectory();
System.IO.Directory.SetCurrentDirectory(fdialog.SelectedPath);
// Shows a add-in model dialog box.
tabControl.ShowAddInRendererManager();
System.IO.Directory.SetCurrentDirectory(rootFolder);
}
}
return parameter;
}
示例4: WorkflowViewWrapper
public WorkflowViewWrapper()
{
this.loader = new Loader();
// Create a Workflow Design Surface
this.surface = new DesignSurface();
this.surface.BeginLoad(this.loader);
// Get the Workflow Designer Host
this.Host = this.surface.GetService(typeof(IDesignerHost)) as IDesignerHost;
if (this.Host == null)
return;
// Create a Sequential Workflow by using the Workflow Designer Host
SequentialWorkflow = (SequentialWorkflowActivity)Host.CreateComponent(typeof(SequentialWorkflowActivity));
SequentialWorkflow.Name = "CustomOutlookWorkflow";
// Create a Workflow View on the Workflow Design Surface
this.workflowView = new WorkflowView(this.surface as IServiceProvider);
// Add a message filter to the workflow view, to support panning
MessageFilter filter = new MessageFilter(this.surface as IServiceProvider, this.workflowView);
this.workflowView.AddDesignerMessageFilter(filter);
// Activate the Workflow View
this.Host.Activate();
this.workflowView.Dock = DockStyle.Fill;
this.Controls.Add(workflowView);
this.Dock = DockStyle.Fill;
}
示例5: CreateComponentsCore
protected virtual IComponent[] CreateComponentsCore(IDesignerHost host)
{
ArrayList list = new ArrayList();
Type componentClass = this.GetType(host, this.AssemblyName, this.TypeName, true);
if (componentClass != null)
{
if (host != null)
{
list.Add(host.CreateComponent(componentClass));
}
else if (typeof(IComponent).IsAssignableFrom(componentClass))
{
list.Add(TypeDescriptor.CreateInstance(null, componentClass, null, null));
}
}
IComponent[] array = new IComponent[list.Count];
list.CopyTo(array, 0);
return array;
}
示例6: CreateComponentsCore
protected override IComponent[] CreateComponentsCore(IDesignerHost host)
{
IComponent[] components = base.CreateComponentsCore(host);
Control parentControl = null;
ControlDesigner parentControlDesigner = null;
TabStrip tabStrip = null;
IComponentChangeService changeSvc = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));
// fish out the parent we're adding the TabStrip to.
if (components.Length > 0 && components[0] is TabStrip) {
tabStrip = components[0] as TabStrip;
ITreeDesigner tabStripDesigner = host.GetDesigner(tabStrip) as ITreeDesigner;
parentControlDesigner = tabStripDesigner.Parent as ControlDesigner;
if (parentControlDesigner != null) {
parentControl = parentControlDesigner.Control;
}
}
// Create a ControlSwitcher on the same parent.
if (host != null) {
TabPageSwitcher controlSwitcher = null;
DesignerTransaction t = null;
try {
try {
t = host.CreateTransaction("add tabswitcher");
}
catch (CheckoutException ex) {
if (ex == CheckoutException.Canceled) {
return components;
}
throw ex;
}
MemberDescriptor controlsMember = TypeDescriptor.GetProperties(parentControlDesigner)["Controls"];
controlSwitcher = host.CreateComponent(typeof(TabPageSwitcher)) as TabPageSwitcher;
if (changeSvc != null) {
changeSvc.OnComponentChanging(parentControl, controlsMember);
changeSvc.OnComponentChanged(parentControl, controlsMember, null, null);
}
Dictionary<string, object> propertyValues = new Dictionary<string, object>();
propertyValues["Location"] = new Point(tabStrip.Left, tabStrip.Bottom + 3);
propertyValues["TabStrip"] = tabStrip;
SetProperties(controlSwitcher, propertyValues, host);
}
finally {
if (t != null)
t.Commit();
}
if (controlSwitcher != null) {
IComponent[] newComponents = new IComponent[components.Length + 1];
Array.Copy(components, newComponents, components.Length);
newComponents[newComponents.Length - 1] = controlSwitcher;
return newComponents;
}
}
return components;
}
示例7: CreateControlWithOnePage
public object CreateControlWithOnePage(IDesignerHost theHost, object theParam)
{
// Control
MultiPaneControl aCtl = (MultiPaneControl)theHost.CreateComponent(typeof(MultiPaneControl));
// Page 1
MultiPanePage aPg = (MultiPanePage)theHost.CreateComponent(typeof(MultiPanePage));
aCtl.Controls.Add(aPg);
return new IComponent[] { aCtl };
}
示例8: CreateComponentsCore
/// <include file='doc\ToolboxItem.uex' path='docs/doc[@for="ToolboxItem.CreateComponentsCore"]/*' />
/// <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) {
ArrayList comps = new ArrayList();
Type createType = GetType(host, AssemblyName, TypeName, true);
if (createType != null) {
if (host != null) {
comps.Add(host.CreateComponent(createType));
}
else if (typeof(IComponent).IsAssignableFrom(createType)) {
comps.Add(TypeDescriptor.CreateInstance(null, createType, null, null));
}
}
IComponent[] temp = new IComponent[comps.Count];
comps.CopyTo(temp, 0);
return temp;
}
示例9: CreateMRUButton
private ButtonItem CreateMRUButton(IDesignerHost dh, string text)
{
ButtonItem button = dh.CreateComponent(typeof(ButtonItem)) as ButtonItem;
button.Text = text;
return button;
}
示例10: Transaction_AddPage
private object Transaction_AddPage(IDesignerHost theHost, object theParam)
{
MultiPaneControl aCtl = DesignedControl;
MultiPanePage aNewPage = (MultiPanePage)theHost.CreateComponent(typeof(MultiPanePage));
MemberDescriptor aMem_Controls = TypeDescriptor.GetProperties(aCtl)["Controls"];
RaiseComponentChanging(aMem_Controls);
aCtl.Controls.Add(aNewPage);
DesignerSelectedPage = aNewPage;
RaiseComponentChanged(aMem_Controls, null, null);
return null;
}
示例11: Transaction_AddTab
private object Transaction_AddTab(IDesignerHost host, object parameter)
{
// Tab Page
NeoTabPage tabPage = (NeoTabPage)host.CreateComponent(typeof(NeoTabPage));
tabPage.BackColor = System.Drawing.Color.Transparent;
// Tab Control
NeoTabWindow tabControl = (NeoTabWindow)parameter;
MemberDescriptor md = TypeDescriptor.GetProperties(tabControl)["Controls"];
RaiseComponentChanging(md);
tabControl.Controls.Add(tabPage);
RaiseComponentChanged(md, null, null);
return parameter;
}
示例12: CreateComponentsCore
protected override IComponent[] CreateComponentsCore(IDesignerHost host)
{
IComponent[] componentArray = null;
object references = this.GetReferences(host);
if (references != null)
{
try
{
System.Runtime.InteropServices.ComTypes.TYPELIBATTR typeLibAttr = this.GetTypeLibAttr();
object[] args = new object[] { "{" + typeLibAttr.guid.ToString() + "}", (int) typeLibAttr.wMajorVerNum, (int) typeLibAttr.wMinorVerNum, typeLibAttr.lcid, "" };
references.GetType().InvokeMember("AddActiveX", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, references, args, CultureInfo.InvariantCulture);
args[4] = "aximp";
object reference = references.GetType().InvokeMember("AddActiveX", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, references, args, CultureInfo.InvariantCulture);
this.axctlType = this.GetAxTypeFromReference(reference, host);
}
catch (TargetInvocationException exception)
{
throw exception.InnerException;
}
catch (Exception exception2)
{
throw exception2;
}
}
if (this.axctlType == null)
{
IUIService service = (IUIService) host.GetService(typeof(IUIService));
if (service == null)
{
System.Windows.Forms.Design.RTLAwareMessageBox.Show(null, System.Design.SR.GetString("AxImportFailed"), null, MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1, 0);
}
else
{
service.ShowError(System.Design.SR.GetString("AxImportFailed"));
}
return new IComponent[0];
}
componentArray = new IComponent[1];
try
{
componentArray[0] = host.CreateComponent(this.axctlType);
}
catch (Exception exception3)
{
throw exception3;
}
return componentArray;
}
示例13: AddDataControl
private LabeledDataControl AddDataControl(IDesignerHost h, GridColumnInfo info)
{
//IDataControl dc = ControlFactory.GetDataControl(columnInfo);
//Control control = dc as Control;
//if (control == null)
//{
// throw new ArgumentException("IDataControl should be System.Windows.Forms.Control!");
//}
//m_parentForm.Controls.Add(control);
Control ic = null;
foreach (string s in ControlsName.DataControlsTypeName)
{
if (s.LastIndexOf(info.DataControlType, StringComparison.OrdinalIgnoreCase) != -1)
{
ic = (Control)h.CreateComponent(Feng.Utils.ReflectionHelper.GetTypeFromName(s));
break;
}
}
if (ic == null)
{
throw new InvalidOperationException("Invalid ControlType of " + info.DataControlType);
}
LabeledDataControl control = (LabeledDataControl)h.CreateComponent(typeof(LabeledDataControl));
MyLabel lbl = (MyLabel)h.CreateComponent(typeof(MyLabel));
lbl.Text = info.Caption;
control.Controls.Add(lbl);
control.Controls.Add(ic);
control.Label = lbl;
control.Control = ic;
IDataControl dc = control as IDataControl;
dc.Caption = info.Caption;
dc.PropertyName = info.PropertyName;
dc.Navigator = info.Navigator;
//dc.Index = info.SeqNo;
dc.Name = info.GridColumnName;
control.ResetLayout();
m_parentForm.Controls.Add(control);
return control;
}
示例14: CreateComponents
private Dictionary<Component, Component> CreateComponents(Type componentType, object instance, IDesignerHost designerHost)
{
Dictionary<Component, Component> components = new Dictionary<Component, Component>();
// get each field of type.
foreach (FieldInfo field in componentType.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
{
// check if it is defined in the type that is being compiled, and not a field in some base class.
if (field.DeclaringType.TypeHandle.Value == componentType.TypeHandle.Value)
{
if (field.FieldType.HasConstructor())
{
object obj = field.GetValue(instance);
// create the component.
Component component = designerHost.CreateComponent(field.FieldType, field.Name) as Component;
components.Add(field.GetValue(instance) as Component, component);
}
}
}
return components;
}
示例15: CreatePage
internal static PageSliderPage CreatePage(PageSlider parent, IDesignerHost dh, IComponentChangeService cc, ISelectionService ss)
{
DesignerTransaction dt = dh.CreateTransaction();
PageSliderPage page = null;
try
{
page = dh.CreateComponent(typeof(PageSliderPage)) as PageSliderPage;
if (cc != null)
cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["Controls"]);
parent.Controls.Add(page);
if (cc != null)
cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["Controls"], null, null);
if (ss != null)
ss.SetSelectedComponents(new PageSliderPage[] { page }, SelectionTypes.Replace);
TypeDescriptor.GetProperties(parent)["SelectedPage"].SetValue(parent, page);
}
catch
{
dt.Cancel();
}
finally
{
if (!dt.Canceled)
dt.Commit();
}
return page;
}