Пример #1
0
 /// <summary>Detach the model from the view.</summary>
 public void Detach()
 {
     explorerPresenter.CommandHistory.ModelChanged -= OnGraphModelChanged;
     if (currentPresenter != null)
     {
         currentPresenter.Detach();
     }
     graphView.OnAxisClick      -= OnAxisClick;
     graphView.OnLegendClick    -= OnLegendClick;
     graphView.OnCaptionClick   -= OnCaptionClick;
     graphView.OnHoverOverPoint -= OnHoverOverPoint;
 }
Пример #2
0
        /// <summary>
        /// Current tab is closing - remove presenter from our presenters list
        /// </summary>
        /// <param name="sender">Sender of event</param>
        /// <param name="e">Event arguments</param>
        private void OnTabClosing(object sender, TabClosingEventArgs e)
        {
            if (e.LeftTabControl)
            {
                IPresenter presenter = presenters1[e.Index - 1];
                e.AllowClose = true;
                if (presenter.GetType() == typeof(ExplorerPresenter))
                {
                    e.AllowClose = ((ExplorerPresenter)presenter).SaveIfChanged();
                }
                if (e.AllowClose)
                {
                    presenter.Detach();
                    this.presenters1.RemoveAt(e.Index - 1);
                }
            }
            else
            {
                IPresenter presenter = presenters2[e.Index - 1];
                e.AllowClose = true;
                if (presenter.GetType() == typeof(ExplorerPresenter))
                {
                    e.AllowClose = ((ExplorerPresenter)presenter).SaveIfChanged();
                }
                if (e.AllowClose)
                {
                    presenter.Detach();
                    this.presenters2.RemoveAt(e.Index - 1);
                }
            }

            // We've just closed Simulations
            // This is a good time to force garbage collection
            GC.Collect(2, GCCollectionMode.Forced, true);
        }
Пример #3
0
 public void Detach()
 {
     if (currentLowerPresenter != null)
     {
         currentLowerPresenter.Detach();
     }
     return;
 }
 /// <summary>
 /// Detach the model from the view.
 /// </summary>
 public void Detach()
 {
     view.Grid2.CellsChanged       -= OnCellValueChanged2;
     intellisense.ItemSelected     -= OnIntellisenseItemSelected;
     view.Grid2.ContextItemsNeeded -= OnContextItemsNeeded;
     propertyPresenter.Detach();
     gridPresenter.Detach();
     explorerPresenter.CommandHistory.ModelChanged -= OnModelChanged;
 }
 public static void Attach <T>(this IPresenter <T> self, T view) where T : AttachableView
 {
     if (self.View != null)
     {
         self.Detach();
     }
     self.View = view;
     self.Setup();
 }
Пример #6
0
        /// <summary>
        /// Detach the model from the view.
        /// </summary>
        public void Detach()
        {
            BuildScript();  // compiles and saves the script
            propertyPresenter.Detach();

            explorerPresenter.CommandHistory.ModelChanged -= CommandHistory_ModelChanged;
            managerView.Editor.ContextItemsNeeded         -= OnNeedVariableNames;
            managerView.Editor.LeaveEditor -= OnEditorLeave;
            intellisense.ItemSelected      -= OnIntellisenseItemSelected;
            intellisense.Cleanup();
        }
Пример #7
0
 /// <summary>
 /// Detach the view
 /// </summary>
 public void Detach()
 {
     this.view.TabSelected -= OnTabSelected;
     if (propertyPresenter != null)
     {
         propertyPresenter.Detach();
     }
     if (versionPresenter != null)
     {
         versionPresenter.Detach();
     }
     if (messagePresenter != null)
     {
         messagePresenter.Detach();
     }
     if (summaryPresenter != null)
     {
         summaryPresenter.Detach();
     }
 }
