public HostControl GetNewHostFromFile(string fileName) { if (fileName == null || !File.Exists(fileName)) { MessageBox.Show("FileName is incorrect: " + fileName); } if (fileName.EndsWith("xml")) { HostSurface hostSurface = (HostSurface)this.CreateDesignSurface(this.ServiceContainer); IDesignerHost host = (IDesignerHost)hostSurface.GetService(typeof(IDesignerHost)); BasicHostLoader basicHostLoader = new BasicHostLoader(fileName); hostSurface.BeginLoad(basicHostLoader); hostSurface.Loader = basicHostLoader; hostSurface.Initialize(); return(new HostControl(hostSurface)); } else { StreamReader sr = new StreamReader(fileName); string strSourceCode = sr.ReadToEnd(); return(GetHostFromSourceCode(strSourceCode)); } }
public HostControl GetNewHost(Type rootComponentType, LoaderType loaderType) { if (loaderType == LoaderType.NoLoader) { return(GetNewHost(rootComponentType)); } HostSurface hostSurface = (HostSurface)this.CreateDesignSurface(this.ServiceContainer); IDesignerHost host = (IDesignerHost)hostSurface.GetService(typeof(IDesignerHost)); switch (loaderType) { case LoaderType.BasicDesignerLoader: BasicHostLoader basicHostLoader = new BasicHostLoader(rootComponentType); hostSurface.BeginLoad(basicHostLoader); hostSurface.Loader = basicHostLoader; break; case LoaderType.CodeDomDesignerLoader: CodeDomHostLoader codeDomHostLoader = new CodeDomHostLoader(); hostSurface.BeginLoad(codeDomHostLoader); hostSurface.Loader = codeDomHostLoader; break; default: throw new Exception("Loader is not defined: " + loaderType.ToString()); } hostSurface.Initialize(); return(new HostControl(hostSurface)); }
private HostControl GetNewHost(Type rootComponentType) { HostSurface hostSurface = (HostSurface)this.CreateDesignSurface(this.ServiceContainer); if (rootComponentType == typeof(DevExpress.XtraEditors.XtraForm)) { hostSurface.BeginLoad(typeof(DevExpress.XtraEditors.XtraForm)); } else if (rootComponentType == typeof(ABCControls.ABCView)) { hostSurface.BeginLoad(typeof(ABCControls.ABCView)); } else if (rootComponentType == typeof(UserControl)) { hostSurface.BeginLoad(typeof(UserControl)); } else if (rootComponentType == typeof(Component)) { hostSurface.BeginLoad(typeof(Component)); } else { throw new Exception("Undefined Host Type: " + rootComponentType.ToString()); } hostSurface.Initialize(); this.ActiveDesignSurface = hostSurface; return(new HostControl(hostSurface)); }
public HostControl(HostSurface hostSurface) { hostSurface.OwnerHostControl = this; // This call is required by the Windows.Forms Form Designer. InitializeComponent(); InitializeHost(hostSurface); TabControl.SelectedPageChanging += new DevExpress.XtraTab.TabPageChangingEventHandler(xtraTabControl1_SelectedPageChanging); SourceCSharpEditor.TextChanged += new EventHandler(SourceCSharpEditor_TextChanged); }
public HostControl GetHostFromSourceCode(String strSourceCode) { HostSurface hostSurface = (HostSurface)this.CreateDesignSurface(this.ServiceContainer); IDesignerHost host = (IDesignerHost)hostSurface.GetService(typeof(IDesignerHost)); CodeDomHostLoader codeDomHostLoader = new CodeDomHostLoader(); codeDomHostLoader.SourceCodeToPasrse = strSourceCode; hostSurface.BeginLoad(codeDomHostLoader); hostSurface.Loader = codeDomHostLoader; hostSurface.Initialize(); return(new HostControl(hostSurface)); }
internal void InitializeHost(HostSurface hostSurface) { try { if (hostSurface == null) { return; } HostSurface = hostSurface; Control control = HostSurface.View as Control; control.Parent = this.tabPageDesigner; control.Dock = DockStyle.Fill; control.Visible = true; control.PreviewKeyDown += new PreviewKeyDownEventHandler(control_PreviewKeyDown); } catch (Exception ex) { Trace.WriteLine(ex.ToString()); } }