Stores the user settings for calculating one set of top-N-by metrics.
Sample user settings stored in one instance of this class, in English: "Get the top 10 vertex names on the vertex worksheet, ranked by closeness centrality, along with the corresponding closeness centralities."
Inheritance: Object
        btnAdd_Click
        (
            object sender,
            EventArgs e
        )
        {
            AssertValid();

            // Let the user edit a new TopNByMetricUserSettings object.

            TopNByMetricUserSettings oTopNByMetricUserSettings =
                new TopNByMetricUserSettings();

            if (TryEditTopNByMetricUserSettings(oTopNByMetricUserSettings))
            {
                // Add the new object to the List and the ListBox, then select the
                // object in the ListBox.

                m_oTopNByMetricUserSettingsClone.Add(oTopNByMetricUserSettings);
                DoDataExchange(false);

                lbxTopNByMetricUserSettings.SelectedIndex =
                    lbxTopNByMetricUserSettings.Items.Count - 1;
            }
        }
        btnEdit_Click
        (
            object sender,
            EventArgs e
        )
        {
            AssertValid();

            // Let the user edit the selected TopNByMetricUserSettings object.

            Int32 iSelectedIndex = lbxTopNByMetricUserSettings.SelectedIndex;

            Debug.Assert(iSelectedIndex >= 0);

            Debug.Assert(lbxTopNByMetricUserSettings.SelectedItem is
                         TopNByMetricUserSettings);

            TopNByMetricUserSettings oTopNByMetricUserSettings =
                (TopNByMetricUserSettings)lbxTopNByMetricUserSettings.SelectedItem;

            if (TryEditTopNByMetricUserSettings(oTopNByMetricUserSettings))
            {
                // Replace the object in the ListBox, then select the object in the
                // ListBox.

                DoDataExchange(false);
                lbxTopNByMetricUserSettings.SelectedIndex = iSelectedIndex;
            }
        }
        TryEditTopNByMetricUserSettings
        (
            TopNByMetricUserSettings oTopNByMetricUserSettings
        )
        {
            Debug.Assert(oTopNByMetricUserSettings != null);
            AssertValid();

            TopNByMetricUserSettingsDialog oTopNByMetricUserSettingsDialog =
                new TopNByMetricUserSettingsDialog(
                    oTopNByMetricUserSettings, m_oWorkbook);

            return(oTopNByMetricUserSettingsDialog.ShowDialog() ==
                   DialogResult.OK);
        }
Example #4
0
        //*************************************************************************
        //  Constructor: TopNByMetricUserSettingsDialog()
        //
        /// <summary>
        /// Initializes a new instance of the <see
        /// cref="TopNByMetricUserSettingsDialog" /> class.
        /// </summary>
        ///
        /// <param name="topNByMetricUserSettings">
        /// The object being edited.
        /// </param>
        ///
        /// <param name="workbook">
        /// Workbook containing the graph contents.
        /// </param>
        //*************************************************************************

        public TopNByMetricUserSettingsDialog
        (
            TopNByMetricUserSettings topNByMetricUserSettings,
            Microsoft.Office.Interop.Excel.Workbook workbook
        )
        {
            Debug.Assert(topNByMetricUserSettings != null);
            Debug.Assert(workbook != null);

            m_oTopNByMetricUserSettings = topNByMetricUserSettings;
            m_oWorkbook = workbook;

            InitializeComponent();

            nudN.Minimum = TopNByMetricUserSettings.MinimumN;
            nudN.Maximum = TopNByMetricUserSettings.MaximumN;

            // This dialog is hard-coded for now to get only the top vertices from
            // the vertex worksheet.  It can be updated later to get the top items
            // from any worksheet later, if necessary.  If that is done,
            // TopNByMetrics.ToString() must also be updated.

            cbxWorksheetName.Items.Add(WorksheetNames.Vertices);
            cbxItemNameColumnName.Items.Add(VertexTableColumnNames.VertexName);

            ListObject oVertexTable;

            if (ExcelTableUtil.TryGetTable(m_oWorkbook, WorksheetNames.Vertices,
                                           TableNames.Vertices, out oVertexTable))
            {
                cbxRankedColumnName.PopulateWithTableColumnNames(oVertexTable);
            }

            // 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_oTopNByMetricUserSettingsDialogUserSettings =
                new TopNByMetricUserSettingsDialogUserSettings(this);

            DoDataExchange(false);

            AssertValid();
        }
    //*************************************************************************
    //  Constructor: TopNByMetricUserSettingsDialog()
    //
    /// <summary>
    /// Initializes a new instance of the <see
    /// cref="TopNByMetricUserSettingsDialog" /> class.
    /// </summary>
    ///
    /// <param name="topNByMetricUserSettings">
    /// The object being edited.
    /// </param>
    ///
    /// <param name="workbook">
    /// Workbook containing the graph contents.
    /// </param>
    //*************************************************************************

    public TopNByMetricUserSettingsDialog
    (
        TopNByMetricUserSettings topNByMetricUserSettings,
        Microsoft.Office.Interop.Excel.Workbook workbook
    )
    {
        Debug.Assert(topNByMetricUserSettings != null);
        Debug.Assert(workbook != null);

        m_oTopNByMetricUserSettings = topNByMetricUserSettings;
        m_oWorkbook = workbook;

        InitializeComponent();

        nudN.Minimum = TopNByMetricUserSettings.MinimumN;
        nudN.Maximum = TopNByMetricUserSettings.MaximumN;

        // This dialog is hard-coded for now to get only the top vertices from
        // the vertex worksheet.  It can be updated later to get the top items
        // from any worksheet later, if necessary.  If that is done,
        // TopNByMetrics.ToString() must also be updated.

        cbxWorksheetName.Items.Add(WorksheetNames.Vertices);
        cbxItemNameColumnName.Items.Add(VertexTableColumnNames.VertexName);

        ListObject oVertexTable;

        if ( ExcelTableUtil.TryGetTable(m_oWorkbook, WorksheetNames.Vertices,
            TableNames.Vertices, out oVertexTable) )
        {
            cbxRankedColumnName.PopulateWithTableColumnNames(oVertexTable);
        }

        // 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_oTopNByMetricUserSettingsDialogUserSettings =
            new TopNByMetricUserSettingsDialogUserSettings(this);

        DoDataExchange(false);

        AssertValid();
    }