Пример #8
0
        /// <summary>Writes PDF for specified auto-doc commands.</summary>
        /// <param name="section">The writer to write to.</param>
        /// <param name="tags">The autodoc tags.</param>
        private void TagsToMigraDoc(Section section, List <AutoDocumentation.ITag> tags)
        {
            int figureNumber = 0;

            foreach (AutoDocumentation.ITag tag in tags)
            {
                if (tag is AutoDocumentation.Heading)
                {
                    AutoDocumentation.Heading heading = tag as AutoDocumentation.Heading;
                    if (heading.headingLevel > 0 && heading.headingLevel <= 6)
                    {
                        Paragraph para = section.AddParagraph(heading.text, "Heading" + heading.headingLevel);
                        para.Format.KeepWithNext = true;
                        int posSpace = heading.text.IndexOf(' ');
                        if (posSpace > 0)
                        {
                            para.AddBookmark(heading.text.Substring(posSpace + 1));
                        }
                        if (heading.headingLevel == 1)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level1;
                        }
                        else if (heading.headingLevel == 2)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level2;
                        }
                        else if (heading.headingLevel == 3)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level3;
                        }
                        else if (heading.headingLevel == 4)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level4;
                        }
                        else if (heading.headingLevel == 5)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level5;
                        }
                        else if (heading.headingLevel == 6)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level6;
                        }
                    }
                }
                else if (tag is AutoDocumentation.Paragraph)
                {
                    AutoDocumentation.Paragraph paragraph = tag as AutoDocumentation.Paragraph;
                    if (paragraph.text.Contains("![Alt Text]"))
                    {
                        figureNumber++;
                    }
                    paragraph.text = paragraph.text.Replace("[FigureNumber]", figureNumber.ToString());
                    AddFormattedParagraphToSection(section, paragraph);
                }
                else if (tag is AutoDocumentation.GraphAndTable)
                {
                    CreateGraphPDF(section, tag as AutoDocumentation.GraphAndTable);
                }
                else if (tag is GraphPage)
                {
                    CreateGraphPage(section, tag as GraphPage);
                }
                else if (tag is AutoDocumentation.NewPage)
                {
                    section.AddPageBreak();
                }
                else if (tag is AutoDocumentation.Table)
                {
                    CreateTable(section, tag as AutoDocumentation.Table);
                }
                else if (tag is Graph)
                {
                    GraphPresenter graphPresenter = new GraphPresenter();
                    explorerPresenter.ApsimXFile.Links.Resolve(graphPresenter);
                    GraphView graphView = new GraphView();
                    graphView.BackColor        = OxyPlot.OxyColors.White;
                    graphView.ForegroundColour = OxyPlot.OxyColors.Black;
                    graphView.FontSize         = 12;
                    graphView.Width            = 500;
                    graphView.Height           = 500;
                    graphPresenter.Attach(tag, graphView, explorerPresenter);
                    string pngFileName = graphPresenter.ExportToPNG(WorkingDirectory);
                    section.AddImage(pngFileName);
                    string caption = (tag as Graph).Caption;
                    if (caption != null)
                    {
                        section.AddParagraph(caption);
                    }
                    graphPresenter.Detach();
                    graphView.MainWidget.Destroy();
                }
                else if (tag is Map && (tag as Map).GetCoordinates().Count > 0)
                {
                    MapPresenter mapPresenter = new MapPresenter();
                    MapView      mapView      = new MapView(null);
                    mapPresenter.Attach(tag, mapView, explorerPresenter);
                    string pngFileName = mapPresenter.ExportToPNG(WorkingDirectory);
                    if (!String.IsNullOrEmpty(pngFileName))
                    {
                        section.AddImage(pngFileName);
                    }
                    mapPresenter.Detach();
                    mapView.MainWidget.Destroy();
                }
                else if (tag is AutoDocumentation.Image)
                {
                    AutoDocumentation.Image imageTag = tag as AutoDocumentation.Image;
                    if (imageTag.image.Width > 700)
                    {
                        imageTag.image = ImageUtilities.ResizeImage(imageTag.image, 700, 500);
                    }
                    string pngFileName = Path.Combine(WorkingDirectory, imageTag.name);
                    imageTag.image.Save(pngFileName, System.Drawing.Imaging.ImageFormat.Png);
                    section.AddImage(pngFileName);
                    figureNumber++;
                }
                else if (tag is AutoDocumentation.ModelView)
                {
                    AutoDocumentation.ModelView modelView     = tag as AutoDocumentation.ModelView;
                    ViewNameAttribute           viewName      = ReflectionUtilities.GetAttribute(modelView.model.GetType(), typeof(ViewNameAttribute), false) as ViewNameAttribute;
                    PresenterNameAttribute      presenterName = ReflectionUtilities.GetAttribute(modelView.model.GetType(), typeof(PresenterNameAttribute), false) as PresenterNameAttribute;
                    if (viewName != null && presenterName != null)
                    {
                        ViewBase owner = ViewBase.MasterView as ViewBase;
                        if (viewName.ToString() == "UserInterface.Views.MapView")
                        {
                            owner = null;
                        }

                        ViewBase   view      = Assembly.GetExecutingAssembly().CreateInstance(viewName.ToString(), false, BindingFlags.Default, null, new object[] { owner }, null, null) as ViewBase;
                        IPresenter presenter = Assembly.GetExecutingAssembly().CreateInstance(presenterName.ToString()) as IPresenter;

                        if (view != null && presenter != null)
                        {
                            explorerPresenter.ApsimXFile.Links.Resolve(presenter);
                            presenter.Attach(modelView.model, view, explorerPresenter);

                            Gtk.Window popupWin = new Gtk.Window(Gtk.WindowType.Popup);
                            popupWin.SetSizeRequest(800, 800);
                            popupWin.Add(view.MainWidget);

                            if (view is IMapView map)
                            {
                                map.HideZoomControls();
                            }

                            popupWin.ShowAll();

                            while (Gtk.Application.EventsPending())
                            {
                                Gtk.Application.RunIteration();
                            }

                            // From MapView:
                            // With WebKit, it appears we need to give it time to actually update the display
                            // Really only a problem with the temporary windows used for generating documentation
                            if (view is MapView)
                            {
                                var watch = new System.Diagnostics.Stopwatch();
                                watch.Start();
                                while (watch.ElapsedMilliseconds < 1000)
                                {
                                    Gtk.Application.RunIteration();
                                }
                            }

                            string pngFileName = (presenter as IExportable).ExportToPNG(WorkingDirectory);
                            section.AddImage(pngFileName);
                            presenter.Detach();
                            view.MainWidget.Destroy();
                            popupWin.Destroy();
                        }
                    }
                }
            }
        }
