public EditorHost (MonoDevelopProxy proxy) { this.proxy = proxy; //set up the services services = new ServiceContainer (); services.AddService (typeof(INameCreationService), new NameCreationService ()); services.AddService (typeof(ISelectionService), new SelectionService ()); services.AddService (typeof(ITypeResolutionService), new TypeResolutionService ()); services.AddService ( typeof(IEventBindingService), new AspNetEdit.Editor.ComponentModel.EventBindingService (proxy) ); ExtenderListService extListServ = new ExtenderListService (); services.AddService (typeof(IExtenderListService), extListServ); services.AddService (typeof(IExtenderProviderService), extListServ); services.AddService (typeof(ITypeDescriptorFilterService), new TypeDescriptorFilterService ()); services.AddService (typeof (IMenuCommandService), new AspNetEdit.Editor.ComponentModel.MenuCommandService ()); //services.AddService (typeof (IToolboxService), toolboxService); var project = MonoDevelop.Ide.IdeApp.Workbench.ActiveDocument.Project as AspNetAppProject; var aspParsedDoc = MonoDevelop.Ide.IdeApp.Workbench.ActiveDocument.ParsedDocument as AspNetParsedDocument; if (project != null && aspParsedDoc != null) { WebFormReferenceManager refMan = new WebFormReferenceManager (project); refMan.Doc = aspParsedDoc; services.AddService (typeof(WebFormReferenceManager), refMan); } System.Diagnostics.Trace.WriteLine ("Creating DesignerHost"); designerHost = new DesignerHost (services, this); System.Diagnostics.Trace.WriteLine ("Created DesignerHost"); designerHost.DocumentChanged += new DesignerHost.DocumentChangedEventHandler (OnDocumentChanged); }
/// <include file='doc\DocumentManager.uex' path='docs/doc[@for="DocumentManager.CreateDesigner2"]/*' /> /// <devdoc> /// Creates a new instance of a form designer. This takes a code stream and attempts /// to create a design instance for it. /// </devdoc> public IDesignerDocument CreateDesigner(DesignerLoader loader, IServiceProvider provider) { DesignerHost dh = new DesignerHost(); dh.Init(provider, loader); return(dh); }
private void OnRemovePage(Object sender, EventArgs e) { var parentControl = (MetroTabControl)Control; Control.ControlCollection oldTabs = parentControl.Controls; if (parentControl.SelectedIndex < 0) { return; } RaiseComponentChanging(TypeDescriptor.GetProperties(parentControl)["TabPages"]); DesignerHost.DestroyComponent(parentControl.TabPages[parentControl.SelectedIndex]); RaiseComponentChanged(TypeDescriptor.GetProperties(parentControl)["TabPages"], oldTabs, parentControl.TabPages); SelectionService.SetSelectedComponents(new IComponent[] { parentControl }, SelectionTypes.Auto); SetVerbs(); }
public DocumentSerializer (DesignerHost hst) { host = hst; document = host.RootDocument; designerContext = String.Empty; //designerContext = ((host.GetDesigner (host.RootComponent) as RootDesigner).GetView (ViewTechnology.Default) as RootDesignerView).DesignerContext; }
void OnInsertPage(Object sender, EventArgs e) { EbTabControl ParentControl = (EbTabControl)Control; Control.ControlCollection oldTabs = ParentControl.Controls; int Index = ParentControl.SelectedIndex; RaiseComponentChanging(TypeDescriptor.GetProperties(ParentControl)["TabPages"]); EbTabPage P = (EbTabPage)(DesignerHost.CreateComponent(typeof(EbTabPage))); P.Text = P.Name; EbTabPage[] tpc = new EbTabPage[ParentControl.TabCount]; //Starting at our Insert Position, store and remove all the tabpages. for (int i = Index; i <= tpc.Length - 1; i++) { tpc[i] = (EbTabPage)ParentControl.TabPages[Index]; ParentControl.TabPages.Remove(ParentControl.TabPages[Index]); } //add the tabpage to be inserted. ParentControl.TabPages.Add(P); //then re-add the original tabpages. for (int i = Index; i <= tpc.Length - 1; i++) { ParentControl.TabPages.Add(tpc[i]); } RaiseComponentChanged(TypeDescriptor.GetProperties(ParentControl)["TabPages"], oldTabs, ParentControl.TabPages); ParentControl.SelectedTab = P; SetVerbs(); }
/// <summary> /// Handles the <see cref="E:RemoveTabPage" /> event. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void OnRemove_TabPage(object sender, System.EventArgs e) { ZeroitAyensuTab ParentControl = (ZeroitAyensuTab)this.Control; if (ParentControl.SelectedIndex < 0) { Verbs_Set(); MessageBox.Show("No TabPage selected."); return; } System.Windows.Forms.Control.ControlCollection oldTabs = ParentControl.Controls; RaiseComponentChanging(TypeDescriptor.GetProperties(ParentControl)["TabPages"]); DesignerHost.DestroyComponent(ParentControl.TabPages[ParentControl.SelectedIndex]); RaiseComponentChanged( TypeDescriptor.GetProperties(ParentControl)["TabPages"], oldTabs, ParentControl.TabPages ); SelectionService.SetSelectedComponents( new IComponent[] { ParentControl }, //System.ComponentModel.Design.SelectionTypes.Auto // .Auto is undefined System.ComponentModel.Design.SelectionTypes.Normal ); Verbs_Set(); }
private void OnInsertPage(object sender, EventArgs e) { VisualTabControl _parentalControl = (VisualTabControl)Control; Control.ControlCollection _controlCollection = _parentalControl.Controls; int _index = _parentalControl.SelectedIndex; RaiseComponentChanging(TypeDescriptor.GetProperties(_parentalControl)["TabPages"]); VisualTabPage _tabPage = (VisualTabPage)DesignerHost.CreateComponent(typeof(VisualTabPage)); _tabPage.Text = _tabPage.Name; var _tabPageCollection = new VisualTabPage[_parentalControl.TabCount]; // Starting at our Insert Position, store and remove all the tab pages. for (int i = _index; i <= _tabPageCollection.Length - 1; i++) { _tabPageCollection[i] = (VisualTabPage)_parentalControl.TabPages[_index]; _parentalControl.TabPages.Remove(_parentalControl.TabPages[_index]); } // add the tab page to be inserted. _parentalControl.TabPages.Add(_tabPage); // then re-add the original tab pages. for (int i = _index; i <= _tabPageCollection.Length - 1; i++) { _parentalControl.TabPages.Add(_tabPageCollection[i]); } RaiseComponentChanged(TypeDescriptor.GetProperties(_parentalControl)["TabPages"], _controlCollection, _parentalControl.TabPages); _parentalControl.SelectedTab = _tabPage; SetVerbs(); }
///<summary>Creates a new document</summary> public Document (Control parent, DesignerHost host, string documentName) { initDocument (parent, host); //newDocument. this.textEditor //Parse (String.Format (newDocument, documentName), documentName); // TODO: get a ExtensibleTextEditor instance, if we have an new empty file }
/// <summary> /// Removes the current page. /// </summary> protected void RemovePageHandler(object sender, EventArgs e) { if (DesignerHost != null) { if (Control.Pages.Count > 1) { Page page = Control.SelectedPage; if (page != null) { int index = Control.SelectedIndex; DesignerHost.DestroyComponent(page); if (index == Control.Pages.Count) { index = Control.Pages.Count - 1; } Control.SelectedIndex = index; if (SelectionService != null) { SelectionService.SetSelectedComponents(new Component[] { Control.SelectedPage }); } } } } }
protected override void OnLoad(EventArgs args) { base.OnLoad(args); _DesignSurface = new DesignSurface(); _DesignSurface.Loaded += new LoadedEventHandler(OnDesignSurfaceLoaded); _ToolboxControl.AddToolboxItem(new ToolboxItem() { TypeName = NameConsts.Pointer, DisplayName = Properties.Resources.Tool_Pointer, Bitmap = new Bitmap(1, 1) }); ToolMap.All(pair => { _ToolboxControl.AddToolboxItem(new ToolboxItem(pair.Key) { DisplayName = pair.Value }); return(true); }); DesignerHost = _DesignSurface.GetService(typeof(IDesignerHost)) as IDesignerHost; DesignerHost.AddService(typeof(IToolboxService), _ToolboxControl.ToolboxService); //DesignerHost.AddService( typeof( IPropertyValueUIService ), new GlyphService() ); SelectionService = _DesignSurface.GetService(typeof(ISelectionService)) as ISelectionService; SelectionService.SelectionChanged += OnDesignerSurfaceView_SelectionChanged; // Initialise the DesignSurface class _DesignSurface.BeginLoad(typeof(RootDesignedComponent)); }
public void ToolBoxItemButtonKeyDown(System.Windows.Forms.KeyEventArgs e, System.Drawing.Design.ToolboxItem toolboxItem) { if (toolboxItem == null) { return; } switch (e.KeyCode) { case Keys.Enter: if (DesignerHost == null) { MessageBox.Show("idh Null"); } IToolboxUser tbu = DesignerHost.GetDesigner(DesignerHost.RootComponent as IComponent) as IToolboxUser; if (tbu != null) { // Enter means place the tool with default location and default size. tbu.ToolPicked(toolboxItem); } break; default: { Console.WriteLine("Error: Not able to add"); break; } } }
/// <summary> /// Handles the <see cref="E:RemovePage" /> event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> void OnRemovePage(Object sender, EventArgs e) { MaterialTabControl ParentControl = (MaterialTabControl)Control; System.Windows.Forms.Control.ControlCollection oldTabs = ParentControl.Controls; if (ParentControl.SelectedIndex < 0) { return; } RaiseComponentChanging(TypeDescriptor.GetProperties(ParentControl)["TabPages"]); DesignerHost.DestroyComponent(ParentControl.TabPages[ParentControl.SelectedIndex]); RaiseComponentChanged(TypeDescriptor.GetProperties(ParentControl)["TabPages"], oldTabs, ParentControl.TabPages); SelectionService.SetSelectedComponents(new IComponent[] { ParentControl }, SelectionTypes.Auto); SetVerbs(); }
protected override void OnDragDrop(DragEventArgs de) { base.OnDragDrop(de); var insertionIndex = (_insertionBeforeControl == null) ? Panel.Controls.Count : Panel.Controls.IndexOf(_insertionBeforeControl); var transaction = DesignerHost.CreateTransaction($"Move {GetSelectedControlsString()} to position {insertionIndex} in {Panel.Name}"); using (transaction) using (Panel.ChangingComponentProperty(nameof(Panel.Controls))) { SelectionService.GetSelectedComponents() .OfType <Control>() .ToList() .ForEach(control => { var currentIndex = Panel.Controls.GetChildIndex(control); if (currentIndex >= 0 && currentIndex < insertionIndex) { insertionIndex--; } Panel.Controls.SetChildIndex(control, insertionIndex++); }); transaction.Commit(); } ClearInsertionDisplay(); }
private IWebApplication GetWebApplication() { IWebApplication webApplication = (IWebApplication)DesignerHost.GetService(typeof(IWebApplication)); Assertion.IsNotNull(webApplication, "The 'IServiceProvider' failed to return an 'IWebApplication' service."); return(webApplication); }
protected override void OnCommit () { if (host == null) return; host.OnTransactionClosing (true); host.OnTransactionClosed (true, this); host = null; }
protected override void OnCancel () { if (host == null) return; host.OnTransactionClosing ( false); host.OnTransactionClosed (false, this); host = null; }
///<summary>Creates a document from an existing file</summary> public Document (Control parent, DesignerHost host, string document, string fileName) { initDocument (parent, host); Control[] controls; aspParser.ProcessFragment (document, out controls, out this.document); GetView (); }
/// <include file='doc\DocumentManager.uex' path='docs/doc[@for="DocumentManager.CreateDesigner3"]/*' /> /// <devdoc> /// Creates a new instance of a form designer. This uses the given component class /// name as the base component for the class. The designer for the component /// class is responsible for attaching a code stream if it wants to persist /// information. /// </devdoc> public IDesignerDocument CreateDesigner(string componentClass, IServiceProvider provider) { DesignerHost dh = new DesignerHost(); ComponentDesignerLoader cs = new ComponentDesignerLoader(componentClass); dh.Init(provider, cs); return(dh); }
public DesignTimeParser (DesignerHost host, Document document) { this.host = host; this.document = document; refMan = host.GetService(typeof(IWebFormReferenceManager)) as IWebFormReferenceManager; if (refMan == null) throw new Exception ("Could not get IWebFormReferenceManager from host"); }
//TODO: Some way to reset this when host is reset public WebFormReferenceManager (DesignerHost host) { if (host == null) throw new ArgumentNullException ("host"); this.host = host; this.typeRes = host.GetService (typeof (ITypeResolutionService)) as ITypeResolutionService; if (typeRes == null) throw new Exception ("Could not obtain ITypesResolutionService from host"); }
private void RemovePage(object sender, System.EventArgs e) { if (DesignerHost != null) { DesignerHost.DestroyComponent(TabControl.TabPages[TabControl.SelectedIndex]); TabControl.TabPages.RemoveAt(TabControl.SelectedIndex); verbRemovePage.Enabled = TabControl.TabPages.Count > 0; } }
public void AddTab() { TabPage page = (TabPage)DesignerHost.CreateComponent(typeof(TabPage)); page.Text = page.Name; this.KryptonTabControl.TabPages.Add(page); this.KryptonTabControl.SelectedTab = page; }
private void AddPage(object sender, System.EventArgs e) { if (DesignerHost != null) { IComponent c = DesignerHost.CreateComponent(typeof(ComponentsNET.cnTabPage)); TabControl.TabPages.Add(c as cnTabPage); verbRemovePage.Enabled = true; } }
public DesignTimeParser(DesignerHost host, Document document) { this.host = host; this.document = document; refMan = host.GetService(typeof(IWebFormReferenceManager)) as IWebFormReferenceManager; if (refMan == null) { throw new Exception("Could not get IWebFormReferenceManager from host"); } }
public override void OnSetComponentDefaults() { HostControl.ManagedPanels.Add((ManagedPanel)DesignerHost.CreateComponent(typeof(ManagedPanel))); HostControl.ManagedPanels.Add((ManagedPanel)DesignerHost.CreateComponent(typeof(ManagedPanel))); PanelManager pm = (PanelManager)Control; pm.ManagedPanels[0].Text = pm.ManagedPanels[0].Name; pm.ManagedPanels[1].Text = pm.ManagedPanels[1].Name; HostControl.SelectedIndex = 0; }
public override void InitializeNewComponent(IDictionary defaultValues) { base.InitializeNewComponent(defaultValues); HostControl.ManagedPanels.Add((Controls.ManagedPanel)DesignerHost.CreateComponent(typeof(Controls.ManagedPanel))); HostControl.ManagedPanels.Add((Controls.ManagedPanel)DesignerHost.CreateComponent(typeof(Controls.ManagedPanel))); Controls.PanelManager pm = (Controls.PanelManager) this.Control; pm.ManagedPanels[0].Text = pm.ManagedPanels[0].Name; pm.ManagedPanels[1].Text = pm.ManagedPanels[1].Name; HostControl.SelectedIndex = 0; }
public void RemoveTab() { if (this.KryptonTabControl.SelectedTab == null) { return; } TabPage page = this.KryptonTabControl.SelectedTab; DesignerHost.DestroyComponent(page); SelectionService.SetSelectedComponents(new IComponent[] { this.KryptonTabControl }, SelectionTypes.Auto); }
internal override bool SendNotification(GridEntry entry, Notify notification) { DesignerTransaction transaction = DesignerHost?.CreateTransaction(); try { return(base.SendNotification(entry, notification)); } finally { transaction?.Commit(); } }
protected internal override bool NotifyChildValue(GridEntry entry, Notify type) { DesignerTransaction transaction = DesignerHost?.CreateTransaction(); try { return(base.NotifyChildValue(entry, type)); } finally { transaction?.Commit(); } }
public override void InitializeNewComponent(IDictionary defaultValues) { base.InitializeNewComponent(defaultValues); VisualTabPage _tabPage1 = (VisualTabPage)DesignerHost.CreateComponent(typeof(VisualTabPage)); VisualTabPage _tabPage2 = (VisualTabPage)DesignerHost.CreateComponent(typeof(VisualTabPage)); _tabPage1.Text = _tabPage1.Name; _tabPage2.Text = _tabPage2.Name; Control.Controls.Add(_tabPage1); Control.Controls.Add(_tabPage2); }
private AccessibleObject GetDesignerAccessibleObject(Control.ControlAccessibleObject cao) { if (cao is null) { return(null); } if (DesignerHost.GetDesigner(cao.Owner) is ControlDesigner ctlDesigner) { return(ctlDesigner.AccessibilityObject); } return(null); }
/// <summary> /// Adds a tab to the designed control. /// </summary> public void AddTab() { if (DesignerHost != null) { Tab tab = (Tab)DesignerHost.CreateComponent(typeof(Tab)); PropertyDescriptor nameProp = TypeDescriptor.GetProperties(tab)["Name"]; string name = (string)nameProp.GetValue(tab); PropertyDescriptor textProp = TypeDescriptor.GetProperties(tab)["Text"]; textProp.SetValue(tab, name); Control.Tabs.Add(tab); Control.SelectedTab = tab; } }
private RootDesignerView(IDesignerHost host) : base() { //it's through this that we communicate with JavaScript comm = new CommandManager(this); //we use the host to get services and designers this.host = host as DesignerHost; if (this.host == null) { throw new ArgumentNullException("host"); } //We use this to monitor component changes and update as necessary changeService = host.GetService(typeof(IComponentChangeService)) as IComponentChangeService; if (changeService == null) { throw new Exception("Could not obtain IComponentChangeService from host"); } //We use this to monitor and set selections selectionService = host.GetService(typeof(ISelectionService)) as ISelectionService; if (selectionService == null) { throw new Exception("Could not obtain ISelectionService from host"); } //This is used to add undo/redo, cut/paste etc commands to menu //Also to launch right-click menu menuService = host.GetService(typeof(IMenuCommandService)) as IMenuCommandService; //if (menuService == null) // return; //Now we've got all services, register our events changeService.ComponentChanged += new ComponentChangedEventHandler(changeService_ComponentChanged); selectionService.SelectionChanged += new EventHandler(selectionService_SelectionChanged); //Register incoming calls from JavaScript comm.RegisterJSHandler("Click", new ClrCall(JSClick)); comm.RegisterJSHandler("Activate", new ClrCall(JSActivate)); comm.RegisterJSHandler("ThrowException", new ClrCall(JSException)); comm.RegisterJSHandler("DebugStatement", new ClrCall(JSDebugStatement)); comm.RegisterJSHandler("ResizeControl", new ClrCall(JSResize)); comm.RegisterJSHandler("DocumentReturn", new ClrCall(JSDocumentReturn)); comm.RegisterJSHandler("RemoveControl", new ClrCall(JSRemoveControl)); comm.RegisterJSHandler("DeserializeAndAdd", new ClrCall(JSDeserializeAndAdd)); comm.RegisterJSHandler("Serialize", new ClrCall(JSSerialize)); System.Diagnostics.Trace.WriteLine("RootDesignerView created"); }
/// <summary> /// Adds a new page. /// </summary> protected void AddPageHandler(object sender, EventArgs e) { if (DesignerHost != null) { Page page = (Page)DesignerHost.CreateComponent(typeof(Page)); page.Text = string.Format("Page {0}", Control.Pages.Count + 1); Control.Pages.Add(page); Control.SelectedPage = page; if (SelectionService != null) { SelectionService.SetSelectedComponents(new Component[] { Control.SelectedPage }); } } }
private void OnAddPanel(Object sender, EventArgs e) { Control.ControlCollection oldManagedPanels = HostControl.Controls; RaiseComponentChanging(TypeDescriptor.GetProperties(HostControl)["ManagedPanels"]); Controls.ManagedPanel P = (Controls.ManagedPanel)DesignerHost.CreateComponent(typeof(Controls.ManagedPanel)); P.Text = P.Name; HostControl.ManagedPanels.Add(P); RaiseComponentChanged(TypeDescriptor.GetProperties(HostControl)["ManagedPanels"], oldManagedPanels, HostControl.ManagedPanels); HostControl.SelectedPanel = P; SetVerbs(); }
private DesignerTransaction CreateDesignerTransaction(String description) { try { return(DesignerHost.CreateTransaction(description)); } catch (CheckoutException exc) { if (exc != CheckoutException.Canceled) { throw; } } return(null); }
private void OnAddPage(object sender, EventArgs e) { VisualTabControl _parentalControl = (VisualTabControl)Control; Control.ControlCollection _controlCollection = _parentalControl.Controls; RaiseComponentChanging(TypeDescriptor.GetProperties(_parentalControl)["TabPages"]); VisualTabPage _tabPage = (VisualTabPage)DesignerHost.CreateComponent(typeof(VisualTabPage)); _tabPage.Text = _tabPage.Name; _parentalControl.TabPages.Add(_tabPage); RaiseComponentChanged(TypeDescriptor.GetProperties(_parentalControl)["TabPages"], _controlCollection, _parentalControl.TabPages); _parentalControl.SelectedTab = _tabPage; SetVerbs(); }
/// <summary> /// The event handler for the "Remove Tab Page" verb. /// </summary> /// <remarks> /// Removes the current tab page from the control. /// </remarks> /// <param name="sender">The object that triggered the event.</param> /// <param name="e">An <see cref="EventArgs"/> describing the event arguments.</param> private void RemoveTabPage(object sender, EventArgs e) { if (DesignedTabControl.SelectedIndex < 0) { return; } VerticalTabControl.TabPageCollection tpcOldPages = DesignedTabControl.TabPages; RaiseComponentChanging(TypeDescriptor.GetProperties(DesignedTabControl)["TabPages"]); DesignerHost.DestroyComponent((VerticalTabPage)(DesignedTabControl.TabPages[DesignedTabControl.SelectedIndex])); RaiseComponentChanged(TypeDescriptor.GetProperties(DesignedTabControl)["TabPages"], tpcOldPages, DesignedTabControl.TabPages); SelectionService.SetSelectedComponents(new IComponent[] { DesignedTabControl }, SelectionTypes.Auto); EnableVerbs(); }
private void initDocument (Control parent, DesignerHost host) { System.Diagnostics.Trace.WriteLine ("Creating document..."); if (!(parent is WebFormPage)) throw new NotImplementedException ("Only WebFormsPages can have a document for now"); this.parent = parent; this.host = host; if (!host.Loading) throw new InvalidOperationException ("The document cannot be initialised or loaded unless the host is loading"); CaseInsensitiveHashCodeProvider provider = new CaseInsensitiveHashCodeProvider(CultureInfo.InvariantCulture); CaseInsensitiveComparer comparer = new CaseInsensitiveComparer(CultureInfo.InvariantCulture); directives = new Hashtable (provider, comparer); this.aspParser = new DesignTimeParser (host, this); }
public RootDesignerView (IDesignerHost host) : base() { //we use the host to get services and designers this.host = host as DesignerHost; if (this.host == null) throw new ArgumentNullException ("host"); baseUri = String.Empty; designerContext = String.Empty; msgManager = new DesignerMessageManager (host as DesignerHost, this); menu = new ContextMenu (host as DesignerHost); menu.Initialize (); // subscribe to messages from the designer surface this.TitleChanged += new TitleChangedHandler (WebView_OnTitleChanged); }
private RootDesignerView (IDesignerHost host) : base() { //it's through this that we communicate with JavaScript comm = new CommandManager (this); //we use the host to get services and designers this.host = host as DesignerHost; if (this.host == null) throw new ArgumentNullException ("host"); //We use this to monitor component changes and update as necessary changeService = host.GetService (typeof (IComponentChangeService)) as IComponentChangeService; if (changeService == null) throw new Exception ("Could not obtain IComponentChangeService from host"); //We use this to monitor and set selections selectionService = host.GetService (typeof (ISelectionService)) as ISelectionService; if (selectionService == null) throw new Exception ("Could not obtain ISelectionService from host"); //This is used to add undo/redo, cut/paste etc commands to menu //Also to launch right-click menu menuService = host.GetService (typeof (IMenuCommandService)) as IMenuCommandService; //if (menuService == null) // return; //Now we've got all services, register our events changeService.ComponentChanged += new ComponentChangedEventHandler (changeService_ComponentChanged); selectionService.SelectionChanged += new EventHandler (selectionService_SelectionChanged); //Register incoming calls from JavaScript comm.RegisterJSHandler ("Click", new ClrCall (JSClick)); comm.RegisterJSHandler ("Activate", new ClrCall (JSActivate)); comm.RegisterJSHandler ("ThrowException", new ClrCall (JSException)); comm.RegisterJSHandler ("DebugStatement", new ClrCall (JSDebugStatement)); comm.RegisterJSHandler ("ResizeControl", new ClrCall (JSResize)); comm.RegisterJSHandler ("DocumentReturn", new ClrCall (JSDocumentReturn)); comm.RegisterJSHandler ("RemoveControl", new ClrCall (JSRemoveControl)); comm.RegisterJSHandler ("DeserializeAndAdd", new ClrCall (JSDeserializeAndAdd)); comm.RegisterJSHandler ("Serialize", new ClrCall (JSSerialize)); System.Diagnostics.Trace.WriteLine ("RootDesignerView created"); }
public EditorHost (MonoDevelopProxy proxy) { this.proxy = proxy; //set up the services services = new ServiceContainer (); services.AddService (typeof (INameCreationService), new NameCreationService ()); services.AddService (typeof (ISelectionService), new SelectionService ()); services.AddService (typeof (ITypeResolutionService), new TypeResolutionService ()); services.AddService (typeof (IEventBindingService), new AspNetEdit.Editor.ComponentModel.EventBindingService (proxy)); ExtenderListService extListServ = new ExtenderListService (); services.AddService (typeof (IExtenderListService), extListServ); services.AddService (typeof (IExtenderProviderService), extListServ); services.AddService (typeof (ITypeDescriptorFilterService), new TypeDescriptorFilterService ()); //services.AddService (typeof (IToolboxService), toolboxService); System.Diagnostics.Trace.WriteLine ("Creating DesignerHost"); host = new DesignerHost (services); System.Diagnostics.Trace.WriteLine ("Created DesignerHost"); }
private void Initialize() { IDesignerHost host; Form form; IRootDesigner rootDesigner; Control view; // Initialise service container and designer host serviceContainer = new ServiceContainer(); serviceContainer.AddService(typeof(INameCreationService), new NameCreationService()); serviceContainer.AddService(typeof(IUIService), new UIService(this)); host = new DesignerHost(serviceContainer); // Add toolbox service serviceContainer.AddService(typeof(IToolboxService), lstToolbox); lstToolbox.designPanel = pnlViewHost; PopulateToolbox(lstToolbox); // Add menu command service menuService = new MenuCommandService(); serviceContainer.AddService(typeof(IMenuCommandService), menuService); // Start the designer host off with a Form to design form = (Form)host.CreateComponent(typeof(Form)); form.TopLevel = false; form.Text = "Form1"; // Get the root designer for the form and add its design view to this form rootDesigner = (IRootDesigner)host.GetDesigner(form); view = (Control)rootDesigner.GetView(ViewTechnology.WindowsForms); view.Dock = DockStyle.Fill; pnlViewHost.Controls.Add(view); // Subscribe to the selectionchanged event and activate the designer ISelectionService s = (ISelectionService)serviceContainer.GetService(typeof(ISelectionService)); s.SelectionChanged += new EventHandler(OnSelectionChanged); host.Activate(); }
public BrowserDesignerTransaction(DesignerHost host) : base() { _host = host; }
Document IDocumentFactory.CreateDocument(DocumentProjectItem projectItem, bool readOnly, DocumentMode mode, DocumentViewType initialView, out DocumentWindow documentWindow, out DesignerHost designerHost) { if (projectItem == null) { throw new ArgumentNullException("projectItem"); } if (initialView == DocumentViewType.Default) { initialView = WebPackage.Instance.WebDefaultView; if (initialView == DocumentViewType.Source) { initialView = DocumentViewType.Composite; } } documentWindow = null; AscxDocument document = new AscxDocument(projectItem); designerHost = new WebFormsDesignerHost(document); document.Load(readOnly); Page page = null; UserControl child = null; if (document.DocumentDirective.Inherits.ToLower().IndexOf("mobile") < 0) { page = new Page(); child = new UserControl(); child.ID = "Page"; documentWindow = new AscxDocumentWindow(designerHost, document, initialView); page.Site = new AscxPageSite(designerHost, page); page.DesignerInitialize(); page.Controls.Add(child); } else { if (!_mobileAssemblyLoadFailed) { if (_mobileAssembly == null) { _mobileAssembly = Assembly.LoadWithPartialName(_mobileAssemblyName); } if (_mobileAssembly != null) { document.Dispose(); document = new AscxDocument(projectItem); Type type = _mobileAssembly.GetType("System.Web.UI.MobileControls.MobilePage"); Type type2 = _mobileAssembly.GetType("System.Web.UI.MobileControls.MobileUserControl"); Type type3 = _mobileAssembly.GetType("System.Web.UI.MobileControls.Form"); page = (Page) Activator.CreateInstance(type); child = (UserControl) Activator.CreateInstance(type2); Control control2 = (Control) Activator.CreateInstance(type3); Type type4 = Type.GetType("Microsoft.Matrix.Packages.Web.Mobile.MobileDesignerHost, Microsoft.Matrix.Packages.Web.Mobile"); designerHost = (DesignerHost) Activator.CreateInstance(type4, new object[] { document }); document.Load(readOnly); Type type5 = Type.GetType("Microsoft.Matrix.Packages.Web.Mobile.MobileWebFormsDocumentWindow, Microsoft.Matrix.Packages.Web.Mobile"); documentWindow = (DocumentWindow) Activator.CreateInstance(type5, new object[] { designerHost, document, initialView }); page.Site = new AscxPageSite(designerHost, page); page.DesignerInitialize(); page.Controls.Add(control2); control2.Controls.Add(child); } else { _mobileAssemblyLoadFailed = true; } } if (_mobileAssemblyLoadFailed) { document.Dispose(); Document document2 = new TextDocument(projectItem); designerHost = new DesignerHost(document2); ((IMxUIService) designerHost.GetService(typeof(IMxUIService))).ReportError("Microsoft Mobile Internet Toolkit is required for design-time editing of mobile user controls.\r\nPlease visit 'http://www.asp.net/mobile/default.aspx' for more information.\r\nThe user control will be opened in the text editor instead.", "Mobile User Controls are not enabled.", true); document2.Load(readOnly); documentWindow = new TextDocumentWindow(designerHost, document2); return document2; } } IDesignerHost host = designerHost; host.Container.Add(child, "UserControl"); child.DesignerInitialize(); return document; }
public MegaDesignerTransaction(DesignerHost host, string description) : base(description) { // Record a reference to the designer host, as we need this in order to tell it the transaction has been completed this.host = host; }
private void initDocument (Control parent, DesignerHost host) { System.Diagnostics.Trace.WriteLine ("Creating document..."); // get the ExtensibleTextEditor instance of the Source code's view textEditor = IdeApp.Workbench.ActiveDocument.PrimaryView.GetContent<SourceEditorView> ().TextEditor; if (!(parent is WebFormPage)) throw new NotImplementedException ("Only WebFormsPages can have a document for now"); this.parent = parent; this.host = host; if (!host.Loading) throw new InvalidOperationException ("The document cannot be initialised or loaded unless the host is loading"); directives = new Hashtable (StringComparer.InvariantCultureIgnoreCase); txtDocDirty = true; suppressSerialization = false; // create and set the event, to let the parser run the first time updateEditorContent = new ManualResetEvent (true); undoTracker = new UndoTracker (); undoHandler = IdeApp.Workbench.ActiveDocument.PrimaryView.GetContent <IUndoHandler> (); if (undoHandler == null) throw new NullReferenceException ("Could not obtain the IUndoHandler from the SourceEditorView"); }
///<summary>Creates a document from an existing file</summary> public Document (Control parent, DesignerHost host) { initDocument (parent, host); }
public DesignerSerializer (DesignerHost hst) { host = hst; document = host.RootDocument; }
public DesignLayer(DesignerHost designerHost, IServiceProvider serviceProvider, string name, IDesigner parentDesigner, bool clearOnActivate) { this._designerHost = designerHost; this._serviceProvider = serviceProvider; this._name = name; this._parentDesigner = parentDesigner; this._clearOnActivate = clearOnActivate; }
public MxDesignerTransaction(DesignerHost host, string description) : base(description) { this._host = host; if (this._host._transactionStack == null) { this._host._transactionStack = new DesignerHost.DesignerTransactionStack(); } this._host._transactionStack.Push(description); if (this._host._transactionStack.Count == 1) { this._host.OnTransactionOpening(EventArgs.Empty); this._host.OnTransactionOpened(EventArgs.Empty); } }
internal DesignerHost(BrowserTree objTree, Panel imagePanel) { _imagePanel = imagePanel; if (_host == null) { _host = this; _serviceContainer = new ServiceContainer(); _serviceContainer.AddService(typeof(IDesignerHost), _host); _serviceContainer.AddService(typeof(IUIService), _host); _serviceContainer.AddService(typeof(ISelectionService), _host); _serviceContainer.AddService(typeof(IToolboxService), new ToolboxService()); } _container = new DesignerContainer(this); _defaultSite = new DesignerSite(this, null, _container, "Default site"); _designSurfaceSite = (DesignerSite)_container.CreateSite(_imagePanel, "Design Surface"); // Hook the design surface to the ParentControlDesigner _parentControlDesigner = new DummyDesigner(); _imagePanel.Site = _designSurfaceSite; _designSurfaceSite.Designer = _parentControlDesigner; _parentControlDesigner.Initialize(_imagePanel); // Used to make sure we don't give a designer for anything higher // than the design surface (GetDesigner is called on the // surface's parent) _designSurfaceParent = ((Control)_imagePanel).Parent; // Get the type for the UI selection service, since its private // the compiler will not let us see it _typeISelectionUIService = ReflectionHelper.GetType("System.Windows.Forms.Design.ISelectionUIService"); // This is required to get an instance of the selection // UI service installed, we don't actually use this // designer for anything _fakePanel = new Panel(); IDesigner compDes = new ComponentDocumentDesigner(); _fakePanel.Site = _container.CreateSite(_fakePanel, "Fake Design Surface"); compDes.Initialize(_fakePanel); // Make the size of the selection service cover the design // surface panel so that it will see all of the events _selUIService = (Control)GetService(_typeISelectionUIService); ObjectBrowser.ImagePanel.ResetSize(_selUIService); _imagePanel.Controls.Add(_selUIService); _imagePanel.SizeChanged += new EventHandler(ImagePanelSizeChange); DesignMode = true; // So we change the object selected when a control is selected SelectionChanged += new EventHandler(objTree.ControlSelectionChanged); }
protected void Dispose (bool disposing) { if (_designerHost != null) { _designerHost.Dispose (); _designerHost.DesignerLoaderHostLoaded -= new LoadedEventHandler (OnDesignerHost_Loaded); _designerHost.DesignerLoaderHostLoading -= new EventHandler (OnDesignerHost_Loading); _designerHost.DesignerLoaderHostUnloading -= new EventHandler (OnDesignerHost_Unloading); _designerHost.DesignerLoaderHostUnloaded -= new EventHandler (OnDesignerHost_Unloaded); _designerHost.Activated -= new EventHandler (OnDesignerHost_Activated); _designerHost = null; } if (_serviceContainer != null) { _serviceContainer.Dispose (); _serviceContainer = null; } if (Disposed != null) Disposed (this, EventArgs.Empty); }
protected override void OnCommit() { if (this._host != null) { string text1 = (string) this._host._transactionStack.Pop(); if (this._host._transactionStack.Count == 0) { DesignerTransactionCloseEventArgs e = new DesignerTransactionCloseEventArgs(true); this._host.OnTransactionClosing(e); this._host.OnTransactionClosed(e); } this._host = null; } }
// this ctor doesn't load the surface // public DesignSurface (IServiceProvider parentProvider) { _serviceContainer = new DesignSurfaceServiceContainer (parentProvider); _serviceContainer.AddNonReplaceableService (typeof (IServiceContainer), _serviceContainer); _designerHost = new DesignerHost ((IServiceProvider) _serviceContainer); _designerHost.DesignerLoaderHostLoaded += new LoadedEventHandler (OnDesignerHost_Loaded); _designerHost.DesignerLoaderHostLoading += new EventHandler (OnDesignerHost_Loading); _designerHost.DesignerLoaderHostUnloading += new EventHandler (OnDesignerHost_Unloading); _designerHost.DesignerLoaderHostUnloaded += new EventHandler (OnDesignerHost_Unloaded); _designerHost.Activated += new EventHandler (OnDesignerHost_Activated); _serviceContainer.AddNonReplaceableService (typeof (IComponentChangeService), _designerHost); _serviceContainer.AddNonReplaceableService (typeof (IDesignerHost), _designerHost); _serviceContainer.AddNonReplaceableService (typeof (IContainer), _designerHost); _serviceContainer.AddService (typeof (ITypeDescriptorFilterService), (ITypeDescriptorFilterService) new TypeDescriptorFilterService (_serviceContainer)); ExtenderService extenderService = new ExtenderService (); _serviceContainer.AddService (typeof (IExtenderProviderService), (IExtenderProviderService) extenderService); _serviceContainer.AddService (typeof (IExtenderListService), (IExtenderListService) extenderService); UISelectionService selection = new UISelectionService ((IServiceProvider) _serviceContainer); _serviceContainer.AddService (typeof (ISelectionService), (ISelectionService) selection); _serviceContainer.AddService (typeof (IUISelectionService), (IUISelectionService)selection); _serviceContainer.AddService (typeof (DesignSurface), this); }
///<summary>Creates a new document</summary> public Document (Control parent, DesignerHost host, string documentName) { initDocument (parent, host); this.document = String.Format (newDocument, documentName); GetView (); }
public DesignerHostTransaction (DesignerHost host, string description) : base (description) { _designerHost = host; }
public DesignContainer (DesignerHost host) { this.host = host; this.designers = new Hashtable (); this.components = new ArrayList (); }
public BrowserDesignerTransaction(DesignerHost host, String name) : base(name) { _host = host; }
public void OnDocumentChanged (DesignerHost.DocumentChangedEventArgs ea) { if ((designerView != null) && designerView.IsRealized) Gtk.Application.Invoke ( delegate { designerView.LoadDocumentInDesigner (ea.Html); }); }