Example #1
0
        //*************************************************************************
        //  Constructor: AutoFillWorkbookWithSchemeDialog()
        //
        /// <overloads>
        /// Initializes a new instance of the <see
        /// cref="AutoFillWorkbookWithSchemeDialog" /> class.
        /// </overloads>
        ///
        /// <summary>
        /// Initializes a new instance of the <see
        /// cref="AutoFillWorkbookWithSchemeDialog" /> class with a workbook.
        /// </summary>
        ///
        /// <param name="workbook">
        /// Workbook containing the graph data.
        /// </param>
        //*************************************************************************

        public AutoFillWorkbookWithSchemeDialog
        (
            Microsoft.Office.Interop.Excel.Workbook workbook
        )
            : this()
        {
            Debug.Assert(workbook != null);

            m_oWorkbook = workbook;

            // 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_oAutoFillWorkbookWithSchemeDialogUserSettings =
                new AutoFillWorkbookWithSchemeDialogUserSettings(this);

            // Populate the column ComboBoxes with the names of the table columns
            // that can be used.

            ListObject oTable;

            if (ExcelUtil.TryGetTable(m_oWorkbook, WorksheetNames.Vertices,
                                      TableNames.Vertices, out oTable))
            {
                cbxVertexCategoryColumnName.PopulateWithTableColumnNames(oTable);
                cbxVertexLabelColumnName.PopulateWithTableColumnNames(oTable);

                cbxVertexLabelColumnName.Items.Add(
                    VertexTableColumnNames.VertexName);
            }

            if (ExcelUtil.TryGetTable(m_oWorkbook, WorksheetNames.Edges,
                                      TableNames.Edges, out oTable))
            {
                cbxEdgeWeightColumnName.PopulateWithTableColumnNames(oTable);
                cbxEdgeTimestampColumnName.PopulateWithTableColumnNames(oTable);
            }

            DoDataExchange(false);

            // Select default column names if the user settings didn't specify
            // other column names.
            //
            // Note that because the DropDownStyle of all the ComboBoxes is set to
            // DropDownList, setting the ComboBox text to a column name that is not
            // currently in the workbook leaves the text empty.

            cbxVertexCategoryColumnName.SetTextIfEmpty(
                DefaultVertexCategoryColumnName);

            cbxEdgeWeightColumnName.SetTextIfEmpty(DefaultEdgeWeightColumnName);

            AssertValid();
        }
        //*************************************************************************
        //  Constructor: AutoFillWorkbookWithSchemeDialog()
        //
        /// <overloads>
        /// Initializes a new instance of the <see
        /// cref="AutoFillWorkbookWithSchemeDialog" /> class.
        /// </overloads>
        ///
        /// <summary>
        /// Initializes a new instance of the <see
        /// cref="AutoFillWorkbookWithSchemeDialog" /> class with a workbook.
        /// </summary>
        ///
        /// <param name="workbook">
        /// Workbook containing the graph data.
        /// </param>
        //*************************************************************************
        public AutoFillWorkbookWithSchemeDialog(
            Microsoft.Office.Interop.Excel.Workbook workbook
            )
            : this()
        {
            Debug.Assert(workbook != null);

            m_oWorkbook = workbook;

            // 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_oAutoFillWorkbookWithSchemeDialogUserSettings =
            new AutoFillWorkbookWithSchemeDialogUserSettings(this);

            // Populate the column ComboBoxes with the names of the table columns
            // that can be used.

            ListObject oTable;

            if ( ExcelUtil.TryGetTable(m_oWorkbook, WorksheetNames.Vertices,
            TableNames.Vertices, out oTable) )
            {
            cbxVertexCategoryColumnName.PopulateWithTableColumnNames(oTable);
            cbxVertexLabelColumnName.PopulateWithTableColumnNames(oTable);

            cbxVertexLabelColumnName.Items.Add(
                VertexTableColumnNames.VertexName);
            }

            if ( ExcelUtil.TryGetTable(m_oWorkbook, WorksheetNames.Edges,
            TableNames.Edges, out oTable) )
            {
            cbxEdgeWeightColumnName.PopulateWithTableColumnNames(oTable);
            cbxEdgeTimestampColumnName.PopulateWithTableColumnNames(oTable);
            }

            DoDataExchange(false);

            // Select default column names if the user settings didn't specify
            // other column names.
            //
            // Note that because the DropDownStyle of all the ComboBoxes is set to
            // DropDownList, setting the ComboBox text to a column name that is not
            // currently in the workbook leaves the text empty.

            cbxVertexCategoryColumnName.SetTextIfEmpty(
            DefaultVertexCategoryColumnName);

            cbxEdgeWeightColumnName.SetTextIfEmpty(DefaultEdgeWeightColumnName);

            AssertValid();
        }