public void ExecuteRibbonAction(IThreatModel threatModel, IActionDefinition action) { try { switch (action.Name) { case "Merge": var dialog = new OpenFileDialog() { AddExtension = true, AutoUpgradeEnabled = true, CheckFileExists = true, CheckPathExists = true, DefaultExt = "tm", DereferenceLinks = true, Filter = "Threat Model (*.tm)|*.tm|Threat Model Template (*.tmt)|*.tmt|Threat Model Json Template (*.tmk)|*.tmk", FilterIndex = 0, Title = "Select file to be merged", RestoreDirectory = true }; if (dialog.ShowDialog(Form.ActiveForm) == DialogResult.OK) { using (var merge = new MergeDialog()) { merge.SetExecutionMode(_executionMode); if (merge.Initialize(threatModel, dialog.FileName)) { if (merge.ShowDialog(Form.ActiveForm) == DialogResult.OK) { RefreshPanels?.Invoke(this); var factory = ExtensionUtils.GetExtensionByLabel <IPanelFactory>("Diagram"); if (factory != null) { ClosePanels?.Invoke(factory); UpdateStatusInfoProviders?.Invoke(); } ShowMessage?.Invoke("Merge succeeded."); } } } } break; } } catch { ShowWarning?.Invoke("Merge failed.\nPlease close the document without saving it."); throw; } }
//"Tools -> Merge -> Merge Databases" menu item private void menu_ToolsMergeMergeDBMenuItem_Click(object sender, EventArgs e) { MergeDialog mdialog = new MergeDialog(GuiPrefs.DefaultDBDir, Mydb); mdialog.StartPosition = FormStartPosition.CenterParent; if (mdialog.ShowDialog() == DialogResult.OK) { if (!Mydb.IsOpen()) { Mydb.OpenDB(Mydb.MyPath); } UpdateAfterOpenDB(); } }