Inheritance: NodeXLApplicationSettingsBase
コード例 #1
0
        TryExportToNodeXLGraphGallery
        (
            Microsoft.Office.Interop.Excel.Workbook oWorkbook,
            NodeXLControl oNodeXLControl
        )
        {
            Debug.Assert(oWorkbook != null);
            Debug.Assert(oNodeXLControl != null);

            ExportToNodeXLGraphGalleryUserSettings
                oExportToNodeXLGraphGalleryUserSettings =
                new ExportToNodeXLGraphGalleryUserSettings();

            String sAuthor, sPassword;

            GetGraphGalleryAuthorAndPassword(
                oExportToNodeXLGraphGalleryUserSettings, out sAuthor,
                out sPassword);

            // Note that a graph summary is used for the description.

            try
            {
                (new NodeXLGraphGalleryExporter()).ExportToNodeXLGraphGallery(
                    oWorkbook,
                    oNodeXLControl,
                    GraphTitleCreator.CreateGraphTitle(oWorkbook),
                    GraphSummarizer.SummarizeGraph(oWorkbook),
                    oExportToNodeXLGraphGalleryUserSettings.SpaceDelimitedTags,
                    sAuthor,
                    sPassword,

                    oExportToNodeXLGraphGalleryUserSettings
                    .ExportWorkbookAndSettings,

                    oExportToNodeXLGraphGalleryUserSettings.ExportGraphML,
                    oExportToNodeXLGraphGalleryUserSettings.UseFixedAspectRatio
                    );

                return(true);
            }
            catch (Exception oException)
            {
                String sMessage;

                if (NodeXLGraphGalleryExceptionHandler
                    .TryGetMessageForRecognizedException(
                        oException, out sMessage))
                {
                    FormUtil.ShowWarning(sMessage);
                }
                else
                {
                    ErrorUtil.OnException(oException);
                }

                return(false);
            }
        }
コード例 #2
0
        GetGraphGalleryAuthorAndPassword
        (
            ExportToNodeXLGraphGalleryUserSettings
            oExportToNodeXLGraphGalleryUserSettings,

            out String sAuthor,
            out String sPassword
        )
        {
            Debug.Assert(oExportToNodeXLGraphGalleryUserSettings != null);

            // The user may have automated the graph without ever opening the
            // ExportToNodeXLGraphGalleryDialog to specify an author and password.
            // This can be worked around.
            //
            // The NodeXLGraphGalleryExporter class requires one of the following:
            //
            // 1. An author that is the name of a Graph Gallery account, along with
            //    the password for that account.
            //
            // 2. A guest author name, with a null password.

            sAuthor = oExportToNodeXLGraphGalleryUserSettings.Author;

            if (String.IsNullOrEmpty(sAuthor))
            {
                // The user hasn't specified an author or password yet.  Export the
                // graph as a guest.
                //
                // Note that there is nothing special about the word "Guest": there
                // is no such Graph Gallery account with that name.  Any name could
                // be used here.

                sAuthor   = "Guest";
                sPassword = null;
            }
            else
            {
                // The user specified either the name of a Graph Gallery account
                // along with a password, or a guest name.  In the first case, the
                // saved password is non-empty; in the second case, it's empty.

                sPassword =
                    (new PasswordUserSettings()).NodeXLGraphGalleryPassword;

                if (sPassword.Length == 0)
                {
                    sPassword = null;
                }
            }
        }
コード例 #3
0
    //*************************************************************************
    //  Constructor: ExportToNodeXLGraphGalleryDialog()
    //
    /// <summary>
    /// Initializes a new instance of the <see
    /// cref="ExportToNodeXLGraphGalleryDialog" /> class.
    /// </summary>
    ///
    /// <param name="mode">
    /// Indicates the mode in which the dialog is being used.
    /// </param>
    ///
    /// <param name="workbook">
    /// Workbook containing the graph data.
    /// </param>
    ///
    /// <param name="nodeXLControl">
    /// NodeXLControl containing the graph.  This can be null if <paramref
    /// name="mode" /> is <see cref="DialogMode.EditOnly" />.
    /// </param>
    //*************************************************************************

    public ExportToNodeXLGraphGalleryDialog
    (
        DialogMode mode,
        Microsoft.Office.Interop.Excel.Workbook workbook,
        NodeXLControl nodeXLControl
    )
    {
        Debug.Assert(workbook != null);
        Debug.Assert(nodeXLControl != null || mode == DialogMode.EditOnly);

        m_eMode = mode;
        m_oWorkbook = workbook;
        m_oNodeXLControl = nodeXLControl;

        m_oExportToNodeXLGraphGalleryUserSettings =
            new ExportToNodeXLGraphGalleryUserSettings();

        m_oPasswordUserSettings = new PasswordUserSettings();

        InitializeComponent();

        if (m_eMode == DialogMode.EditOnly)
        {
            InitializeForEditOnly();
        }

        lnkNodeXLGraphGallery.Tag = ProjectInformation.NodeXLGraphGalleryUrl;

        usrExportedFilesDescription.Workbook = workbook;

        lnkCreateAccount.Tag =
            ProjectInformation.NodeXLGraphGalleryCreateAccountUrl;

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

        m_oExportToNodeXLGraphGalleryDialogUserSettings =
            new ExportToNodeXLGraphGalleryDialogUserSettings(this);

        DoDataExchange(false);

        AssertValid();
    }
