private void button1_Click(object sender, RibbonControlEventArgs e) { if (settingsWindow.ShowDialog() == DialogResult.OK) { foreach (Workbook wb in Globals.ThisAddIn.Application.Workbooks) { if (IsWorkbookInBasePath(wb)) { var cfg = new ConfigManager(wb); dic_wb_cm.Add(wb, cfg); if (wb == Globals.ThisAddIn.Application.ActiveWorkbook) cfg.ShowUIPane(true); } else { ConfigManager cfg = null; if (dic_wb_cm.TryGetValue(wb, out cfg)) { cfg.Dispose(); dic_wb_cm.Remove(wb); } } } foreach (var cfg in dic_wb_cm.Values.ToArray()) { if (!IsWorkbookInBasePath(cfg.Wb)) { cfg.Dispose(); dic_wb_cm.Remove(cfg.Wb); } } } }
private void OnWorkbookActivate(Workbook Wb, bool createIfNotCashe) { ConfigManager cfg = null; if (!dic_wb_cm.TryGetValue(Wb, out cfg)) { if (createIfNotCashe) { // 不存在 cfg = new ConfigManager(Wb); dic_wb_cm.Add(Wb, cfg); } else { MessageBox.Show(Properties.Resources.NotInBasePathMessage, "Tyrant.ExcelAddIn.DesignerData", MessageBoxButtons.OK, MessageBoxIcon.Information); } } if (cfg != null) cfg.ShowUIPane(true); }