//************************************************************************* // Constructor: MergeDuplicateEdgesUserSettingsDialog() // /// <summary> /// Initializes a new instance of the <see /// cref="MergeDuplicateEdgesUserSettingsDialog" /> class. /// </summary> /// /// <param name="mode"> /// Indicates the mode in which the dialog is being used. /// </param> /// /// <param name="mergeDuplicateEdgesUserSettings"> /// The object being edited. /// </param> /// /// <param name="workbook"> /// Workbook containing the graph contents. /// </param> //************************************************************************* public MergeDuplicateEdgesUserSettingsDialog ( DialogMode mode, MergeDuplicateEdgesUserSettings mergeDuplicateEdgesUserSettings, Microsoft.Office.Interop.Excel.Workbook workbook ) { Debug.Assert(mergeDuplicateEdgesUserSettings != null); mergeDuplicateEdgesUserSettings.AssertValid(); Debug.Assert(workbook != null); m_oMergeDuplicateEdgesUserSettings = mergeDuplicateEdgesUserSettings; // 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_oMergeDuplicateEdgesUserSettingsDialogUserSettings = new MergeDuplicateEdgesUserSettingsDialogUserSettings(this); InitializeComponent(); if (mode == DialogMode.EditOnly) { this.Text += " Options"; } ListObject oEdgeTable; if (ExcelTableUtil.TryGetTable(workbook, WorksheetNames.Edges, TableNames.Edges, out oEdgeTable)) { cbxThirdColumnNameForDuplicateDetection .PopulateWithTableColumnNames(oEdgeTable); } DoDataExchange(false); AssertValid(); }
//************************************************************************* // Constructor: MergeDuplicateEdgesUserSettingsDialog() // /// <summary> /// Initializes a new instance of the <see /// cref="MergeDuplicateEdgesUserSettingsDialog" /> class. /// </summary> /// /// <param name="mode"> /// Indicates the mode in which the dialog is being used. /// </param> /// /// <param name="mergeDuplicateEdgesUserSettings"> /// The object being edited. /// </param> /// /// <param name="workbook"> /// Workbook containing the graph contents. /// </param> //************************************************************************* public MergeDuplicateEdgesUserSettingsDialog ( DialogMode mode, MergeDuplicateEdgesUserSettings mergeDuplicateEdgesUserSettings, Microsoft.Office.Interop.Excel.Workbook workbook ) { Debug.Assert(mergeDuplicateEdgesUserSettings != null); mergeDuplicateEdgesUserSettings.AssertValid(); Debug.Assert(workbook != null); m_oMergeDuplicateEdgesUserSettings = mergeDuplicateEdgesUserSettings; // 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_oMergeDuplicateEdgesUserSettingsDialogUserSettings = new MergeDuplicateEdgesUserSettingsDialogUserSettings(this); InitializeComponent(); if (mode == DialogMode.EditOnly) { this.Text += " Options"; } ListObject oEdgeTable; if ( ExcelTableUtil.TryGetTable(workbook, WorksheetNames.Edges, TableNames.Edges, out oEdgeTable) ) { cbxThirdColumnNameForDuplicateDetection .PopulateWithTableColumnNames(oEdgeTable); } DoDataExchange(false); AssertValid(); }
btnOptions_Click ( object sender, EventArgs e ) { AssertValid(); // These are shared by several cases below. Form oUserSettingsDialog = null; NodeXLApplicationSettingsBase oUserSettings = null; switch ( (AutomationTasks)clbTasksToRun.SelectedValue ) { case AutomationTasks.MergeDuplicateEdges: oUserSettings = new MergeDuplicateEdgesUserSettings(); oUserSettingsDialog = new MergeDuplicateEdgesUserSettingsDialog( MergeDuplicateEdgesUserSettingsDialog.DialogMode.EditOnly, (MergeDuplicateEdgesUserSettings)oUserSettings, m_oThisWorkbook.InnerObject); break; case AutomationTasks.CalculateClusters: oUserSettings = new ClusterUserSettings(); oUserSettingsDialog = new ClusterUserSettingsDialog( ClusterUserSettingsDialog.DialogMode.EditOnly, (ClusterUserSettings)oUserSettings); break; case AutomationTasks.CalculateGraphMetrics: ( new GraphMetricsDialog( GraphMetricsDialog.DialogMode.EditOnly, m_oThisWorkbook.InnerObject) ).ShowDialog(); break; case AutomationTasks.AutoFillWorkbook: // ThisWorkbook manages the modeless AutoFillWorkbookDialog, so // tell ThisWorkbook to open the dialog. m_oThisWorkbook.AutoFillWorkbook( AutoFillWorkbookDialog.DialogMode.EditOnly); break; case AutomationTasks.CreateSubgraphImages: ( new CreateSubgraphImagesDialog( CreateSubgraphImagesDialog.DialogMode.EditOnly, null, null) ).ShowDialog(); break; case AutomationTasks.ReadWorkbook: oUserSettings = new GeneralUserSettings(); oUserSettingsDialog = new GeneralUserSettingsDialog( (GeneralUserSettings)oUserSettings, m_oThisWorkbook.InnerObject); break; case AutomationTasks.SaveWorkbookIfNeverSaved: EditFolderToSaveWorkbookTo(); break; case AutomationTasks.SaveGraphImageFile: oUserSettings = new AutomatedGraphImageUserSettings(); oUserSettingsDialog = new AutomatedGraphImageUserSettingsDialog( (AutomatedGraphImageUserSettings)oUserSettings); break; case AutomationTasks.ExportToNodeXLGraphGallery: ( new ExportToNodeXLGraphGalleryDialog( ExportToNodeXLGraphGalleryDialog.DialogMode.EditOnly, m_oThisWorkbook.InnerObject, null) ).ShowDialog(); break; case AutomationTasks.ExportToEmail: ( new ExportToEmailDialog( ExportToEmailDialog.DialogMode.EditOnly, m_oThisWorkbook.InnerObject, null) ).ShowDialog(); break; default: Debug.Assert(false); break; } if (oUserSettingsDialog != null) { Debug.Assert(oUserSettings != null); if (oUserSettingsDialog.ShowDialog() == DialogResult.OK) { oUserSettings.Save(); } } }
btnOptions_Click ( object sender, EventArgs e ) { AssertValid(); // These are shared by several cases below. Form oUserSettingsDialog = null; NodeXLApplicationSettingsBase oUserSettings = null; switch ((AutomationTasks)clbTasksToRun.SelectedValue) { case AutomationTasks.MergeDuplicateEdges: oUserSettings = new MergeDuplicateEdgesUserSettings(); oUserSettingsDialog = new MergeDuplicateEdgesUserSettingsDialog( MergeDuplicateEdgesUserSettingsDialog.DialogMode.EditOnly, (MergeDuplicateEdgesUserSettings)oUserSettings, m_oThisWorkbook.InnerObject); break; case AutomationTasks.CalculateClusters: oUserSettings = new ClusterUserSettings(); oUserSettingsDialog = new ClusterUserSettingsDialog( ClusterUserSettingsDialog.DialogMode.EditOnly, (ClusterUserSettings)oUserSettings); break; case AutomationTasks.CalculateGraphMetrics: (new GraphMetricsDialog( GraphMetricsDialog.DialogMode.EditOnly, m_oThisWorkbook.InnerObject)).ShowDialog(); break; case AutomationTasks.AutoFillWorkbook: // ThisWorkbook manages the modeless AutoFillWorkbookDialog, so // tell ThisWorkbook to open the dialog. m_oThisWorkbook.AutoFillWorkbook( AutoFillWorkbookDialog.DialogMode.EditOnly); break; case AutomationTasks.CreateSubgraphImages: (new CreateSubgraphImagesDialog( CreateSubgraphImagesDialog.DialogMode.EditOnly, null, null)).ShowDialog(); break; case AutomationTasks.ReadWorkbook: oUserSettings = new GeneralUserSettings(); oUserSettingsDialog = new GeneralUserSettingsDialog( (GeneralUserSettings)oUserSettings, m_oThisWorkbook.InnerObject); break; case AutomationTasks.SaveWorkbookIfNeverSaved: EditFolderToSaveWorkbookTo(); break; case AutomationTasks.SaveGraphImageFile: oUserSettings = new AutomatedGraphImageUserSettings(); oUserSettingsDialog = new AutomatedGraphImageUserSettingsDialog( (AutomatedGraphImageUserSettings)oUserSettings); break; case AutomationTasks.ExportToNodeXLGraphGallery: (new ExportToNodeXLGraphGalleryDialog( ExportToNodeXLGraphGalleryDialog.DialogMode.EditOnly, m_oThisWorkbook.InnerObject, null)).ShowDialog(); break; case AutomationTasks.ExportToEmail: (new ExportToEmailDialog( ExportToEmailDialog.DialogMode.EditOnly, m_oThisWorkbook.InnerObject, null)).ShowDialog(); break; default: Debug.Assert(false); break; } if (oUserSettingsDialog != null) { Debug.Assert(oUserSettings != null); if (oUserSettingsDialog.ShowDialog() == DialogResult.OK) { oUserSettings.Save(); } } }