public PreviewEditorView(Control editor, string mainAssembly, IEnumerable <string> references, Func <string> getCode) { //Size = new Size (200, 200); Editor = editor; MainAssemblyPath = mainAssembly; this.getCode = getCode; if (EnableAppDomains) { designPanel = new AppDomainDesignHost(); } else { designPanel = new InProcessDesignPanel(); } designPanel.MainAssembly = mainAssembly; designPanel.References = references; designPanel.ControlCreated = () => FinishProcessing(null); designPanel.Error = FinishProcessing; designPanelHolder = new Panel(); designPanelHolder.Content = designPanel.GetContainer(); designPanel.ContainerChanged = () => designPanelHolder.Content = designPanel.GetContainer(); Orientation = Orientation.Vertical; FixedPanel = SplitterFixedPanel.None; errorPanel = new Panel { Padding = new Padding(5), Visible = false, BackgroundColor = new Color(Colors.Red, .4f) }; Panel1 = new StackLayout { HorizontalContentAlignment = HorizontalAlignment.Stretch, Items = { new StackLayoutItem(designPanelHolder, expand: true), errorPanel } }; Panel2 = editor; RelativePosition = lastPosition; timer = new UITimer { Interval = RefreshTime }; timer.Elapsed += Timer_Elapsed; errorTimer = new UITimer { Interval = ErrorDisplayTime }; errorTimer.Elapsed += ErrorTimer_Elapsed; }
public object GetContainer() { // keep ref otherwise it gets gc'd in the app domain container = designPanel.GetContainer(); return(container.ToContract()); }