Represents a dialog box for saving an image of a graph to a file.
Call ShowDialogAndSaveImage() to allow the user to save an image in a format of his choice to a location of his choice.

This class extends the SaveImageFileDialog base class by adding an option to save the graph to an XPS file.

Inheritance: Smrf.AppLib.SaveImageFileDialog
コード例 #1
0
    SaveImage()
    {
        AssertValid();

        if (oNodeXLControl.IsLayingOutGraph)
        {
            return;
        }

        // Get the size of the image.

        GraphImageUserSettings oGraphImageUserSettings =
            new GraphImageUserSettings();

        Int32 iWidth, iHeight;

        if (oGraphImageUserSettings.UseControlSize)
        {
            Size oNodeXLControlSizePx = ehNodeXLControlHost.ClientSize;
            iWidth = oNodeXLControlSizePx.Width;
            iHeight = oNodeXLControlSizePx.Height;

            if (iWidth == 0 || iHeight == 0)
            {
                // The size is unusable.

                FormUtil.ShowWarning(
                    "The graph is too small to save.  Make the graph window"
                    + " larger."
                    );

                return;
            }
        }
        else
        {
            Size oImageSize = oGraphImageUserSettings.ImageSize;
            iWidth = oImageSize.Width;
            iHeight = oImageSize.Height;
        }

        if (m_oSaveGraphImageFileDialog == null)
        {
            m_oSaveGraphImageFileDialog =
                new SaveGraphImageFileDialog(String.Empty, "GraphImage");

            m_oSaveGraphImageFileDialog.DialogTitle = "Save Image to File";
        }

        Boolean bIncludeHeader = oGraphImageUserSettings.IncludeHeader;
        Boolean bIncludeFooter = oGraphImageUserSettings.IncludeFooter;

        Debug.Assert(!bIncludeHeader ||
            oGraphImageUserSettings.HeaderText != null);

        Debug.Assert(!bIncludeFooter ||
            oGraphImageUserSettings.FooterText != null);

        m_oSaveGraphImageFileDialog.ShowDialogAndSaveGraphImage(
            oNodeXLControl, iWidth, iHeight,
            bIncludeHeader ? oGraphImageUserSettings.HeaderText : null,
            bIncludeFooter ? oGraphImageUserSettings.FooterText : null,
            oGraphImageUserSettings.HeaderFooterFont, GetLegendControls()
            );
    }