btnOK_Click ( object sender, System.EventArgs e ) { if (!DoDataExchange(true)) { return; } if (m_oGraphMetricUserSettings.GraphMetricsToCalculate == GraphMetrics.None) { this.ShowWarning("No metrics have been selected."); return; } // The IGraphMetricCalculator2 implementations read the // GraphMetricUserSettings settings, so save them. m_oGraphMetricUserSettings.Save(); if (m_eMode == DialogMode.EditOnly) { DialogResult = DialogResult.OK; this.Close(); return; } // The CalculateGraphMetricsDialog does all the work. Use the // constructor overload that uses a default list of graph metric // calculators. CalculateGraphMetricsDialog oCalculateGraphMetricsDialog = new CalculateGraphMetricsDialog(null, m_oWorkbook); if (oCalculateGraphMetricsDialog.ShowDialog() == DialogResult.OK) { if (m_oGraphMetricUserSettings.ShouldCalculateGraphMetrics( GraphMetrics.TopNBy)) { // The CalculateGraphMetricsDialog does not calculate top-N-by // metrics by default, because those metrics can't always be // calculated without first calculating other metrics and // writing them to the workbook. Now that the other metrics // have been calculated and written to the workbook, calculate // the top-N-by metrics. if (!CalculateTopNByMetrics()) { return; } } DialogResult = DialogResult.OK; this.Close(); } }
CalculateTopNByMetrics() { AssertValid(); TopNByMetricCalculator2 oTopNByMetricCalculator2 = new TopNByMetricCalculator2(); CalculateGraphMetricsDialog oCalculateGraphMetricsDialog = new CalculateGraphMetricsDialog(null, m_oWorkbook, new IGraphMetricCalculator2 [] { oTopNByMetricCalculator2 }, null, true); return(oCalculateGraphMetricsDialog.ShowDialog() == DialogResult.OK); }
CalculateReadabilityMetrics ( Boolean bEmptySelectionIsError ) { AssertValid(); if (!DoDataExchange(true)) { return(false); } if (m_oReadabilityMetricUserSettings.ReadabilityMetricsToCalculate == ReadabilityMetrics.None) { if (bEmptySelectionIsError) { this.ShowInformation("No metrics have been selected."); } return(false); } // ReadabilityMetricCalcuator2 reads the ReadabilityMetricUserSettings // settings, so save them. m_oReadabilityMetricUserSettings.Save(); CalculateGraphMetricsDialog oCalculateGraphMetricsDialog = new CalculateGraphMetricsDialog( m_oNodeXLControl.Graph, m_oWorkbook, new IGraphMetricCalculator2 [] { new ReadabilityMetricCalculator2(new System.Windows.Size( m_oNodeXLControl.ActualWidth, m_oNodeXLControl.ActualHeight)) }, "Calculating Readability Metrics", false ); oCalculateGraphMetricsDialog.ShowDialog(); return(true); }
TryCalculateGraphMetrics ( Microsoft.Office.Interop.Excel.Workbook oWorkbook ) { Debug.Assert(oWorkbook != null); CalculateGraphMetricsDialog oCalculateGraphMetricsDialog = new CalculateGraphMetricsDialog(null, oWorkbook); if (oCalculateGraphMetricsDialog.ShowDialog() != DialogResult.OK) { return(false); } if ((new GraphMetricUserSettings()).ShouldCalculateGraphMetrics( GraphMetrics.TopNBy)) { // See the comments in GraphMetricsDialog for details on how // top-N-by metrics must be calculated after the other metrics // are calculated. TopNByMetricCalculator2 oTopNByMetricCalculator2 = new TopNByMetricCalculator2(); oCalculateGraphMetricsDialog = new CalculateGraphMetricsDialog( null, oWorkbook, new IGraphMetricCalculator2 [] { oTopNByMetricCalculator2 }, null, true); if (oCalculateGraphMetricsDialog.ShowDialog() != DialogResult.OK) { return(false); } } return(true); }
btnOK_Click ( object sender, System.EventArgs e ) { if ( !DoDataExchange(true) ) { return; } if (m_oGraphMetricUserSettings.GraphMetricsToCalculate == GraphMetrics.None) { this.ShowWarning("No metrics have been selected."); return; } // The IGraphMetricCalculator2 implementations read the // GraphMetricUserSettings settings, so save them. m_oGraphMetricUserSettings.Save(); if (m_eMode == DialogMode.EditOnly) { DialogResult = DialogResult.OK; this.Close(); return; } // The CalculateGraphMetricsDialog does all the work. Use the // constructor overload that uses a default list of graph metric // calculators. CalculateGraphMetricsDialog oCalculateGraphMetricsDialog = new CalculateGraphMetricsDialog(null, m_oWorkbook); if (oCalculateGraphMetricsDialog.ShowDialog() == DialogResult.OK) { if ( m_oGraphMetricUserSettings.ShouldCalculateGraphMetrics( GraphMetrics.TopNBy) ) { // The CalculateGraphMetricsDialog does not calculate top-N-by // metrics by default, because those metrics can't always be // calculated without first calculating other metrics and // writing them to the workbook. Now that the other metrics // have been calculated and written to the workbook, calculate // the top-N-by metrics. if ( !CalculateTopNByMetrics() ) { return; } } DialogResult = DialogResult.OK; this.Close(); } }
CalculateTopNByMetrics() { AssertValid(); TopNByMetricCalculator2 oTopNByMetricCalculator2 = new TopNByMetricCalculator2(); CalculateGraphMetricsDialog oCalculateGraphMetricsDialog = new CalculateGraphMetricsDialog(null, m_oWorkbook, new IGraphMetricCalculator2 [] {oTopNByMetricCalculator2}, null, true); return (oCalculateGraphMetricsDialog.ShowDialog() == DialogResult.OK); }
TryCalculateGraphMetrics ( Microsoft.Office.Interop.Excel.Workbook oWorkbook ) { Debug.Assert(oWorkbook != null); CalculateGraphMetricsDialog oCalculateGraphMetricsDialog = new CalculateGraphMetricsDialog(null, oWorkbook); if (oCalculateGraphMetricsDialog.ShowDialog() != DialogResult.OK) { return (false); } if ( ( new GraphMetricUserSettings() ).ShouldCalculateGraphMetrics( GraphMetrics.TopNBy) ) { // See the comments in GraphMetricsDialog for details on how // top-N-by metrics must be calculated after the other metrics // are calculated. TopNByMetricCalculator2 oTopNByMetricCalculator2 = new TopNByMetricCalculator2(); oCalculateGraphMetricsDialog = new CalculateGraphMetricsDialog( null, oWorkbook, new IGraphMetricCalculator2 [] {oTopNByMetricCalculator2}, null, true); if (oCalculateGraphMetricsDialog.ShowDialog() != DialogResult.OK) { return (false); } } return (true); }
CalculateReadabilityMetrics ( Boolean bEmptySelectionIsError ) { AssertValid(); if ( !DoDataExchange(true) ) { return (false); } if (m_oReadabilityMetricUserSettings.ReadabilityMetricsToCalculate == ReadabilityMetrics.None) { if (bEmptySelectionIsError) { this.ShowInformation("No metrics have been selected."); } return (false); } // ReadabilityMetricCalcuator2 reads the ReadabilityMetricUserSettings // settings, so save them. m_oReadabilityMetricUserSettings.Save(); CalculateGraphMetricsDialog oCalculateGraphMetricsDialog = new CalculateGraphMetricsDialog( m_oNodeXLControl.Graph, m_oWorkbook, new IGraphMetricCalculator2 [] { new ReadabilityMetricCalculator2( new System.Windows.Size( m_oNodeXLControl.ActualWidth, m_oNodeXLControl.ActualHeight) ) }, "Calculating Readability Metrics", false ); oCalculateGraphMetricsDialog.ShowDialog(); return (true); }