Пример #9
0
        /// <summary>Writes PDF for specified auto-doc commands.</summary>
        /// <param name="section">The writer to write to.</param>
        /// <param name="tags">The autodoc tags.</param>
        /// <param name="workingDirectory">The working directory.</param>
        private void TagsToMigraDoc(Section section, List <AutoDocumentation.ITag> tags, string workingDirectory)
        {
            int figureNumber = 0;

            foreach (AutoDocumentation.ITag tag in tags)
            {
                if (tag is AutoDocumentation.Heading)
                {
                    AutoDocumentation.Heading heading = tag as AutoDocumentation.Heading;
                    if (heading.headingLevel > 0 && heading.headingLevel <= 6)
                    {
                        Paragraph para = section.AddParagraph(heading.text, "Heading" + heading.headingLevel);
                        para.Format.KeepWithNext = true;
                        if (heading.headingLevel == 1)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level1;
                        }
                        else if (heading.headingLevel == 2)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level2;
                        }
                        else if (heading.headingLevel == 3)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level3;
                        }
                        else if (heading.headingLevel == 4)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level4;
                        }
                        else if (heading.headingLevel == 5)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level5;
                        }
                        else if (heading.headingLevel == 6)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level6;
                        }
                    }
                }
                else if (tag is AutoDocumentation.Paragraph)
                {
                    AutoDocumentation.Paragraph paragraph = tag as AutoDocumentation.Paragraph;
                    if (paragraph.text.Contains("![Alt Text]"))
                    {
                        figureNumber++;
                    }
                    paragraph.text = paragraph.text.Replace("[FigureNumber]", figureNumber.ToString());
                    AddFormattedParagraphToSection(section, paragraph);
                }
                else if (tag is AutoDocumentation.GraphAndTable)
                {
                    CreateGraphPDF(section, tag as AutoDocumentation.GraphAndTable, workingDirectory);
                }
                else if (tag is GraphPage)
                {
                    CreateGraphPage(section, tag as GraphPage, workingDirectory);
                }
                else if (tag is AutoDocumentation.NewPage)
                {
                    section.AddPageBreak();
                }
                else if (tag is AutoDocumentation.Table)
                {
                    CreateTable(section, tag as AutoDocumentation.Table, workingDirectory);
                }
                else if (tag is Graph)
                {
                    GraphPresenter graphPresenter = new GraphPresenter();
                    explorerPresenter.ApsimXFile.Links.Resolve(graphPresenter);
                    GraphView graphView = new GraphView();
                    graphView.BackColor        = OxyPlot.OxyColors.White;
                    graphView.ForegroundColour = OxyPlot.OxyColors.Black;
                    graphView.FontSize         = 12;
                    graphView.Width            = 500;
                    graphView.Height           = 500;
                    graphPresenter.Attach(tag, graphView, explorerPresenter);
                    string pngFileName = graphPresenter.ExportToPNG(workingDirectory);
                    section.AddImage(pngFileName);
                    string caption = (tag as Graph).Caption;
                    if (caption != null)
                    {
                        section.AddParagraph(caption);
                    }
                    graphPresenter.Detach();
                    graphView.MainWidget.Destroy();
                }
                else if (tag is Map && (tag as Map).GetCoordinates().Count > 0)
                {
                    MapPresenter mapPresenter = new MapPresenter();
                    MapView      mapView      = new MapView(null);
                    mapPresenter.Attach(tag, mapView, explorerPresenter);
                    string pngFileName = mapPresenter.ExportToPNG(workingDirectory);
                    if (!String.IsNullOrEmpty(pngFileName))
                    {
                        section.AddImage(pngFileName);
                    }
                    mapPresenter.Detach();
                    mapView.MainWidget.Destroy();
                }
                else if (tag is AutoDocumentation.Image)
                {
                    AutoDocumentation.Image imageTag = tag as AutoDocumentation.Image;
                    if (imageTag.image.Width > 700)
                    {
                        imageTag.image = ImageUtilities.ResizeImage(imageTag.image, 700, 500);
                    }
                    string pngFileName = Path.Combine(workingDirectory, imageTag.name);
                    imageTag.image.Save(pngFileName, System.Drawing.Imaging.ImageFormat.Png);
                    section.AddImage(pngFileName);
                    figureNumber++;
                }
                else if (tag is AutoDocumentation.ModelView)
                {
                    AutoDocumentation.ModelView modelView     = tag as AutoDocumentation.ModelView;
                    ViewNameAttribute           viewName      = ReflectionUtilities.GetAttribute(modelView.model.GetType(), typeof(ViewNameAttribute), false) as ViewNameAttribute;
                    PresenterNameAttribute      presenterName = ReflectionUtilities.GetAttribute(modelView.model.GetType(), typeof(PresenterNameAttribute), false) as PresenterNameAttribute;
                    if (viewName != null && presenterName != null)
                    {
                        ViewBase   view      = Assembly.GetExecutingAssembly().CreateInstance(viewName.ToString(), false, BindingFlags.Default, null, new object[] { ViewBase.MasterView }, null, null) as ViewBase;
                        IPresenter presenter = Assembly.GetExecutingAssembly().CreateInstance(presenterName.ToString()) as IPresenter;

                        if (view != null && presenter != null)
                        {
                            explorerPresenter.ApsimXFile.Links.Resolve(presenter);
                            presenter.Attach(modelView.model, view, explorerPresenter);

                            Gtk.Window popupWin = null;
                            if (view is MapView)
                            {
                                popupWin = (view as MapView)?.GetPopupWin();
                                popupWin?.SetSizeRequest(515, 500);
                            }
                            if (popupWin == null)
                            {
                                popupWin = new Gtk.Window(Gtk.WindowType.Popup);
                                popupWin.SetSizeRequest(800, 800);
                                popupWin.Add(view.MainWidget);
                            }
                            popupWin.ShowAll();
                            while (Gtk.Application.EventsPending())
                            {
                                Gtk.Application.RunIteration();
                            }

                            string pngFileName = (presenter as IExportable).ExportToPNG(workingDirectory);
                            section.AddImage(pngFileName);
                            presenter.Detach();
                            view.MainWidget.Destroy();
                            popupWin.Destroy();
                        }
                    }
                }
            }
        }