Example #6
0
        Clone()
        {
            AssertValid();

            TopNByMetricUserSettings oTopNByMetricUserSettings =
                new TopNByMetricUserSettings();

            oTopNByMetricUserSettings.N = m_iN;

            oTopNByMetricUserSettings.WorksheetName =
                String.Copy(m_sWorksheetName);

            oTopNByMetricUserSettings.TableName = String.Copy(m_sTableName);

            oTopNByMetricUserSettings.RankedColumnName =
                String.Copy(m_sRankedColumnName);

            oTopNByMetricUserSettings.ItemNameColumnName =
                String.Copy(m_sItemNameColumnName);

            return(oTopNByMetricUserSettings);
        }
    btnAdd_Click
    (
        object sender,
        EventArgs e
    )
    {
        AssertValid();

        // Let the user edit a new TopNByMetricUserSettings object.

        TopNByMetricUserSettings oTopNByMetricUserSettings =
            new TopNByMetricUserSettings();

        if ( TryEditTopNByMetricUserSettings(oTopNByMetricUserSettings) )
        {
            // Add the new object to the List and the ListBox, then select the
            // object in the ListBox.

            m_oTopNByMetricUserSettingsClone.Add(oTopNByMetricUserSettings);
            DoDataExchange(false);

            lbxTopNByMetricUserSettings.SelectedIndex =
                lbxTopNByMetricUserSettings.Items.Count - 1;
        }
    }
    TryEditTopNByMetricUserSettings
    (
        TopNByMetricUserSettings oTopNByMetricUserSettings
    )
    {
        Debug.Assert(oTopNByMetricUserSettings != null);
        AssertValid();

        TopNByMetricUserSettingsDialog oTopNByMetricUserSettingsDialog =
            new TopNByMetricUserSettingsDialog(
                oTopNByMetricUserSettings, m_oWorkbook);

        return (oTopNByMetricUserSettingsDialog.ShowDialog() ==
            DialogResult.OK);
    }
    Clone()
    {
        AssertValid();

        TopNByMetricUserSettings oTopNByMetricUserSettings =
            new TopNByMetricUserSettings();

        oTopNByMetricUserSettings.N = m_iN;

        oTopNByMetricUserSettings.WorksheetName =
            String.Copy(m_sWorksheetName);

        oTopNByMetricUserSettings.TableName = String.Copy(m_sTableName);

        oTopNByMetricUserSettings.RankedColumnName =
            String.Copy(m_sRankedColumnName);

        oTopNByMetricUserSettings.ItemNameColumnName =
            String.Copy(m_sItemNameColumnName);

        return (oTopNByMetricUserSettings);
    }