internal SampleSelectionService(IDesignerHost host) { this.host = host; this.container = host.Container; this.selectionsByComponent = new Hashtable(); this.selectionChanged = false; // We initialize this to true to catch anything that would cause // an update during load. this.batchMode = true; // And configure the events we want to listen to. IComponentChangeService cs = (IComponentChangeService)host.GetService(typeof(IComponentChangeService)); Debug.Assert(cs != null, "IComponentChangeService not found"); if (cs != null) { cs.ComponentAdded += new ComponentEventHandler(this.DesignerHost_ComponentAdd); cs.ComponentRemoved += new ComponentEventHandler(this.DesignerHost_ComponentRemove); cs.ComponentChanged += new ComponentChangedEventHandler(this.DesignerHost_ComponentChanged); } host.TransactionOpened += new EventHandler(this.DesignerHost_TransactionOpened); host.TransactionClosed += new DesignerTransactionCloseEventHandler(this.DesignerHost_TransactionClosed); // If our host is already in a transaction, we handle it. if (host.InTransaction) { DesignerHost_TransactionOpened(host, EventArgs.Empty); } host.LoadComplete += new EventHandler(this.DesignerHost_LoadComplete); }
public SelectionUIService(IDesignerHost host) { base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.StandardClick | ControlStyles.Opaque, true); this.host = host; this.dragHandler = null; this.dragComponents = null; this.selectionItems = new Hashtable(); this.selectionHandlers = new Hashtable(); this.AllowDrop = true; this.Text = "SelectionUIOverlay"; this.selSvc = (ISelectionService) host.GetService(typeof(ISelectionService)); if (this.selSvc != null) { this.selSvc.SelectionChanged += new EventHandler(this.OnSelectionChanged); } host.TransactionOpened += new EventHandler(this.OnTransactionOpened); host.TransactionClosed += new DesignerTransactionCloseEventHandler(this.OnTransactionClosed); if (host.InTransaction) { this.OnTransactionOpened(host, EventArgs.Empty); } IComponentChangeService service = (IComponentChangeService) host.GetService(typeof(IComponentChangeService)); if (service != null) { service.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemove); service.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged); } SystemEvents.DisplaySettingsChanged += new EventHandler(this.OnSystemSettingChanged); SystemEvents.InstalledFontsChanged += new EventHandler(this.OnSystemSettingChanged); SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(this.OnUserPreferenceChanged); }
internal static ExpressionBuilder GetExpressionBuilder(string expressionPrefix, VirtualPath virtualPath, IDesignerHost host) { // If there is no expressionPrefix, it's a v1 style databinding expression if (expressionPrefix.Length == 0) { if (dataBindingExpressionBuilder == null) { dataBindingExpressionBuilder = new DataBindingExpressionBuilder(); } return dataBindingExpressionBuilder; } CompilationSection config = null; // If we are in the designer, we need to access IWebApplication config instead #if !FEATURE_PAL // FEATURE_PAL does not support designer-based features if (host != null) { IWebApplication webapp = (IWebApplication)host.GetService(typeof(IWebApplication)); if (webapp != null) { config = webapp.OpenWebConfiguration(true).GetSection("system.web/compilation") as CompilationSection; } } #endif // !FEATURE_PAL // If we failed to get config from the designer, fall back on runtime config always if (config == null) { config = MTConfigUtil.GetCompilationConfig(virtualPath); } System.Web.Configuration.ExpressionBuilder builder = config.ExpressionBuilders[expressionPrefix]; if (builder == null) { throw new HttpParseException(SR.GetString(SR.InvalidExpressionPrefix, expressionPrefix)); } Type expressionBuilderType = null; if (host != null) { // If we are in the designer, we have to use the type resolution service ITypeResolutionService ts = (ITypeResolutionService)host.GetService(typeof(ITypeResolutionService)); if (ts != null) { expressionBuilderType = ts.GetType(builder.Type); } } if (expressionBuilderType == null) { expressionBuilderType = builder.TypeInternal; } Debug.Assert(expressionBuilderType != null, "expressionBuilderType should not be null"); if (!typeof(ExpressionBuilder).IsAssignableFrom(expressionBuilderType)) { throw new HttpParseException(SR.GetString(SR.ExpressionBuilder_InvalidType, expressionBuilderType.FullName)); } ExpressionBuilder expressionBuilder = (ExpressionBuilder)HttpRuntime.FastCreatePublicInstance(expressionBuilderType); return expressionBuilder; }
// protected override IComponent[] CreateComponentsCore(IDesignerHost host) { Type typeOfComponent = GetType(host, AssemblyName, TypeName, true); if (typeOfComponent == null && host != null) typeOfComponent = host.GetType(TypeName); if (typeOfComponent == null) { ITypeProviderCreator tpc = null; if (host != null) tpc = (ITypeProviderCreator)host.GetService(typeof(ITypeProviderCreator)); if (tpc != null) { System.Reflection.Assembly assembly = tpc.GetTransientAssembly(this.AssemblyName); if (assembly != null) typeOfComponent = assembly.GetType(this.TypeName); } if (typeOfComponent == null) typeOfComponent = GetType(host, AssemblyName, TypeName, true); } ArrayList comps = new ArrayList(); if (typeOfComponent != null) { if (typeof(IComponent).IsAssignableFrom(typeOfComponent)) comps.Add(TypeDescriptor.CreateInstance(null, typeOfComponent, null, null)); } IComponent[] temp = new IComponent[comps.Count]; comps.CopyTo(temp, 0); return temp; }
/// <summary> /// <para> /// Gets the delarative type for the /// specified type. /// </para> /// </summary> /// <param name='type'> /// The type of the declarator. /// </param> /// <param name='host'> /// The services interface exposed by the webforms designer. /// </param> private static string GetDeclarativeType(Type type, IDesignerHost host) { Debug.Assert(host != null, "Need an IDesignerHost to create declarative type names"); string declarativeType = null; if (host != null) { IWebFormReferenceManager refMgr = (IWebFormReferenceManager)host.GetService(typeof(IWebFormReferenceManager)); Debug.Assert(refMgr != null, "Did not get back IWebFormReferenceManager service from host."); if (refMgr != null) { string tagPrefix = refMgr.GetTagPrefix(type); if ((tagPrefix != null) && (tagPrefix.Length != 0)) { declarativeType = tagPrefix + ":" + type.Name; } } } if (declarativeType == null) { /* Begin AUI 7201 */ /* Original declarativeType = type.FullName; */ if (type == typeof(System.Web.UI.MobileControls.Style)) { declarativeType = type.Name; } else { declarativeType = type.FullName; } /* End AUI 7201 */ } return declarativeType; }
public CodeDomHostLoader(IDesignerHost host, string formFile, string unitFile) { _trs = host.GetService(typeof(ITypeResolutionService)) as TypeResolutionService; this.formFile = formFile; this.unitFile = unitFile; this.host = host; }
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; } }
public static string GetUniqueSiteName(IDesignerHost host, string name) { if (string.IsNullOrEmpty(name)) { return null; } INameCreationService service = (INameCreationService)host.GetService(typeof(INameCreationService)); if (service == null) { return null; } if (host.Container.Components[name] == null) { if (!service.IsValidName(name)) { return null; } return name; } string str = name; for (int i = 1; !service.IsValidName(str); i++) { str = name + i.ToString(CultureInfo.InvariantCulture); } return str; }
public SampleToolboxService(IDesignerHost host) { this.host = host; // Our MainForm adds our ToolboxPane to the host's services. toolbox = host.GetService(typeof(SampleDesignerApplication.ToolBoxPane)) as SampleDesignerApplication.ToolBoxPane; }
public RootParsingObject(IDesignerHost host) : base("", "", null) { this.host = host; refMan = host.GetService(typeof(IWebFormReferenceManager)) as IWebFormReferenceManager; if (refMan == null) throw new Exception ("Could not get IWebFormReferenceManager from host"); }
public fmEasilyReportDesigner(IReport rpt, IDesignerHost designerHost) { InitializeComponent(); designReport = rpt; tempReport = rpt.Copy(); componentChangeService = designerHost.GetService(typeof(IComponentChangeService)) as IComponentChangeService; }
/// <summary> /// This method sets various values on the newly created component. /// </summary> private IComponent[] RunWizard(IDesignerHost host, IComponent[] comps) { DialogResult result = DialogResult.No; IVsUIShell uiShell = null; if (host != null) { uiShell = (IVsUIShell)host.GetService(typeof(IVsUIShell)); } // Always use the UI shell service to show a messagebox if possible. // There are also some useful helper methods for this in VsShellUtilities. if (uiShell != null) { int nResult = 0; Guid emptyGuid = Guid.Empty; uiShell.ShowMessageBox(0, ref emptyGuid, "Question", "Do you want to set the Text property?", null, 0, OLEMSGBUTTON.OLEMSGBUTTON_YESNO, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND, OLEMSGICON.OLEMSGICON_QUERY, 0, out nResult); if (nResult == IDYES) { result = DialogResult.Yes; } } else { result = MessageBox.Show("Do you want to set the Text property?", "Question", MessageBoxButtons.YesNo); } if (result == DialogResult.Yes) { if (comps.Length > 0) { // Use Types from the ITypeResolutionService. Do not use locally defined types. ITypeResolutionService typeResolver = (ITypeResolutionService)host.GetService(typeof(ITypeResolutionService)); if (typeResolver != null) { Type t = typeResolver.GetType(typeof(MyCustomTextBoxWithPopup).FullName); // Check to ensure we got the right Type. if (t != null && comps[0].GetType().IsAssignableFrom(t)) { // Use a property descriptor instead of direct property access. // This will allow the change to appear in the undo stack and it will get // serialized correctly. PropertyDescriptor pd = TypeDescriptor.GetProperties(comps[0])["Text"]; if (pd != null) { pd.SetValue(comps[0], "Text Property was initialized!"); } } } } } return comps; }
public SelectionService(IDesignerHost host) { this.host = host; selectedComponents = new ArrayList(); // Subscribe to the componentremoved event IComponentChangeService c = (IComponentChangeService)host.GetService(typeof(IComponentChangeService)); c.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); }
public SelectionServiceImpl(IDesignerHost host) { this.host = host; selectedComponents = new ArrayList(); // we need to know when components get aded and/or removed IComponentChangeService changeService = (IComponentChangeService)host.GetService(typeof(IComponentChangeService)); changeService.ComponentAdded +=new ComponentEventHandler(OnComponentAdded); changeService.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (provider != null) { IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if ((service == null) || (context.Instance == null)) { return(value); } IDesignerHost host = (IDesignerHost)provider.GetService(typeof(IDesignerHost)); if (host == null) { return(value); } //if (this.dataGridViewColumnCollectionDialog == null) //{ // this.dataGridViewColumnCollectionDialog = new DataGridViewColumnCollectionDialog(((DataGridView)context.Instance).Site); //} if (this.dataGridViewColumnCollectionDialog == null) { Type type = Type.GetType("System.Windows.Forms.Design.DataGridViewColumnCollectionDialog"); this.dataGridViewColumnCollectionDialog = Activator.CreateInstance( type, BindingFlags.Instance | BindingFlags.NonPublic, null, new object[] { provider }, CultureInfo.CurrentCulture) as Form; } //this.dataGridViewColumnCollectionDialog.SetLiveDataGridView((DataGridView)context.Instance); MethodInfo methodInfo = this.dataGridViewColumnCollectionDialog.GetType().GetMethod("SetLiveDataGridView", BindingFlags.NonPublic | BindingFlags.Instance); methodInfo.Invoke(this.dataGridViewColumnCollectionDialog, new object[] { context.Instance }); //using (DesignerTransaction transaction = host.CreateTransaction(System.Design.SR.GetString("DataGridViewColumnCollectionTransaction"))) using (DesignerTransaction transaction = host.CreateTransaction()) { host.RemoveService(typeof(ITypeDiscoveryService)); host.AddService(typeof(ITypeDiscoveryService), new TypeDiscoveryService()); ITypeDiscoveryService service2 = (ITypeDiscoveryService)host.GetService(typeof(ITypeDiscoveryService)); if (service.ShowDialog(this.dataGridViewColumnCollectionDialog) == DialogResult.OK) { transaction.Commit(); return(value); } transaction.Cancel(); } } return(value); }
public DesignSurface this[int index] { get { IDesignerHost designer = _designers[index]; DesignSurface surface = designer.GetService(typeof(DesignSurface)) as DesignSurface; if (surface == null) { throw new NotSupportedException(); } return(surface); } }
/// <summary> /// This function generates the default CodeCompileUnit template /// </summary> public CodeCompileUnit GetCodeCompileUnit(IDesignerHost host) { this.host = host; IDesignerHost idh = (IDesignerHost)this.host.GetService(typeof(IDesignerHost)); root = idh.RootComponent; Hashtable nametable = new Hashtable(idh.Container.Components.Count); ns = new CodeNamespace("DesignerHostSample"); myDesignerClass = new CodeTypeDeclaration(); initializeComponent = new CodeMemberMethod(); CodeCompileUnit code = new CodeCompileUnit(); // Imports ns.Imports.Add(new CodeNamespaceImport("System")); ns.Imports.Add(new CodeNamespaceImport("System.ComponentModel")); ns.Imports.Add(new CodeNamespaceImport("System.Windows.Forms")); code.Namespaces.Add(ns); myDesignerClass = new CodeTypeDeclaration(root.Site.Name); myDesignerClass.BaseTypes.Add(typeof(Form).FullName); IDesignerSerializationManager manager = host.GetService(typeof(IDesignerSerializationManager)) as IDesignerSerializationManager; ns.Types.Add(myDesignerClass); // Constructor CodeConstructor con = new CodeConstructor(); con.Attributes = MemberAttributes.Public; con.Statements.Add(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), "InitializeComponent"))); myDesignerClass.Members.Add(con); // Main CodeEntryPointMethod main = new CodeEntryPointMethod(); main.Name = "Main"; main.Attributes = MemberAttributes.Public | MemberAttributes.Static; main.CustomAttributes.Add(new CodeAttributeDeclaration("System.STAThreadAttribute")); main.Statements.Add(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeTypeReferenceExpression(typeof(System.Windows.Forms.Application)), "Run"), new CodeExpression[] { new CodeObjectCreateExpression(new CodeTypeReference(root.Site.Name)) })); myDesignerClass.Members.Add(main); // InitializeComponent initializeComponent.Name = "InitializeComponent"; initializeComponent.Attributes = MemberAttributes.Private; initializeComponent.ReturnType = new CodeTypeReference(typeof(void)); myDesignerClass.Members.Add(initializeComponent); codeCompileUnit = code; return(codeCompileUnit); }
/// <summary> /// This function generates the default CodeCompileUnit template /// </summary> public CodeCompileUnit GetCodeCompileUnit(IDesignerHost host) { this.host = host; IDesignerHost idh = (IDesignerHost)this.host.GetService(typeof(IDesignerHost)); root = idh.RootComponent; Hashtable nametable = new Hashtable(idh.Container.Components.Count); ns = new CodeNamespace("DesignerHostSample"); myDesignerClass = new CodeTypeDeclaration(); initializeComponent = new CodeMemberMethod(); CodeCompileUnit code = new CodeCompileUnit(); // Imports ns.Imports.Add(new CodeNamespaceImport("System")); ns.Imports.Add(new CodeNamespaceImport("System.ComponentModel")); ns.Imports.Add(new CodeNamespaceImport("System.Windows.Forms")); code.Namespaces.Add(ns); myDesignerClass = new CodeTypeDeclaration(root.Site.Name); myDesignerClass.BaseTypes.Add(typeof(Form).FullName); IDesignerSerializationManager manager = host.GetService(typeof(IDesignerSerializationManager)) as IDesignerSerializationManager; ns.Types.Add(myDesignerClass); // Constructor CodeConstructor con = new CodeConstructor(); con.Attributes = MemberAttributes.Public; con.Statements.Add(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), "InitializeComponent"))); myDesignerClass.Members.Add(con); // Main CodeEntryPointMethod main = new CodeEntryPointMethod(); main.Name = "Main"; main.Attributes = MemberAttributes.Public | MemberAttributes.Static; main.CustomAttributes.Add(new CodeAttributeDeclaration("System.STAThreadAttribute")); main.Statements.Add(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeTypeReferenceExpression(typeof(System.Windows.Forms.Application)), "Run"), new CodeExpression[] { new CodeObjectCreateExpression(new CodeTypeReference(root.Site.Name)) })); myDesignerClass.Members.Add(main); // InitializeComponent initializeComponent.Name = "InitializeComponent"; initializeComponent.Attributes = MemberAttributes.Private; initializeComponent.ReturnType = new CodeTypeReference(typeof(void)); initializeComponent.Statements.Add(new CodeAssignStatement(new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "Text"), new CodePrimitiveExpression(root.Site.Name))); //roman// myDesignerClass.Members.Add(initializeComponent); codeCompileUnit = code; return codeCompileUnit; }
private void sendVOBnotice(enumVobNotice notice, object data) { IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost)); if (host != null) { InterfaceVOB vob = (InterfaceVOB)host.GetService(typeof(InterfaceVOB)); if (vob != null) { vob.SendNotice(notice, data); } } }
/// <summary> /// Gets or sets the document at the specified index. /// </summary> public DesignSurface this[int index] { get { IDesignerHost host = _designers[index]; if (host.GetService(typeof(DesignSurface)) is DesignSurface surface) { return(surface); } throw new NotSupportedException(); } }
private void LaunchWebAdmin() { IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost)); if (host != null) { IWebAdministrationService service = (IWebAdministrationService)host.GetService(typeof(IWebAdministrationService)); if (service != null) { service.Start(null); } } }
void componentChangeService_ComponentRemoving(object sender, ComponentEventArgs e) { IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost)); if (host != null) { VOB.OutputWindow O = (VOB.OutputWindow)host.GetService(typeof(VOB.OutputWindow)); if (O != null) { O.AppendMessage("ComponentRemoving " + e.Component.Site.Name); } } }
/// <include file='doc\SelectionService.uex' path='docs/doc[@for="SelectionService.Dispose"]/*' /> /// <devdoc> /// Disposes the entire selection manager. /// </devdoc> public void Dispose() { // We've got to be careful here. We're one of the last things to go away when // a form is being torn down, and we've got to be wary if things have pulled out // already. // host.RemoveService(typeof(ISelectionService)); host.TransactionOpened -= new EventHandler(this.OnTransactionOpened); host.TransactionClosed -= new DesignerTransactionCloseEventHandler(this.OnTransactionClosed); if (host.InTransaction) { OnTransactionClosed(host, new DesignerTransactionCloseEventArgs(true)); } host.LoadComplete -= new EventHandler(this.OnLoadComplete); // And configure the events we want to listen to. // IComponentChangeService cs = (IComponentChangeService)host.GetService(typeof(IComponentChangeService)); Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || cs != null, "IComponentChangeService not found"); if (cs != null) { cs.ComponentAdded -= new ComponentEventHandler(this.OnComponentAdd); cs.ComponentRemoved -= new ComponentEventHandler(this.OnComponentRemove); cs.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged); } SelectionItem[] sels = new SelectionItem[selectionsByComponent.Values.Count]; selectionsByComponent.Values.CopyTo(sels, 0); for (int i = 0; i < sels.Length; i++) { sels[i].Dispose(); } selectionsByComponent.Clear(); primarySelection = null; }
/// <summary> /// Creates the necessary components associated with this data adapter instance /// </summary> /// <param name="host">The designer host</param> /// <returns>The components created by this toolbox item</returns> protected override IComponent[] CreateComponentsCore(IDesignerHost host) { DbProviderFactory fact = DbProviderFactories.GetFactory("Npgsql"); DbDataAdapter dataAdapter = fact.CreateDataAdapter(); IContainer container = host.Container; using (DbCommand adapterCommand = fact.CreateCommand()) { adapterCommand.DesignTimeVisible = false; dataAdapter.SelectCommand = (DbCommand)((ICloneable)adapterCommand).Clone(); container.Add(dataAdapter.SelectCommand, GenerateName(container, "SelectCommand")); dataAdapter.InsertCommand = (DbCommand)((ICloneable)adapterCommand).Clone(); container.Add(dataAdapter.InsertCommand, GenerateName(container, "InsertCommand")); dataAdapter.UpdateCommand = (DbCommand)((ICloneable)adapterCommand).Clone(); container.Add(dataAdapter.UpdateCommand, GenerateName(container, "UpdateCommand")); dataAdapter.DeleteCommand = (DbCommand)((ICloneable)adapterCommand).Clone(); container.Add(dataAdapter.DeleteCommand, GenerateName(container, "DeleteCommand")); } ITypeResolutionService typeResService = (ITypeResolutionService)host.GetService(typeof(ITypeResolutionService)); if (typeResService != null) { typeResService.ReferenceAssembly(dataAdapter.GetType().Assembly.GetName()); } container.Add(dataAdapter); List<IComponent> list = new List<IComponent>(); list.Add(dataAdapter); // Show the connection wizard if we have a type for it if (_wizard != null) { using (Form wizard = (Form)Activator.CreateInstance(_wizard, new object[] { host, dataAdapter })) { wizard.ShowDialog(); } } if (dataAdapter.SelectCommand != null) list.Add(dataAdapter.SelectCommand); if (dataAdapter.InsertCommand != null) list.Add(dataAdapter.InsertCommand); if (dataAdapter.DeleteCommand != null) list.Add(dataAdapter.DeleteCommand); if (dataAdapter.UpdateCommand != null) list.Add(dataAdapter.UpdateCommand); return list.ToArray(); }
/// <summary> /// 将View类添加到CodeCompileUnit中,CodeCompileUnit:为 CodeDOM 程序图形提供容器。 /// </summary> /// <param name="host"></param> /// <returns></returns> public CodeCompileUnit GetCodeCompileUnit(IDesignerHost host) { CodeNamespace nameSpace = new CodeNamespace(); //定义命名空间 CodeTypeDeclaration myDesignerClass = new CodeTypeDeclaration(); //定义类型 CodeCompileUnit compileUnit = new CodeCompileUnit(); IDesignerHost iDesignHost = (IDesignerHost)host.GetService(typeof(IDesignerHost)); IComponent root = iDesignHost.RootComponent; //获取当前设计器的根主键 myDesignerClass = new CodeTypeDeclaration(root.Site.Name); //用指定的名称初始化 CodeTypeDeclaration 类的新实例。 myDesignerClass.BaseTypes.Add(typeof(CassView).FullName); //将类成员添加到类 nameSpace.Types.Add(myDesignerClass); compileUnit.Namespaces.Add(nameSpace); return(compileUnit); }
internal object GetService(System.Type serviceType) { if (this.context == null) { return(null); } IDesignerHost service = this.context.GetService(typeof(IDesignerHost)) as IDesignerHost; if (service == null) { return(this.context.GetService(serviceType)); } return(service.GetService(serviceType)); }
protected override void OnMouseEnter(EventArgs e) { base.OnMouseEnter(e); IDesignerHost idh = _rootDesigner.GetService(typeof(IDesignerHost)) as IDesignerHost; if (idh != null) { VOB.InterfaceVOB vob = idh.GetService(typeof(VOB.InterfaceVOB)) as VOB.InterfaceVOB; if (vob != null) { vob.SendNotice(VOB.enumVobNotice.HideToolbox, true); } } }
public override void Initialize(IComponent component) { base.Initialize(component); IDesignerHost designerHost = (IDesignerHost)GetService(typeof(IDesignerHost)); if (designerHost != null) { changeNotificationService = (IComponentChangeService)designerHost.GetService(typeof(IComponentChangeService)); if (changeNotificationService != null) { changeNotificationService.ComponentRemoved += DataSource_ComponentRemoved; } } }
} // OnPaint public void InvokeToolboxItem(System.Drawing.Design.ToolboxItem tool) { IDesignerHost dh = DesignerHost; if (dh != null) { VOB.InterfaceVOB vob = dh.GetService(typeof(VOB.InterfaceVOB)) as VOB.InterfaceVOB; if (vob != null) { vob.SendNotice(VOB.enumVobNotice.NewObject, tool); } } Invalidate(); }
public override object GetService(Type serviceType) { object service = null; if (host != null) { service = host.GetService(serviceType); } if (service == null && baseProvider != null) { service = baseProvider.GetService(serviceType); } return(service); }
public override void Initialize(IComponent component) { base.Initialize(component); IDesignerHost service = (IDesignerHost)this.GetService(typeof(IDesignerHost)); if (service != null) { this.changeNotificationService = (IComponentChangeService)service.GetService(typeof(IComponentChangeService)); if (this.changeNotificationService != null) { this.changeNotificationService.ComponentRemoved += new ComponentEventHandler(this.DataSource_ComponentRemoved); } } }
public override void Exec() { try { UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer; if (((System.Array)solExplorer.SelectedItems).Length != 1) { return; } UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0)); ProjectItem pi = (ProjectItem)hierItem.Object; Window w = pi.Open(BIDSViewKinds.Designer); //opens the designer w.Activate(); IDesignerHost designer = w.Object as IDesignerHost; if (designer == null) { return; } EditorWindow win = (EditorWindow)designer.GetService(typeof(Microsoft.DataWarehouse.ComponentModel.IComponentNavigator)); Package package = win.PropertiesLinkComponent as Package; if (package == null) { return; } PackageHelper.SetTargetServerVersion(package); //set the TargetServerVersion variable so that we can retrieve it later Results results = new Results(); foreach (DesignPractice practice in _practices) { if (!practice.Enabled) { continue; } practice.Check(package, pi); results.AddRange(practice.Results); } AddErrorsToVSErrorList(w, results); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } }
protected override void OnDragDrop(DragEventArgs drgevent) { if (drgevent.Effect == DragDropEffects.Copy) { (designerHost.RootComponent as Control).SuspendLayout(); IToolboxService tbsvc = designerHost.GetService(typeof(IToolboxService)) as IToolboxService; IToolboxUser tbu = designerHost.GetDesigner(designerHost.RootComponent) as IToolboxUser; ISelectionService selsvc = designerHost.GetService(typeof(ISelectionService)) as ISelectionService; DesignerTransaction transaction = designerHost.CreateTransaction("DoDragDrop"); //避免当前有选中控件,会把新创建的控件放到选中控件中 selsvc.SetSelectedComponents(null); ToolboxItem item = drgevent.Data.GetData(typeof(ToolboxItem)) as ToolboxItem; tbu.ToolPicked(item); ICollection components = item.CreateComponents(); tbsvc.SelectedToolboxItemUsed(); Control createdControl = selsvc.PrimarySelection as Control; Point location1 = PointToScreen(this.Location); createdControl.Location = new Point(drgevent.X - location1.X + this.Left, drgevent.Y - location1.Y + this.Top); selsvc.SetSelectedComponents(null); selsvc.SetSelectedComponents(new Control[] { createdControl }); transaction.Commit(); ((IDisposable)transaction).Dispose(); (designerHost.RootComponent as Control).ResumeLayout(); } else { base.OnDragDrop(drgevent); } }
private void LaunchWebAdmin() { if (base.Component.Site != null) { IDesignerHost host = (IDesignerHost)base.Component.Site.GetService(typeof(IDesignerHost)); if (host != null) { IWebAdministrationService service = (IWebAdministrationService)host.GetService(typeof(IWebAdministrationService)); if (service != null) { service.Start(null); } } } }
internal DesignerToolboxInfo(ToolboxService toolboxService, IDesignerHost host) { this._toolboxService = toolboxService; this._host = host; this._selectionService = host.GetService(typeof(ISelectionService)) as ISelectionService; if (this._selectionService != null) { this._selectionService.SelectionChanged += new EventHandler(this.OnSelectionChanged); } if (this._host.RootComponent != null) { this._host.RootComponent.Disposed += new EventHandler(this.OnDesignerDisposed); } TypeDescriptor.Refreshed += new RefreshEventHandler(this.OnTypeDescriptorRefresh); }
internal DesignerToolboxInfo(ToolboxService toolboxService, IDesignerHost host) { this._toolboxService = toolboxService; this._host = host; this._selectionService = host.GetService(typeof(ISelectionService)) as ISelectionService; if (this._selectionService != null) { this._selectionService.SelectionChanged += new EventHandler(this.OnSelectionChanged); } if (this._host.RootComponent != null) { this._host.RootComponent.Disposed += new EventHandler(this.OnDesignerDisposed); } TypeDescriptor.Refreshed += new RefreshEventHandler(this.OnTypeDescriptorRefresh); }
private void AutoFormat_HelpRequested(object sender, HelpEventArgs e) { if ((this.dgrid != null) && (this.dgrid.Site != null)) { IDesignerHost host = this.dgrid.Site.GetService(typeof(IDesignerHost)) as IDesignerHost; if (host != null) { IHelpService service = host.GetService(typeof(IHelpService)) as IHelpService; if (service != null) { service.ShowHelpFromKeyword("vs.DataGridAutoFormatDialog"); } } } }
/// <summary> /// Called when it is time for the tab order UI to go away. /// </summary> protected override void Dispose(bool disposing) { if (disposing) { if (region != null) { region.Dispose(); region = null; } if (host != null) { IOverlayService os = (IOverlayService)host.GetService(typeof(IOverlayService)); if (os != null) { os.RemoveOverlay(this); } IEventHandlerService ehs = (IEventHandlerService)host.GetService(typeof(IEventHandlerService)); if (ehs != null) { ehs.PopHandler(this); } IMenuCommandService mcs = (IMenuCommandService)host.GetService(typeof(IMenuCommandService)); if (mcs != null) { foreach (MenuCommand mc in newCommands) { mcs.RemoveCommand(mc); } } // We sync add, remove and change events so we remain in sync with any nastiness that the // form may pull on us. // IComponentChangeService cs = (IComponentChangeService)host.GetService(typeof(IComponentChangeService)); if (cs != null) { cs.ComponentAdded -= new ComponentEventHandler(OnComponentAddRemove); cs.ComponentRemoved -= new ComponentEventHandler(OnComponentAddRemove); cs.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged); } IHelpService hs = (IHelpService)host.GetService(typeof(IHelpService)); if (hs != null) { hs.RemoveContextAttribute("Keyword", "TabOrderView"); } host = null; } } base.Dispose(disposing); }
/// <summary> /// The constructor for this class which takes the serviceprovider used to get the selectionservice. This ToolStripInSituService is ToolStrip specific. /// </summary> public ToolStripInSituService(IServiceProvider provider) { _sp = provider; _designerHost = (IDesignerHost)provider.GetService(typeof(IDesignerHost)); Debug.Assert(_designerHost != null, "ToolStripKeyboardHandlingService relies on the selection service, which is unavailable."); if (_designerHost != null) { _designerHost.AddService(typeof(ISupportInSituService), this); } _componentChangeSvc = (IComponentChangeService)_designerHost.GetService(typeof(IComponentChangeService)); Debug.Assert(_componentChangeSvc != null, "ToolStripKeyboardHandlingService relies on the componentChange service, which is unavailable."); if (_componentChangeSvc != null) { _componentChangeSvc.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); } }
internal object GetService(Type serviceType) { if (this.context != null) { IDesignerHost host = this.context.GetService(typeof(IDesignerHost)) as IDesignerHost; if (host == null) { return(this.context.GetService(serviceType)); } else { return(host.GetService(serviceType)); } } return(null); }
internal object GetService(Type serviceType) { if (_context == null) { return(null); } IDesignerHost host = _context.GetService(typeof(IDesignerHost)) as IDesignerHost; if (host == null) { return(_context.GetService(serviceType)); } return(host.GetService(serviceType)); }
protected override void OnHandleCreated(EventArgs e) { base.OnHandleCreated(e); if (DesignMode && Site != null) { designerHost = Site.GetService(typeof(IDesignerHost)) as IDesignerHost; behaviorService = designerHost?.GetService(typeof(BehaviorService)) as BehaviorService; var designer = designerHost?.GetDesigner(this) as ControlDesigner; if (designer != null) { var adorner = new Adorner(); behaviorService.Adorners.Insert(0, adorner); adorner.Glyphs.Add(new MyTLPGlypg(behaviorService, this)); } } }
//- rely on SurfaceManager.ActiveDesignSurface //- which effectively points to ACTIVE DesignSurface private void OrientPropertyGridTowardsObject() { //- IDesignerEventService provides a global eventing mechanism for designer events. With this mechanism, //- an application is informed when a designer becomes active. The service provides a collection of //- designers and a single place where global objects, such as the Properties window, can monitor selection //- change events. IDesignerEventService des = (IDesignerEventService) SurfaceManager.GetService( typeof( IDesignerEventService ) ); if( null == des ) return; IDesignerHost host = des.ActiveDesigner; //- get the ISelectionService from the active Designsurface //- and if we are not able to get it then it'sType better to exit ISelectionService iSel = host.GetService( typeof( ISelectionService ) ) as ISelectionService; if (iSel == null) return; //- get the name of the control selected from the comboBox //- and if we are not able to get it then it's better to exit object sName = pgrdComboBox.SelectedItem; //string sName = (pgrdComboBox.SelectedItem as EbControl).EbControl.Name; //if (string.IsNullOrEmpty(sName)) // return; //- save the collection of objects currently selected //- loop through the controls inside the current Designsurface //- if we find the one selected into the comboBox then //- use the ISelectionService to select it //- (and this will select it into the PropertyGridHost) ComponentCollection ctrlsExisting = host.Container.Components; Debug.Assert( 0 != ctrlsExisting.Count ); foreach( Component comp in ctrlsExisting ) { string sItemText = TranslateComponentToName( comp ); if ( sName == comp){ Component[] arr = { comp }; //- ISelectionService in action... iSel.SetSelectedComponents( arr ); //this.SelectedObject = arr[0]; break; } }//end_foreach }
private void mi_addComponent(object sender, EventArgs e) { IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost)); if (host != null) { HostSurface surface = host.GetService(typeof(DesignSurface)) as HostSurface; if (surface != null) { ClassPointer root = surface.Loader.GetRootId(); if (root != null) { root.AddComponent(null); } } } }
private void DeployMdxScript() { IDesignerHost designer = (IDesignerHost)ApplicationObject.ActiveWindow.Object; if (designer == null) { return; } ProjectItem pi = ApplicationObject.ActiveWindow.ProjectItem; EditorWindow win = (EditorWindow)designer.GetService(typeof(Microsoft.DataWarehouse.ComponentModel.IComponentNavigator)); if (win.SelectedView.MenuItemCommandID.ID == 12899) //if (win.SelectedView.Caption == "Calculations") { DeployMDXScriptPlugin.DeployScript(pi, this.ApplicationObject); } }
private void DeployMdxScript() { IDesignerHost designer = (IDesignerHost)ApplicationObject.ActiveWindow.Object; if (designer == null) { return; } ProjectItem pi = ApplicationObject.ActiveWindow.ProjectItem; EditorWindow win = (EditorWindow)designer.GetService(typeof(IComponentNavigator)); if (win.SelectedView.MenuItemCommandID.ID == (int)BIDSViewMenuItemCommandID.Calculations) //if (win.SelectedView.Caption == "Calculations") { DeployMdxScriptPlugin.Instance.DeployScript(pi, this.ApplicationObject); } }
protected override void OnDragDrop(DragEventArgs e) { object data = e.Data.GetData(typeof(ToolboxItem)); if (data != null) { IDesignerHost dh = DesignerHost; if (dh != null) { VOB.InterfaceVOB vob = dh.GetService(typeof(VOB.InterfaceVOB)) as VOB.InterfaceVOB; if (vob != null) { vob.SendNotice(VOB.enumVobNotice.NewObject, data); } } } }
public override IComponent[] CreateComponentsWithUI(IDesignerHost host) { Uri url = null; Type proxyClass = null; IExtendedUIService extUIService = host.GetService(typeof(IExtendedUIService)) as IExtendedUIService; if (extUIService != null) extUIService.AddWebReference(out url, out proxyClass); IComponent[] components = base.CreateComponentsWithUI(host); if (components.GetLength(0) > 0) { InvokeWebServiceActivity webService = components[0] as InvokeWebServiceActivity; if (webService != null) webService.ProxyClass = proxyClass; } return components; }
public override IComponent[] CreateComponentsWithUI(IDesignerHost host) { Uri url = null; Type proxyClass = null; IExtendedUIService service = host.GetService(typeof(IExtendedUIService)) as IExtendedUIService; if (service != null) { service.AddWebReference(out url, out proxyClass); } IComponent[] componentArray = base.CreateComponentsWithUI(host); if (componentArray.GetLength(0) > 0) { InvokeWebServiceActivity activity = componentArray[0] as InvokeWebServiceActivity; if (activity != null) { activity.ProxyClass = proxyClass; } } return componentArray; }
private static void EnsureDefaultChildHierarchy(IDesignerHost designerHost) { CompositeActivity rootComponent = designerHost.RootComponent as CompositeActivity; if ((rootComponent != null) && (rootComponent.Activities.Count == 0)) { object[] customAttributes = rootComponent.GetType().GetCustomAttributes(typeof(ToolboxItemAttribute), false); ToolboxItemAttribute attribute = ((customAttributes != null) && (customAttributes.GetLength(0) > 0)) ? (customAttributes[0] as ToolboxItemAttribute) : null; if ((attribute != null) && (attribute.ToolboxItemType != null)) { IComponent[] componentArray = (Activator.CreateInstance(attribute.ToolboxItemType, new object[] { rootComponent.GetType() }) as ToolboxItem).CreateComponents(); CompositeActivity activity2 = null; foreach (IComponent component in componentArray) { if (component.GetType() == rootComponent.GetType()) { activity2 = component as CompositeActivity; break; } } if ((activity2 != null) && (activity2.Activities.Count > 0)) { IIdentifierCreationService service = designerHost.GetService(typeof(IIdentifierCreationService)) as IIdentifierCreationService; if (service != null) { Activity[] childActivities = activity2.Activities.ToArray(); activity2.Activities.Clear(); service.EnsureUniqueIdentifiers(rootComponent, childActivities); foreach (Activity activity3 in childActivities) { rootComponent.Activities.Add(activity3); } foreach (Activity activity4 in childActivities) { WorkflowDesignerLoader.AddActivityToDesigner(designerHost, activity4); } } } } } }
internal SampleSelectionService(IDesignerHost host) { this.host = host; this.container = host.Container; this.selectionsByComponent = new Hashtable(); this.selectionChanged = false; this.batchMode = true; IComponentChangeService cs = (IComponentChangeService) host.GetService(typeof(IComponentChangeService)); Debug.Assert(cs != null, "IComponentChangeService not found"); if (cs != null) { cs.ComponentAdded += new ComponentEventHandler(this.DesignerHost_ComponentAdd); cs.ComponentRemoved += new ComponentEventHandler(this.DesignerHost_ComponentRemove); cs.ComponentChanged += new ComponentChangedEventHandler(this.DesignerHost_ComponentChanged); } host.TransactionOpened += new EventHandler(this.DesignerHost_TransactionOpened); host.TransactionClosed += new DesignerTransactionCloseEventHandler(this.DesignerHost_TransactionClosed); if (host.InTransaction) { this.DesignerHost_TransactionOpened(host, EventArgs.Empty); } host.LoadComplete += new EventHandler(this.DesignerHost_LoadComplete); }
protected override IComponent[] CreateComponentsCore(IDesignerHost host) { Type c = this.GetType(host, base.AssemblyName, base.TypeName, true); if ((c == null) && (host != null)) { c = host.GetType(base.TypeName); } if (c == null) { ITypeProviderCreator service = null; if (host != null) { service = (ITypeProviderCreator) host.GetService(typeof(ITypeProviderCreator)); } if (service != null) { Assembly transientAssembly = service.GetTransientAssembly(base.AssemblyName); if (transientAssembly != null) { c = transientAssembly.GetType(base.TypeName); } } if (c == null) { c = this.GetType(host, base.AssemblyName, base.TypeName, true); } } ArrayList list = new ArrayList(); if ((c != null) && typeof(IComponent).IsAssignableFrom(c)) { list.Add(TypeDescriptor.CreateInstance(null, c, null, null)); } IComponent[] array = new IComponent[list.Count]; list.CopyTo(array, 0); return array; }
protected override bool CanExecuteCommand(IDesignerHost host) { ISelectionService selectionService = (ISelectionService)host.GetService(typeof(ISelectionService)); return selectionService.SelectionCount > 1; }
private object GetReferences(IDesignerHost host) { object target = null; System.Type serviceType = System.Type.GetType("EnvDTE.ProjectItem, EnvDTE, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); if (serviceType == null) { return null; } target = host.GetService(serviceType); if (target == null) { return null; } target.GetType().InvokeMember("Name", BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance, null, target, null, CultureInfo.InvariantCulture).ToString(); object obj3 = target.GetType().InvokeMember("ContainingProject", BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance, null, target, null, CultureInfo.InvariantCulture); object obj4 = obj3.GetType().InvokeMember("Object", BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance, null, obj3, null, CultureInfo.InvariantCulture); return obj4.GetType().InvokeMember("References", BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance, null, obj4, null, CultureInfo.InvariantCulture); }
private System.Type GetAxTypeFromReference(object reference, IDesignerHost host) { string fileName = (string) reference.GetType().InvokeMember("Path", BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance, null, reference, null, CultureInfo.InvariantCulture); if ((fileName == null) || (fileName.Length <= 0)) { return null; } FileInfo info = new FileInfo(fileName); string fullName = info.FullName; Assembly a = ((ITypeResolutionService) host.GetService(typeof(ITypeResolutionService))).GetAssembly(AssemblyName.GetAssemblyName(fullName)); return this.GetAxTypeFromAssembly(a); }
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; }
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; }
//TODO: need to find a way to pick up changes to the package more quickly than just the WindowActivated event //The DtsPackageView object seems to have the appropriate methods, but it's internal to the Microsoft.DataTransformationServices.Design assembly. public override void OnWindowActivated(Window GotFocus, Window LostFocus) { try { if (GotFocus.Caption == "Expressions") return; if (GotFocus == null) { return; } if (GotFocus.DTE.Mode == vsIDEMode.vsIDEModeDebug) { return; } if (GotFocus.Object == null) { return; } designer = GotFocus.Object as IDesignerHost; if (designer == null) return; ProjectItem pi = GotFocus.ProjectItem; if (!(pi.Name.ToLower().EndsWith(".dtsx"))) { return; } win = (EditorWindow)designer.GetService(typeof(Microsoft.DataWarehouse.ComponentModel.IComponentNavigator)); return; } catch { } finally { } }
private static void PersistObject(HtmlTextWriter writer, object control, IDesignerHost host, bool runAtServer) { //look up tag prefix from host IWebFormReferenceManager refMan = host.GetService (typeof (IWebFormReferenceManager)) as IWebFormReferenceManager; if (refMan == null) throw new Exception("Could not obtain IWebFormReferenceManager service"); string prefix = refMan.GetTagPrefix (control.GetType ()); //write tag to HtmlTextWriter writer.WriteBeginTag (prefix + ":" + control.GetType().Name); //go through all the properties and add attributes if necessary PropertyDescriptorCollection properties = TypeDescriptor.GetProperties (control); foreach (PropertyDescriptor prop in properties) ProcessAttribute (prop, control, writer, string.Empty); if (runAtServer) writer.WriteAttribute ("runat", "server"); //do the same for events IComponent comp = control as IComponent; if (comp != null && comp.Site != null) { IEventBindingService evtBind = (IEventBindingService) comp.Site.GetService (typeof (IEventBindingService)); if (evtBind != null) foreach (EventDescriptor e in TypeDescriptor.GetEvents (comp)) ProcessEvent (e, comp, writer, evtBind); } //ControlDesigner designer = (ControlDesigner) host.GetDesigner(control); //TODO: we don't yet support designer.GetPersistInnerHtml() 'cause we don't have the designers... if (HasInnerProperties(control)) { writer.Write (HtmlTextWriter.TagRightChar); writer.Indent++; PersistInnerProperties (writer, control, host); writer.Indent--; writer.WriteEndTag (prefix + ":" + control.GetType ().Name); } else writer.Write (HtmlTextWriter.SelfClosingTagEnd); writer.WriteLine (); writer.Flush (); }
public override void Initialize(IComponent component) { base.Initialize(component); sections = new List<BaseSection>(); // We need to listen to change events. If a shape changes, // we need to invalidate our view. // this.componentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); if (this.componentChangeService != null) { this.componentChangeService.ComponentAdded += new ComponentEventHandler(OnComponentAdded); // this.componentChangeService.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving); // this.componentChangeService.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); this.componentChangeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); // this.componentChangeService.ComponentChanging += new ComponentChangingEventHandler(OnComponentChanging); } // Add the menu commands we support. We must be a member of the VSIP program to // define new menu items, but we can handle any item located within the StandardCommands // class because Visual Studio already defines them. // menuCommandService = (MenuCommandService)GetService(typeof(MenuCommandService)); /* if (menuCommandService != null) { /* m_menuCommands = new MenuCommand[] { new MenuCommand(new EventHandler(OnMenuCut), StandardCommands.Cut), new MenuCommand(new EventHandler(OnMenuCopy), StandardCommands.Copy), // new ImmediateMenuCommand(new EventHandler(OnMenuPasteStatus), new EventHandler(OnMenuPaste), StandardCommands.Paste), new MenuCommand(new EventHandler(OnMenuDelete), StandardCommands.Delete) }; foreach(MenuCommand mc in m_menuCommands) { m_menuCommandService.AddCommand(mc); } System.Console.WriteLine("RootDesigner menuService set"); } */ // Select our base shape. By default there is nothing selected but that looks // strange (the property grid is empty). // this.selectionService = (ISelectionService)GetService(typeof(ISelectionService)); if (this.selectionService != null) { this.selectionService.SetSelectedComponents(new object[] {component}, SelectionTypes.Replace); this.selectionService.SelectionChanged += new EventHandler(OnSelectionChanged); } this.host = (IDesignerHost)GetService(typeof(IDesignerHost)); this.menuCommandService = (MenuCommandService)host.GetService(typeof(MenuCommandService)); if (host != null) { host.LoadComplete += new EventHandler(OnLoadComplete); } //Dragdropp only allowed in Section this.Control.AllowDrop = false; }