Пример #10
0
        /// <summary>Writes PDF for specified auto-doc commands.</summary>
        /// <param name="section">The writer to write to.</param>
        /// <param name="tags">The autodoc tags.</param>
        private void TagsToMigraDoc(Section section, List <AutoDocumentation.ITag> tags)
        {
            int figureNumber = 0;

            foreach (AutoDocumentation.ITag tag in tags)
            {
                if (tag is AutoDocumentation.Heading)
                {
                    AutoDocumentation.Heading heading = tag as AutoDocumentation.Heading;
                    if (heading.headingLevel > 0 && heading.headingLevel <= 6)
                    {
                        Paragraph para = section.AddParagraph(heading.text, "Heading" + heading.headingLevel);
                        para.Format.KeepWithNext = true;
                        int posSpace = heading.text.IndexOf(' ');
                        if (posSpace > 0)
                        {
                            para.AddBookmark(heading.text.Substring(posSpace + 1));
                        }
                        if (heading.headingLevel == 1)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level1;
                        }
                        else if (heading.headingLevel == 2)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level2;
                        }
                        else if (heading.headingLevel == 3)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level3;
                        }
                        else if (heading.headingLevel == 4)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level4;
                        }
                        else if (heading.headingLevel == 5)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level5;
                        }
                        else if (heading.headingLevel == 6)
                        {
                            para.Format.OutlineLevel = OutlineLevel.Level6;
                        }
                    }
                }
                else if (tag is AutoDocumentation.Paragraph)
                {
                    AutoDocumentation.Paragraph paragraph = tag as AutoDocumentation.Paragraph;
                    if (paragraph.text.Contains("![Alt Text]"))
                    {
                        figureNumber++;
                    }
                    paragraph.text = paragraph.text.Replace("[FigureNumber]", figureNumber.ToString());
                    AddFormattedParagraphToSection(section, paragraph);
                }
                else if (tag is AutoDocumentation.GraphAndTable)
                {
                    CreateGraphPDF(section, tag as AutoDocumentation.GraphAndTable);
                }
                else if (tag is GraphPage)
                {
                    CreateGraphPage(section, tag as GraphPage);
                }
                else if (tag is AutoDocumentation.NewPage)
                {
                    section.AddPageBreak();
                    if ((tag as AutoDocumentation.NewPage).Portrait)
                    {
                        section.PageSetup.Orientation = Orientation.Portrait;
                    }
                    else
                    {
                        section.PageSetup.Orientation = Orientation.Landscape;
                    }
                }
                else if (tag is AutoDocumentation.PageSetup)
                {
                    if ((tag as AutoDocumentation.PageSetup).Portrait)
                    {
                        section.PageSetup.Orientation = Orientation.Portrait;
                    }
                    else
                    {
                        section.PageSetup.Orientation = Orientation.Landscape;
                    }
                }
                else if (tag is AutoDocumentation.Table)
                {
                    CreateTable(section, tag as AutoDocumentation.Table);
                }
                else if (tag is Graph)
                {
                    GraphPresenter graphPresenter = new GraphPresenter();
                    explorerPresenter.ApsimXFile.Links.Resolve(graphPresenter);
                    GraphView graphView = new GraphView();
                    graphView.BackColor        = OxyPlot.OxyColors.White;
                    graphView.ForegroundColour = OxyPlot.OxyColors.Black;
                    graphView.FontSize         = 12;
                    graphView.Width            = 500;
                    graphView.Height           = 500;
                    graphPresenter.Attach(tag, graphView, explorerPresenter);
                    string pngFileName = graphPresenter.ExportToPNG(WorkingDirectory);
                    section.AddResizeImage(pngFileName);
                    string caption = (tag as Graph).Caption;
                    if (caption != null)
                    {
                        section.AddParagraph(caption);
                    }
                    graphPresenter.Detach();
                    graphView.MainWidget.Cleanup();
                }
                else if (tag is Map && (tag as Map).GetCoordinates().Count > 0)
                {
#if NETFRAMEWORK
                    MapPresenter mapPresenter = new MapPresenter();
                    MapView      mapView      = new MapView(null);
                    mapPresenter.Attach(tag, mapView, explorerPresenter);
                    var    map         = mapView.Export();
                    string pngFileName = Path.ChangeExtension(Path.GetTempFileName(), ".png");
                    if (map.Width > section.PageSetup.PageWidth)
                    {
                        map = ImageUtilities.ResizeImage(map, section.PageSetup.PageWidth, double.MaxValue);
                    }
                    map.Save(pngFileName);
                    if (!String.IsNullOrEmpty(pngFileName))
                    {
                        section.AddResizeImage(pngFileName);
                    }
                    mapPresenter.Detach();
                    mapView.MainWidget.Destroy();
#else
                    section.AddParagraph("MapView has not been implemented in gtk3. Use the framework/gtk2 build instead.");
#endif
                }
                else if (tag is AutoDocumentation.Image)
                {
                    AutoDocumentation.Image imageTag = tag as AutoDocumentation.Image;
                    string pngFileName = Path.Combine(WorkingDirectory, $"{imageTag.name}.png");
                    imageTag.image.Save(pngFileName, System.Drawing.Imaging.ImageFormat.Png);
                    section.AddResizeImage(pngFileName);
                    figureNumber++;
                }
                else if (tag is AutoDocumentation.ModelView)
                {
                    try
                    {
                        AutoDocumentation.ModelView modelView     = tag as AutoDocumentation.ModelView;
                        ViewNameAttribute           viewName      = ReflectionUtilities.GetAttribute(modelView.model.GetType(), typeof(ViewNameAttribute), false) as ViewNameAttribute;
                        PresenterNameAttribute      presenterName = ReflectionUtilities.GetAttribute(modelView.model.GetType(), typeof(PresenterNameAttribute), false) as PresenterNameAttribute;
                        if (viewName != null && presenterName != null)
                        {
                            ViewBase owner = ViewBase.MasterView as ViewBase;
                            if (viewName.ToString() == "UserInterface.Views.MapView")
                            {
                                owner = null;
                            }

                            ViewBase   view      = Assembly.GetExecutingAssembly().CreateInstance(viewName.ToString(), false, BindingFlags.Default, null, new object[] { owner }, null, null) as ViewBase;
                            IPresenter presenter = Assembly.GetExecutingAssembly().CreateInstance(presenterName.ToString()) as IPresenter;

                            if (view != null && presenter != null)
                            {
                                explorerPresenter.ApsimXFile.Links.Resolve(presenter);
                                presenter.Attach(modelView.model, view, explorerPresenter);

#if NETFRAMEWORK
                                Gtk.Window popupWin = new Gtk.Window(Gtk.WindowType.Popup);
#endif
                                try
                                {
#if NETFRAMEWORK
                                    popupWin.SetSizeRequest(700, 700);
                                    popupWin.Add(view.MainWidget);
#endif

                                    if (view is MapView map)
                                    {
                                        map.HideZoomControls();
                                    }
#if NETFRAMEWORK
                                    popupWin.ShowAll();
#endif
                                    while (Gtk.Application.EventsPending())
                                    {
                                        Gtk.Application.RunIteration();
                                    }

                                    // From MapView:
                                    // With WebKit, it appears we need to give it time to actually update the display
                                    // Really only a problem with the temporary windows used for generating documentation
                                    string pngFileName;
                                    if (view is MapView mapView)
                                    {
                                        var img = mapView.Export();
                                        pngFileName = Path.ChangeExtension(Path.GetTempFileName(), ".png");
                                        if (section.PageSetup.PageWidth > 0 && img.Width > section.PageSetup.PageWidth)
                                        {
                                            img = ImageUtilities.ResizeImage(img, section.PageSetup.PageWidth, double.MaxValue);
                                        }
                                        img.Save(pngFileName);
                                    }
                                    else
                                    {
                                        pngFileName = (presenter as IExportable).ExportToPNG(WorkingDirectory);
                                    }
                                    section.AddResizeImage(pngFileName);
                                    presenter.Detach();
                                    view.MainWidget.Cleanup();
                                }
                                finally
                                {
#if NETFRAMEWORK
                                    popupWin.Cleanup();
#endif
                                    while (GLib.MainContext.Iteration())
                                    {
                                        ;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception err)
                    {
                        Console.WriteLine(err);
                    }
                }
            }
        }