Esempio n. 1
0
        //*************************************************************************
        //  Constructor: GraphImageUserSettingsDialog()
        //
        /// <overloads>
        /// Initializes a new instance of the <see
        /// cref="GraphImageUserSettingsDialog" /> class.
        /// </overloads>
        ///
        /// <summary>
        /// Initializes a new instance of the <see
        /// cref="GraphImageUserSettingsDialog" /> class with a
        /// <see cref="GraphImageUserSettings" /> object and a NodeXLControlSize.
        /// </summary>
        ///
        /// <param name="graphImageUserSettings">
        /// The object being edited.
        /// </param>
        ///
        /// <param name="nodeXLControlSizePx">
        /// The size of the NodeXLControl, in pixels.
        /// </param>
        //*************************************************************************

        public GraphImageUserSettingsDialog
        (
            GraphImageUserSettings graphImageUserSettings,
            Size nodeXLControlSizePx
        )
            : this()
        {
            Debug.Assert(graphImageUserSettings != null);
            graphImageUserSettings.AssertValid();
            Debug.Assert(nodeXLControlSizePx.Width >= 0);
            Debug.Assert(nodeXLControlSizePx.Height >= 0);

            m_oGraphImageUserSettings = graphImageUserSettings;

            // Instantiate an object that saves and retrieves the user settings for
            // this dialog.  Note that the object automatically saves the settings
            // when the form closes.

            m_oGraphImageUserSettingsDialogUserSettings =
                new GraphImageUserSettingsDialogUserSettings(this);

            lblControlWidth.Text =
                nodeXLControlSizePx.Width.ToString(ExcelTemplateForm.Int32Format);

            lblControlHeight.Text =
                nodeXLControlSizePx.Height.ToString(ExcelTemplateForm.Int32Format);

            DoDataExchange(false);

            AssertValid();
        }
        //*************************************************************************
        //  Constructor: GraphImageUserSettingsDialog()
        //
        /// <overloads>
        /// Initializes a new instance of the <see
        /// cref="GraphImageUserSettingsDialog" /> class.
        /// </overloads>
        ///
        /// <summary>
        /// Initializes a new instance of the <see
        /// cref="GraphImageUserSettingsDialog" /> class with a
        /// <see cref="GraphImageUserSettings" /> object and a NodeXLControlSize.
        /// </summary>
        ///
        /// <param name="graphImageUserSettings">
        /// The object being edited.
        /// </param>
        ///
        /// <param name="nodeXLControlSizePx">
        /// The size of the NodeXLControl, in pixels.
        /// </param>
        //*************************************************************************
        public GraphImageUserSettingsDialog(
            GraphImageUserSettings graphImageUserSettings,
            Size nodeXLControlSizePx
            )
            : this()
        {
            Debug.Assert(graphImageUserSettings != null);
            graphImageUserSettings.AssertValid();
            Debug.Assert(nodeXLControlSizePx.Width >= 0);
            Debug.Assert(nodeXLControlSizePx.Height >= 0);

            m_oGraphImageUserSettings = graphImageUserSettings;

            // Instantiate an object that saves and retrieves the user settings for
            // this dialog.  Note that the object automatically saves the settings
            // when the form closes.

            m_oGraphImageUserSettingsDialogUserSettings =
            new GraphImageUserSettingsDialogUserSettings(this);

            lblControlWidth.Text =
            nodeXLControlSizePx.Width.ToString(ExcelTemplateForm.Int32Format);

            lblControlHeight.Text =
            nodeXLControlSizePx.Height.ToString(ExcelTemplateForm.Int32Format);

            DoDataExchange(false);

            AssertValid();
        }
Esempio n. 3
0
        //*************************************************************************
        //  Method: SetImageSize()
        //
        /// <summary>
        /// Shows a dialog for setting the size of images saved to a file.
        /// </summary>
        //*************************************************************************
        protected void SetImageSize()
        {
            AssertValid();

            if (oNodeXLControl.IsLayingOutGraph)
            {
            return;
            }

            // Allow the user to edit the graph image settings.

            GraphImageUserSettings oGraphImageUserSettings =
            new GraphImageUserSettings();

            Size oNodeXLControlSizePx = ehNodeXLControlHost.ClientSize;

            GraphImageUserSettingsDialog oGraphImageUserSettingsDialog =
            new GraphImageUserSettingsDialog(oGraphImageUserSettings,
                oNodeXLControlSizePx);

            if (oGraphImageUserSettingsDialog.ShowDialog() == DialogResult.OK)
            {
            // Save the new settings.

            oGraphImageUserSettings.Save();
            }
        }
Esempio n. 4
0
        //*************************************************************************
        //  Method: SaveImage()
        //
        /// <summary>
        /// Saves the graph image to a file.
        /// </summary>
        //*************************************************************************
        protected void 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";
            }

            m_oSaveGraphImageFileDialog.ShowDialogAndSaveGraphImage(oNodeXLControl,
            iWidth, iHeight);
        }