コード例 #4
0
        //*************************************************************************
        //  Constructor: ExportToNodeXLGraphGalleryDialog()
        //
        /// <summary>
        /// Initializes a new instance of the <see
        /// cref="ExportToNodeXLGraphGalleryDialog" /> class.
        /// </summary>
        ///
        /// <param name="mode">
        /// Indicates the mode in which the dialog is being used.
        /// </param>
        ///
        /// <param name="workbook">
        /// Workbook containing the graph data.
        /// </param>
        ///
        /// <param name="nodeXLControl">
        /// NodeXLControl containing the graph.  This can be null if <paramref
        /// name="mode" /> is <see cref="DialogMode.EditOnly" />.
        /// </param>
        //*************************************************************************

        public ExportToNodeXLGraphGalleryDialog
        (
            DialogMode mode,
            Microsoft.Office.Interop.Excel.Workbook workbook,
            NodeXLControl nodeXLControl
        )
        {
            Debug.Assert(workbook != null);
            Debug.Assert(nodeXLControl != null || mode == DialogMode.EditOnly);

            m_eMode          = mode;
            m_oWorkbook      = workbook;
            m_oNodeXLControl = nodeXLControl;

            m_oExportToNodeXLGraphGalleryUserSettings =
                new ExportToNodeXLGraphGalleryUserSettings();

            m_oPasswordUserSettings = new PasswordUserSettings();

            InitializeComponent();

            if (m_eMode == DialogMode.EditOnly)
            {
                InitializeForEditOnly();
            }

            lnkNodeXLGraphGallery.Tag = ProjectInformation.NodeXLGraphGalleryUrl;

            lnkCreateAccount.Tag =
                ProjectInformation.NodeXLGraphGalleryCreateAccountUrl;

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

            m_oExportToNodeXLGraphGalleryDialogUserSettings =
                new ExportToNodeXLGraphGalleryDialogUserSettings(this);

            DoDataExchange(false);

            AssertValid();
        }
コード例 #5
0
    GetGraphGalleryAuthorAndPassword
    (
        ExportToNodeXLGraphGalleryUserSettings
            oExportToNodeXLGraphGalleryUserSettings,

        out String sAuthor,
        out String sPassword
    )
    {
        Debug.Assert(oExportToNodeXLGraphGalleryUserSettings != null);

        // The user may have automated the graph without ever opening the
        // ExportToNodeXLGraphGalleryDialog to specify an author and password.
        // This can be worked around.
        //
        // The NodeXLGraphGalleryExporter class requires one of the following:
        //
        // 1. An author that is the name of a Graph Gallery account, along with
        //    the password for that account.
        //
        // 2. A guest author name, with a null password.

        sAuthor = oExportToNodeXLGraphGalleryUserSettings.Author;

        if ( String.IsNullOrEmpty(sAuthor) )
        {
            // The user hasn't specified an author or password yet.  Export the
            // graph as a guest.
            //
            // Note that there is nothing special about the word "Guest": there
            // is no such Graph Gallery account with that name.  Any name could
            // be used here.

            sAuthor = "Guest";
            sPassword = null;
        }
        else
        {
            // The user specified either the name of a Graph Gallery account
            // along with a password, or a guest name.  In the first case, the
            // saved password is non-empty; in the second case, it's empty.

            sPassword =
                ( new PasswordUserSettings() ).NodeXLGraphGalleryPassword;

            if (sPassword.Length == 0)
            {
                sPassword = null;
            }
        }
    }
コード例 #6
0
    TryExportToNodeXLGraphGallery
    (
        Microsoft.Office.Interop.Excel.Workbook oWorkbook,
        NodeXLControl oNodeXLControl
    )
    {
        Debug.Assert(oWorkbook != null);
        Debug.Assert(oNodeXLControl != null);

        ExportToNodeXLGraphGalleryUserSettings
            oExportToNodeXLGraphGalleryUserSettings =
            new ExportToNodeXLGraphGalleryUserSettings();

        String sAuthor, sPassword;

        GetGraphGalleryAuthorAndPassword(
            oExportToNodeXLGraphGalleryUserSettings, out sAuthor,
            out sPassword);

        // Note that the workbook's name is used for the title, and a graph
        // summary is used for the description.

        Debug.Assert( !String.IsNullOrEmpty(oWorkbook.Name) );

        try
        {
            ( new NodeXLGraphGalleryExporter() ).ExportToNodeXLGraphGallery(
                oWorkbook,
                oNodeXLControl,
                oWorkbook.Name,
                GraphSummarizer.SummarizeGraph(oWorkbook),
                oExportToNodeXLGraphGalleryUserSettings.SpaceDelimitedTags,
                sAuthor,
                sPassword,

                oExportToNodeXLGraphGalleryUserSettings
                    .ExportWorkbookAndSettings,

                oExportToNodeXLGraphGalleryUserSettings.ExportGraphML,
                oExportToNodeXLGraphGalleryUserSettings.UseFixedAspectRatio
            );

            return (true);
        }
        catch (Exception oException)
        {
            String sMessage;

            if ( NodeXLGraphGalleryExceptionHandler
                .TryGetMessageForRecognizedException(
                    oException, out sMessage) )
            {
                FormUtil.ShowWarning(sMessage);
            }
            else
            {
                ErrorUtil.OnException(oException);
            }

            return (false);
        }
    }